diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8d0f9a6a66..90c6fa66a4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,21 @@ +2011-03-01 Juan Manuel Ramon + + * include/ajax/skins.ajax.php: Replaced "give_acl" function call to + "check_acl". + * include/config_process.php: "block_size" and "flash_charts" user options + override global options. + * include/functions_ui.php: If user has assigned a skin then use skins's + css files if it's possible. + * include/functions_db.php: Added missing function get_profile_filter. + * include/functions_themes.php: New parameter "path" in order to list all + css files of an specific path. + * index.php: Added functions_themes.php include statement. + * operation/users/user_edit.php + godmode/users/configure_user.php: Added new user options: "skin", "block_size" + and "flash_charts". + * godmode/setup/setup_visuals.php: Removed "custom_logo" options in setup for + pandora enterprise version. + 2011-03-01 Miguel de Dios * include/db/postgresql.php, include/db/mysql.php, include/functions_db.php: diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index a7e39c5ce8..34b602e2e9 100644 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -80,14 +80,14 @@ $table->data[9][1] = print_select ($iconsets, 'status_images_set', $config["stat $table->data[10][0] = __('Font path'); $table->data[10][1] = print_input_text ('fontpath', $config["fontpath"], '', 50, 255, true); +$table->data[11][0] = __('Flash charts'); +$table->data[11][1] = __('Yes').' '.print_radio_button ('flash_charts', 1, '', $config["flash_charts"], true).'  '; +$table->data[11][1] .= __('No').' '.print_radio_button ('flash_charts', 0, '', $config["flash_charts"], true); -$table->data[12][0] = __('Flash charts'); -$table->data[12][1] = __('Yes').' '.print_radio_button ('flash_charts', 1, '', $config["flash_charts"], true).'  '; -$table->data[12][1] .= __('No').' '.print_radio_button ('flash_charts', 0, '', $config["flash_charts"], true); - -$table->data[13][0] = __('Custom logo') . print_help_icon("custom_logo", true); -$table->data[13][1] = print_select (list_files ('images/custom_logo', "png", 1, 0), 'custom_logo', $config["custom_logo"], '', '', '', true); - +if (!defined ('PANDORA_ENTERPRISE')){ + $table->data[12][0] = __('Custom logo') . print_help_icon("custom_logo", true); + $table->data[12][1] = print_select (list_files ('images/custom_logo', "png", 1, 0), 'custom_logo', $config["custom_logo"], '', '', '', true); +} echo '
'; print_input_hidden ('update_config', 1); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index c33e9d88e9..ff19610ac8 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -63,6 +63,9 @@ if ($new_user && $config['admin_can_add_user']) { $user_info['is_admin'] = 0; $user_info['language'] = $config["language"]; $user_info['id_skin'] = ''; + //This attributes are inherited from global configuration + $user_info['block_size'] = $config["block_size"]; + $user_info['flash_chart'] = $config["flash_charts"]; } if ($create_user) { @@ -84,6 +87,8 @@ if ($create_user) { $values['is_admin'] = get_parameter ('is_admin', 0); $values['language'] = get_parameter ('language', $config["language"]); $values['id_skin'] = get_parameter ('skin', 0); + $values['block_size'] = get_parameter ('block_size', $config["block_size"]); + $values['flash_chart'] = get_parameter ('flash_charts', $config["flash_charts"]); if ($id == '') { print_error_message (__('User ID cannot be empty')); @@ -111,7 +116,8 @@ if ($create_user) { ' Lastname: ' . $values['lastname'] . ' Email: ' . $values['email'] . ' Phone: ' . $values['phone'] . ' Comments: ' . $values['comments'] . ' Is_admin: ' . $values['is_admin'] . - ' Language: ' . $values['language'] . ' Skin: ' . $values['id_skin']; + ' Language: ' . $values['language'] . ' Skin: ' . $values['id_skin'] . + ' Block size: ' . $values['block_size'] . ' Flash Chats: ' . $values['flash_chart']; $result = create_user ($id, $password_new, $values); @@ -148,6 +154,8 @@ if ($update_user) { $values['is_admin'] = get_parameter ('is_admin', 0 ); $values['language'] = (string) get_parameter ('language', $config["language"]); $values['id_skin'] = get_parameter ('skin', 0); + $values['block_size'] = get_parameter ('block_size', $config["block_size"]); + $values['flash_chart'] = get_parameter ('flash_charts', $config["flash_charts"]); $res1 = update_user ($id, $values); @@ -170,7 +178,8 @@ if ($update_user) { ' Lastname: ' . $values['lastname'] . ' Email: ' . $values['email'] . ' Phone: ' . $values['phone'] . ' Comments: ' . $values['comments'] . ' Is_admin: ' . $values['is_admin'] . - ' Language: ' . $values['language'] . ' Skin: ' . $values['id_skin']; + ' Language: ' . $values['language'] . ' Skin: ' . $values['id_skin'] . + ' Block size: ' . $values['block_size'] . ' Flash Chats: ' . $values['flash_chart']; pandora_audit("User management", "Updated user ".safe_input($id), false, false, $info); @@ -286,11 +295,17 @@ $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'])); +$own_info = get_user_info ($config['id_user']); +if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) + $display_all_group = true; +else + $display_all_group = false; + +if ($new_user){ + $usr_groups = (get_user_groups($config['id_user'], 'AR', $display_all_group)); $id_usr = $config['id_user']; }else{ - $usr_groups = (get_user_groups($id)); + $usr_groups = (get_user_groups($id, 'AR', $display_all_group)); $id_usr = $id; } @@ -304,6 +319,13 @@ if (count($usr_groups) > 1){ } } +$table->data[11][0] = __('Flash charts'); +$table->data[11][1] = __('Yes').' '.print_radio_button ('flash_charts', 1, '', $user_info["flash_chart"], true).'  '; +$table->data[11][1] .= __('No').' '.print_radio_button ('flash_charts', 0, '', $user_info["flash_chart"], true); + +$table->data[12][0] = __('Block size for pagination'); +$table->data[12][1] = print_input_text ('block_size', $user_info["block_size"], '', 5, 5, true); + echo ''; print_table ($table); diff --git a/pandora_console/include/ajax/skins.ajax.php b/pandora_console/include/ajax/skins.ajax.php index f74abbf130..94489c6da6 100644 --- a/pandora_console/include/ajax/skins.ajax.php +++ b/pandora_console/include/ajax/skins.ajax.php @@ -17,7 +17,7 @@ global $config; check_login (); -if (! give_acl ($config['id_user'], 0, "IR")) { +if (! check_acl ($config['id_user'], 0, "IR")) { pandora_audit("ACL Violation", "Trying to access report builder"); require ("general/noaccess.php"); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 4d57e8dda0..0665239a9e 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -103,6 +103,12 @@ if (isset ($config['id_user'])){ $config['user_language'] = $userinfo["language"]; } + // If block_size or flash_chart are provided then override global settings + if (!empty($userinfo["block_size"])) + $config["block_size"] = $userinfo["block_size"]; + if (!empty($userinfo["block_size"])) + $config["flash_charts"] = $userinfo["flash_chart"]; + // Each user could have it's own timezone) if (isset($userinfo["timezone"])) { if ($userinfo["timezone"] != ""){ diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 55d801d8f4..308b165810 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -437,6 +437,24 @@ function get_profiles () { return $return; } +/** + * Selects profiles filtered + * + * @return array List of profiles filtered + */ +function get_profiles_filter ($filter) { + $sql = sprintf('SELECT * FROM tperfil WHERE %s', $filter); + $profiles = get_db_all_rows_sql ($sql); + $return = array (); + if ($profiles === false) { + return $return; + } + foreach ($profiles as $profile) { + $return[$profile["id_perfil"]] = $profile["name"]; + } + return $return; +} + /** * Create Profile for User diff --git a/pandora_console/include/functions_themes.php b/pandora_console/include/functions_themes.php index 323321b2ee..75b9072773 100644 --- a/pandora_console/include/functions_themes.php +++ b/pandora_console/include/functions_themes.php @@ -22,16 +22,27 @@ /** * Get a list of CSS themes installed. * + * @param bool List all css files of an specific path without filter "pandora*" pattern + * * @return array An indexed array with the file name in the index and the theme * name (if available) as the value. */ -function get_css_themes () { - $theme_dir = 'include/styles/'; +function get_css_themes ($path = false) { + if ($path) + $theme_dir = $path; + else + $theme_dir = 'include/styles/'; - $files = list_files ($theme_dir, "pandora", 1, 0); + if ($path) + $files = list_files ($theme_dir, "pandora", 0, 0); + else + $files = list_files ($theme_dir, "pandora", 1, 0); $retval = array (); foreach ($files as $file) { + //Skip '..' and '.' entries and files not ended in '.css' + if ($path && ($file == '.' || $file == '..' || strtolower(substr ($file, strlen ($file) - 4)) !== '.css')) + continue; $data = implode ('', file ($theme_dir.'/'.$file)); preg_match ('|Name:(.*)$|mi', $data, $name); if (isset ($name[1])) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index f9dfd84faf..f06dd1a803 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -831,13 +831,35 @@ function process_page_head ($string, $bitfield) { if (empty ($config['css'])) { $config['css'] = array (); } + + //First, if user has assigned a skin then try to use css files of skin subdirectory + $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); + if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { + //Checks if user's skin is available + $exists_skin = enterprise_hook('is_skin_path_set'); + if ($exists_skin){ + $skin_path = enterprise_hook('get_skin_path'); + $skin_styles = get_css_themes ($skin_path . 'include/styles/'); + $exists_css = !empty($skin_styles); + } + } + //If skin's css files exists then add them + if ($exists_css){ + foreach ($skin_styles as $filename => $name){ + $style = substr ($filename, 0, strlen ($filename) - 4); + $config['css'] = array_merge(array ($style => $skin_path . 'include/styles/' . $filename)); + } + } + //Otherwise assign default and user's css + else{ - //User style should go last so it can rewrite common styles - $config['css'] = array_merge (array ( - "common" => "include/styles/common.css", - "menu" => "include/styles/menu.css", - "tip", "include/styles/tip.css", - $config['style'] => "include/styles/".$config['style'].".css"), $config['css']); + //User style should go last so it can rewrite common styles + $config['css'] = array_merge (array ( + "common" => "include/styles/common.css", + "menu" => "include/styles/menu.css", + "tip", "include/styles/tip.css", + $config['style'] => "include/styles/".$config['style'].".css"), $config['css']); + } //We can't load empty and we loaded (conditionally) ie $loaded = array ('', 'ie'); diff --git a/pandora_console/index.php b/pandora_console/index.php index f1b32ca3d6..8ad6d7df46 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -116,7 +116,7 @@ enterprise_include ('index.php'); // This tag is included in the buffer passed to process_page_head so // technically it can be stripped echo ''."\n"; - +require_once ("include/functions_themes.php"); ob_start ('process_page_body'); $config["remote_addr"] = $_SERVER['REMOTE_ADDR']; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 614a74afe2..a70e359708 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -54,6 +54,9 @@ if (isset ($_GET["modified"]) && !$view_mode) { $upd_info["phone"] = get_parameter_post ("phone", $user_info["phone"]); $upd_info["comments"] = get_parameter_post ("comments", $user_info["comments"]); $upd_info["language"] = get_parameter_post ("language", $user_info["language"]); + $upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]); + $upd_info["block_size"] = get_parameter ("block_size", $config["block_size"]); + $upd_info["flash_chart"] = get_parameter ("flash_charts", $config["flash_charts"]); if ( !empty ($password_new)) { if ($config["user_can_update_password"] && $password_confirm == $password_new) { @@ -135,7 +138,33 @@ echo print_select_from_sql ('SELECT id_language, name FROM tlanguage', echo ''.__('Comments').''; print_textarea ("comments", 2, 60, $user_info["comments"], ($view_mode ? 'readonly="readonly"' : '')); - + +$own_info = get_user_info ($config['id_user']); +if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) + $display_all_group = true; +else + $display_all_group = false; + +$usr_groups = (get_user_groups($config['id_user'], 'AR', $display_all_group)); +$id_usr = $config['id_user']; + +// 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) { + echo '' . __('Skin') . ''; + echo print_select_skins($id_usr,'skin', $user_info['id_skin'], '', __('None'), 0, true); + } +} + +echo ''.__('Flash charts').''; +echo __('Yes').' '.print_radio_button ('flash_charts', 1, '', $user_info["flash_chart"], true).'  '; +echo __('No').' '.print_radio_button ('flash_charts', 0, '', $user_info["flash_chart"], true); + +echo ''.__('Block size for pagination').''; +echo print_input_text ('block_size', $user_info["block_size"], '', 5, 5, true); + echo ''; echo '
';