2011-05-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_profile.php: modified the function "create_user_profile" for to return the id of new user profile. * include/functions_agents.php: added in function "agents_get_agents" the code to filter with enterprise ACL. * operation/agentes/estado_agente.php: cleaned source code style. * godmode/agentes/modificar_agente.php: added the filter for to enterprise ACL. * godmode/users/configure_user.php: added hooks for to enterprise ACL. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4332 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
5e68307afb
commit
5283f3f520
pandora_console
|
@ -1,3 +1,18 @@
|
|||
2011-05-10 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_profile.php: modified the function "create_user_profile"
|
||||
for to return the id of new user profile.
|
||||
|
||||
* include/functions_agents.php: added in function "agents_get_agents" the
|
||||
code to filter with enterprise ACL.
|
||||
|
||||
* operation/agentes/estado_agente.php: cleaned source code style.
|
||||
|
||||
* godmode/agentes/modificar_agente.php: added the filter for to
|
||||
enterprise ACL.
|
||||
|
||||
* godmode/users/configure_user.php: added hooks for to enterprise ACL.
|
||||
|
||||
2011-05-10 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php: Fixed mistake of my last
|
||||
|
|
|
@ -40,6 +40,12 @@ enterprise_include_once('include/functions_policies.php');
|
|||
require_once ('include/functions_agents.php');
|
||||
require_once ('include/functions_users.php');
|
||||
|
||||
//Add enterprise function to add other enterprise ACL.
|
||||
$enterprise_acl = false;
|
||||
if (ENTERPRISE_NOT_HOOK !== enterprise_include_once('include/functions_policies.php')) {
|
||||
$enterprise_acl = true;
|
||||
}
|
||||
|
||||
$search = get_parameter ("search", "");
|
||||
|
||||
$agent_to_delete = (int)get_parameter('borrar_agente');
|
||||
|
@ -244,48 +250,55 @@ else {
|
|||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$sql = sprintf ('SELECT COUNT(*)
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql);
|
||||
$total_agents = db_get_sql ($sql);
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s
|
||||
ORDER BY %s %s LIMIT %d, %d',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s
|
||||
ORDER BY %s %s LIMIT %d OFFSET %d',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
|
||||
break;
|
||||
case "oracle":
|
||||
$set = array ();
|
||||
$set['limit'] = $config["block_size"];
|
||||
$set['offset'] = $offset;
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s
|
||||
ORDER BY %s %s',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql, $order['field'], $order['order']);
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
if (!$enterprise_acl) {
|
||||
$sql = sprintf ('SELECT COUNT(*)
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql);
|
||||
|
||||
$total_agents = db_get_sql ($sql);
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s
|
||||
ORDER BY %s %s LIMIT %d, %d',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s
|
||||
ORDER BY %s %s LIMIT %d OFFSET %d',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
|
||||
break;
|
||||
case "oracle":
|
||||
$set = array ();
|
||||
$set['limit'] = $config["block_size"];
|
||||
$set['offset'] = $offset;
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente
|
||||
WHERE id_grupo IN (%s)
|
||||
%s
|
||||
ORDER BY %s %s',
|
||||
implode (',', array_keys (get_user_groups ())),
|
||||
$search_sql, $order['field'], $order['order']);
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$total_agents = enterprise_count_agents_manage_agents($search_sql);
|
||||
|
||||
$sql = enterprise_sql_manage_agents($search_sql, $order, $offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,12 @@ include_once ($config['homedir'] . '/include/functions_groups.php');
|
|||
|
||||
$isFunctionSkins = enterprise_include_once ('include/functions_skins.php');
|
||||
|
||||
//Add the columns for the enterprise Pandora edition.
|
||||
$enterprise_include = false;
|
||||
if (ENTERPRISE_NOT_HOOK !== enterprise_include('include/functions_policies.php')) {
|
||||
$enterprise_include = true;
|
||||
}
|
||||
|
||||
// This defines the working user. Beware with this, old code get confusses
|
||||
// and operates with current logged user (dangerous).
|
||||
|
||||
|
@ -225,6 +231,11 @@ if ($add_profile) {
|
|||
db_pandora_audit("User management",
|
||||
"Added profile for user ".io_safe_input($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2);
|
||||
$return = create_user_profile ($id2, $profile2, $group2);
|
||||
|
||||
if ($enterprise_include) {
|
||||
add_enterprise_db_data_user_profile_form($return);
|
||||
}
|
||||
|
||||
ui_print_result_message ($return,
|
||||
__('Profile added successfully'),
|
||||
__('Profile cannot be added'));
|
||||
|
@ -359,7 +370,7 @@ if (empty ($id) || $new_user)
|
|||
|
||||
echo '<h3>'.__('Profiles/Groups assigned to this user').'</h3>';
|
||||
|
||||
$table->width = '75%';
|
||||
$table->width = '85%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->align = array ();
|
||||
|
@ -371,6 +382,10 @@ $table->head[1] = __('Group');
|
|||
$table->head[2] = __('Action');
|
||||
$table->align[2] = 'center';
|
||||
|
||||
if ($enterprise_include) {
|
||||
add_enterprise_column_user_profile_form($table);
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id);
|
||||
if ($result === false) {
|
||||
$result = array ();
|
||||
|
@ -388,25 +403,39 @@ foreach ($result as $profile) {
|
|||
$data[2] .= html_print_input_image ('del', 'images/cross.png', 1, '', true);
|
||||
$data[2] .= '</form>';
|
||||
|
||||
if ($enterprise_include) {
|
||||
add_data_enterprise_column_user_profile_form($data, $profile['id_up']);
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
$data[0] = '<form method="post">';
|
||||
if (check_acl ($config['id_user'], 0, "PM")) {
|
||||
$data[0] .= html_print_select (get_profiles (), 'assign_profile', 0, '', __('None'),
|
||||
0, true, false, false);
|
||||
if (!$enterprise_include) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<form method="post">';
|
||||
if (check_acl ($config['id_user'], 0, "PM")) {
|
||||
$data[0] .= html_print_select (get_profiles (), 'assign_profile', 0, '',
|
||||
__('None'), 0, true, false, false);
|
||||
}
|
||||
else {
|
||||
$data[0] .= html_print_select (get_profiles (array ('pandora_management' => '<> 1',
|
||||
'db_management' => '<> 1')), 'assign_profile', 0, '', __('None'), 0,
|
||||
true, false, false);
|
||||
}
|
||||
|
||||
$data[1] = html_print_select_groups($config['id_user'], "UM",
|
||||
$own_info['is_admin'], 'assign_group', -1, '', __('None'), -1, true,
|
||||
false, false);
|
||||
|
||||
$data[2] = html_print_input_image ('add', 'images/add.png', 1, '', true);
|
||||
$data[2] .= html_print_input_hidden ('id', $id, true);
|
||||
$data[2] .= html_print_input_hidden ('add_profile', 1, true);
|
||||
$data[2] .= '</form>';
|
||||
}
|
||||
else {
|
||||
$data[0] .= html_print_select (get_profiles (array ('pandora_management' => '<> 1', 'db_management' => '<> 1')), 'assign_profile', 0, '', __('None'),
|
||||
0, true, false, false);
|
||||
add_row_enterprise_form_user_profile_form($data, $own_info, $id);
|
||||
}
|
||||
$data[1] = html_print_select_groups($config['id_user'], "UM", $own_info['is_admin'],
|
||||
'assign_group', -1, '', __('None'), -1, true, false, false);
|
||||
$data[2] = html_print_input_image ('add', 'images/add.png', 1, '', true);
|
||||
$data[2] .= html_print_input_hidden ('id', $id, true);
|
||||
$data[2] .= html_print_input_hidden ('add_profile', 1, true);
|
||||
$data[2] .= '</form>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
|
||||
|
@ -414,4 +443,8 @@ html_print_table ($table);
|
|||
echo '</form>';
|
||||
|
||||
unset ($table);
|
||||
|
||||
if ($enterprise_include) {
|
||||
add_script_enterprise_profile_form();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -320,6 +320,12 @@ function agents_get_alerts_compound ($id_agent = false, $filter = '', $options =
|
|||
*/
|
||||
function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $order = array('field' => 'nombre', 'order' => 'ASC')) {
|
||||
global $config;
|
||||
|
||||
//Add enterprise function to add other enterprise ACL.
|
||||
$enterprise_include = false;
|
||||
if (ENTERPRISE_NOT_HOOK !== enterprise_include_once('include/functions_policies.php')) {
|
||||
$enterprise_include = true;
|
||||
}
|
||||
|
||||
if (! is_array ($filter)) {
|
||||
$filter = array ();
|
||||
|
@ -363,6 +369,11 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||
}
|
||||
|
||||
$filter['order'] = $order['field'] . ' ' . $order['order'];
|
||||
|
||||
if ($enterprise_include) {
|
||||
add_enterprise_agents_get_agents_filter_acl($filter);
|
||||
}
|
||||
|
||||
return db_get_all_rows_filter ('tagente', $filter, $fields);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ function get_profiles ($filter = false) {
|
|||
* @param int Group ID (default 1 => All)
|
||||
* @param string Assign User who assign the profile to user.
|
||||
*
|
||||
* @return bool True if succesful, false if not
|
||||
* @return mixed Number id if succesful, false if not
|
||||
*/
|
||||
function create_user_profile ($id_user, $id_profile = 1, $id_group = 0, $assignUser = false) {
|
||||
global $config;
|
||||
|
@ -89,7 +89,7 @@ function create_user_profile ($id_user, $id_profile = 1, $id_group = 0, $assignU
|
|||
"assigned_by" => $assign
|
||||
);
|
||||
|
||||
return (bool) db_process_sql_insert ("tusuario_perfil", $insert);
|
||||
return db_process_sql_insert ("tusuario_perfil", $insert);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -251,7 +251,8 @@ else {
|
|||
// Not selected any specific group
|
||||
if (check_acl ($config['id_user'], 0, "PM")){
|
||||
$agent_names = get_group_agents(0, $filter, "upper", true);
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
$user_group = get_user_groups($config["id_user"], "AR");
|
||||
$groups = array_keys($user_group);
|
||||
$agent_names = get_group_agents(array_keys ($user_group), $filter, "upper");
|
||||
|
@ -264,28 +265,31 @@ if (! empty ($agent_names)) {
|
|||
if (check_acl ($config['id_user'], 0, "PM")){
|
||||
$sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql);
|
||||
$total_agents = db_get_sql ($sql);
|
||||
|
||||
$sql = sprintf ('SELECT * FROM tagente WHERE 1=1 %s ORDER BY %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
|
||||
$agents = db_get_all_rows_sql ($sql);
|
||||
|
||||
}else{
|
||||
$total_agents = agents_get_agents (array ('id_agente' => array_keys ($agent_names),
|
||||
}
|
||||
else{
|
||||
$total_agents = agents_get_agents(array ('id_agente' => array_keys ($agent_names),
|
||||
'order' => 'nombre ASC',
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $groups),
|
||||
array ('COUNT(*) as total'));
|
||||
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
|
||||
$agents = agents_get_agents (array ('id_agente' => array_keys ($agent_names),
|
||||
|
||||
$agents = agents_get_agents(array ('id_agente' => array_keys ($agent_names),
|
||||
'order' => 'nombre ASC',
|
||||
'id_grupo' => $groups,
|
||||
'offset' => (int) get_parameter ('offset'),
|
||||
'limit' => (int) $config['block_size']),
|
||||
array ('id_agente',
|
||||
'id_grupo',
|
||||
'id_os',
|
||||
'ultimo_contacto',
|
||||
'intervalo'),
|
||||
'AR',
|
||||
$order);
|
||||
array ('id_agente',
|
||||
'id_grupo',
|
||||
'id_os',
|
||||
'ultimo_contacto',
|
||||
'intervalo'),
|
||||
'AR',
|
||||
$order);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue