Blame Identity/Webenv/phpBB/3.0.4/includes/acp/acp_jabber.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package acp
ef5584
* @version $Id: acp_jabber.php 8990 2008-10-09 15:41:19Z acydburn $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*
ef5584
* @todo Check/enter/update transport info
ef5584
*/
ef5584
ef5584
/**
ef5584
* @ignore
ef5584
*/
ef5584
if (!defined('IN_PHPBB'))
ef5584
{
ef5584
	exit;
ef5584
}
ef5584
ef5584
/**
ef5584
* @package acp
ef5584
*/
ef5584
class acp_jabber
ef5584
{
ef5584
	var $u_action;
ef5584
ef5584
	function main($id, $mode)
ef5584
	{
ef5584
		global $db, $user, $auth, $template;
ef5584
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
ef5584
ef5584
		$user->add_lang('acp/board');
ef5584
ef5584
		include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
ef5584
ef5584
		$action	= request_var('action', '');
ef5584
		$submit = (isset($_POST['submit'])) ? true : false;
ef5584
ef5584
		if ($mode != 'settings')
ef5584
		{
ef5584
			return;
ef5584
		}
ef5584
ef5584
		$this->tpl_name = 'acp_jabber';
ef5584
		$this->page_title = 'ACP_JABBER_SETTINGS';
ef5584
ef5584
		$jab_enable			= request_var('jab_enable', $config['jab_enable']);
ef5584
		$jab_host			= request_var('jab_host', $config['jab_host']);
ef5584
		$jab_port			= request_var('jab_port', $config['jab_port']);
ef5584
		$jab_username		= request_var('jab_username', $config['jab_username']);
ef5584
		$jab_password		= request_var('jab_password', $config['jab_password']);
ef5584
		$jab_package_size	= request_var('jab_package_size', $config['jab_package_size']);
ef5584
		$jab_use_ssl		= request_var('jab_use_ssl', $config['jab_use_ssl']);
ef5584
ef5584
		$form_name = 'acp_jabber';
ef5584
		add_form_key($form_name);
ef5584
ef5584
		if ($submit)
ef5584
		{
ef5584
			if (!check_form_key($form_name))
ef5584
			{
ef5584
				trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
ef5584
			}
ef5584
ef5584
			$error = array();
ef5584
ef5584
			$message = $user->lang['JAB_SETTINGS_CHANGED'];
ef5584
			$log = 'JAB_SETTINGS_CHANGED';
ef5584
ef5584
			// Is this feature enabled? Then try to establish a connection
ef5584
			if ($jab_enable)
ef5584
			{
ef5584
				$jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl);
ef5584
ef5584
				if (!$jabber->connect())
ef5584
				{
ef5584
					trigger_error($user->lang['ERR_JAB_CONNECT'] . '

' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
ef5584
				}
ef5584
ef5584
				// We'll try to authorise using this account
ef5584
				if (!$jabber->login())
ef5584
				{
ef5584
					trigger_error($user->lang['ERR_JAB_AUTH'] . '

' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
ef5584
				}
ef5584
ef5584
				$jabber->disconnect();
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				// This feature is disabled.
ef5584
				// We update the user table to be sure all users that have IM as notify type are set to both  as notify type
ef5584
				$sql_ary = array(
ef5584
					'user_notify_type'		=> NOTIFY_BOTH,
ef5584
				);
ef5584
ef5584
				$sql = 'UPDATE ' . USERS_TABLE . '
ef5584
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
ef5584
					WHERE user_notify_type = ' . NOTIFY_IM;
ef5584
				$db->sql_query($sql);
ef5584
			}
ef5584
ef5584
			set_config('jab_enable', $jab_enable);
ef5584
			set_config('jab_host', $jab_host);
ef5584
			set_config('jab_port', $jab_port);
ef5584
			set_config('jab_username', $jab_username);
ef5584
			set_config('jab_password', $jab_password);
ef5584
			set_config('jab_package_size', $jab_package_size);
ef5584
			set_config('jab_use_ssl', $jab_use_ssl);
ef5584
ef5584
			add_log('admin', 'LOG_' . $log);
ef5584
			trigger_error($message . adm_back_link($this->u_action));
ef5584
		}
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'U_ACTION'				=> $this->u_action,
ef5584
			'JAB_ENABLE'			=> $jab_enable,
ef5584
			'L_JAB_SERVER_EXPLAIN'	=> sprintf($user->lang['JAB_SERVER_EXPLAIN'], '', ''),
ef5584
			'JAB_HOST'				=> $jab_host,
ef5584
			'JAB_PORT'				=> $jab_port,
ef5584
			'JAB_USERNAME'			=> $jab_username,
ef5584
			'JAB_PASSWORD'			=> $jab_password,
ef5584
			'JAB_PACKAGE_SIZE'		=> $jab_package_size,
ef5584
			'JAB_USE_SSL'			=> $jab_use_ssl,
ef5584
			'S_CAN_USE_SSL'			=> jabber::can_use_ssl(),
ef5584
			'S_GTALK_NOTE'			=> (!@function_exists('dns_get_record')) ? true : false,
ef5584
		));
ef5584
	}
ef5584
}
ef5584
ef5584
?>