6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 * @todo Check/enter/update transport info
15 if (!defined('IN_PHPBB'))
27 function main($id, $mode)
29 global $db, $user, $auth, $template;
30 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
32 $user->add_lang('acp/board');
34 include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
36 $action = request_var('action', '');
37 $submit = (isset($_POST['submit'])) ? true : false;
39 if ($mode != 'settings')
44 $this->tpl_name = 'acp_jabber';
45 $this->page_title = 'ACP_JABBER_SETTINGS';
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']);
55 $form_name = 'acp_jabber';
56 add_form_key($form_name);
60 if (!check_form_key($form_name))
62 trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
67 $message = $user->lang['JAB_SETTINGS_CHANGED'];
68 $log = 'JAB_SETTINGS_CHANGED';
70 // Is this feature enabled? Then try to establish a connection
73 $jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl);
75 if (!$jabber->connect())
77 trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
80 // We'll try to authorise using this account
81 if (!$jabber->login())
83 trigger_error($user->lang['ERR_JAB_AUTH'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
86 $jabber->disconnect();
90 // This feature is disabled.
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.
94 'user_notify_type' => NOTIFY_BOTH,
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);
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);
111 add_log('admin', 'LOG_' . $log);
112 trigger_error($message . adm_back_link($this->u_action));
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,
120 'JAB_PORT' => ($jab_port) ? $jab_port : '',
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,