Add a controller for group-related actions

This commit is contained in:
Dmitriy Simushev 2014-05-20 14:06:39 +00:00
parent 4f5207858f
commit d6d4e36640
11 changed files with 505 additions and 360 deletions

View File

@ -0,0 +1,423 @@
<?php
/*
* Copyright 2005-2014 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.
*/
namespace Mibew\Controller;
use Mibew\Database;
use Mibew\Http\Exception\NotFoundException;
use Symfony\Component\HttpFoundation\Request;
/**
* Contains all actions which are related with operators' groups.
*/
class GroupController extends AbstractController
{
/**
* Generates list of all available groups.
*
* @param Request $request
* @return string Rendered page content
*/
public function indexAction(Request $request)
{
set_csrf_token();
$operator = $request->attributes->get('_operator');
$page = array(
'errors' => array(),
);
$sort_by = $request->query->get('sortby');
if (!in_array($sort_by, array('name', 'lastseen', 'weight'))) {
$sort_by = 'name';
}
$sort['by'] = $sort_by;
$sort['desc'] = ($request->query->get('sortdirection', 'desc') == 'desc');
// Load and prepare groups
$groups = get_sorted_groups($sort);
foreach ($groups as &$group) {
$group['vclocalname'] = $group['vclocalname'];
$group['vclocaldescription'] = $group['vclocaldescription'];
$group['isOnline'] = group_is_online($group);
$group['isAway'] = group_is_away($group);
$group['lastTimeOnline'] = time() - ($group['ilastseen'] ? $group['ilastseen'] : time());
$group['inumofagents'] = $group['inumofagents'];
}
unset($group);
// Set values that are needed to build sorting block.
$page['groups'] = $groups;
$page['formsortby'] = $sort['by'];
$page['formsortdirection'] = $sort['desc'] ? 'desc' : 'asc';
$page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator);
$page['availableOrders'] = array(
array('id' => 'name', 'name' => getlocal('form.field.groupname')),
array('id' => 'lastseen', 'name' => getlocal('page_agents.status')),
array('id' => 'weight', 'name' => getlocal('page.groups.weight')),
);
$page['availableDirections'] = array(
array('id' => 'desc', 'name' => getlocal('page.groups.sortdirection.desc')),
array('id' => 'asc', 'name' => getlocal('page.groups.sortdirection.asc')),
);
// Set other variables and render the response.
$page['title'] = getlocal('page.groups.title');
$page['menuid'] = 'groups';
$page = array_merge($page, prepare_menu($operator));
return $this->render('groups', $page);
}
/**
* Removes a group from the database.
*
* @param Request $request
* @return string Rendered page content
*/
public function deleteAction(Request $request)
{
csrf_check_token($request);
$db = Database::getInstance();
// Remove the group and all its relations.
$group_id = $request->attributes->getInt('group_id');
$db->query("DELETE FROM {chatgroup} WHERE groupid = ?", array($group_id));
$db->query("DELETE FROM {chatgroupoperator} WHERE groupid = ?", array($group_id));
$db->query("UPDATE {chatthread} SET groupid = 0 WHERE groupid = ?", array($group_id));
// Redirect user to canned messages list. Use only "sortby" and
// "sortdirection" get params for the target URL.
$parameters = array_intersect_key(
$request->query->all(),
array_flip(array('sortby', 'sortdirection'))
);
return $this->redirect($this->generateUrl('groups', $parameters));
}
/**
* Builds a page with members edit form.
*
* @param Request $request
* @return string Rendered page content
*/
public function showMembersFormAction(Request $request)
{
set_csrf_token();
$operator = $request->attributes->get('_operator');
$group_id = $request->attributes->getInt('group_id');
$page = array(
'groupid' => $group_id,
// Use errors list stored in the request. We need to do so to have
// an ability to pass the request from the "submitMembersForm" action.
'errors' => $request->attributes->get('errors', array()),
);
$operators = get_operators_list();
$group = group_by_id($group_id);
// Check if the group exists
if (!$group) {
throw new NotFoundException('The group is not found.');
}
$page['formop'] = array();
$page['currentgroup'] = $group
? htmlspecialchars($group['vclocalname'])
: '';
// Get list of group's members
$checked_operators = array();
foreach (get_group_members($group_id) as $rel) {
$checked_operators[] = $rel['operatorid'];
}
// Prepare the list of all operators
$page['operators'] = array();
foreach ($operators as $op) {
$op['vclocalename'] = $op['vclocalename'];
$op['vclogin'] = $op['vclogin'];
$op['checked'] = in_array($op['operatorid'], $checked_operators);
$page['operators'][] = $op;
}
// Set other values and render the page
$page['stored'] = $request->query->get('stored');
$page['title'] = getlocal('page.groupmembers.title');
$page['menuid'] = 'groups';
$page = array_merge($page, prepare_menu($operator));
$page['tabs'] = $this->buildTabs($request);
return $this->render('group_members', $page);
}
/**
* Processes submitting of the form which is generated in
* {@link \Mibew\Controller\GroupController::showMembersFormAction()} method.
*
* @param Request $request
* @return string Rendered page content
*/
public function submitMembersFormAction(Request $request)
{
csrf_check_token($request);
$operators = get_operators_list();
$group_id = $request->attributes->getInt('group_id');
$group = group_by_id($group_id);
// Check if specified group exists
if (!$group) {
throw new NotFoundException('The group is not found.');
}
// Update members list
$new_members = array();
foreach ($operators as $op) {
if ($request->request->get('op' . $op['operatorid']) == 'on') {
$new_members[] = $op['operatorid'];
}
}
update_group_members($group_id, $new_members);
// Redirect opeartor to group members page.
$parameters = array(
'group_id' => $group_id,
'stored' => true,
);
return $this->redirect($this->generateUrl('group_members', $parameters));
}
/**
* Builds a page with form for add/edit group.
*
* @param Request $request
* @return string Rendered page content
*/
public function showEditFormAction(Request $request)
{
set_csrf_token();
$operator = $request->attributes->get('_operator');
$group_id = $request->attributes->getInt('group_id', false);
$page = array(
'gid' => false,
// Use errors list stored in the request. We need to do so to have
// an ability to pass the request from the "submitEditForm" action.
'errors' => $request->attributes->get('errors', array()),
);
if ($group_id) {
// Check if the group exisits
$group = group_by_id($group_id);
if (!$group) {
throw new NotFoundException('The group is not found.');
}
// Set form values
$page['formname'] = $group['vclocalname'];
$page['formdescription'] = $group['vclocaldescription'];
$page['formcommonname'] = $group['vccommonname'];
$page['formcommondescription'] = $group['vccommondescription'];
$page['formemail'] = $group['vcemail'];
$page['formweight'] = $group['iweight'];
$page['formparentgroup'] = $group['parent'];
$page['grid'] = $group['groupid'];
$page['formtitle'] = $group['vctitle'];
$page['formchattitle'] = $group['vcchattitle'];
$page['formhosturl'] = $group['vchosturl'];
$page['formlogo'] = $group['vclogo'];
}
// Override group's fields from the request if it's needed. This
// case will take place when save handler fails.
if ($request->isMethod('POST')) {
$page['formname'] = $request->request->get('name');
$page['formdescription'] = $request->request->get('description');
$page['formcommonname'] = $request->request->get('commonname');
$page['formcommondescription'] = $request->request->get('commondescription');
$page['formemail'] = $request->request->get('email');
$page['formweight'] = $request->request->get('weight');
$page['formparentgroup'] = $request->request->get('parentgroup');
$page['formtitle'] = $request->request->get('title');
$page['formchattitle'] = $request->request->get('chattitle');
$page['formhosturl'] = $request->request->get('hosturl');
$page['formlogo'] = $request->request->get('logo');
}
// Set other page variables and render the template.
$page['stored'] = $request->query->has('stored');
$page['availableParentGroups'] = get_available_parent_groups($group_id);
$page['formaction'] = $request->getBaseUrl() . $request->getPathInfo();
$page['title'] = getlocal('page.group.title');
$page['menuid'] = 'groups';
$page = array_merge($page, prepare_menu($operator));
$page['tabs'] = $this->buildTabs($request);
return $this->render('group_edit', $page);
}
/**
* Processes submitting of the form which is generated in
* {@link \Mibew\Controller\GroupController::showEditFormAction()} method.
*
* @param Request $request
* @return string Rendered page content
*/
public function submitEditFormAction(Request $request)
{
csrf_check_token($request);
$errors = array();
// Use value from the form and not from the path to make sure it is
// correct. If not, treat the param as empty one.
$group_id = $request->request->get('gid', false);
if (!preg_match("/^\d{1,10}$/", $group_id)) {
$group_id = false;
}
$parent_group = $request->request->get('parentgroup');
if (!$parent_group || !preg_match("/^\d{1,10}$/", $parent_group)) {
$parent_group = null;
}
$name = $request->request->get('name');
$description = $request->request->get('description');
$common_name = $request->request->get('commonname');
$common_description = $request->request->get('commondescription');
$email = $request->request->get('email');
$weight = $request->request->get('weight');
$title = $request->request->get('title');
$chat_title = $request->request->get('chattitle');
$host_url = $request->request->get('hosturl');
$logo = $request->request->get('logo');
if (!$name) {
$errors[] = no_field("form.field.groupname");
}
if ($email != '' && !is_valid_email($email)) {
$errors[] = wrong_field("form.field.mail");
}
if (!preg_match("/^(\d{1,10})?$/", $weight)) {
$errors[] = wrong_field("form.field.groupweight");
}
if (!$weight) {
$weight = 0;
}
$existing_group = group_by_name($name);
$duplicate_name = (!$group_id && $existing_group)
|| ($group_id
&& $existing_group
&& $group_id != $existing_group['groupid']);
if ($duplicate_name) {
$errors[] = getlocal("page.group.duplicate_name");
}
if (count($errors) != 0) {
$request->attributes->set('errors', $errors);
// The form should be rebuild. Invoke appropriate action.
return $this->showEditFormAction($request);
}
if (!$group_id) {
// Greate new group
$new_dep = create_group(array(
'name' => $name,
'description' => $description,
'commonname' => $common_name,
'commondescription' => $common_description,
'email' => $email,
'weight' => $weight,
'parent' => $parent_group,
'title' => $title,
'chattitle' => $chat_title,
'hosturl' => $host_url,
'logo' => $logo));
// Redirect an operator to group's member page.
$redirect_to = $this->generateUrl(
'group_members',
array('group_id' => (int)$new_dep['groupid'])
);
} else {
// Update exisitng group
update_group(array(
'id' => $group_id,
'name' => $name,
'description' => $description,
'commonname' => $common_name,
'commondescription' => $common_description,
'email' => $email,
'weight' => $weight,
'parent' => $parent_group,
'title' => $title,
'chattitle' => $chat_title,
'hosturl' => $host_url,
'logo' => $logo));
// Redirect an operator to group's page.
$redirect_to = $this->generateUrl(
'group_edit',
array('group_id' => $group_id)
);
}
return $this->redirect($redirect_to);
}
/**
* Builds list of the group tabs.
*
* @param Request $request Current request.
* @return array Tabs list. The keys of the array are tabs titles and the
* values are tabs URLs.
*/
protected function buildTabs(Request $request)
{
$tabs = array();
$route = $request->attributes->get('_route');
$group_id = $request->attributes->get('group_id', false);
$args = array('group_id' => $group_id);
if ($group_id) {
$tabs[getlocal('page_group.tab.main')] = ($route == 'group_members')
? $this->generateUrl('group_edit', $args)
: '';
$tabs[getlocal('page_group.tab.members')] = ($route != 'group_members')
? $this->generateUrl('group_members', $args)
: '';
}
return $tabs;
}
}

