-function xmpp_login($a,$b) {
- if (!$_SESSION["allow_api"]) {
- $password = substr(random_string(),0,16);
- set_pconfig(local_user(), "xmpp", "password", $password);
+function xmpp_addon_settings_post()
+{
+ if (!local_user() || empty($_POST['xmpp-settings-submit'])) {
+ return;
+ }
+
+ 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)
+{
+ if (!local_user()) {
+ return;
+ }
+
+ /* Add our stylesheet to the xmpp so we can make our settings look nice */
+
+ DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/xmpp/xmpp.css' . '" media="all" />' . "\r\n";
+
+ /* Get the current state of our config variable */
+
+ $enabled = intval(DI::pConfig()->get(local_user(), 'xmpp', 'enabled'));
+ $enabled_checked = (($enabled) ? ' checked="checked" ' : '');
+
+ $individual = intval(DI::pConfig()->get(local_user(), 'xmpp', 'individual'));
+ $individual_checked = (($individual) ? ' checked="checked" ' : '');
+
+ $bosh_proxy = DI::pConfig()->get(local_user(), "xmpp", "bosh_proxy");
+
+ /* Add some HTML to the existing form */
+ $s .= '<span id="settings_xmpp_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_xmpp_expanded\'); openClose(\'settings_xmpp_inflated\');">';
+ $s .= '<h3>' . DI::l10n()->t('XMPP-Chat (Jabber)') . '</h3>';
+ $s .= '</span>';
+ $s .= '<div id="settings_xmpp_expanded" class="settings-block" style="display: none;">';
+ $s .= '<span class="fakelink" onclick="openClose(\'settings_xmpp_expanded\'); openClose(\'settings_xmpp_inflated\');">';
+ $s .= '<h3>' . DI::l10n()->t('XMPP-Chat (Jabber)') . '</h3>';
+ $s .= '</span>';
+
+ $s .= '<div id="xmpp-settings-wrapper">';
+ $s .= '<label id="xmpp-enabled-label" for="xmpp-enabled">' . DI::l10n()->t('Enable Webchat') . '</label>';
+ $s .= '<input id="xmpp-enabled" type="checkbox" name="xmpp_enabled" value="1" ' . $enabled_checked . '/>';
+ $s .= '<div class="clear"></div>';
+
+ 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>';