Merge pull request #1061 from annando/issue-9692
[friendica-addons.git/.git] / xmpp / xmpp.php
index 5c049f4..81adec8 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 use Friendica\App;
-use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
 use Friendica\DI;
@@ -22,14 +21,6 @@ function xmpp_install()
        Hook::register('logged_in', 'addon/xmpp/xmpp.php', 'xmpp_login');
 }
 
-function xmpp_uninstall()
-{
-       Hook::unregister('addon_settings', 'addon/xmpp/xmpp.php', 'xmpp_addon_settings');
-       Hook::unregister('addon_settings_post', 'addon/xmpp/xmpp.php', 'xmpp_addon_settings_post');
-       Hook::unregister('page_end', 'addon/xmpp/xmpp.php', 'xmpp_script');
-       Hook::unregister('logged_in', 'addon/xmpp/xmpp.php', 'xmpp_login');
-}
-
 function xmpp_addon_settings_post()
 {
        if (!local_user() || empty($_POST['xmpp-settings-submit'])) {
@@ -39,8 +30,6 @@ function xmpp_addon_settings_post()
        DI::pConfig()->set(local_user(), 'xmpp', 'enabled', $_POST['xmpp_enabled'] ?? false);
        DI::pConfig()->set(local_user(), 'xmpp', 'individual', $_POST['xmpp_individual'] ?? false);
        DI::pConfig()->set(local_user(), 'xmpp', 'bosh_proxy', $_POST['xmpp_bosh_proxy'] ?? '');
-
-       info(DI::l10n()->t('XMPP settings updated.') . EOL);
 }
 
 function xmpp_addon_settings(App $a, &$s)
@@ -77,13 +66,13 @@ function xmpp_addon_settings(App $a, &$s)
        $s .= '<input id="xmpp-enabled" type="checkbox" name="xmpp_enabled" value="1" ' . $enabled_checked . '/>';
        $s .= '<div class="clear"></div>';
 
-       if (Config::get("xmpp", "central_userbase")) {
+       if (DI::config()->get("xmpp", "central_userbase")) {
                $s .= '<label id="xmpp-individual-label" for="xmpp-individual">' . DI::l10n()->t('Individual Credentials') . '</label>';
                $s .= '<input id="xmpp-individual" type="checkbox" name="xmpp_individual" value="1" ' . $individual_checked . '/>';
                $s .= '<div class="clear"></div>';
        }
 
-       if (!Config::get("xmpp", "central_userbase") || DI::pConfig()->get(local_user(), "xmpp", "individual")) {
+       if (!DI::config()->get("xmpp", "central_userbase") || DI::pConfig()->get(local_user(), "xmpp", "individual")) {
                $s .= '<label id="xmpp-bosh-proxy-label" for="xmpp-bosh-proxy">' . DI::l10n()->t('Jabber BOSH host') . '</label>';
                $s .= ' <input id="xmpp-bosh-proxy" type="text" name="xmpp_bosh_proxy" value="' . $bosh_proxy . '" />';
                $s .= '<div class="clear"></div>';
@@ -110,8 +99,8 @@ function xmpp_addon_admin(App $a, &$o)
 
        $o = Renderer::replaceMacros($t, [
                '$submit' => DI::l10n()->t('Save Settings'),
-               '$bosh_proxy' => ['bosh_proxy', DI::l10n()->t('Jabber BOSH host'), Config::get('xmpp', 'bosh_proxy'), ''],
-               '$central_userbase' => ['central_userbase', DI::l10n()->t('Use central userbase'), Config::get('xmpp', 'central_userbase'), DI::l10n()->t('If enabled, users will automatically login to an ejabberd server that has to be installed on this machine with synchronized credentials via the "auth_ejabberd.php" script.')],
+               '$bosh_proxy' => ['bosh_proxy', DI::l10n()->t('Jabber BOSH host'), DI::config()->get('xmpp', 'bosh_proxy'), ''],
+               '$central_userbase' => ['central_userbase', DI::l10n()->t('Use central userbase'), DI::config()->get('xmpp', 'central_userbase'), DI::l10n()->t('If enabled, users will automatically login to an ejabberd server that has to be installed on this machine with synchronized credentials via the "auth_ejabberd.php" script.')],
        ]);
 }
 
@@ -120,10 +109,8 @@ function xmpp_addon_admin_post()
        $bosh_proxy = (!empty($_POST['bosh_proxy']) ? trim($_POST['bosh_proxy']) : '');
        $central_userbase = (!empty($_POST['central_userbase']) ? intval($_POST['central_userbase']) : false);
 
-       Config::set('xmpp', 'bosh_proxy', $bosh_proxy);
-       Config::set('xmpp', 'central_userbase', $central_userbase);
-
-       info(DI::l10n()->t('Settings updated.') . EOL);
+       DI::config()->set('xmpp', 'bosh_proxy', $bosh_proxy);
+       DI::config()->set('xmpp', 'central_userbase', $central_userbase);
 }
 
 function xmpp_script(App $a)
@@ -156,8 +143,8 @@ function xmpp_converse(App $a)
        DI::page()['htmlhead'] .= '<link type="text/css" rel="stylesheet" media="screen" href="addon/xmpp/converse/css/converse.css" />' . "\n";
        DI::page()['htmlhead'] .= '<script src="addon/xmpp/converse/builds/converse.min.js"></script>' . "\n";
 
-       if (Config::get("xmpp", "central_userbase") && !DI::pConfig()->get(local_user(), "xmpp", "individual")) {
-               $bosh_proxy = Config::get("xmpp", "bosh_proxy");
+       if (DI::config()->get("xmpp", "central_userbase") && !DI::pConfig()->get(local_user(), "xmpp", "individual")) {
+               $bosh_proxy = DI::config()->get("xmpp", "bosh_proxy");
 
                $password = DI::pConfig()->get(local_user(), "xmpp", "password", '', true);