X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=xmpp%2Fxmpp.php;h=d80abb64cf1e7309adaf23c7414adc8facfb57cb;hb=7f1fda43aea76a01dfaffba565af94cd2eb28ead;hp=e93ce9d50e496abc920cfbc10d7e994623b595bb;hpb=26800cddb3fe0f93a6cdd3c9ece0c714fcc5085d;p=friendica-addons.git diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index e93ce9d5..d80abb64 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -5,11 +5,13 @@ * Version: 0.1 * Author: Michael Vogel */ + use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Core\Renderer; function xmpp_install() { @@ -29,12 +31,13 @@ function xmpp_uninstall() function xmpp_addon_settings_post() { - if (!local_user() || (!x($_POST, 'xmpp-settings-submit'))) { + if (!local_user() || empty($_POST['xmpp-settings-submit'])) { return; } - PConfig::set(local_user(), 'xmpp', 'enabled', intval($_POST['xmpp_enabled'])); - PConfig::set(local_user(), 'xmpp', 'individual', intval($_POST['xmpp_individual'])); - PConfig::set(local_user(), 'xmpp', 'bosh_proxy', $_POST['xmpp_bosh_proxy']); + + PConfig::set(local_user(), 'xmpp', 'enabled', defaults($_POST, 'xmpp_enabled', false)); + PConfig::set(local_user(), 'xmpp', 'individual', defaults($_POST, 'xmpp_individual', false)); + PConfig::set(local_user(), 'xmpp', 'bosh_proxy', defaults($_POST, 'xmpp_bosh_proxy', '')); info(L10n::t('XMPP settings updated.') . EOL); } @@ -47,7 +50,7 @@ function xmpp_addon_settings(App $a, &$s) /* Add our stylesheet to the xmpp so we can make our settings look nice */ - $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variable */ @@ -94,17 +97,17 @@ function xmpp_addon_settings(App $a, &$s) function xmpp_login() { - if (empty($_SESSION["allow_api"])) { + if (empty($_SESSION['allow_api'])) { $password = random_string(16); - PConfig::set(local_user(), "xmpp", "password", $password); + PConfig::set(local_user(), 'xmpp', 'password', $password); } } function xmpp_addon_admin(App $a, &$o) { - $t = get_markup_template("admin.tpl", "addon/xmpp/"); + $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/xmpp/'); - $o = replace_macros($t, [ + $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.')], @@ -113,10 +116,12 @@ function xmpp_addon_admin(App $a, &$o) function xmpp_addon_admin_post() { - $bosh_proxy = ((x($_POST, 'bosh_proxy')) ? trim($_POST['bosh_proxy']) : ''); - $central_userbase = ((x($_POST, 'central_userbase')) ? intval($_POST['central_userbase']) : false); + $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(L10n::t('Settings updated.') . EOL); } @@ -160,7 +165,7 @@ function xmpp_converse(App $a) PConfig::set(local_user(), "xmpp", "password", $password); } - $jid = $a->user["nickname"] . "@" . $a->get_hostname() . "/converse-" . random_string(5); + $jid = $a->user["nickname"] . "@" . $a->getHostName() . "/converse-" . random_string(5); $auto_login = "auto_login: true, authentication: 'login',