2009-03-23 00:22:51 +03:00
|
|
|
<?php
|
|
|
|
/*
|
2013-03-07 01:22:53 +04:00
|
|
|
* Copyright 2005-2013 the original author or authors.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-03-23 00:22:51 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../libs/common.php');
|
|
|
|
require_once('../libs/operator.php');
|
|
|
|
require_once('../libs/operator_settings.php');
|
|
|
|
|
|
|
|
$operator = check_login();
|
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
function update_operator_groups($operatorid, $newvalue)
|
|
|
|
{
|
|
|
|
global $mysqlprefix;
|
2009-03-23 00:22:51 +03:00
|
|
|
$link = connect();
|
2011-02-26 16:13:16 +03:00
|
|
|
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid", $link);
|
2011-02-26 17:06:19 +03:00
|
|
|
foreach ($newvalue as $groupid) {
|
2011-02-26 16:13:16 +03:00
|
|
|
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
|
2009-03-23 00:22:51 +03:00
|
|
|
}
|
2011-11-09 18:16:37 +04:00
|
|
|
close_connection($link);
|
2009-03-23 00:22:51 +03:00
|
|
|
}
|
|
|
|
|
2012-02-25 23:40:05 +04:00
|
|
|
$operator_in_isolation = in_isolation($operator);
|
2009-07-19 04:07:34 +04:00
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
$opId = verifyparam("op", "/^\d{1,9}$/");
|
2009-04-10 18:12:57 +04:00
|
|
|
$page = array('opid' => $opId);
|
2009-07-19 04:07:34 +04:00
|
|
|
$link = connect();
|
2012-02-25 23:40:05 +04:00
|
|
|
$page['groups'] = $operator_in_isolation?get_all_groups_for_operator($operator, $link):get_all_groups($link);
|
2011-11-09 18:16:37 +04:00
|
|
|
close_connection($link);
|
2009-03-23 00:22:51 +03:00
|
|
|
$errors = array();
|
|
|
|
|
2012-02-18 23:58:46 +04:00
|
|
|
$canmodify = is_capable($can_administrate, $operator);
|
2009-05-31 20:13:22 +04:00
|
|
|
|
2009-03-23 00:22:51 +03:00
|
|
|
$op = operator_by_id($opId);
|
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
if (!$op) {
|
2009-03-23 00:22:51 +03:00
|
|
|
$errors[] = getlocal("no_such_operator");
|
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
} else if (isset($_POST['op'])) {
|
2009-03-23 00:22:51 +03:00
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
if (!$canmodify) {
|
2009-04-10 18:12:57 +04:00
|
|
|
$errors[] = getlocal('page_agent.cannot_modify');
|
2009-03-23 00:22:51 +03:00
|
|
|
}
|
2009-05-31 20:13:22 +04:00
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
if (count($errors) == 0) {
|
2009-04-10 18:12:57 +04:00
|
|
|
$new_groups = array();
|
2011-02-26 17:06:19 +03:00
|
|
|
foreach ($page['groups'] as $group) {
|
|
|
|
if (verifyparam("group" . $group['groupid'], "/^on$/", "") == "on") {
|
2009-04-10 18:12:57 +04:00
|
|
|
$new_groups[] = $group['groupid'];
|
|
|
|
}
|
|
|
|
}
|
2011-02-26 17:06:19 +03:00
|
|
|
|
|
|
|
update_operator_groups($op['operatorid'], $new_groups);
|
2009-04-10 18:12:57 +04:00
|
|
|
header("Location: $webimroot/operator/opgroups.php?op=$opId&stored");
|
|
|
|
exit;
|
|
|
|
}
|
2009-03-23 00:22:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$page['formgroup'] = array();
|
2011-02-26 17:06:19 +03:00
|
|
|
$page['currentop'] = $op ? topage(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : "-not found-";
|
2009-05-31 20:13:22 +04:00
|
|
|
$page['canmodify'] = $canmodify ? "1" : "";
|
2009-03-23 00:22:51 +03:00
|
|
|
|
2011-02-26 17:06:19 +03:00
|
|
|
if ($op) {
|
|
|
|
foreach (get_operator_groupids($opId) as $rel) {
|
2009-03-23 00:22:51 +03:00
|
|
|
$page['formgroup'][] = $rel['groupid'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-25 02:34:57 +03:00
|
|
|
$page['stored'] = isset($_GET['stored']);
|
2009-03-23 00:22:51 +03:00
|
|
|
prepare_menu($operator);
|
2011-02-26 17:06:19 +03:00
|
|
|
setup_operator_settings_tabs($opId, 2);
|
2009-03-23 00:22:51 +03:00
|
|
|
start_html_output();
|
|
|
|
require('../view/operator_groups.php');
|
2011-11-09 18:16:37 +04:00
|
|
|
?>
|