View File

@ -79,32 +79,6 @@ function get_group_name($group)
} }
} }
/**
* Builds list of group settings tabs. The keys are tabs titles and the values
* are tabs URLs.
*
* @param int $gid ID of the group whose settings page is displayed.
* @param int $active Number of the active tab. The count starts from 0.
* @return array Tabs list
*/
function setup_group_settings_tabs($gid, $active)
{
$tabs = array();
if ($gid) {
$tabs = array(
getlocal("page_group.tab.main") => ($active != 0
? (MIBEW_WEB_ROOT . "/operator/group.php?gid=$gid")
: ""),
getlocal("page_group.tab.members") => ($active != 1
? (MIBEW_WEB_ROOT . "/operator/groupmembers.php?gid=$gid")
: ""),
);
}
return $tabs;
}
/** /**
* Builds list of group ids for specific operator * Builds list of group ids for specific operator
* *

View File

@ -60,6 +60,79 @@ canned_messages:
_controller: Mibew\Controller\CannedMessageController::indexAction _controller: Mibew\Controller\CannedMessageController::indexAction
_access_check: Mibew\AccessControl\Check\LoggedInCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
## Groups
group_delete:
path: /operator/group/{group_id}/delete
defaults:
_controller: Mibew\Controller\GroupController::deleteAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
group_id: \d{0,10}
group_add:
path: /operator/group/add
defaults:
_controller: Mibew\Controller\GroupController::showEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
methods: [GET]
group_add_save:
path: /operator/group/add
defaults:
_controller: Mibew\Controller\GroupController::submitEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
methods: [POST]
group_edit:
path: /operator/group/{group_id}/edit
defaults:
_controller: Mibew\Controller\GroupController::showEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
group_id: \d{0,10}
methods: [GET]
group_edit_save:
path: /operator/group/{group_id}/edit
defaults:
_controller: Mibew\Controller\GroupController::submitEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
group_id: \d{0,10}
methods: [POST]
group_members:
path: /operator/group/{group_id}/members
defaults:
_controller: Mibew\Controller\GroupController::showMembersFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
group_id: \d{0,10}
methods: [GET]
group_members_save:
path: /operator/group/{group_id}/members
defaults:
_controller: Mibew\Controller\GroupController::submitMembersFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
group_id: \d{0,10}
methods: [POST]
groups:
path: /operator/group
defaults:
_controller: Mibew\Controller\GroupController::indexAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
## History ## History
history: history:
path: /operator/history path: /operator/history

View File

@ -1,158 +0,0 @@
<?php
/*
* Copyright 2005-2014 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.
*/
// Import namespaces and classes of the core
use Mibew\Style\PageStyle;
// Initialize libraries
require_once(dirname(dirname(__FILE__)) . '/libs/init.php');
$operator = check_login();
csrf_check_token();
$page = array(
'grid' => '',
'errors' => array(),
);
$group_id = '';
if (isset($_POST['name'])) {
$group_id = verify_param("gid", "/^(\d{1,9})?$/", "");
$name = get_param('name');
$description = get_param('description');
$common_name = get_param('commonname');
$common_description = get_param('commondescription');
$email = get_param('email');
$weight = get_param('weight');
$parent_group = verify_param("parentgroup", "/^(\d{1,9})?$/", "");
$title = get_param('title');
$chat_title = get_param('chattitle');
$host_url = get_param('hosturl');
$logo = get_param('logo');
if (!$name) {
$page['errors'][] = no_field("form.field.groupname");
}
if ($email != '' && !is_valid_email($email)) {
$page['errors'][] = wrong_field("form.field.mail");
}
if (!preg_match("/^(\d{1,9})?$/", $weight)) {
$page['errors'][] = wrong_field("form.field.groupweight");
}
if ($weight == '') {
$weight = 0;
}
if (!$parent_group) {
$parent_group = null;
}
$existing_group = group_by_name($name);
$duplicate_name = (!$group_id && $existing_group)
|| ($group_id
&& $existing_group
&& $group_id != $existing_group['groupid']);
if ($duplicate_name) {
$page['errors'][] = getlocal("page.group.duplicate_name");
}
if (count($page['errors']) == 0) {
if (!$group_id) {
$new_dep = create_group(array(
'name' => $name,
'description' => $description,
'commonname' => $common_name,
'commondescription' => $common_description,
'email' => $email,
'weight' => $weight,
'parent' => $parent_group,
'title' => $title,
'chattitle' => $chat_title,
'hosturl' => $host_url,
'logo' => $logo));
header("Location: " . MIBEW_WEB_ROOT . "/operator/groupmembers.php?gid=" . intval($new_dep['groupid']));
exit;
} else {
update_group(array(
'id' => $group_id,
'name' => $name,
'description' => $description,
'commonname' => $common_name,
'commondescription' => $common_description,
'email' => $email,
'weight' => $weight,
'parent' => $parent_group,
'title' => $title,
'chattitle' => $chat_title,
'hosturl' => $host_url,
'logo' => $logo));
header("Location: " . MIBEW_WEB_ROOT . "/operator/group.php?gid=" . intval($group_id) . "&stored");
exit;
}
} else {
$page['formname'] = $name;
$page['formdescription'] = $description;
$page['formcommonname'] = $common_name;
$page['formcommondescription'] = $common_description;
$page['formemail'] = $email;
$page['formweight'] = $weight;
$page['formparentgroup'] = $parent_group;
$page['grid'] = $group_id;
$page['formtitle'] = $title;
$page['formchattitle'] = $chat_title;
$page['formhosturl'] = $host_url;
$page['formlogo'] = $logo;
}
} elseif (isset($_GET['gid'])) {
$group_id = verify_param('gid', "/^\d{1,9}$/");
$group = group_by_id($group_id);
if (!$group) {
$page['errors'][] = getlocal("page.group.no_such");
$page['grid'] = $group_id;
} else {
$page['formname'] = $group['vclocalname'];
$page['formdescription'] = $group['vclocaldescription'];
$page['formcommonname'] = $group['vccommonname'];
$page['formcommondescription'] = $group['vccommondescription'];
$page['formemail'] = $group['vcemail'];
$page['formweight'] = $group['iweight'];
$page['formparentgroup'] = $group['parent'];
$page['grid'] = $group['groupid'];
$page['formtitle'] = $group['vctitle'];
$page['formchattitle'] = $group['vcchattitle'];
$page['formhosturl'] = $group['vchosturl'];
$page['formlogo'] = $group['vclogo'];
}
}
$page['stored'] = isset($_GET['stored']);
$page['availableParentGroups'] = get_available_parent_groups($group_id);
$page['title'] = getlocal("page.group.title");
$page['menuid'] = "groups";
$page = array_merge($page, prepare_menu($operator));
$page['tabs'] = setup_group_settings_tabs($group_id, 0);
$page_style = new PageStyle(PageStyle::getCurrentStyle());
$page_style->render('group', $page);

