2007-10-10 19:15:47 +04:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* This file is part of Web Instant Messenger project.
|
|
|
|
*
|
2008-10-02 16:01:31 +04:00
|
|
|
* Copyright (c) 2005-2008 Web Messenger Community
|
2007-10-10 19:15:47 +04:00
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* Evgeny Gryaznov - initial API and implementation
|
|
|
|
*/
|
|
|
|
|
2008-06-05 01:36:54 +04:00
|
|
|
require_once('../libs/common.php');
|
|
|
|
require_once('../libs/chat.php');
|
|
|
|
require_once('../libs/operator.php');
|
2008-10-02 13:51:31 +04:00
|
|
|
require_once('../libs/pagination.php');
|
2008-10-11 02:26:14 +04:00
|
|
|
require_once('../libs/expand.php');
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
$operator = check_login();
|
|
|
|
|
|
|
|
$threadid = verifyparam( "thread", "/^\d{1,8}$/");
|
|
|
|
|
|
|
|
if( !isset($_GET['token']) ) {
|
|
|
|
|
2008-09-30 02:46:27 +04:00
|
|
|
$remote_level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
|
|
|
|
if( $remote_level != "ajaxed" ) {
|
2007-10-10 19:15:47 +04:00
|
|
|
die("old browser is used, please update it");
|
|
|
|
}
|
|
|
|
|
|
|
|
$thread = thread_by_id($threadid);
|
|
|
|
if( !$thread || !isset($thread['ltoken']) ) {
|
|
|
|
die("wrong thread");
|
|
|
|
}
|
|
|
|
|
2008-10-02 13:51:31 +04:00
|
|
|
$viewonly = verifyparam( "viewonly", "/^true$/", false);
|
|
|
|
|
|
|
|
$forcetake = verifyparam("force", "/^true$/", false);
|
|
|
|
if( !$viewonly && $thread['istate'] == $state_chatting && $operator['operatorid'] != $thread['agentId'] && $forcetake == false ) {
|
|
|
|
$page = array(
|
|
|
|
'user' => topage($thread['userName']), 'agent' => topage($thread['agentName']), 'link' => $_SERVER['PHP_SELF']."?thread=$threadid&force=true"
|
|
|
|
);
|
2008-10-02 17:25:26 +04:00
|
|
|
start_html_output();
|
2008-10-02 13:51:31 +04:00
|
|
|
require('../view/confirm.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$viewonly)
|
|
|
|
take_thread($thread,$operator);
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2008-09-30 02:46:27 +04:00
|
|
|
$token = $thread['ltoken'];
|
|
|
|
header("Location: $webimroot/operator/agent.php?thread=$threadid&token=$token&level=$remote_level");
|
|
|
|
exit;
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
$token = verifyparam( "token", "/^\d{1,8}$/");
|
|
|
|
|
|
|
|
$thread = thread_by_id($threadid);
|
|
|
|
if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
|
|
|
|
die("wrong thread");
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_chatview_for_operator($thread, $operator);
|
|
|
|
|
|
|
|
start_html_output();
|
|
|
|
|
2008-10-02 13:51:31 +04:00
|
|
|
$pparam = verifyparam( "act", "/^(redirect)$/", "default");
|
|
|
|
if( $pparam == "redirect" ) {
|
|
|
|
$found = get_operators();
|
|
|
|
setup_pagination($found);
|
2008-10-12 04:16:44 +04:00
|
|
|
|
2008-10-12 03:55:25 +04:00
|
|
|
$agent_list = "";
|
|
|
|
$params = array('thread' => $threadid, 'token' => $token);
|
|
|
|
for( $indagent = 0; $indagent < count($page['pagination.items']); $indagent += 1 ) {
|
|
|
|
$agent = $page['pagination.items'][$indagent];
|
|
|
|
$params['nextAgent'] = $agent['operatorid'];
|
|
|
|
$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params)."\" title=\"".topage($agent['vclocalename'])."\">".topage($agent['vclocalename'])."</a>";
|
|
|
|
}
|
|
|
|
$page['pagination_list'] = $agent_list;
|
2008-10-12 04:16:44 +04:00
|
|
|
|
2008-10-12 03:55:25 +04:00
|
|
|
expand("../design/default/redirect.tpl");
|
2008-10-02 13:51:31 +04:00
|
|
|
} else {
|
2008-10-11 02:26:14 +04:00
|
|
|
expand("../design/default/chat.tpl");
|
2008-10-02 13:51:31 +04:00
|
|
|
}
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2007-05-10 21:31:10 +04:00
|
|
|
?>
|