diff --git a/main/admin/settings.php b/main/admin/settings.php index 19428c4bf7..fe7f7445b7 100755 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -484,7 +484,13 @@ if (!empty($_GET['category'])) { // add event to system log $user_id = api_get_user_id(); $category = $_GET['category']; - event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id); + event_system( + LOG_CONFIGURATION_SETTINGS_CHANGE, + LOG_CONFIGURATION_SETTINGS_CATEGORY, + $category, + api_get_utc_datetime(), + $user_id + ); Display :: display_confirmation_message(get_lang('DashboardPluginsHaveBeenUpdatedSucesslly')); } } diff --git a/main/inc/lib/dashboard.lib.php b/main/inc/lib/dashboard.lib.php index b8d01302e5..75818cba2b 100755 --- a/main/inc/lib/dashboard.lib.php +++ b/main/inc/lib/dashboard.lib.php @@ -19,24 +19,24 @@ class DashboardManager * contructor */ public function __construct() - { - } + { + } - /** + /** * This function allows easy activating and inactivating of dashboard plugins * @return void - */ + */ public static function handle_dashboard_plugins() - { - $token = Security::get_existing_token(); - $tokenCondition = '&sec_token='.$token; + { + $token = Security::get_existing_token(); + $tokenCondition = '&sec_token='.$token; /* We scan the plugin directory. Each folder is a potential plugin. */ $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; $possibleplugins = self::get_posible_dashboard_plugins_path(); $table_cols = array('name', 'version', 'description'); - echo Display::page_subheader(get_lang('DashboardPlugins')); + echo Display::page_subheader(get_lang('DashboardPlugins')); echo '
'; echo ''; echo ''; @@ -51,28 +51,30 @@ class DashboardManager // We display all the possible enabled or disabled plugins foreach ($possibleplugins as $testplugin) { $plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info"; - $plugin_info = array(); if (file_exists($plugin_info_file) && is_readable($plugin_info_file)) { $plugin_info = parse_info_file($plugin_info_file); - // change index to lower case - $plugin_info = array_change_key_case($plugin_info); - - echo ''; - self::display_dashboard_plugin_checkboxes($testplugin); - for ($i = 0 ; $i < count($table_cols); $i++) { - if (isset($plugin_info[strtolower($table_cols[$i])])) { - echo ''; - } else { - echo ''; - } - } - echo ''; - } else { - echo Display::tag('tr', Display::tag('td', get_lang('CheckFilePermissions').' '.Security::remove_XSS($plugin_info_file) , array('colspan'=>'3'))); - } + // change index to lower case + $plugin_info = array_change_key_case($plugin_info); + + echo ''; + self::display_dashboard_plugin_checkboxes($testplugin); + for ($i = 0 ; $i < count($table_cols); $i++) { + if (isset($plugin_info[strtolower($table_cols[$i])])) { + echo ''; + } else { + echo ''; + } + } + echo ''; + } else { + echo Display::tag( + 'tr', + Display::tag('td', get_lang('CheckFilePermissions').' '.Security::remove_XSS($plugin_info_file) , array('colspan'=>'3')) + ); + } } // display all disabled block data @@ -84,17 +86,17 @@ class DashboardManager if (isset($disabled_block[strtolower($table_cols[$j])])) { if ($j == 2) { echo ''; + echo ''.$disabled_block[$table_cols[$j]].'
'; + echo ''.get_lang('ThisPluginHasbeenDeletedFromDashboardPluginDirectory').''; + echo ''; } else { echo ''; + echo ''.$disabled_block[$table_cols[$j]].''; + echo ''; } - } else { - echo ''; - } + } else { + echo ''; + } } echo ''; } @@ -113,9 +115,9 @@ class DashboardManager public static function display_dashboard_plugin_checkboxes($plugin_path) { $tbl_block = Database::get_main_table(TABLE_MAIN_BLOCK); - $plugin_path = Database::escape_string($plugin_path); - $sql = "SELECT * FROM $tbl_block WHERE path = '$plugin_path' AND active = 1"; + $sql = "SELECT * FROM $tbl_block + WHERE path = '".Database::escape_string($plugin_path)."' AND active = 1"; $rs = Database::query($sql); $checked = ''; @@ -124,18 +126,18 @@ class DashboardManager } echo ""; } /** - * This function allows easy activating and inactivating of plugins and save them inside db - * @param array dashboard plugin paths + * This function allows easy activating and inactivating + * of plugins and save them inside db + * @param array $plugin_paths dashboard plugin paths * return int affected rows - */ + */ public static function store_dashboard_plugins($plugin_paths) { - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); $affected_rows = 0; @@ -145,8 +147,8 @@ class DashboardManager if (count($possibleplugins) > 0) { - $selected_plugins = array_intersect(array_keys($plugin_paths),$possibleplugins); - $not_selected_plugins = array_diff($possibleplugins,array_keys($plugin_paths)); + $selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins); + $not_selected_plugins = array_diff($possibleplugins, array_keys($plugin_paths)); // get blocks id from not selected path $not_selected_blocks_id = array(); @@ -183,7 +185,6 @@ class DashboardManager // update extra user blocks data $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); - } // clean from block data @@ -196,7 +197,6 @@ class DashboardManager } } - // store selected plugins foreach ($selected_plugins as $testplugin) { $selected_path = Database::escape_string($testplugin); @@ -254,18 +254,16 @@ class DashboardManager // get all plugins path inside plugin directory /* We scan the plugin directory. Each folder is a potential plugin. */ - $possibleplugins = array(); + $possiblePlugins = array(); $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; $handle = @opendir($dashboard_pluginpath); - while (false !== ($file = readdir($handle))) - { - if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) - { - $possibleplugins[] = $file; + while (false !== ($file = readdir($handle))) { + if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { + $possiblePlugins[] = $file; } } @closedir($handle); - return $possibleplugins; + return $possiblePlugins; } /** @@ -284,9 +282,9 @@ class DashboardManager while ($row = Database::fetch_array($rs)) { $path = $row['path']; if (!in_array($row['path'],$possibleplugins)) { - $active = 0; + $active = 0; } else { - $active = 1; + $active = 1; } // update active $upd = "UPDATE $tbl_block SET active = '$active' WHERE path = '".$row['path']."'"; @@ -371,28 +369,28 @@ class DashboardManager $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; require_once $dashboard_plugin_path.$filename_controller; if (class_exists($controller_class)) { - $obj_block = new $controller_class($user_id); - - // check if user is allowed to see the block - if (method_exists($obj_block, 'is_block_visible_for_user')) { - $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); - if (!$is_block_visible_for_user) continue; - } - - echo ''; - // checkboxes - self::display_user_dashboard_list_checkboxes($user_id, $block['id']); - echo ''; - echo ''; - echo ''; + // checkboxes + self::display_user_dashboard_list_checkboxes($user_id, $block['id']); + echo ''; + echo ''; + echo ''; - echo ''; + echo ''; } else { - echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); + echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); } } @@ -427,7 +425,7 @@ class DashboardManager } echo ""; } @@ -437,7 +435,7 @@ class DashboardManager * @param array selected blocks * @param array columns position * @return bool - */ + */ public static function store_user_blocks($user_id, $enabled_blocks, $columns) { $selected_blocks_id = array(); if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { @@ -469,11 +467,11 @@ class DashboardManager $data = array(); foreach ($extra_user_data as $extra) { $split_extra = explode(':',$extra); - if (!empty($split_extra)) { - $block_id = $split_extra[0]; - $column = isset($split_extra[1]) ? $split_extra[1] : null; - $data[$block_id] = array('block_id' => $block_id, 'column' => $column); - } + if (!empty($split_extra)) { + $block_id = $split_extra[0]; + $column = isset($split_extra[1]) ? $split_extra[1] : null; + $data[$block_id] = array('block_id' => $block_id, 'column' => $column); + } } return $data; }
'; - echo $plugin_info[$table_cols[$i]]; - echo '
'; + echo $plugin_info[$table_cols[$i]]; + echo '
'; - echo ''.$disabled_block[$table_cols[$j]].'
'; - echo ''.get_lang('ThisPluginHasbeenDeletedFromDashboardPluginDirectory').''; - echo '
'; - echo ''.$disabled_block[$table_cols[$j]].''; - echo '  
"; - echo ''; + echo ''; echo "
'.$block['name'].''.$block['description'].'
+ $obj_block = new $controller_class($user_id); + + // check if user is allowed to see the block + if (method_exists($obj_block, 'is_block_visible_for_user')) { + $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); + if (!$is_block_visible_for_user) continue; + } + + echo '
'.$block['name'].''.$block['description'].'
"; - echo ''; + echo ''; echo "