View File

@ -1,78 +0,0 @@
<?php
/*
* Copyright 2005-2014 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.
*/
// Import namespaces and classes of the core
use Mibew\Style\PageStyle;
// Initialize libraries
require_once(dirname(dirname(__FILE__)) . '/libs/init.php');
$operator = check_login();
csrf_check_token();
$group_id = verify_param("gid", "/^\d{1,9}$/");
$page = array(
'groupid' => $group_id,
'errors' => array(),
);
$operators = get_operators_list();
$group = group_by_id($group_id);
if (!$group) {
$page['errors'][] = getlocal("page.group.no_such");
} elseif (isset($_POST['gid'])) {
$new_members = array();
foreach ($operators as $op) {
if (verify_param("op" . $op['operatorid'], "/^on$/", "") == "on") {
$new_members[] = $op['operatorid'];
}
}
update_group_members($group_id, $new_members);
header("Location: " . MIBEW_WEB_ROOT . "/operator/groupmembers.php?gid=" . intval($group_id) . "&stored");
exit;
}
$page['formop'] = array();
$page['currentgroup'] = $group ? htmlspecialchars($group['vclocalname']) : "";
$checked_operators = array();
foreach (get_group_members($group_id) as $rel) {
$checked_operators[] = $rel['operatorid'];
}
$page['operators'] = array();
foreach ($operators as $op) {
$op['vclocalename'] = $op['vclocalename'];
$op['vclogin'] = $op['vclogin'];
$op['checked'] = in_array($op['operatorid'], $checked_operators);
$page['operators'][] = $op;
}
$page['stored'] = isset($_GET['stored']);
$page['title'] = getlocal("page.groupmembers.title");
$page['menuid'] = "groups";
$page = array_merge($page, prepare_menu($operator));
$page['tabs'] = setup_group_settings_tabs($group_id, 1);
$page_style = new PageStyle(PageStyle::getCurrentStyle());
$page_style->render('group_members', $page);

