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/language_import_helper.php =================================================================== --- units/helpers/language_import_helper.php (revision 14103) +++ units/helpers/language_import_helper.php (working copy) @@ -166,7 +166,10 @@ $this->_updateEventsCache(); } - $this->_initImportTables(); + if ( !$this->_initImportTables() ) { + // no permission to create temp tables for import + return false; + } $phrase_types = explode('|', substr($phrase_types, 1, -1) ); // $module_ids = explode('|', substr($module_ids, 1, -1) ); @@ -582,6 +585,8 @@ $this->_tables['phrases'] = $this->_prepareTempTable('phrases', $drop_only); $this->_tables['emailevents'] = $this->_prepareTempTable('emailevents', $drop_only); $this->_tables['country-state'] = $this->_prepareTempTable('country-state', $drop_only); + + return !$this->Conn->hasError(); } /** @@ -598,7 +603,7 @@ $sql = 'DROP TABLE IF EXISTS %s'; $this->Conn->Query( sprintf($sql, $temp_table) ); - if (!$drop_only) { + if (!$drop_only && !$this->Conn->hasError()) { $sql = 'CREATE TABLE ' . $temp_table . ' SELECT * FROM ' . $table . ' WHERE 0'; $this->Conn->Query($sql); 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)); } Index: units/helpers/themes_helper.php =================================================================== --- units/helpers/themes_helper.php (revision 14103) +++ units/helpers/themes_helper.php (working copy) @@ -86,6 +86,11 @@ WHERE ThemeId = '.$theme_id; $this->Conn->Query($sql); + if ( $this->Conn->hasError() ) { + // do nothing, since ThemeFiles table isn't accessible + return false; + } + // get all theme files from db $sql = 'SELECT FileId, CONCAT(FilePath, "/", FileName) AS FullPath FROM '.TABLE_PREFIX.'ThemeFiles @@ -473,6 +478,10 @@ WHERE '.$id_field.' IN ('.implode(',', $theme_ids).')'; $this->Conn->Query($sql); + if ( $this->Conn->hasError() ) { + return ; + } + $sql = 'DELETE FROM '.TABLE_PREFIX.'ThemeFiles WHERE '.$id_field.' IN ('.implode(',', $theme_ids).')'; $this->Conn->Query($sql);