diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 70ef78e599..677dc7bbcd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2011-02-14 Juan Manuel Ramon + + * include/functions_config.php: Loads relative_path variable in user + session. + * include/functions_db.php: Added include call to + functions_extensions.php. + * godmode/groups/configure_group.php + godmode/groups/group_list.php: Added functionality to assign a skin to + a group. + * godmode/menu.php: Added an entry to skins submenu. + * godmode/users/configure_user.php: Added functionality to assign a skin to + a user. + 2011-02-09 Miguel de Dios * pandoradb.data.postgreSQL.sql: added the first version of data of Pandora diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 1cb7277c6c..cdd04a9f88 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -31,6 +31,7 @@ $id_parent = 0; $alerts_disabled = 0; $custom_id = ""; $propagate = 0; +$skin = 0; $create_group = (bool) get_parameter ('create_group'); $id_group = (int) get_parameter ('id_group'); @@ -44,6 +45,7 @@ if ($id_group) { $id_parent = $group["parent"]; $custom_id = $group["custom_id"]; $propagate = $group["propagate"]; + $skin = $group["id_skin"]; } else { echo "

".__('There was a problem loading group')."

"; echo ""; @@ -98,6 +100,12 @@ $table->data[4][1] = print_checkbox('propagate', 1, $propagate, true); $table->data[5][0] = __('Custom ID'); $table->data[5][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true); +$isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); +if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { + $table->data[6][0] = __('Skin'); + $table->data[6][1] = print_select_skins($config["id_user"], 'skin', $skin, '', __('None'), 0, true); +} + echo '
'; print_table ($table); echo '
'; diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index b0e8105577..ea1a3ca141 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -92,12 +92,13 @@ if ($create_group) { $id_parent = (int) get_parameter ('id_parent'); $alerts_disabled = (bool) get_parameter ('alerts_disabled'); $custom_id = (string) get_parameter ('custom_id'); + $skin = (string) get_parameter ('skin'); /*Check if name field is empty*/ if ($name != "") { - $sql = sprintf ('INSERT INTO tgrupo (nombre, icon, parent, disabled, custom_id) - VALUES ("%s", "%s", %d, %d, "%s")', - $name, substr ($icon, 0, -4), $id_parent, $alerts_disabled, $custom_id); + $sql = sprintf ('INSERT INTO tgrupo (nombre, icon, parent, disabled, custom_id, id_skin) + VALUES ("%s", "%s", %d, %d, "%s", %d)', + $name, substr ($icon, 0, -4), $id_parent, $alerts_disabled, $custom_id, $skin); $result = mysql_query ($sql); } else { $result = false; @@ -118,13 +119,14 @@ if ($update_group) { $alerts_enabled = (bool) get_parameter ('alerts_enabled'); $custom_id = (string) get_parameter ('custom_id'); $propagate = (bool) get_parameter('propagate'); + $skin = (string) get_parameter ('skin'); /*Check if name field is empty*/ if( $name != "") { $sql = sprintf ('UPDATE tgrupo SET nombre = "%s", - icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d + icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d, id_skin = %d WHERE id_grupo = %d', - $name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $custom_id, $propagate, $id_group); + $name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $custom_id, $propagate, $skin, $id_group); $result = process_sql ($sql); } else { $result = false; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index a7800a0f81..0f424e8c7c 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -204,6 +204,7 @@ if (give_acl ($config['id_user'], 0, "PM")) { $sub["godmode/setup/os"]["text"] = __('Edit OS'); enterprise_hook ('historydb_submenu'); enterprise_hook ('enterprise_acl_submenu'); + enterprise_hook ('skins_submenu'); $sub["extras/pandora_diag"]["text"] = __('Diagnostic info'); $menu["gsetup"]["sub"] = $sub; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index fd8bfbf6c1..fc98effa12 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -62,6 +62,7 @@ if ($new_user && $config['admin_can_add_user']) { $user_info['comments'] = ''; $user_info['is_admin'] = 0; $user_info['language'] = $config["language"]; + $user_info['id_skin'] = ''; } if ($create_user) { @@ -82,6 +83,7 @@ if ($create_user) { $values['comments'] = (string) get_parameter ('comments'); $values['is_admin'] = get_parameter ('is_admin', 0); $values['language'] = get_parameter ('language', $config["language"]); + $values['id_skin'] = get_parameter ('skin', 0); if ($id == '') { print_error_message (__('User ID cannot be empty')); @@ -109,7 +111,7 @@ if ($create_user) { ' Lastname: ' . $values['lastname'] . ' Email: ' . $values['email'] . ' Phone: ' . $values['phone'] . ' Comments: ' . $values['comments'] . ' Is_admin: ' . $values['is_admin'] . - ' Laguage: ' . $values['language']; + ' Language: ' . $values['language'] . ' Skin: ' . $values['id_skin']; $result = create_user ($id, $password_new, $values); @@ -145,6 +147,7 @@ if ($update_user) { $values['comments'] = (string) get_parameter ('comments'); $values['is_admin'] = get_parameter ('is_admin', 0 ); $values['language'] = (string) get_parameter ('language', $config["language"]); + $values['id_skin'] = get_parameter ('skin', 0); $res1 = update_user ($id, $values); @@ -167,7 +170,7 @@ if ($update_user) { ' Lastname: ' . $values['lastname'] . ' Email: ' . $values['email'] . ' Phone: ' . $values['phone'] . ' Comments: ' . $values['comments'] . ' Is_admin: ' . $values['is_admin'] . - ' Laguage: ' . $values['language']; + ' Language: ' . $values['language'] . ' Skin: ' . $values['id_skin']; pandora_audit("User management", "Updated user ".safe_input($id), false, false, $info); @@ -279,6 +282,25 @@ $table->data[9][0] = __('Comments'); $table->data[9][1] = print_textarea ("comments", 2, 65, $user_info['comments'], ($view_mode ? 'readonly="readonly"' : ''), true); +// If we want to create a new user, skins displayed are the skins of the creator's group. If we want to update, skins displayed are the skins of the modified user. +if ($new_user){ + $usr_groups = (get_user_groups($config['id_user'])); + $id_usr = $config['id_user']; +}else{ + $usr_groups = (get_user_groups($id)); + $id_usr = $id; +} + +// User only can change skins if has more than one group +if (count($usr_groups) > 1){ + + $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); + if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { + $table->data[10][0] = __('Skin'); + $table->data[10][1] = print_select_skins($id_usr,'skin', $user_info['id_skin'], '', __('None'), 0, true); + } +} + echo ''; print_table ($table); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 9bed896ae7..a9e9b368f6 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -240,6 +240,10 @@ function update_config () { else { update_config_value ('can_block_policies', get_parameter('can_block_policies', $config['can_block_policies'])); } + $enterprise = enterprise_include_once ('include/functions_skins.php'); + if ($enterprise !== ENTERPRISE_NOT_HOOK) { + $config['relative_path'] = get_parameter('relative_path', $config['relative_path']); + } } @@ -313,7 +317,7 @@ function process_config () { if (!isset ($config['status_images_set'])) { update_config_value ('status_images_set', 'default'); } - + // Load user session if (isset ($_SESSION['id_usuario'])) $config["id_user"] = $_SESSION["id_usuario"]; @@ -386,7 +390,6 @@ function process_config () { unset($config[$keyConfig]); } - // This is not set here. The first time, when no // setup is done, update_manager extension manage it @@ -590,6 +593,17 @@ function process_config () { update_config_value ( 'can_block_policies', 0); } + if (!isset ($config['relative_path']) && (isset ($_POST['nick']) || isset ($config['id_user']))) { + + $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); + if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { + if(isset($config['id_user'])) + $relative_path = enterprise_hook('set_image_skin_path',array($config['id_user'])); + else + $relative_path = enterprise_hook('set_image_skin_path',array($_POST['nick'])); + $config['relative_path'] = $relative_path; + } + } /* Finally, check if any value was overwritten in a form */ update_config (); } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 3644a7ab22..47899f0c85 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -19,6 +19,8 @@ * @subpackage DataBase */ +include_once("include/functions_extensions.php"); + /** * When you delete (with the function "process_sql_delete" or other) any row in * any table, some times the cache save the data just deleted, because you