Index: branches/RC/themes/default2007/platform/elements/side_boxes/search.tpl
===================================================================
diff -u -r9198 -r9261
--- branches/RC/themes/default2007/platform/elements/side_boxes/search.tpl (.../search.tpl) (revision 9198)
+++ branches/RC/themes/default2007/platform/elements/side_boxes/search.tpl (.../search.tpl) (revision 9261)
@@ -4,7 +4,29 @@
">
-
+
!" />
Index: branches/RC/core/units/general/cat_event_handler.php
===================================================================
diff -u -r9021 -r9261
--- branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9021)
+++ branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9261)
@@ -334,6 +334,26 @@
}
/**
+ * Returns SQL clause, that will help to select only data from specified category & it's children
+ *
+ * @param int $category_id
+ * @return string
+ */
+ function getCategoryLimitClause($category_id)
+ {
+ if (!$category_id) {
+ return false;
+ }
+
+ $sql = 'SELECT TreeLeft, TreeRight
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$category_id;
+ $tree_indexes = $this->Conn->GetRow($sql);
+
+ return TABLE_PREFIX.'Category.TreeLeft BETWEEN '.$tree_indexes['TreeLeft'].' AND '.$tree_indexes['TreeRight'];
+ }
+
+ /**
* Apply filters to list
*
* @param kEvent $event
@@ -361,15 +381,11 @@
if ((string) $parent_cat_id != 'any') {
if ($event->getEventParam('recursive')) {
- if ($parent_cat_id > 0) {
- // not "Home" category
- $sql = 'SELECT TreeLeft, TreeRight
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$parent_cat_id;
- $tree_indexes = $this->Conn->GetRow($sql);
-
- $object->addFilter('category_filter', TABLE_PREFIX.'Category.TreeLeft BETWEEN '.$tree_indexes['TreeLeft'].' AND '.$tree_indexes['TreeRight']);
+ $filter_clause = $this->getCategoryLimitClause($parent_cat_id);
+ if ($filter_clause !== false) {
+ $object->addFilter('category_filter', $filter_clause);
}
+
$object->addFilter('primary_filter', 'PrimaryCat = 1');
}
else {
@@ -929,6 +945,18 @@
$search_helper =& $this->Application->recallObject('SearchHelper');
$where_clause = $search_helper->buildWhereClause($keywords, $field_list);
+ $search_scope = $this->Application->GetVar('search_scope');
+ if ($search_scope == 'category') {
+ $category_id = $this->Application->GetVar('m_cat_id');
+ $category_filter = $this->getCategoryLimitClause($category_id);
+ if ($category_filter !== false) {
+ $join_clauses[] = ' LEFT JOIN '.TABLE_PREFIX.'CategoryItems ON '.TABLE_PREFIX.'CategoryItems.ItemResourceId = '.$items_table.'.ResourceId';
+ $join_clauses[] = ' LEFT JOIN '.TABLE_PREFIX.'Category ON '.TABLE_PREFIX.'Category.CategoryId = '.TABLE_PREFIX.'CategoryItems.CategoryId';
+
+ $where_clause = '('.$this->getCategoryLimitClause($category_id).') AND '.$where_clause;
+ }
+ }
+
$where_clause = $where_clause.' AND '.$items_table.'.Status=1';
if($this->Application->GetVar('Action') == 'm_simple_subsearch') // subsearch, In-portal