From bec330faaf57db4462dd557591408a589bfe9af8 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 18 Jun 2013 11:38:54 +0000 Subject: [PATCH] 2013-06-18 Miguel de Dios * operation/menu.php: showed the message entry in workspace menu for all users. * include/functions_groups.php: added filters into the function "groups_get_users" for to avoid to get user without perms. * operation/messages/message_edit.php: fixed the ACL for to destination users. MERGED FROM THE BRANCH PANDORA_4.0 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8347 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 ++++++++ pandora_console/include/functions_groups.php | 33 ++++++++++--------- pandora_console/operation/menu.php | 23 +++++++------ .../operation/messages/message_edit.php | 26 +++++++++++++-- 4 files changed, 65 insertions(+), 30 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 826cb471b8..96d308108a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-06-18 Miguel de Dios + + * operation/menu.php: showed the message entry in workspace menu for + all users. + + * include/functions_groups.php: added filters into the function + "groups_get_users" for to avoid to get user without perms. + + * operation/messages/message_edit.php: fixed the ACL for to + destination users. + + MERGED FROM THE BRANCH PANDORA_4.0 + 2013-06-18 Ramon Novoa * include/functions.php: Fixed a warning. diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index cf10fbe86f..86a1bd9980 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -357,7 +357,7 @@ function groups_is_all_group($idGroups) { break; } } - + return $returnVar; } @@ -603,22 +603,26 @@ function groups_get_users ($id_group, $filter = false) { $filter['id_grupo'] = $id_group; - $resulta = array(); - $resulta = db_get_all_rows_filter ("tusuario_perfil", $filter); + $result_a = array(); + if (!is_array($id_group) && !empty($id_group)) { + $result_a = db_get_all_rows_filter ("tusuario_perfil", $filter); + } - // The users of the group All (0) will be also returned - $filter['id_grupo'] = 0; - $resultb = array(); - $resultb = db_get_all_rows_filter ("tusuario_perfil", $filter); + $result_b = array(); + if ($return_user_all) { + // The users of the group All (0) will be also returned + $filter['id_grupo'] = 0; + $result_b = db_get_all_rows_filter ("tusuario_perfil", $filter); + } - if ($resulta == false && $resultb == false) + if ($result_a == false && $result_b == false) $result = false; - elseif ($resulta == false) - $result = $resultb; - elseif ($resultb == false) - $result = $resulta; + elseif ($result_a == false) + $result = $result_b; + elseif ($result_b == false) + $result = $result_a; else - $result = array_merge($resulta,$resultb); + $result = array_merge($result_a, $result_b); if ($result === false) return array (); @@ -1353,7 +1357,7 @@ function groups_total_agents ($group_array, $disabled = false) { return 0; } - else if (!is_array ($group_array)){ + else if (!is_array ($group_array)) { $group_array = array($group_array); } @@ -1393,5 +1397,4 @@ function groups_agent_disabled ($group_array) { return db_get_sql ($sql); } - ?> diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index e1d3e01ee4..872ebe007e 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -26,7 +26,7 @@ $menu_operation = array (); $menu_operation['class'] = 'operation'; // Agent read, Server read -if (check_acl ($config['id_user'], 0, "AR")) { +if (check_acl ($config['id_user'], 0, "AR")) { //View agents $menu_operation["estado"]["text"] = __('Monitoring'); $menu_operation["estado"]["sec2"] = "operation/agentes/tactical"; @@ -283,6 +283,7 @@ $sub["operation/users/user_edit"]["refr"] = 0; $sub["operation/users/webchat"]["text"] = __('WebChat'); $sub["operation/users/webchat"]["refr"] = 0; + //Incidents if (check_acl ($config['id_user'], 0, "IR") == 1) { $temp_sec2 = $sec2; @@ -306,17 +307,15 @@ if (check_acl ($config['id_user'], 0, "IR") == 1) { $sec2 = $temp_sec2; } -if (check_acl ($config['id_user'], 0, "AR")) { - - // Messages - $sub["operation/messages/message_list"]["text"] = __('Messages'); - $sub["operation/messages/message_list"]["refr"] = 0; - - $sub2 = array (); - $sub2["operation/messages/message_edit&new_msg=1"]["text"] = __('New message'); - - $sub["operation/messages/message_list"]["sub2"] = $sub2; -} + +// Messages +$sub["operation/messages/message_list"]["text"] = __('Messages'); +$sub["operation/messages/message_list"]["refr"] = 0; + +$sub2 = array (); +$sub2["operation/messages/message_edit&new_msg=1"]["text"] = __('New message'); + +$sub["operation/messages/message_list"]["sub2"] = $sub2; $menu_operation["workspace"]["sub"] = $sub; diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index 3186aa062f..e538ed5607 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -37,11 +37,11 @@ $buttons['message_list'] = array('active' => false, $buttons['sent_messages'] = array('active' => false, 'text' => '' . html_print_image("images/email_outbox.png", true, array ("title" => __('Sent messages'))) .''); - + $buttons['create_message'] = array('active' => true, 'text' => '' . html_print_image("images/new_message.png", true, array ("title" => __('Create message'))) .''); - + // Header ui_print_page_header (__('Messages'), "images/email_mc.png", false, "", false, $buttons); @@ -129,6 +129,7 @@ if (($new_msg) && (!empty ($dst_user)) && (!$reply)) { if (!$user_name) { $user_name = $dst_user; } + ui_print_result_message ($return, __('Message successfully sent to user %s', $user_name), __('Error sending message to user %s', $user_name)); @@ -163,12 +164,31 @@ else { $table->data[1][0] = __('Destination'); -$users_full = groups_get_users (array_keys(users_get_groups())); +$is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); + +if ($is_admin) { + $users_full = db_get_all_rows_filter('tusuario', array(), array('id_user', 'fullname')); +} +else { + $users_full = groups_get_users (array_keys(users_get_groups()), false, false); +} + $users = array(); foreach ($users_full as $user_id => $user_info) { $users[$user_info['id_user']] = $user_info['fullname']; } +//Check if the user to reply is in the list, if not add reply user +if ($reply) { + if (!array_key_exists($dst_user, $users)) { + //Add the user to reply + $user_reply = db_get_row('tusuario', 'id_user', $dst_user); + $users[$user_reply['id_user']] = $user_reply['fullname']; + } +} + + + if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) $return_all_groups = true; else