mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
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
4b91a832db
commit
b5e26cc7ef
@ -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>
|
2011-05-10 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* godmode/agentes/configurar_agente.php: Fixed mistake of my last
|
* 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_agents.php');
|
||||||
require_once ('include/functions_users.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", "");
|
$search = get_parameter ("search", "");
|
||||||
|
|
||||||
$agent_to_delete = (int)get_parameter('borrar_agente');
|
$agent_to_delete = (int)get_parameter('borrar_agente');
|
||||||
@ -244,48 +250,55 @@ else {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (!$enterprise_acl) {
|
||||||
$sql = sprintf ('SELECT COUNT(*)
|
$sql = sprintf ('SELECT COUNT(*)
|
||||||
FROM tagente
|
FROM tagente
|
||||||
WHERE id_grupo IN (%s)
|
WHERE id_grupo IN (%s)
|
||||||
%s',
|
%s',
|
||||||
implode (',', array_keys (get_user_groups ())),
|
implode (',', array_keys (get_user_groups ())),
|
||||||
$search_sql);
|
$search_sql);
|
||||||
$total_agents = db_get_sql ($sql);
|
|
||||||
|
$total_agents = db_get_sql ($sql);
|
||||||
switch ($config["dbtype"]) {
|
|
||||||
case "mysql":
|
switch ($config["dbtype"]) {
|
||||||
$sql = sprintf ('SELECT *
|
case "mysql":
|
||||||
FROM tagente
|
$sql = sprintf ('SELECT *
|
||||||
WHERE id_grupo IN (%s)
|
FROM tagente
|
||||||
%s
|
WHERE id_grupo IN (%s)
|
||||||
ORDER BY %s %s LIMIT %d, %d',
|
%s
|
||||||
implode (',', array_keys (get_user_groups ())),
|
ORDER BY %s %s LIMIT %d, %d',
|
||||||
$search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
|
implode (',', array_keys (get_user_groups ())),
|
||||||
break;
|
$search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
|
||||||
case "postgresql":
|
break;
|
||||||
$sql = sprintf ('SELECT *
|
case "postgresql":
|
||||||
FROM tagente
|
$sql = sprintf ('SELECT *
|
||||||
WHERE id_grupo IN (%s)
|
FROM tagente
|
||||||
%s
|
WHERE id_grupo IN (%s)
|
||||||
ORDER BY %s %s LIMIT %d OFFSET %d',
|
%s
|
||||||
implode (',', array_keys (get_user_groups ())),
|
ORDER BY %s %s LIMIT %d OFFSET %d',
|
||||||
$search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
|
implode (',', array_keys (get_user_groups ())),
|
||||||
break;
|
$search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
|
||||||
case "oracle":
|
break;
|
||||||
$set = array ();
|
case "oracle":
|
||||||
$set['limit'] = $config["block_size"];
|
$set = array ();
|
||||||
$set['offset'] = $offset;
|
$set['limit'] = $config["block_size"];
|
||||||
$sql = sprintf ('SELECT *
|
$set['offset'] = $offset;
|
||||||
FROM tagente
|
$sql = sprintf ('SELECT *
|
||||||
WHERE id_grupo IN (%s)
|
FROM tagente
|
||||||
%s
|
WHERE id_grupo IN (%s)
|
||||||
ORDER BY %s %s',
|
%s
|
||||||
implode (',', array_keys (get_user_groups ())),
|
ORDER BY %s %s',
|
||||||
$search_sql, $order['field'], $order['order']);
|
implode (',', array_keys (get_user_groups ())),
|
||||||
$sql = oracle_recode_query ($sql, $set);
|
$search_sql, $order['field'], $order['order']);
|
||||||
break;
|
$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');
|
$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
|
// This defines the working user. Beware with this, old code get confusses
|
||||||
// and operates with current logged user (dangerous).
|
// and operates with current logged user (dangerous).
|
||||||
|
|
||||||
@ -225,6 +231,11 @@ if ($add_profile) {
|
|||||||
db_pandora_audit("User management",
|
db_pandora_audit("User management",
|
||||||
"Added profile for user ".io_safe_input($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2);
|
"Added profile for user ".io_safe_input($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2);
|
||||||
$return = create_user_profile ($id2, $profile2, $group2);
|
$return = create_user_profile ($id2, $profile2, $group2);
|
||||||
|
|
||||||
|
if ($enterprise_include) {
|
||||||
|
add_enterprise_db_data_user_profile_form($return);
|
||||||
|
}
|
||||||
|
|
||||||
ui_print_result_message ($return,
|
ui_print_result_message ($return,
|
||||||
__('Profile added successfully'),
|
__('Profile added successfully'),
|
||||||
__('Profile cannot be added'));
|
__('Profile cannot be added'));
|
||||||
@ -359,7 +370,7 @@ if (empty ($id) || $new_user)
|
|||||||
|
|
||||||
echo '<h3>'.__('Profiles/Groups assigned to this user').'</h3>';
|
echo '<h3>'.__('Profiles/Groups assigned to this user').'</h3>';
|
||||||
|
|
||||||
$table->width = '75%';
|
$table->width = '85%';
|
||||||
$table->data = array ();
|
$table->data = array ();
|
||||||
$table->head = array ();
|
$table->head = array ();
|
||||||
$table->align = array ();
|
$table->align = array ();
|
||||||
@ -371,6 +382,10 @@ $table->head[1] = __('Group');
|
|||||||
$table->head[2] = __('Action');
|
$table->head[2] = __('Action');
|
||||||
$table->align[2] = 'center';
|
$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);
|
$result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$result = array ();
|
$result = array ();
|
||||||
@ -388,25 +403,39 @@ foreach ($result as $profile) {
|
|||||||
$data[2] .= html_print_input_image ('del', 'images/cross.png', 1, '', true);
|
$data[2] .= html_print_input_image ('del', 'images/cross.png', 1, '', true);
|
||||||
$data[2] .= '</form>';
|
$data[2] .= '</form>';
|
||||||
|
|
||||||
|
if ($enterprise_include) {
|
||||||
|
add_data_enterprise_column_user_profile_form($data, $profile['id_up']);
|
||||||
|
}
|
||||||
|
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array ();
|
if (!$enterprise_include) {
|
||||||
$data[0] = '<form method="post">';
|
$data = array ();
|
||||||
if (check_acl ($config['id_user'], 0, "PM")) {
|
|
||||||
$data[0] .= html_print_select (get_profiles (), 'assign_profile', 0, '', __('None'),
|
$data[0] = '<form method="post">';
|
||||||
0, true, false, false);
|
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 {
|
else {
|
||||||
$data[0] .= html_print_select (get_profiles (array ('pandora_management' => '<> 1', 'db_management' => '<> 1')), 'assign_profile', 0, '', __('None'),
|
add_row_enterprise_form_user_profile_form($data, $own_info, $id);
|
||||||
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>';
|
|
||||||
|
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
|
|
||||||
@ -414,4 +443,8 @@ html_print_table ($table);
|
|||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
unset ($table);
|
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')) {
|
function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $order = array('field' => 'nombre', 'order' => 'ASC')) {
|
||||||
global $config;
|
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)) {
|
if (! is_array ($filter)) {
|
||||||
$filter = array ();
|
$filter = array ();
|
||||||
@ -363,6 +369,11 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filter['order'] = $order['field'] . ' ' . $order['order'];
|
$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);
|
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 int Group ID (default 1 => All)
|
||||||
* @param string Assign User who assign the profile to user.
|
* @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) {
|
function create_user_profile ($id_user, $id_profile = 1, $id_group = 0, $assignUser = false) {
|
||||||
global $config;
|
global $config;
|
||||||
@ -89,7 +89,7 @@ function create_user_profile ($id_user, $id_profile = 1, $id_group = 0, $assignU
|
|||||||
"assigned_by" => $assign
|
"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
|
// Not selected any specific group
|
||||||
if (check_acl ($config['id_user'], 0, "PM")){
|
if (check_acl ($config['id_user'], 0, "PM")){
|
||||||
$agent_names = get_group_agents(0, $filter, "upper", true);
|
$agent_names = get_group_agents(0, $filter, "upper", true);
|
||||||
}else{
|
}
|
||||||
|
else{
|
||||||
$user_group = get_user_groups($config["id_user"], "AR");
|
$user_group = get_user_groups($config["id_user"], "AR");
|
||||||
$groups = array_keys($user_group);
|
$groups = array_keys($user_group);
|
||||||
$agent_names = get_group_agents(array_keys ($user_group), $filter, "upper");
|
$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")){
|
if (check_acl ($config['id_user'], 0, "PM")){
|
||||||
$sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql);
|
$sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql);
|
||||||
$total_agents = db_get_sql ($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"]);
|
$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);
|
$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',
|
'order' => 'nombre ASC',
|
||||||
'disabled' => 0,
|
'disabled' => 0,
|
||||||
'id_grupo' => $groups),
|
'id_grupo' => $groups),
|
||||||
array ('COUNT(*) as total'));
|
array ('COUNT(*) as total'));
|
||||||
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
|
$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',
|
'order' => 'nombre ASC',
|
||||||
'id_grupo' => $groups,
|
'id_grupo' => $groups,
|
||||||
'offset' => (int) get_parameter ('offset'),
|
'offset' => (int) get_parameter ('offset'),
|
||||||
'limit' => (int) $config['block_size']),
|
'limit' => (int) $config['block_size']),
|
||||||
array ('id_agente',
|
array ('id_agente',
|
||||||
'id_grupo',
|
'id_grupo',
|
||||||
'id_os',
|
'id_os',
|
||||||
'ultimo_contacto',
|
'ultimo_contacto',
|
||||||
'intervalo'),
|
'intervalo'),
|
||||||
'AR',
|
'AR',
|
||||||
$order);
|
$order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user