View File

@ -1,89 +0,0 @@
<?php
/*
* Copyright 2005-2014 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.
*/
// Import namespaces and classes of the core
use Mibew\Database;
use Mibew\Style\PageStyle;
// Initialize libraries
require_once(dirname(dirname(__FILE__)) . '/libs/init.php');
$operator = check_login();
csrf_check_token();
$page = array(
'errors' => array(),
);
if (isset($_GET['act']) && $_GET['act'] == 'del') {
$group_id = isset($_GET['gid']) ? $_GET['gid'] : "";
if (!preg_match("/^\d+$/", $group_id)) {
$page['errors'][] = getlocal("page.groups.error.cannot_delete");
}
if (!is_capable(CAN_ADMINISTRATE, $operator)) {
$page['errors'][] = getlocal("page.groups.error.forbidden_remove");
}
if (count($page['errors']) == 0) {
$db = Database::getInstance();
$db->query("delete from {chatgroup} where groupid = ?", array($group_id));
$db->query("delete from {chatgroupoperator} where groupid = ?", array($group_id));
$db->query("update {chatthread} set groupid = 0 where groupid = ?", array($group_id));
header("Location: " . MIBEW_WEB_ROOT . "/operator/groups.php");
exit;
}
}
$sort['by'] = verify_param("sortby", "/^(name|lastseen|weight)$/", "name");
$sort['desc'] = (verify_param("sortdirection", "/^(desc|asc)$/", "desc") == "desc");
// Load and prepare groups
$groups = get_sorted_groups($sort);
foreach ($groups as &$group) {
$group['vclocalname'] = $group['vclocalname'];
$group['vclocaldescription'] = $group['vclocaldescription'];
$group['isOnline'] = group_is_online($group);
$group['isAway'] = group_is_away($group);
$group['lastTimeOnline'] = time() - ($group['ilastseen'] ? $group['ilastseen'] : time());
$group['inumofagents'] = $group['inumofagents'];
}
unset($group);
$page['groups'] = $groups;
$page['formsortby'] = $sort['by'];
$page['formsortdirection'] = $sort['desc'] ? 'desc' : 'asc';
$page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator);
$page['availableOrders'] = array(
array('id' => 'name', 'name' => getlocal('form.field.groupname')),
array('id' => 'lastseen', 'name' => getlocal('page_agents.status')),
array('id' => 'weight', 'name' => getlocal('page.groups.weight')),
);
$page['availableDirections'] = array(
array('id' => 'desc', 'name' => getlocal('page.groups.sortdirection.desc')),
array('id' => 'asc', 'name' => getlocal('page.groups.sortdirection.asc')),
);
$page['title'] = getlocal("page.groups.title");
$page['menuid'] = "groups";
$page = array_merge($page, prepare_menu($operator));
$page_style = new PageStyle(PageStyle::getCurrentStyle());
$page_style->render('groups', $page);

