mirror of
https://github.com/Mibew/i18n.git
synced 2025-02-02 17:44:42 +03:00
thread.php: extract ok/error methods
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@119 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
parent
96519f6158
commit
cf1068db58
@ -16,11 +16,11 @@ require_once('libs/common.php');
|
|||||||
require_once('libs/chat.php');
|
require_once('libs/chat.php');
|
||||||
require_once('libs/operator.php');
|
require_once('libs/operator.php');
|
||||||
|
|
||||||
$act = verifyparam( "act", "/^(refresh|post|rename|close|ping".")$/");
|
$act = verifyparam( "act", "/^(refresh|post|rename|close|ping)$/");
|
||||||
$token = verifyparam( "token", "/^\d{1,9}$/");
|
$token = verifyparam( "token", "/^\d{1,9}$/");
|
||||||
$threadid = verifyparam( "thread", "/^\d{1,9}$/");
|
$threadid = verifyparam( "thread", "/^\d{1,9}$/");
|
||||||
$isuser = verifyparam( "user", "/^true$/", "false") == 'true';
|
$isuser = verifyparam( "user", "/^true$/", "false") == 'true';
|
||||||
$outformat = (verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml";
|
$outformat = ((verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml");
|
||||||
$istyping = verifyparam( "typed", "/^1$/", "") == '1';
|
$istyping = verifyparam( "typed", "/^1$/", "") == '1';
|
||||||
|
|
||||||
$thread = thread_by_id($threadid);
|
$thread = thread_by_id($threadid);
|
||||||
@ -28,8 +28,17 @@ if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
|
|||||||
die("wrong thread");
|
die("wrong thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
# This code helps in simulation of operator connection problems
|
function show_ok_result($resid) {
|
||||||
# if( !$isuser ) die("error");
|
start_xml_output();
|
||||||
|
echo "<$resid></$resid>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_error($message) {
|
||||||
|
start_xml_output();
|
||||||
|
echo "<error><descr>$message</descr></error>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
ping_thread($thread, $isuser,$istyping);
|
ping_thread($thread, $isuser,$istyping);
|
||||||
|
|
||||||
@ -57,9 +66,7 @@ if( $act == "refresh" ) {
|
|||||||
} else if( $act == "rename" ) {
|
} else if( $act == "rename" ) {
|
||||||
|
|
||||||
if( !$user_can_change_name ) {
|
if( !$user_can_change_name ) {
|
||||||
start_xml_output();
|
show_error("server: forbidden to change name");
|
||||||
echo "<error></error>";
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$newname = getrawparam('name');
|
$newname = getrawparam('name');
|
||||||
@ -67,25 +74,17 @@ if( $act == "refresh" ) {
|
|||||||
rename_user($thread, $newname);
|
rename_user($thread, $newname);
|
||||||
$data = strtr(base64_encode(myiconv($webim_encoding,"utf-8",$newname)), '+/=', '-_,');
|
$data = strtr(base64_encode(myiconv($webim_encoding,"utf-8",$newname)), '+/=', '-_,');
|
||||||
setcookie($namecookie, $data, time()+60*60*24*365);
|
setcookie($namecookie, $data, time()+60*60*24*365);
|
||||||
start_xml_output();
|
show_ok_result("rename");
|
||||||
echo "<changedname></changedname>";
|
|
||||||
exit;
|
|
||||||
|
|
||||||
} else if( $act == "ping" ) {
|
} else if( $act == "ping" ) {
|
||||||
|
show_ok_result("ping");
|
||||||
start_xml_output();
|
|
||||||
echo "<ping></ping>";
|
|
||||||
exit;
|
|
||||||
|
|
||||||
} else if( $act == "close" ) {
|
} else if( $act == "close" ) {
|
||||||
|
|
||||||
if( $isuser || $thread['agentId'] == $operator['operatorid']) {
|
if( $isuser || $thread['agentId'] == $operator['operatorid']) {
|
||||||
close_thread($thread, $isuser);
|
close_thread($thread, $isuser);
|
||||||
}
|
}
|
||||||
|
show_ok_result("closed");
|
||||||
start_xml_output();
|
|
||||||
echo "<closed></closed>";
|
|
||||||
exit;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user