X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=xmpp%2Fxmpp.php;h=33da9715554de63a0c0b039aa831c01411dafc88;hb=b11e418f3570a5a61bab3fb3bc2660b92635b108;hp=a2a1e17dbb70e4d9411a27c9c6b7ca9ce321298b;hpb=b351fabb4f39b8dda09be8401cd84653ba4eab85;p=friendica-addons.git
diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php
index a2a1e17d..33da9715 100644
--- a/xmpp/xmpp.php
+++ b/xmpp/xmpp.php
@@ -8,10 +8,7 @@
*/
use Friendica\App;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
-use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Util\Strings;
@@ -38,11 +35,11 @@ function xmpp_addon_settings_post()
return;
}
- PConfig::set(local_user(), 'xmpp', 'enabled', $_POST['xmpp_enabled'] ?? false);
- PConfig::set(local_user(), 'xmpp', 'individual', $_POST['xmpp_individual'] ?? false);
- PConfig::set(local_user(), 'xmpp', 'bosh_proxy', $_POST['xmpp_bosh_proxy'] ?? '');
+ 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(L10n::t('XMPP settings updated.') . EOL);
+ info(DI::l10n()->t('XMPP settings updated.') . EOL);
}
function xmpp_addon_settings(App $a, &$s)
@@ -57,36 +54,36 @@ function xmpp_addon_settings(App $a, &$s)
/* Get the current state of our config variable */
- $enabled = intval(PConfig::get(local_user(), 'xmpp', 'enabled'));
+ $enabled = intval(DI::pConfig()->get(local_user(), 'xmpp', 'enabled'));
$enabled_checked = (($enabled) ? ' checked="checked" ' : '');
- $individual = intval(PConfig::get(local_user(), 'xmpp', 'individual'));
+ $individual = intval(DI::pConfig()->get(local_user(), 'xmpp', 'individual'));
$individual_checked = (($individual) ? ' checked="checked" ' : '');
- $bosh_proxy = PConfig::get(local_user(), "xmpp", "bosh_proxy");
+ $bosh_proxy = DI::pConfig()->get(local_user(), "xmpp", "bosh_proxy");
/* Add some HTML to the existing form */
$s .= '';
- $s .= '' . L10n::t('XMPP-Chat (Jabber)') . '
';
+ $s .= '' . DI::l10n()->t('XMPP-Chat (Jabber)') . '
';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '' . L10n::t('XMPP-Chat (Jabber)') . '
';
+ $s .= '' . DI::l10n()->t('XMPP-Chat (Jabber)') . '
';
$s .= '';
$s .= '
';
- $s .= '
';
+ $s .= '
';
$s .= '
';
$s .= '
';
- if (Config::get("xmpp", "central_userbase")) {
- $s .= '
';
+ if (DI::config()->get("xmpp", "central_userbase")) {
+ $s .= '
';
$s .= '
';
$s .= '
';
}
- if (!Config::get("xmpp", "central_userbase") || PConfig::get(local_user(), "xmpp", "individual")) {
- $s .= '
';
+ if (!DI::config()->get("xmpp", "central_userbase") || DI::pConfig()->get(local_user(), "xmpp", "individual")) {
+ $s .= '
';
$s .= '
';
$s .= '
';
}
@@ -95,14 +92,14 @@ function xmpp_addon_settings(App $a, &$s)
/* provide a submit button */
- $s .= '
';
+ $s .= '
';
}
function xmpp_login()
{
if (empty($_SESSION['allow_api'])) {
$password = Strings::getRandomHex(16);
- PConfig::set(local_user(), 'xmpp', 'password', $password);
+ DI::pConfig()->set(local_user(), 'xmpp', 'password', $password);
}
}
@@ -111,9 +108,9 @@ function xmpp_addon_admin(App $a, &$o)
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/xmpp/');
$o = Renderer::replaceMacros($t, [
- '$submit' => L10n::t('Save Settings'),
- '$bosh_proxy' => ['bosh_proxy', L10n::t('Jabber BOSH host'), Config::get('xmpp', 'bosh_proxy'), ''],
- '$central_userbase' => ['central_userbase', L10n::t('Use central userbase'), Config::get('xmpp', 'central_userbase'), 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.')],
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$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.')],
]);
}
@@ -122,10 +119,10 @@ 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);
+ DI::config()->set('xmpp', 'bosh_proxy', $bosh_proxy);
+ DI::config()->set('xmpp', 'central_userbase', $central_userbase);
- info(L10n::t('Settings updated.') . EOL);
+ info(DI::l10n()->t('Settings updated.') . EOL);
}
function xmpp_script(App $a)
@@ -147,7 +144,7 @@ function xmpp_converse(App $a)
return;
}
- if (!PConfig::get(local_user(), "xmpp", "enabled")) {
+ if (!DI::pConfig()->get(local_user(), "xmpp", "enabled")) {
return;
}
@@ -158,14 +155,14 @@ function xmpp_converse(App $a)
DI::page()['htmlhead'] .= '' . "\n";
DI::page()['htmlhead'] .= '' . "\n";
- if (Config::get("xmpp", "central_userbase") && !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 = PConfig::get(local_user(), "xmpp", "password", '', true);
+ $password = DI::pConfig()->get(local_user(), "xmpp", "password", '', true);
if ($password == "") {
$password = Strings::getRandomHex(16);
- PConfig::set(local_user(), "xmpp", "password", $password);
+ DI::pConfig()->set(local_user(), "xmpp", "password", $password);
}
$jid = $a->user["nickname"] . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5);
@@ -176,7 +173,7 @@ function xmpp_converse(App $a)
password: '$password',
allow_logout: false,";
} else {
- $bosh_proxy = PConfig::get(local_user(), "xmpp", "bosh_proxy");
+ $bosh_proxy = DI::pConfig()->get(local_user(), "xmpp", "bosh_proxy");
$auto_login = "";
}