View File

@ -30,7 +30,7 @@
{{#if showadmin}} {{#if showadmin}}
<li{{#ifEqual menuid "getcode"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/getcode.php">{{l10n "leftMenu.client_gen_button"}}</a></li> <li{{#ifEqual menuid "getcode"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/getcode.php">{{l10n "leftMenu.client_gen_button"}}</a></li>
<li{{#ifEqual menuid "operators"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/operators.php">{{l10n "leftMenu.client_agents"}}</a></li> <li{{#ifEqual menuid "operators"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/operators.php">{{l10n "leftMenu.client_agents"}}</a></li>
<li{{#ifEqual menuid "groups"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/groups.php">{{l10n "menu.groups"}}</a></li> <li{{#ifEqual menuid "groups"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/group">{{l10n "menu.groups"}}</a></li>
<li{{#ifEqual menuid "settings"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/settings.php">{{l10n "leftMenu.client_settings"}}</a></li> <li{{#ifEqual menuid "settings"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/settings.php">{{l10n "leftMenu.client_settings"}}</a></li>
<li{{#ifEqual menuid "translate"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/translate.php">{{l10n "menu.translate"}}</a></li> <li{{#ifEqual menuid "translate"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/translate.php">{{l10n "menu.translate"}}</a></li>
<li{{#ifEqual menuid "updates"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/updates">{{l10n "menu.updates"}}</a></li> <li{{#ifEqual menuid "updates"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/updates">{{l10n "menu.updates"}}</a></li>

View File

@ -22,7 +22,7 @@
<div id="formmessage">{{l10n "data.saved"}}</div> <div id="formmessage">{{l10n "data.saved"}}</div>
{{/if}} {{/if}}
<form name="groupForm" method="post" action="{{mibewRoot}}/operator/group.php"> <form name="groupForm" method="post" action="{{formaction}}">
{{csrfTokenInput}} {{csrfTokenInput}}
<input type="hidden" name="gid" value="{{grid}}"/> <input type="hidden" name="gid" value="{{grid}}"/>

View File

@ -13,7 +13,7 @@
<div id="formmessage">{{l10n "data.saved"}}</div> <div id="formmessage">{{l10n "data.saved"}}</div>
{{/if}} {{/if}}
<form name="membersForm" method="post" action="{{mibewRoot}}/operator/groupmembers.php"> <form name="membersForm" method="post" action="{{mibewRoot}}/operator/group/{{groupid}}/members">
{{csrfTokenInput}} {{csrfTokenInput}}
<input type="hidden" name="gid" value="{{groupid}}"/> <input type="hidden" name="gid" value="{{groupid}}"/>

View File

@ -25,7 +25,7 @@
{{> _errors}} {{> _errors}}
<form name="groupsForm" method="get" action="{{mibewRoot}}/operator/groups.php"> <form name="groupsForm" method="get" action="{{mibewRoot}}/operator/group">
<div class="mform"> <div class="mform">
<div class="formtop"> <div class="formtop">
<div class="formtopi"></div> <div class="formtopi"></div>
@ -63,7 +63,7 @@
{{#if canmodify}} {{#if canmodify}}
<div class="tabletool"> <div class="tabletool">
<img src="{{stylePath}}/images/buttons/createdep.gif" border="0" alt="" /> <img src="{{stylePath}}/images/buttons/createdep.gif" border="0" alt="" />
<a href="{{mibewRoot}}/operator/group.php" title="{{l10n "page.groups.new"}}"> <a href="{{mibewRoot}}/operator/group/add" title="{{l10n "page.groups.new"}}">
{{l10n "page.groups.new"}} {{l10n "page.groups.new"}}
</a> </a>
</div> </div>
@ -88,7 +88,7 @@
{{#each groups}} {{#each groups}}
<tr> <tr>
<td class="notlast level{{level}}"> <td class="notlast level{{level}}">
<a href="{{../mibewRoot}}/operator/group.php?gid={{groupid}}" id="ti{{groupid}}" class="man"> <a href="{{../mibewRoot}}/operator/group/{{groupid}}/edit" id="ti{{groupid}}" class="man">
{{vclocalname}} {{vclocalname}}
</a> </a>
</td> </td>
@ -114,7 +114,7 @@
</td> </td>
<td> <td>
<a href="{{../mibewRoot}}/operator/groupmembers.php?gid={{groupid}}"> <a href="{{../mibewRoot}}/operator/group/{{groupid}}/members">
{{inumofagents}} {{inumofagents}}
</a> </a>
</td> </td>
@ -125,7 +125,7 @@
{{#if ../canmodify}} {{#if ../canmodify}}
<td> <td>
<a href="{{../mibewRoot}}/operator/groups.php?act=del&amp;gid={{groupid}}{{csrfTokenInUrl}}" id="i{{groupid}}" class="removelink"> <a href="{{../mibewRoot}}/operator/group/{{groupid}}/delete?{{csrfTokenInUrl}}" id="i{{groupid}}" class="removelink">
{{l10n "remove.item"}} {{l10n "remove.item"}}
</a> </a>
</td> </td>

View File

@ -104,7 +104,7 @@
<div class="dashitem"> <div class="dashitem">
<div class="dashitem-content"> <div class="dashitem-content">
<img src="{{stylePath}}/images/dash/dep.gif" alt=""/> <img src="{{stylePath}}/images/dash/dep.gif" alt=""/>
<a href="{{mibewRoot}}/operator/groups.php"> <a href="{{mibewRoot}}/operator/group">
{{l10n "menu.groups"}} {{l10n "menu.groups"}}
</a> </a>
{{l10n "menu.groups.content"}} {{l10n "menu.groups.content"}}