Index: branches/5.1.x/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r12453 -r12657 --- branches/5.1.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 12453) +++ branches/5.1.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 12657) @@ -1,6 +1,6 @@ Application->isDebugMode(false) && in_array($event->Name, $system_events)) { - return true; + if (in_array($event->Name, $system_events)) { + // events from "Tools -> System Tools" section are controlled via that section "edit" permission + $perm_value = $this->Application->CheckPermission($event->getSection() . '.edit'); } $tools_events = Array ( @@ -62,15 +67,18 @@ ); if (array_key_exists($event->Name, $tools_events)) { - return $this->Application->CheckPermission($tools_events[$event->Name]); + $perm_value = $this->Application->CheckPermission($tools_events[$event->Name]); } if ($event->Name == 'OnSaveMenuFrameWidth') { - if (!$this->Application->IsAdmin() || !$this->Application->LoggedIn()) { - return false; - } + $perm_value = $this->Application->IsAdmin() && $this->Application->LoggedIn(); + } - return true; + if (isset($perm_value)) { + $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + /* @var $perm_helper kPermissionsHelper */ + + return $perm_helper->finalizePermissionCheck($event, $perm_value); } return parent::CheckPermission($event); @@ -105,34 +113,88 @@ $event->status = erSTOP; } - $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"'); + $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Cache + WHERE VarName = "sections_parsed"'; + $this->Conn->Query($sql); + if (isset($this->Application->Memcached)) { $this->Application->Memcached->delete('master:sections_parsed'); } + + $event->SetRedirectParam('refresh_tree', 1); } function OnResetConfigsCache(&$event) { if ($this->Application->GetVar('ajax') == 'yes') { $event->status = erSTOP; } - $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files" OR VarName = "configs_parsed" OR VarName = "sections_parsed"'); + + $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Cache + WHERE VarName IN("config_files", "configs_parsed", "sections_parsed")'; + $this->Conn->Query($sql); + if (isset($this->Application->Memcached)) { $this->Application->Memcached->delete('master:config_files'); $this->Application->Memcached->delete('master:configs_parsed'); $this->Application->Memcached->delete('master:sections_parsed'); } + + $event->SetRedirectParam('refresh_tree', 1); } function OnCompileTemplates(&$event) { $compiler =& $this->Application->recallObject('NParserCompiler'); /* @var $compiler NParserCompiler */ + $compiler->CompileTemplatesStep(); $event->status = erSTOP; } /** + * Deletes all compiled templates + * + * @param kEvent $event + */ + function OnDeleteCompiledTemplates(&$event) + { + if ($this->Application->GetVar('ajax') == 'yes') { + $event->status = erSTOP; + } + + $base_path = WRITEABLE . DIRECTORY_SEPARATOR . 'cache'; + + // delete debugger reports + $debugger_reports = glob($base_path . '/debug_@*@.txt'); + + foreach ($debugger_reports as $debugger_report) { + unlink($debugger_report); + } + + $this->_deleteCompiledTemplates($base_path); + } + + function _deleteCompiledTemplates($folder, $unlink_folder = false) + { + $sub_folders = glob($folder . '/*', GLOB_ONLYDIR); + + foreach ($sub_folders as $sub_folder) { + $this->_deleteCompiledTemplates($sub_folder, true); + } + + $files = glob($folder . '/*.php'); + + foreach ($files as $file) { + unlink($file); + } + + if ($unlink_folder) { + rmdir($folder); + } + } + + /** * Generates sturcture for specified table * * @param kEvent $event @@ -171,7 +233,7 @@ // 1. prepare config keys $grids = Array ( 'Default' => Array ( - 'Icons' => Array ('default' => 'icon16_custom.gif'), + 'Icons' => Array ('default' => 'icon16_item.png'), 'Fields' => Array (), ) ); @@ -552,7 +614,7 @@ $value = $this->Application->GetVar('Filedata'); if (!$value) return ; - $tmp_path = WRITEABLE.'/tmp/'; + $tmp_path = WRITEABLE . '/tmp/'; $fname = $value['name']; $id = $this->Application->GetVar('id'); if ($id) $fname = $id.'_'.$fname;