mirror of
https://github.com/Mibew/i18n.git
synced 2025-02-02 09:34:41 +03:00
Fixed a problem with multiple installations on the same domain.
When a user logged in on one chat, they also got logged in to all the other chats.
This commit is contained in:
parent
e304901bd0
commit
7cc810c683
767
src/messenger/webim/libs/operator.php
Normal file → Executable file
767
src/messenger/webim/libs/operator.php
Normal file → Executable file
@ -1,383 +1,384 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* This file is part of Mibew Messenger project.
|
* This file is part of Mibew Messenger project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2005-2010 Mibew Messenger Community
|
* Copyright (c) 2005-2010 Mibew Messenger Community
|
||||||
* All rights reserved. The contents of this file are subject to the terms of
|
* All rights reserved. The contents of this file are subject to the terms of
|
||||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||||
* to allow use of your version of this file only under the terms of the GPL, and
|
* to allow use of your version of this file only under the terms of the GPL, and
|
||||||
* not to allow others to use your version of this file under the terms of the
|
* not to allow others to use your version of this file under the terms of the
|
||||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||||
* with the notice and other provisions required by the GPL.
|
* with the notice and other provisions required by the GPL.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Evgeny Gryaznov - initial API and implementation
|
* Evgeny Gryaznov - initial API and implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$can_administrate = 0;
|
$can_administrate = 0;
|
||||||
$can_takeover = 1;
|
$can_takeover = 1;
|
||||||
$can_viewthreads = 2;
|
$can_viewthreads = 2;
|
||||||
$can_modifyprofile = 3;
|
$can_modifyprofile = 3;
|
||||||
|
|
||||||
$can_count = 4;
|
$can_count = 4;
|
||||||
|
|
||||||
$permission_ids = array(
|
$permission_ids = array(
|
||||||
$can_administrate => "admin",
|
$can_administrate => "admin",
|
||||||
$can_takeover => "takeover",
|
$can_takeover => "takeover",
|
||||||
$can_viewthreads => "viewthreads",
|
$can_viewthreads => "viewthreads",
|
||||||
$can_modifyprofile => "modifyprofile"
|
$can_modifyprofile => "modifyprofile"
|
||||||
);
|
);
|
||||||
|
|
||||||
function operator_by_login($login) {
|
function operator_by_login($login) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$operator = select_one_row(
|
$operator = select_one_row(
|
||||||
"select * from " . $mysqlprefix . "chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
|
"select * from " . $mysqlprefix . "chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operator;
|
return $operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_by_email($mail) {
|
function operator_by_email($mail) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$operator = select_one_row(
|
$operator = select_one_row(
|
||||||
"select * from " . $mysqlprefix . "chatoperator where vcemail = '".mysql_real_escape_string($mail)."'", $link );
|
"select * from " . $mysqlprefix . "chatoperator where vcemail = '".mysql_real_escape_string($mail)."'", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operator;
|
return $operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_by_id_($id,$link) {
|
function operator_by_id_($id,$link) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
return select_one_row(
|
return select_one_row(
|
||||||
"select * from " .$mysqlprefix . "chatoperator where operatorid = $id", $link );
|
"select * from " .$mysqlprefix . "chatoperator where operatorid = $id", $link );
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_by_id($id) {
|
function operator_by_id($id) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$operator = operator_by_id_($id,$link);
|
$operator = operator_by_id_($id,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operator;
|
return $operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_get_all() {
|
function operator_get_all() {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||||
"from " . $mysqlprefix . "chatoperator order by vclogin";
|
"from " . $mysqlprefix . "chatoperator order by vclogin";
|
||||||
$operators = select_multi_assoc($query, $link);
|
$operators = select_multi_assoc($query, $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operators;
|
return $operators;
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_is_online($operator) {
|
function operator_is_online($operator) {
|
||||||
global $settings;
|
global $settings;
|
||||||
return $operator['time'] < $settings['online_timeout'];
|
return $operator['time'] < $settings['online_timeout'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_is_available($operator) {
|
function operator_is_available($operator) {
|
||||||
global $settings;
|
global $settings;
|
||||||
return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_is_away($operator) {
|
function operator_is_away($operator) {
|
||||||
global $settings;
|
global $settings;
|
||||||
return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_operator($operatorid,$login,$email,$jabber,$password,$localename,$commonname,$notify) {
|
function update_operator($operatorid,$login,$email,$jabber,$password,$localename,$commonname,$notify) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"update " . $mysqlprefix . "chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'".
|
"update " . $mysqlprefix . "chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'".
|
||||||
", vcemail = '%s', vcjabbername= '%s', inotify = %s".
|
", vcemail = '%s', vcjabbername= '%s', inotify = %s".
|
||||||
" where operatorid = %s",
|
" where operatorid = %s",
|
||||||
mysql_real_escape_string($login),
|
mysql_real_escape_string($login),
|
||||||
($password ? " vcpassword='".md5($password)."'," : ""),
|
($password ? " vcpassword='".md5($password)."'," : ""),
|
||||||
mysql_real_escape_string($localename),
|
mysql_real_escape_string($localename),
|
||||||
mysql_real_escape_string($commonname),
|
mysql_real_escape_string($commonname),
|
||||||
mysql_real_escape_string($email),
|
mysql_real_escape_string($email),
|
||||||
mysql_real_escape_string($jabber),
|
mysql_real_escape_string($jabber),
|
||||||
$notify,
|
$notify,
|
||||||
$operatorid );
|
$operatorid );
|
||||||
|
|
||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_operator_avatar($operatorid,$avatar) {
|
function update_operator_avatar($operatorid,$avatar) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"update " . $mysqlprefix . "chatoperator set vcavatar = '%s' where operatorid = %s",
|
"update " . $mysqlprefix . "chatoperator set vcavatar = '%s' where operatorid = %s",
|
||||||
mysql_real_escape_string($avatar), $operatorid );
|
mysql_real_escape_string($avatar), $operatorid );
|
||||||
|
|
||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link) {
|
function create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"insert into " . $mysqlprefix . "chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername,inotify) values ('%s','%s','%s','%s','%s','%s','%s',%s)",
|
"insert into " . $mysqlprefix . "chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername,inotify) values ('%s','%s','%s','%s','%s','%s','%s',%s)",
|
||||||
mysql_real_escape_string($login),
|
mysql_real_escape_string($login),
|
||||||
md5($password),
|
md5($password),
|
||||||
mysql_real_escape_string($localename),
|
mysql_real_escape_string($localename),
|
||||||
mysql_real_escape_string($commonname),
|
mysql_real_escape_string($commonname),
|
||||||
'' /* no avatar */,
|
'' /* no avatar */,
|
||||||
mysql_real_escape_string($email),
|
mysql_real_escape_string($email),
|
||||||
mysql_real_escape_string($jabber),
|
mysql_real_escape_string($jabber),
|
||||||
$notify);
|
$notify);
|
||||||
|
|
||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
$id = mysql_insert_id($link);
|
$id = mysql_insert_id($link);
|
||||||
|
|
||||||
return select_one_row("select * from " . $mysqlprefix . "chatoperator where operatorid = $id", $link );
|
return select_one_row("select * from " . $mysqlprefix . "chatoperator where operatorid = $id", $link );
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_operator($login,$email,$jabber,$password,$localename,$commonname,$notify) {
|
function create_operator($login,$email,$jabber,$password,$localename,$commonname,$notify) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$newop = create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link);
|
$newop = create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $newop;
|
return $newop;
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify_operator_alive($operatorid, $istatus) {
|
function notify_operator_alive($operatorid, $istatus) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("update " . $mysqlprefix . "chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
|
perform_query("update " . $mysqlprefix . "chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function has_online_operators($groupid="") {
|
function has_online_operators($groupid="") {
|
||||||
global $settings, $mysqlprefix;
|
global $settings, $mysqlprefix;
|
||||||
loadsettings();
|
loadsettings();
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from " . $mysqlprefix . "chatoperator";
|
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from " . $mysqlprefix . "chatoperator";
|
||||||
if($groupid) {
|
if($groupid) {
|
||||||
$query .= ", " . $mysqlprefix . "chatgroupoperator where groupid = $groupid and " . $mysqlprefix . "chatoperator.operatorid = " .
|
$query .= ", " . $mysqlprefix . "chatgroupoperator where groupid = $groupid and " . $mysqlprefix . "chatoperator.operatorid = " .
|
||||||
$mysqlprefix . "chatgroupoperator.operatorid and istatus = 0";
|
$mysqlprefix . "chatgroupoperator.operatorid and istatus = 0";
|
||||||
} else {
|
} else {
|
||||||
$query .= " where istatus = 0";
|
$query .= " where istatus = 0";
|
||||||
}
|
}
|
||||||
$row = select_one_row($query,$link);
|
$row = select_one_row($query,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $row['time'] < $settings['online_timeout'] && $row['total'] > 0;
|
return $row['time'] < $settings['online_timeout'] && $row['total'] > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_operator_online($operatorid, $link) {
|
function is_operator_online($operatorid, $link) {
|
||||||
global $settings, $mysqlprefix;
|
global $settings, $mysqlprefix;
|
||||||
loadsettings_($link);
|
loadsettings_($link);
|
||||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||||
"from " . $mysqlprefix . "chatoperator where operatorid = $operatorid";
|
"from " . $mysqlprefix . "chatoperator where operatorid = $operatorid";
|
||||||
$row = select_one_row($query,$link);
|
$row = select_one_row($query,$link);
|
||||||
return $row['time'] < $settings['online_timeout'] && $row['total'] == 1;
|
return $row['time'] < $settings['online_timeout'] && $row['total'] == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_operator_name($operator) {
|
function get_operator_name($operator) {
|
||||||
global $home_locale, $current_locale;
|
global $home_locale, $current_locale;
|
||||||
if( $home_locale == $current_locale )
|
if( $home_locale == $current_locale )
|
||||||
return $operator['vclocalename'];
|
return $operator['vclocalename'];
|
||||||
else
|
else
|
||||||
return $operator['vccommonname'];
|
return $operator['vccommonname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function append_query($link,$pv) {
|
function append_query($link,$pv) {
|
||||||
$infix = '?';
|
$infix = '?';
|
||||||
if( strstr($link,$infix) !== FALSE )
|
if( strstr($link,$infix) !== FALSE )
|
||||||
$infix = '&';
|
$infix = '&';
|
||||||
return "$link$infix$pv";
|
return "$link$infix$pv";
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_login($redirect=true) {
|
function check_login($redirect=true) {
|
||||||
global $webimroot;
|
global $webimroot, $mysqlprefix;
|
||||||
if( !isset( $_SESSION['operator'] ) ) {
|
if( !isset( $_SESSION[$mysqlprefix . 'operator'] ) ) {
|
||||||
if( isset($_COOKIE['webim_lite']) ) {
|
if( isset($_COOKIE['webim_lite']) ) {
|
||||||
list($login,$pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
|
list($login,$pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
|
||||||
$op = operator_by_login($login);
|
$op = operator_by_login($login);
|
||||||
if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) {
|
if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) {
|
||||||
$_SESSION['operator'] = $op;
|
$_SESSION[$mysqlprefix . 'operator'] = $op;
|
||||||
return $op;
|
return $op;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$requested = $_SERVER['PHP_SELF'];
|
$requested = $_SERVER['PHP_SELF'];
|
||||||
if($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
|
if($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
|
||||||
$requested .= "?".$_SERVER['QUERY_STRING'];
|
$requested .= "?".$_SERVER['QUERY_STRING'];
|
||||||
}
|
}
|
||||||
if($redirect) {
|
if($redirect) {
|
||||||
$_SESSION['backpath'] = $requested;
|
$_SESSION['backpath'] = $requested;
|
||||||
header("Location: $webimroot/operator/login.php");
|
header("Location: $webimroot/operator/login.php");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $_SESSION['operator'];
|
return $_SESSION[$mysqlprefix . 'operator'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_logged_in() {
|
function get_logged_in() {
|
||||||
return isset( $_SESSION['operator'] ) ? $_SESSION['operator'] : FALSE;
|
global $mysqlprefix;
|
||||||
}
|
return isset( $_SESSION[$mysqlprefix . 'operator'] ) ? $_SESSION[$mysqlprefix . 'operator'] : FALSE;
|
||||||
|
}
|
||||||
function login_operator($operator,$remember) {
|
|
||||||
global $webimroot;
|
function login_operator($operator,$remember) {
|
||||||
$_SESSION['operator'] = $operator;
|
global $webimroot, $mysqlprefix;
|
||||||
if( $remember ) {
|
$_SESSION[$mysqlprefix . 'operator'] = $operator;
|
||||||
$value = $operator['vclogin'].",".md5($operator['vcpassword']);
|
if( $remember ) {
|
||||||
setcookie('webim_lite', $value, time()+60*60*24*1000, "$webimroot/");
|
$value = $operator['vclogin'].",".md5($operator['vcpassword']);
|
||||||
|
setcookie('webim_lite', $value, time()+60*60*24*1000, "$webimroot/");
|
||||||
} else if( isset($_COOKIE['webim_lite']) ) {
|
|
||||||
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
|
} else if( isset($_COOKIE['webim_lite']) ) {
|
||||||
}
|
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function logout_operator() {
|
|
||||||
global $webimroot;
|
function logout_operator() {
|
||||||
unset($_SESSION['operator']);
|
global $webimroot, $mysqlprefix;
|
||||||
unset($_SESSION['backpath']);
|
unset($_SESSION[$mysqlprefix . 'operator']);
|
||||||
if( isset($_COOKIE['webim_lite']) ) {
|
unset($_SESSION['backpath']);
|
||||||
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
|
if( isset($_COOKIE['webim_lite']) ) {
|
||||||
}
|
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function setup_redirect_links($threadid,$token) {
|
|
||||||
global $page, $webimroot, $settings, $mysqlprefix;
|
function setup_redirect_links($threadid,$token) {
|
||||||
loadsettings();
|
global $page, $webimroot, $settings, $mysqlprefix;
|
||||||
$link = connect();
|
loadsettings();
|
||||||
|
$link = connect();
|
||||||
$operatorscount = db_rows_count($mysqlprefix . "chatoperator", array(), "", $link);
|
|
||||||
|
$operatorscount = db_rows_count($mysqlprefix . "chatoperator", array(), "", $link);
|
||||||
$groupscount = 0;
|
|
||||||
if($settings['enablegroups'] == "1") {
|
$groupscount = 0;
|
||||||
$groups = array();
|
if($settings['enablegroups'] == "1") {
|
||||||
foreach(get_groups($link, true) as $group) {
|
$groups = array();
|
||||||
if($group['inumofagents'] == 0) {
|
foreach(get_groups($link, true) as $group) {
|
||||||
continue;
|
if($group['inumofagents'] == 0) {
|
||||||
}
|
continue;
|
||||||
$groups[] = $group;
|
}
|
||||||
}
|
$groups[] = $group;
|
||||||
$groupscount = count($groups);
|
}
|
||||||
}
|
$groupscount = count($groups);
|
||||||
|
}
|
||||||
prepare_pagination(max($operatorscount,$groupscount),8);
|
|
||||||
$p = $page['pagination'];
|
prepare_pagination(max($operatorscount,$groupscount),8);
|
||||||
$limit = $p['limit'];
|
$p = $page['pagination'];
|
||||||
|
$limit = $p['limit'];
|
||||||
$operators = select_multi_assoc(db_build_select(
|
|
||||||
"operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
|
$operators = select_multi_assoc(db_build_select(
|
||||||
$mysqlprefix . "chatoperator", array(), "order by vclogin $limit"), $link);
|
"operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
|
||||||
|
$mysqlprefix . "chatoperator", array(), "order by vclogin $limit"), $link);
|
||||||
$groups = array_slice($groups, $p['start'], $p['end']-$p['start']);
|
|
||||||
|
$groups = array_slice($groups, $p['start'], $p['end']-$p['start']);
|
||||||
mysql_close($link);
|
|
||||||
|
mysql_close($link);
|
||||||
$agent_list = "";
|
|
||||||
$params = array('thread' => $threadid, 'token' => $token);
|
$agent_list = "";
|
||||||
foreach($operators as $agent) {
|
$params = array('thread' => $threadid, 'token' => $token);
|
||||||
$params['nextAgent'] = $agent['operatorid'];
|
foreach($operators as $agent) {
|
||||||
$status = $agent['time'] < $settings['online_timeout']
|
$params['nextAgent'] = $agent['operatorid'];
|
||||||
? ($agent['istatus'] == 0
|
$status = $agent['time'] < $settings['online_timeout']
|
||||||
? getlocal("char.redirect.operator.online_suff")
|
? ($agent['istatus'] == 0
|
||||||
: getlocal("char.redirect.operator.away_suff")
|
? getlocal("char.redirect.operator.online_suff")
|
||||||
)
|
: getlocal("char.redirect.operator.away_suff")
|
||||||
: "";
|
)
|
||||||
$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
: "";
|
||||||
"\" title=\"".topage(get_operator_name($agent))."\">".
|
$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
||||||
topage(get_operator_name($agent)).
|
"\" title=\"".topage(get_operator_name($agent))."\">".
|
||||||
"</a> $status</li>";
|
topage(get_operator_name($agent)).
|
||||||
}
|
"</a> $status</li>";
|
||||||
$page['redirectToAgent'] = $agent_list;
|
}
|
||||||
|
$page['redirectToAgent'] = $agent_list;
|
||||||
$group_list = "";
|
|
||||||
if($settings['enablegroups'] == "1") {
|
$group_list = "";
|
||||||
$params = array('thread' => $threadid, 'token' => $token);
|
if($settings['enablegroups'] == "1") {
|
||||||
foreach($groups as $group) {
|
$params = array('thread' => $threadid, 'token' => $token);
|
||||||
$params['nextGroup'] = $group['groupid'];
|
foreach($groups as $group) {
|
||||||
$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout']
|
$params['nextGroup'] = $group['groupid'];
|
||||||
? getlocal("char.redirect.operator.online_suff")
|
$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout']
|
||||||
: ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout']
|
? getlocal("char.redirect.operator.online_suff")
|
||||||
? getlocal("char.redirect.operator.away_suff")
|
: ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout']
|
||||||
: "");
|
? getlocal("char.redirect.operator.away_suff")
|
||||||
$group_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
: "");
|
||||||
"\" title=\"".topage(get_group_name($group))."\">".
|
$group_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
||||||
topage(get_group_name($group)).
|
"\" title=\"".topage(get_group_name($group))."\">".
|
||||||
"</a> $status</li>";
|
topage(get_group_name($group)).
|
||||||
}
|
"</a> $status</li>";
|
||||||
}
|
}
|
||||||
$page['redirectToGroup'] = $group_list;
|
}
|
||||||
}
|
$page['redirectToGroup'] = $group_list;
|
||||||
|
}
|
||||||
$permission_list = array();
|
|
||||||
|
$permission_list = array();
|
||||||
function get_permission_list() {
|
|
||||||
global $permission_list, $permission_ids;
|
function get_permission_list() {
|
||||||
if(count($permission_list) == 0) {
|
global $permission_list, $permission_ids;
|
||||||
foreach($permission_ids as $permid) {
|
if(count($permission_list) == 0) {
|
||||||
$permission_list[] = array(
|
foreach($permission_ids as $permid) {
|
||||||
'id' => $permid,
|
$permission_list[] = array(
|
||||||
'descr' => getlocal("permission.$permid")
|
'id' => $permid,
|
||||||
);
|
'descr' => getlocal("permission.$permid")
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
return $permission_list;
|
}
|
||||||
}
|
return $permission_list;
|
||||||
|
}
|
||||||
function is_capable($perm,$operator) {
|
|
||||||
$permissions = $operator && isset($operator['iperm']) ? $operator['iperm'] : 0;
|
function is_capable($perm,$operator) {
|
||||||
return $perm >= 0 && $perm < 32 && ($permissions & (1 << $perm)) != 0;
|
$permissions = $operator && isset($operator['iperm']) ? $operator['iperm'] : 0;
|
||||||
}
|
return $perm >= 0 && $perm < 32 && ($permissions & (1 << $perm)) != 0;
|
||||||
|
}
|
||||||
function prepare_menu($operator,$hasright=true) {
|
|
||||||
global $page, $settings, $can_administrate;
|
function prepare_menu($operator,$hasright=true) {
|
||||||
$page['operator'] = topage(get_operator_name($operator));
|
global $page, $settings, $can_administrate;
|
||||||
if($hasright) {
|
$page['operator'] = topage(get_operator_name($operator));
|
||||||
loadsettings();
|
if($hasright) {
|
||||||
$page['showban'] = $settings['enableban'] == "1";
|
loadsettings();
|
||||||
$page['showgroups'] = $settings['enablegroups'] == "1";
|
$page['showban'] = $settings['enableban'] == "1";
|
||||||
$page['showstat'] = $settings['enablestatistics'] == "1";
|
$page['showgroups'] = $settings['enablegroups'] == "1";
|
||||||
$page['showadmin'] = is_capable($can_administrate, $operator);
|
$page['showstat'] = $settings['enablestatistics'] == "1";
|
||||||
$page['currentopid'] = $operator['operatorid'];
|
$page['showadmin'] = is_capable($can_administrate, $operator);
|
||||||
}
|
$page['currentopid'] = $operator['operatorid'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function get_all_groups($link) {
|
|
||||||
global $mysqlprefix;
|
function get_all_groups($link) {
|
||||||
$query = "select " . $mysqlprefix . "chatgroup.groupid as groupid, vclocalname, vclocaldescription from " . $mysqlprefix . "chatgroup order by vclocalname";
|
global $mysqlprefix;
|
||||||
return select_multi_assoc($query, $link);
|
$query = "select " . $mysqlprefix . "chatgroup.groupid as groupid, vclocalname, vclocaldescription from " . $mysqlprefix . "chatgroup order by vclocalname";
|
||||||
}
|
return select_multi_assoc($query, $link);
|
||||||
|
}
|
||||||
function get_groups($link,$checkaway) {
|
|
||||||
global $mysqlprefix;
|
function get_groups($link,$checkaway) {
|
||||||
$query = "select " . $mysqlprefix . "chatgroup.groupid as groupid, vclocalname, vclocaldescription".
|
global $mysqlprefix;
|
||||||
", (SELECT count(*) from " . $mysqlprefix . "chatgroupoperator where " . $mysqlprefix . "chatgroup.groupid = " .
|
$query = "select " . $mysqlprefix . "chatgroup.groupid as groupid, vclocalname, vclocaldescription".
|
||||||
$mysqlprefix . "chatgroupoperator.groupid) as inumofagents".
|
", (SELECT count(*) from " . $mysqlprefix . "chatgroupoperator where " . $mysqlprefix . "chatgroup.groupid = " .
|
||||||
", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
$mysqlprefix . "chatgroupoperator.groupid) as inumofagents".
|
||||||
"from " . $mysqlprefix . "chatgroupoperator, " . $mysqlprefix . "chatoperator where istatus = 0 and " .
|
", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||||
$mysqlprefix . "chatgroup.groupid = " . $mysqlprefix . "chatgroupoperator.groupid ".
|
"from " . $mysqlprefix . "chatgroupoperator, " . $mysqlprefix . "chatoperator where istatus = 0 and " .
|
||||||
"and " . $mysqlprefix . "chatgroupoperator.operatorid = " . $mysqlprefix . "chatoperator.operatorid) as ilastseen".
|
$mysqlprefix . "chatgroup.groupid = " . $mysqlprefix . "chatgroupoperator.groupid ".
|
||||||
($checkaway
|
"and " . $mysqlprefix . "chatgroupoperator.operatorid = " . $mysqlprefix . "chatoperator.operatorid) as ilastseen".
|
||||||
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
($checkaway
|
||||||
"from " . $mysqlprefix . "chatgroupoperator, " . $mysqlprefix . "chatoperator where istatus <> 0 and " .
|
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||||
$mysqlprefix . "chatgroup.groupid = " . $mysqlprefix . "chatgroupoperator.groupid ".
|
"from " . $mysqlprefix . "chatgroupoperator, " . $mysqlprefix . "chatoperator where istatus <> 0 and " .
|
||||||
"and " . $mysqlprefix . "chatgroupoperator.operatorid = " . $mysqlprefix . "chatoperator.operatorid) as ilastseenaway"
|
$mysqlprefix . "chatgroup.groupid = " . $mysqlprefix . "chatgroupoperator.groupid ".
|
||||||
: ""
|
"and " . $mysqlprefix . "chatgroupoperator.operatorid = " . $mysqlprefix . "chatoperator.operatorid) as ilastseenaway"
|
||||||
).
|
: ""
|
||||||
" from " . $mysqlprefix . "chatgroup order by vclocalname";
|
).
|
||||||
return select_multi_assoc($query, $link);
|
" from " . $mysqlprefix . "chatgroup order by vclocalname";
|
||||||
}
|
return select_multi_assoc($query, $link);
|
||||||
|
}
|
||||||
function get_operator_groupids($operatorid) {
|
|
||||||
global $mysqlprefix;
|
function get_operator_groupids($operatorid) {
|
||||||
$link = connect();
|
global $mysqlprefix;
|
||||||
$query = "select groupid from " . $mysqlprefix . "chatgroupoperator where operatorid = $operatorid";
|
$link = connect();
|
||||||
$result = select_multi_assoc($query, $link);
|
$query = "select groupid from " . $mysqlprefix . "chatgroupoperator where operatorid = $operatorid";
|
||||||
mysql_close($link);
|
$result = select_multi_assoc($query, $link);
|
||||||
return $result;
|
mysql_close($link);
|
||||||
}
|
return $result;
|
||||||
|
}
|
||||||
?>
|
|
||||||
|
?>
|
||||||
|
208
src/messenger/webim/operator/avatar.php
Normal file → Executable file
208
src/messenger/webim/operator/avatar.php
Normal file → Executable file
@ -1,105 +1,105 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* This file is part of Mibew Messenger project.
|
* This file is part of Mibew Messenger project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2005-2010 Mibew Messenger Community
|
* Copyright (c) 2005-2010 Mibew Messenger Community
|
||||||
* All rights reserved. The contents of this file are subject to the terms of
|
* All rights reserved. The contents of this file are subject to the terms of
|
||||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||||
* to allow use of your version of this file only under the terms of the GPL, and
|
* to allow use of your version of this file only under the terms of the GPL, and
|
||||||
* not to allow others to use your version of this file under the terms of the
|
* not to allow others to use your version of this file under the terms of the
|
||||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||||
* with the notice and other provisions required by the GPL.
|
* with the notice and other provisions required by the GPL.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Evgeny Gryaznov - initial API and implementation
|
* Evgeny Gryaznov - initial API and implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('../libs/common.php');
|
require_once('../libs/common.php');
|
||||||
require_once('../libs/operator.php');
|
require_once('../libs/operator.php');
|
||||||
require_once('../libs/operator_settings.php');
|
require_once('../libs/operator_settings.php');
|
||||||
|
|
||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
|
|
||||||
$opId = verifyparam( "op","/^\d{1,9}$/");
|
$opId = verifyparam( "op","/^\d{1,9}$/");
|
||||||
$page = array('opid' => $opId, 'avatar' => '');
|
$page = array('opid' => $opId, 'avatar' => '');
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||||
|| is_capable($can_administrate, $operator);
|
|| is_capable($can_administrate, $operator);
|
||||||
|
|
||||||
$op = operator_by_id($opId);
|
$op = operator_by_id($opId);
|
||||||
|
|
||||||
if( !$op ) {
|
if( !$op ) {
|
||||||
$errors[] = getlocal("no_such_operator");
|
$errors[] = getlocal("no_such_operator");
|
||||||
|
|
||||||
} else if( isset($_POST['op']) ) {
|
} else if( isset($_POST['op']) ) {
|
||||||
$avatar = $op['vcavatar'];
|
$avatar = $op['vcavatar'];
|
||||||
|
|
||||||
if(!$canmodify) {
|
if(!$canmodify) {
|
||||||
$errors[] = getlocal('page_agent.cannot_modify');
|
$errors[] = getlocal('page_agent.cannot_modify');
|
||||||
|
|
||||||
} else if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) {
|
} else if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) {
|
||||||
$valid_types = array("gif","jpg", "png", "tif");
|
$valid_types = array("gif","jpg", "png", "tif");
|
||||||
|
|
||||||
$orig_filename = $_FILES['avatarFile']['name'];
|
$orig_filename = $_FILES['avatarFile']['name'];
|
||||||
$tmp_file_name = $_FILES['avatarFile']['tmp_name'];
|
$tmp_file_name = $_FILES['avatarFile']['tmp_name'];
|
||||||
|
|
||||||
$ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, ".")));
|
$ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, ".")));
|
||||||
$new_file_name = "$opId.$ext";
|
$new_file_name = "$opId.$ext";
|
||||||
loadsettings();
|
loadsettings();
|
||||||
|
|
||||||
$file_size = $_FILES['avatarFile']['size'];
|
$file_size = $_FILES['avatarFile']['size'];
|
||||||
if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) {
|
if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) {
|
||||||
$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
|
$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
|
||||||
} elseif(!in_array($ext, $valid_types)) {
|
} elseif(!in_array($ext, $valid_types)) {
|
||||||
$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
|
$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
|
||||||
} else {
|
} else {
|
||||||
$avatar_local_dir = "../images/avatar/";
|
$avatar_local_dir = "../images/avatar/";
|
||||||
$full_file_path = $avatar_local_dir.$new_file_name;
|
$full_file_path = $avatar_local_dir.$new_file_name;
|
||||||
if (file_exists($full_file_path)) {
|
if (file_exists($full_file_path)) {
|
||||||
unlink($full_file_path);
|
unlink($full_file_path);
|
||||||
}
|
}
|
||||||
if (!move_uploaded_file($_FILES['avatarFile']['tmp_name'], $full_file_path)) {
|
if (!move_uploaded_file($_FILES['avatarFile']['tmp_name'], $full_file_path)) {
|
||||||
$errors[] = failed_uploading_file($orig_filename, "errors.file.move.error");
|
$errors[] = failed_uploading_file($orig_filename, "errors.file.move.error");
|
||||||
} else {
|
} else {
|
||||||
$avatar = "$webimroot/images/avatar/$new_file_name";
|
$avatar = "$webimroot/images/avatar/$new_file_name";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errors[] = "No file selected";
|
$errors[] = "No file selected";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($errors) == 0) {
|
if(count($errors) == 0) {
|
||||||
update_operator_avatar($op['operatorid'],$avatar);
|
update_operator_avatar($op['operatorid'],$avatar);
|
||||||
|
|
||||||
if ($opId && $avatar && $_SESSION['operator'] && $operator['operatorid'] == $opId) {
|
if ($opId && $avatar && $_SESSION[$mysqlprefix . 'operator'] && $operator['operatorid'] == $opId) {
|
||||||
$_SESSION['operator']['vcavatar'] = $avatar;
|
$_SESSION[$mysqlprefix . 'operator']['vcavatar'] = $avatar;
|
||||||
}
|
}
|
||||||
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$page['avatar'] = topage($op['vcavatar']);
|
$page['avatar'] = topage($op['vcavatar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (isset($_GET['delete']) && $_GET['delete'] == "true" && $canmodify) {
|
if (isset($_GET['delete']) && $_GET['delete'] == "true" && $canmodify) {
|
||||||
update_operator_avatar($op['operatorid'],'');
|
update_operator_avatar($op['operatorid'],'');
|
||||||
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$page['avatar'] = topage($op['vcavatar']);
|
$page['avatar'] = topage($op['vcavatar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
||||||
$page['canmodify'] = $canmodify ? "1" : "";
|
$page['canmodify'] = $canmodify ? "1" : "";
|
||||||
|
|
||||||
prepare_menu($operator);
|
prepare_menu($operator);
|
||||||
setup_operator_settings_tabs($opId,1);
|
setup_operator_settings_tabs($opId,1);
|
||||||
start_html_output();
|
start_html_output();
|
||||||
require('../view/avatar.php');
|
require('../view/avatar.php');
|
||||||
?>
|
?>
|
182
src/messenger/webim/operator/permissions.php
Normal file → Executable file
182
src/messenger/webim/operator/permissions.php
Normal file → Executable file
@ -1,91 +1,91 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* This file is part of Mibew Messenger project.
|
* This file is part of Mibew Messenger project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2005-2010 Mibew Messenger Community
|
* Copyright (c) 2005-2010 Mibew Messenger Community
|
||||||
* All rights reserved. The contents of this file are subject to the terms of
|
* All rights reserved. The contents of this file are subject to the terms of
|
||||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||||
* to allow use of your version of this file only under the terms of the GPL, and
|
* to allow use of your version of this file only under the terms of the GPL, and
|
||||||
* not to allow others to use your version of this file under the terms of the
|
* not to allow others to use your version of this file under the terms of the
|
||||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||||
* with the notice and other provisions required by the GPL.
|
* with the notice and other provisions required by the GPL.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Evgeny Gryaznov - initial API and implementation
|
* Evgeny Gryaznov - initial API and implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('../libs/common.php');
|
require_once('../libs/common.php');
|
||||||
require_once('../libs/operator.php');
|
require_once('../libs/operator.php');
|
||||||
require_once('../libs/operator_settings.php');
|
require_once('../libs/operator_settings.php');
|
||||||
|
|
||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
|
|
||||||
function update_operator_permissions($operatorid,$newvalue) {
|
function update_operator_permissions($operatorid,$newvalue) {
|
||||||
global $mysqlprefix;
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "update " . $mysqlprefix . "chatoperator set iperm = $newvalue where operatorid = $operatorid";
|
$query = "update " . $mysqlprefix . "chatoperator set iperm = $newvalue where operatorid = $operatorid";
|
||||||
|
|
||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$opId = verifyparam( "op","/^\d{1,9}$/");
|
$opId = verifyparam( "op","/^\d{1,9}$/");
|
||||||
$page = array('opid' => $opId, 'canmodify' => is_capable($can_administrate, $operator) ? "1" : "");
|
$page = array('opid' => $opId, 'canmodify' => is_capable($can_administrate, $operator) ? "1" : "");
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
$op = operator_by_id($opId);
|
$op = operator_by_id($opId);
|
||||||
|
|
||||||
if( !$op ) {
|
if( !$op ) {
|
||||||
$errors[] = getlocal("no_such_operator");
|
$errors[] = getlocal("no_such_operator");
|
||||||
|
|
||||||
} else if( isset($_POST['op']) ) {
|
} else if( isset($_POST['op']) ) {
|
||||||
|
|
||||||
if(!is_capable($can_administrate, $operator)) {
|
if(!is_capable($can_administrate, $operator)) {
|
||||||
$errors[] = getlocal('page_agent.cannot_modify');
|
$errors[] = getlocal('page_agent.cannot_modify');
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_permissions = isset($op['iperm']) ? $op['iperm'] : 0;
|
$new_permissions = isset($op['iperm']) ? $op['iperm'] : 0;
|
||||||
|
|
||||||
foreach($permission_ids as $perm => $id) {
|
foreach($permission_ids as $perm => $id) {
|
||||||
if( verifyparam("permissions$id","/^on$/", "") == "on") {
|
if( verifyparam("permissions$id","/^on$/", "") == "on") {
|
||||||
$new_permissions |= (1 << $perm);
|
$new_permissions |= (1 << $perm);
|
||||||
} else {
|
} else {
|
||||||
$new_permissions &= ~ (1 << $perm);
|
$new_permissions &= ~ (1 << $perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($errors) == 0) {
|
if(count($errors) == 0) {
|
||||||
update_operator_permissions($op['operatorid'],$new_permissions);
|
update_operator_permissions($op['operatorid'],$new_permissions);
|
||||||
|
|
||||||
if ($opId && $_SESSION['operator'] && $operator['operatorid'] == $opId) {
|
if ($opId && $_SESSION[$mysqlprefix . 'operator'] && $operator['operatorid'] == $opId) {
|
||||||
$_SESSION['operator']['iperm'] = $new_permissions;
|
$_SESSION[$mysqlprefix . $mysqlprefix . 'operator']['iperm'] = $new_permissions;
|
||||||
}
|
}
|
||||||
header("Location: $webimroot/operator/permissions.php?op=$opId&stored");
|
header("Location: $webimroot/operator/permissions.php?op=$opId&stored");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$page['permissionsList'] = get_permission_list();
|
$page['permissionsList'] = get_permission_list();
|
||||||
$page['formpermissions'] = array("");
|
$page['formpermissions'] = array("");
|
||||||
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
||||||
|
|
||||||
if($op) {
|
if($op) {
|
||||||
foreach($permission_ids as $perm => $id) {
|
foreach($permission_ids as $perm => $id) {
|
||||||
if(is_capable($perm,$op)) {
|
if(is_capable($perm,$op)) {
|
||||||
$page['formpermissions'][] = $id;
|
$page['formpermissions'][] = $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$page['stored'] = isset($_GET['stored']);
|
$page['stored'] = isset($_GET['stored']);
|
||||||
prepare_menu($operator);
|
prepare_menu($operator);
|
||||||
setup_operator_settings_tabs($opId,3);
|
setup_operator_settings_tabs($opId,3);
|
||||||
start_html_output();
|
start_html_output();
|
||||||
require('../view/permissions.php');
|
require('../view/permissions.php');
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user