Index: admin_templates/tools/system_tools.tpl =================================================================== --- admin_templates/tools/system_tools.tpl (revision 14103) +++ admin_templates/tools/system_tools.tpl (working copy) @@ -175,6 +175,7 @@
  • master:cms_menu
  • master:template_mapping
  • master:StructureTree
  • +
  • master:last_cache_rebuild
  • Index: kernel/utility/unit_config_reader.php =================================================================== --- kernel/utility/unit_config_reader.php (revision 14103) +++ kernel/utility/unit_config_reader.php (working copy) @@ -131,18 +131,19 @@ 'Application.ModuleInfo' => $this->Application->ModuleInfo, ); + $cache_rebuild_by = SERVER_NAME . ' (' . getenv('REMOTE_ADDR') . ') - ' . adodb_date('d/m/Y H:i:s'); + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { $this->Application->setCache('master:configs_parsed', serialize($cache)); $this->Application->setCache('master:config_files', serialize($this->configFiles)); + $this->Application->setCache('master:last_cache_rebuild', $cache_rebuild_by); } else { $this->Application->setDBCache('configs_parsed', serialize($cache)); $this->Application->setDBCache('config_files', serialize($this->configFiles)); + $this->Application->setDBCache('last_cache_rebuild', $cache_rebuild_by); } - $cache_rebuild_by = SERVER_NAME . ' (' . getenv('REMOTE_ADDR') . ') - ' . adodb_date('d/m/Y H:i:s'); - $this->Application->setDBCache('last_cache_rebuild', $cache_rebuild_by); - unset($this->configFiles); } Index: units/agents/agent_eh.php =================================================================== --- units/agents/agent_eh.php (revision 14103) +++ units/agents/agent_eh.php (working copy) @@ -45,11 +45,17 @@ /* @var $object kDBItem */ $processed_ids = Array (); + $agents = $this->Conn->Query($object->GetSelectSQL(), 'AgentName'); + + if ( $this->Conn->hasError() ) { + // no access to Agents table + return ; + } + foreach ($regular_events as $run_mode => $events) { + foreach ($events as $agent_name => $agent_params) { - $object->Load($agent_name, 'AgentName'); - - if (!$object->isLoaded()) { + if ( !isset($agents[$agent_name]) ) { $fields_hash = Array ( 'Event' => $agent_params['EventName'], 'AgentName' => $agent_name, @@ -59,12 +65,17 @@ 'RunMode' => $run_mode, ); + $object->Clear(); $object->SetDBFieldsFromHash($fields_hash); $object->Create(); } + else { + $object->LoadFromHash( $agents[$agent_name] ); + } $processed_ids[] = $object->GetID(); } + } // delete all non-processed agents (ones, that were deleted from unit configs) Index: units/categories/categories_event_handler.php =================================================================== --- units/categories/categories_event_handler.php (revision 14103) +++ units/categories/categories_event_handler.php (working copy) @@ -1886,32 +1886,11 @@ $this->Application->setUnitOption($event->Prefix, 'SectionAdjustments', $section_ajustments); - // prepare structure dropdown - $category_helper =& $this->Application->recallObject('CategoryHelper'); - /* @var $category_helper CategoryHelper */ - - $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); - - $fields['ParentId']['default'] = (int)$this->Application->GetVar('m_cat_id'); - $fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions(); - - // limit design list by theme - $design_folders = Array ('tf.FilePath = "/designs"', 'tf.FilePath = "/platform/designs"'); - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - $design_folders[] = 'tf.FilePath = "/' . $module_info['TemplatePath'] . 'designs"'; + if (!$this->Application->isAdmin || $this->Application->LoggedIn()) { + // Front-end OR logged-in user + $this->linkCategoriesToStructure($event); } - $design_folders = array_unique($design_folders); - $theme_id = $this->_getCurrentThemeId(); - $design_sql = $fields['Template']['options_sql']; - $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); - $fields['Template']['options_sql'] = $design_sql; - - // adds "Inherit From Parent" option to "Template" field - $fields['Template']['options'] = Array (CATEGORY_TEMPLATE_INHERIT => $this->Application->Phrase('la_opt_InheritFromParent')); - - $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); - if ($this->Application->isAdmin) { // don't sort by Front-End sorting fields $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); @@ -1940,6 +1919,40 @@ } /** + * Links categories to site structure + * + * @param kEvent $event + */ + function linkCategoriesToStructure(&$event) + { + // prepare structure dropdown + $category_helper =& $this->Application->recallObject('CategoryHelper'); + /* @var $category_helper CategoryHelper */ + + $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); + + $fields['ParentId']['default'] = (int)$this->Application->GetVar('m_cat_id'); + $fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions(); + + // limit design list by theme + $design_folders = Array ('tf.FilePath = "/designs"', 'tf.FilePath = "/platform/designs"'); + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + $design_folders[] = 'tf.FilePath = "/' . $module_info['TemplatePath'] . 'designs"'; + } + $design_folders = array_unique($design_folders); + + $theme_id = $this->_getCurrentThemeId(); + $design_sql = $fields['Template']['options_sql']; + $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); + $fields['Template']['options_sql'] = $design_sql; + + // adds "Inherit From Parent" option to "Template" field + $fields['Template']['options'] = Array (CATEGORY_TEMPLATE_INHERIT => $this->Application->Phrase('la_opt_InheritFromParent')); + + $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); + } + + /** * Removes this item and it's children (recursive) from structure dropdown * * @param kEvent $event Index: units/custom_data/custom_data_event_handler.php =================================================================== --- units/custom_data/custom_data_event_handler.php (revision 14103) +++ units/custom_data/custom_data_event_handler.php (working copy) @@ -98,6 +98,10 @@ FROM '.TABLE_PREFIX.'CustomField'; $ret = $this->Conn->Query($sql, 'CustomFieldId'); + if ( $this->Conn->hasError() ) { + return Array (); + } + ksort($ret); return $ret; Index: units/helpers/category_helper.php =================================================================== --- units/helpers/category_helper.php (revision 14103) +++ units/helpers/category_helper.php (working copy) @@ -497,6 +497,10 @@ WHERE c.Status = ' . STATUS_ACTIVE; $pages = $this->Conn->Query($sql, 'SrcTemplate'); + if ( $this->Conn->hasError() ) { + return Array (); + } + $mapping = Array (); $base_url = $this->Application->BaseURL(); Index: units/helpers/site_helper.php =================================================================== --- units/helpers/site_helper.php (revision 14103) +++ units/helpers/site_helper.php (working copy) @@ -82,6 +82,10 @@ ORDER BY Priority DESC'; $cache = $this->Conn->Query($sql, 'DomainId'); + if ( $this->Conn->hasError() ) { + $cache = Array (); + } + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { $this->Application->setCache('master:domains_parsed', serialize($cache)); }