Index: branches/5.1.x/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r13086 -r13168 --- branches/5.1.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 13086) +++ branches/5.1.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 13168) @@ -1,6 +1,6 @@ Name, $system_events)) { // events from "Tools -> System Tools" section are controlled via that section "edit" permission - $perm_value = $this->Application->CheckPermission($event->getSection() . '.edit'); + $perm_value = /*$this->Application->isDebugMode() ||*/ $this->Application->CheckPermission($event->getSection() . '.edit'); } $tools_events = Array ( @@ -95,7 +95,7 @@ $event->status = erSTOP; } - $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName LIKE "mod_rw%"'); + $this->Conn->Query('DELETE FROM ' . TABLE_PREFIX . 'CachedUrls'); } function OnResetSections(&$event) @@ -104,13 +104,12 @@ $event->status = erSTOP; } - $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'); + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { + $this->Application->deleteCache('master:sections_parsed'); } + else { + $this->Application->deleteDBCache('sections_parsed'); + } $event->SetRedirectParam('refresh_tree', 1); } @@ -121,22 +120,34 @@ $event->status = erSTOP; } - $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Cache - WHERE VarName IN("config_files", "configs_parsed", "sections_parsed")'; - $this->Conn->Query($sql); + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { + $this->Application->deleteCache('master:config_files'); + $this->Application->deleteCache('master:configs_parsed'); + $this->Application->deleteCache('master:sections_parsed'); + } + else { + $this->Application->deleteDBCache('config_files'); + $this->Application->deleteDBCache('configs_parsed'); + $this->Application->deleteDBCache('sections_parsed'); + } $skin_helper =& $this->Application->recallObject('SkinHelper'); /* @var $skin_helper SkinHelper */ $skin_helper->deleteCompiled(); - 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 OnResetMemcache(&$event) + { + if ($this->Application->GetVar('ajax') == 'yes') { + $event->status = erSTOP; } - $event->SetRedirectParam('refresh_tree', 1); + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { + $this->Application->memoryCache->reset(); + } } function OnCompileTemplates(&$event) @@ -1247,4 +1258,75 @@ } } + /** + * Retrieves data from memory cache + * + * @param kEvent $event + */ + function OnMemoryCacheGet(&$event) + { + $event->status = erSTOP; + + $ret = Array ('message' => '', 'code' => 0); // 0 - ok, > 0 - error + $key = $this->Application->GetVar('key'); + + if (!$key) { + $ret['code'] = 1; + $ret['message'] = 'Key name missing'; + } + else { + $value = $this->Application->getCache($key); + + $ret['value'] =& $value; + $ret['size'] = is_string($value) ? formatSize( strlen($value) ) : '?'; + $ret['type'] = gettype($value); + + if (IsSerialized($value)) { + $value = unserialize($value); + } + + if (is_array($value)) { + $ret['value'] = print_r($value, true); + } + + if ($ret['value'] === false) { + $ret['code'] = 2; + $ret['message'] = 'Key "' . $key . '" doesn\'t exist'; + } + } + + $json_helper =& $this->Application->recallObject('JSONHelper'); + /* @var $json_helper JSONHelper */ + + echo $json_helper->encode($ret); + } + + /** + * Retrieves data from memory cache + * + * @param kEvent $event + */ + function OnMemoryCacheSet(&$event) + { + $event->status = erSTOP; + + $ret = Array ('message' => '', 'code' => 0); // 0 - ok, > 0 - error + $key = $this->Application->GetVar('key'); + + if (!$key) { + $ret['code'] = 1; + $ret['message'] = 'Key name missing'; + } + else { + $value = $this->Application->GetVar('value'); + $res = $this->Application->setCache($key, $value); + + $ret['result'] = $res ? 'OK' : 'FAILED'; + } + + $json_helper =& $this->Application->recallObject('JSONHelper'); + /* @var $json_helper JSONHelper */ + + echo $json_helper->encode($ret); + } } \ No newline at end of file