[400] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | *
|
---|
| 4 | * @package acp
|
---|
[702] | 5 | * @version $Id$
|
---|
[400] | 6 | * @copyright (c) 2005 phpBB Group
|
---|
| 7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
---|
| 8 | *
|
---|
| 9 | * @todo Check/enter/update transport info
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | * @ignore
|
---|
| 14 | */
|
---|
| 15 | if (!defined('IN_PHPBB'))
|
---|
| 16 | {
|
---|
| 17 | exit;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
| 21 | * @package acp
|
---|
| 22 | */
|
---|
| 23 | class acp_jabber
|
---|
| 24 | {
|
---|
| 25 | var $u_action;
|
---|
| 26 |
|
---|
| 27 | function main($id, $mode)
|
---|
| 28 | {
|
---|
| 29 | global $db, $user, $auth, $template;
|
---|
| 30 | global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
---|
| 31 |
|
---|
| 32 | $user->add_lang('acp/board');
|
---|
| 33 |
|
---|
| 34 | include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
|
---|
| 35 |
|
---|
| 36 | $action = request_var('action', '');
|
---|
| 37 | $submit = (isset($_POST['submit'])) ? true : false;
|
---|
| 38 |
|
---|
| 39 | if ($mode != 'settings')
|
---|
| 40 | {
|
---|
| 41 | return;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | $this->tpl_name = 'acp_jabber';
|
---|
| 45 | $this->page_title = 'ACP_JABBER_SETTINGS';
|
---|
| 46 |
|
---|
[702] | 47 | $jab_enable = request_var('jab_enable', (bool) $config['jab_enable']);
|
---|
| 48 | $jab_host = request_var('jab_host', (string) $config['jab_host']);
|
---|
| 49 | $jab_port = request_var('jab_port', (int) $config['jab_port']);
|
---|
| 50 | $jab_username = request_var('jab_username', (string) $config['jab_username']);
|
---|
| 51 | $jab_password = request_var('jab_password', (string) $config['jab_password']);
|
---|
| 52 | $jab_package_size = request_var('jab_package_size', (int) $config['jab_package_size']);
|
---|
| 53 | $jab_use_ssl = request_var('jab_use_ssl', (bool) $config['jab_use_ssl']);
|
---|
[400] | 54 |
|
---|
| 55 | $form_name = 'acp_jabber';
|
---|
| 56 | add_form_key($form_name);
|
---|
| 57 |
|
---|
| 58 | if ($submit)
|
---|
| 59 | {
|
---|
| 60 | if (!check_form_key($form_name))
|
---|
| 61 | {
|
---|
| 62 | trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | $error = array();
|
---|
| 66 |
|
---|
| 67 | $message = $user->lang['JAB_SETTINGS_CHANGED'];
|
---|
| 68 | $log = 'JAB_SETTINGS_CHANGED';
|
---|
| 69 |
|
---|
| 70 | // Is this feature enabled? Then try to establish a connection
|
---|
| 71 | if ($jab_enable)
|
---|
| 72 | {
|
---|
| 73 | $jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl);
|
---|
| 74 |
|
---|
| 75 | if (!$jabber->connect())
|
---|
| 76 | {
|
---|
| 77 | trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | // We'll try to authorise using this account
|
---|
| 81 | if (!$jabber->login())
|
---|
| 82 | {
|
---|
| 83 | trigger_error($user->lang['ERR_JAB_AUTH'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | $jabber->disconnect();
|
---|
| 87 | }
|
---|
| 88 | else
|
---|
| 89 | {
|
---|
| 90 | // This feature is disabled.
|
---|
[702] | 91 | // We update the user table to be sure all users that have IM as notify type are set to both as notify type
|
---|
| 92 | // We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled.
|
---|
[400] | 93 | $sql_ary = array(
|
---|
| 94 | 'user_notify_type' => NOTIFY_BOTH,
|
---|
| 95 | );
|
---|
| 96 |
|
---|
| 97 | $sql = 'UPDATE ' . USERS_TABLE . '
|
---|
| 98 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
---|
| 99 | WHERE user_notify_type = ' . NOTIFY_IM;
|
---|
| 100 | $db->sql_query($sql);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | set_config('jab_enable', $jab_enable);
|
---|
| 104 | set_config('jab_host', $jab_host);
|
---|
| 105 | set_config('jab_port', $jab_port);
|
---|
| 106 | set_config('jab_username', $jab_username);
|
---|
| 107 | set_config('jab_password', $jab_password);
|
---|
| 108 | set_config('jab_package_size', $jab_package_size);
|
---|
| 109 | set_config('jab_use_ssl', $jab_use_ssl);
|
---|
| 110 |
|
---|
| 111 | add_log('admin', 'LOG_' . $log);
|
---|
| 112 | trigger_error($message . adm_back_link($this->u_action));
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | $template->assign_vars(array(
|
---|
| 116 | 'U_ACTION' => $this->u_action,
|
---|
| 117 | 'JAB_ENABLE' => $jab_enable,
|
---|
| 118 | 'L_JAB_SERVER_EXPLAIN' => sprintf($user->lang['JAB_SERVER_EXPLAIN'], '<a href="http://www.jabber.org/">', '</a>'),
|
---|
| 119 | 'JAB_HOST' => $jab_host,
|
---|
[702] | 120 | 'JAB_PORT' => ($jab_port) ? $jab_port : '',
|
---|
[400] | 121 | 'JAB_USERNAME' => $jab_username,
|
---|
| 122 | 'JAB_PASSWORD' => $jab_password,
|
---|
| 123 | 'JAB_PACKAGE_SIZE' => $jab_package_size,
|
---|
| 124 | 'JAB_USE_SSL' => $jab_use_ssl,
|
---|
| 125 | 'S_CAN_USE_SSL' => jabber::can_use_ssl(),
|
---|
| 126 | 'S_GTALK_NOTE' => (!@function_exists('dns_get_record')) ? true : false,
|
---|
| 127 | ));
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | ?>
|
---|