Index: branches/5.3.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r16195 -r16395 --- branches/5.3.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 16195) +++ branches/5.3.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 16395) @@ -1,6 +1,6 @@ Application->recallObject('SearchHelper'); + if (in_array('search', $types) || in_array('search', $except_types)) { $event_mapping = Array ( 'simple' => 'OnSimpleSearch', @@ -532,8 +535,8 @@ $object = $event->getObject(); /* @var $object kDBList */ - $search_sql = ' FROM ' . TABLE_PREFIX . 'ses_' . $this->Application->GetSID() . '_' . TABLE_PREFIX . 'Search - search_result JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId'; + $search_sql = ' FROM ' . $search_helper->getSearchTable() . ' search_result + JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId'; $sql = str_replace('FROM %1$s', $search_sql, $object->GetPlainSelectSQL()); $object->SetSelectSQL($sql); @@ -545,9 +548,6 @@ $type_clauses['search']['having_filter'] = false; } - $search_helper = $this->Application->recallObject('SearchHelper'); - /* @var $search_helper kSearchHelper */ - $search_helper->SetComplexFilter($event, $type_clauses, implode(',', $types), implode(',', $except_types)); } @@ -614,6 +614,8 @@ return parent::getPassedID($event); } + $event->setEventParam(kEvent::FLAG_ID_FROM_REQUEST, true); + return $this->Application->GetVar('m_cat_id'); } @@ -628,6 +630,8 @@ static $page_by_template = Array (); if ( $event->Special == 'current' ) { + $event->setEventParam(kEvent::FLAG_ID_FROM_REQUEST, true); + return $this->Application->GetVar('m_cat_id'); } @@ -667,6 +671,7 @@ if ( !$page_id && !$this->Application->isAdmin ) { $page_id = $this->Application->GetVar('m_cat_id'); + $event->setEventParam(kEvent::FLAG_ID_FROM_REQUEST, true); } return $page_id; @@ -1781,17 +1786,7 @@ } } else { - $not_found = $this->Application->ConfigValue('ErrorTemplate'); - $real_t = $not_found ? $not_found : 'error_notfound'; - - $themes_helper = $this->Application->recallObject('ThemesHelper'); - /* @var $themes_helper kThemesHelper */ - - $theme_id = $this->Application->GetVar('m_theme'); - $category_id = $themes_helper->getPageByTemplate($real_t, $theme_id); - $this->Application->SetVar('m_cat_id', $category_id); - - header('HTTP/1.0 404 Not Found'); + $this->Application->UrlManager->show404(); } // replace alias in form #alias_name# to actual template used in this theme @@ -1857,9 +1852,13 @@ } } - $is_admin = $this->Application->isAdminUser; + // Don't allow creating records on behalf of another user. + if ( !$this->Application->isAdminUser && !defined('CRON') ) { + $object->SetDBField('CreatedById', $object->GetOriginalField('CreatedById')); + } - if ( (!$object->IsTempTable() && !$is_admin) || ($is_admin && !$object->GetDBField('CreatedById')) ) { + // Auto-assign records to currently logged-in user. + if ( !$object->GetDBField('CreatedById') ) { $object->SetDBField('CreatedById', $this->Application->RecallVar('user_id')); } @@ -2198,17 +2197,23 @@ $config = $event->getUnitConfig(); // set root category - $config->addSectionAdjustments(Array ( + $section_adjustments = Array ( 'in-portal:browse' => Array ( - 'url' => Array ('m_cat_id' => $root_category), - 'late_load' => Array ('m_cat_id' => $root_category), - 'onclick' => 'checkCatalog(' . $root_category . ')', + 'url' => Array ('m_cat_id' => $root_category), + 'late_load' => Array ('m_cat_id' => $root_category), + 'onclick' => 'checkCatalog(' . $root_category . ', "c")', ), 'in-portal:browse_site' => Array ( - 'url' => Array ('editing_mode' => $settings['default_editing_mode']), + 'url' => Array ('editing_mode' => $settings['default_editing_mode']), ) - )); + ); + if ( $this->Application->ConfigValue('Catalog_PreselectModuleTab') ) { + $section_adjustments['in-portal:browse']['url']['anchor'] = 'tab-c'; + } + + $config->addSectionAdjustments($section_adjustments); + // prepare structure dropdown $category_helper = $this->Application->recallObject('CategoryHelper'); /* @var $category_helper CategoryHelper */ @@ -2464,13 +2469,16 @@ function OnSimpleSearch($event) { $event->redirect = false; - $search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search'; $keywords = $this->Application->unescapeRequestVariable(trim($this->Application->GetVar('keywords'))); $query_object = $this->Application->recallObject('kHTTPQuery'); /* @var $query_object kHTTPQuery */ + /** @var kSearchHelper $search_helper */ + $search_helper = $this->Application->recallObject('SearchHelper'); + + $search_table = $search_helper->getSearchTable(); $sql = 'SHOW TABLES LIKE "'.$search_table.'"'; if ( !isset($query_object->Get['keywords']) && !isset($query_object->Post['keywords']) && $this->Conn->Query($sql) ) { @@ -2480,7 +2488,7 @@ if(!$keywords || strlen($keywords) < $this->Application->ConfigValue('Search_MinKeyword_Length')) { - $this->Conn->Query('DROP TABLE IF EXISTS '.$search_table); + $search_helper->ensureEmptySearchTable(); $this->Application->SetVar('keywords_too_short', 1); return; // if no or too short keyword entered, doing nothing } @@ -2601,10 +2609,7 @@ } } - // keyword string processing - $search_helper = $this->Application->recallObject('SearchHelper'); - /* @var $search_helper kSearchHelper */ - + // Keyword string processing. $where_clause = Array (); foreach ($field_list as $field) { if (preg_match('/^' . preg_quote($items_table, '/') . '\.(.*)/', $field, $regs)) { @@ -2748,9 +2753,12 @@ // keep search results from other items after doing a sub-search on current item type $this->Application->SetVar('do_not_drop_search_table', true); - $ids = Array (); - $search_table = TABLE_PREFIX . 'ses_' . $this->Application->GetSID() . '_' . TABLE_PREFIX . 'Search'; + /** @var kSearchHelper $search_helper */ + $search_helper = $this->Application->recallObject('SearchHelper'); + + $search_table = $search_helper->getSearchTable(); $sql = 'SHOW TABLES LIKE "' . $search_table . '"'; + $ids = array(); if ( $this->Conn->Query($sql) ) { $item_type = $event->getUnitConfig()->getItemType();