1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/acp/acp_jabber.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,131 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package acp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +* @todo Check/enter/update transport info
1.13 +*/
1.14 +
1.15 +/**
1.16 +* @ignore
1.17 +*/
1.18 +if (!defined('IN_PHPBB'))
1.19 +{
1.20 + exit;
1.21 +}
1.22 +
1.23 +/**
1.24 +* @package acp
1.25 +*/
1.26 +class acp_jabber
1.27 +{
1.28 + var $u_action;
1.29 +
1.30 + function main($id, $mode)
1.31 + {
1.32 + global $db, $user, $auth, $template;
1.33 + global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
1.34 +
1.35 + $user->add_lang('acp/board');
1.36 +
1.37 + include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
1.38 +
1.39 + $action = request_var('action', '');
1.40 + $submit = (isset($_POST['submit'])) ? true : false;
1.41 +
1.42 + if ($mode != 'settings')
1.43 + {
1.44 + return;
1.45 + }
1.46 +
1.47 + $this->tpl_name = 'acp_jabber';
1.48 + $this->page_title = 'ACP_JABBER_SETTINGS';
1.49 +
1.50 + $jab_enable = request_var('jab_enable', (bool) $config['jab_enable']);
1.51 + $jab_host = request_var('jab_host', (string) $config['jab_host']);
1.52 + $jab_port = request_var('jab_port', (int) $config['jab_port']);
1.53 + $jab_username = request_var('jab_username', (string) $config['jab_username']);
1.54 + $jab_password = request_var('jab_password', (string) $config['jab_password']);
1.55 + $jab_package_size = request_var('jab_package_size', (int) $config['jab_package_size']);
1.56 + $jab_use_ssl = request_var('jab_use_ssl', (bool) $config['jab_use_ssl']);
1.57 +
1.58 + $form_name = 'acp_jabber';
1.59 + add_form_key($form_name);
1.60 +
1.61 + if ($submit)
1.62 + {
1.63 + if (!check_form_key($form_name))
1.64 + {
1.65 + trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
1.66 + }
1.67 +
1.68 + $error = array();
1.69 +
1.70 + $message = $user->lang['JAB_SETTINGS_CHANGED'];
1.71 + $log = 'JAB_SETTINGS_CHANGED';
1.72 +
1.73 + // Is this feature enabled? Then try to establish a connection
1.74 + if ($jab_enable)
1.75 + {
1.76 + $jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl);
1.77 +
1.78 + if (!$jabber->connect())
1.79 + {
1.80 + trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
1.81 + }
1.82 +
1.83 + // We'll try to authorise using this account
1.84 + if (!$jabber->login())
1.85 + {
1.86 + trigger_error($user->lang['ERR_JAB_AUTH'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
1.87 + }
1.88 +
1.89 + $jabber->disconnect();
1.90 + }
1.91 + else
1.92 + {
1.93 + // This feature is disabled.
1.94 + // We update the user table to be sure all users that have IM as notify type are set to both as notify type
1.95 + // 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.
1.96 + $sql_ary = array(
1.97 + 'user_notify_type' => NOTIFY_BOTH,
1.98 + );
1.99 +
1.100 + $sql = 'UPDATE ' . USERS_TABLE . '
1.101 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
1.102 + WHERE user_notify_type = ' . NOTIFY_IM;
1.103 + $db->sql_query($sql);
1.104 + }
1.105 +
1.106 + set_config('jab_enable', $jab_enable);
1.107 + set_config('jab_host', $jab_host);
1.108 + set_config('jab_port', $jab_port);
1.109 + set_config('jab_username', $jab_username);
1.110 + set_config('jab_password', $jab_password);
1.111 + set_config('jab_package_size', $jab_package_size);
1.112 + set_config('jab_use_ssl', $jab_use_ssl);
1.113 +
1.114 + add_log('admin', 'LOG_' . $log);
1.115 + trigger_error($message . adm_back_link($this->u_action));
1.116 + }
1.117 +
1.118 + $template->assign_vars(array(
1.119 + 'U_ACTION' => $this->u_action,
1.120 + 'JAB_ENABLE' => $jab_enable,
1.121 + 'L_JAB_SERVER_EXPLAIN' => sprintf($user->lang['JAB_SERVER_EXPLAIN'], '<a href="http://www.jabber.org/">', '</a>'),
1.122 + 'JAB_HOST' => $jab_host,
1.123 + 'JAB_PORT' => ($jab_port) ? $jab_port : '',
1.124 + 'JAB_USERNAME' => $jab_username,
1.125 + 'JAB_PASSWORD' => $jab_password,
1.126 + 'JAB_PACKAGE_SIZE' => $jab_package_size,
1.127 + 'JAB_USE_SSL' => $jab_use_ssl,
1.128 + 'S_CAN_USE_SSL' => jabber::can_use_ssl(),
1.129 + 'S_GTALK_NOTE' => (!@function_exists('dns_get_record')) ? true : false,
1.130 + ));
1.131 + }
1.132 +}
1.133 +
1.134 +?>
1.135 \ No newline at end of file