Index: trunk/kernel/units/general/cat_event_handler.php =================================================================== diff -u -r4228 -r4231 --- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4228) +++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4231) @@ -689,10 +689,7 @@ unset($field_list[$key]); continue; // ignoring having type clauses in simple search /*$user_object =& $this->Application->recallObject('u'); - $user_groups = $user_object->GetDBField('PortalUserId') ? - implode(',', $this->Conn->GetCol(' SELECT GroupId - FROM '.TABLE_PREFIX.'UserGroup - WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0; + $user_groups = $this->Application->RecallVar('UserGroups'); $having_list[$key] = str_replace('{PREFIX}', TABLE_PREFIX, $exploded[1]); $join_clause = str_replace('{PREFIX}', TABLE_PREFIX, $search_config[$field]['JoinClause']); $join_clause = str_replace('{USER_GROUPS}', $user_groups, $join_clause); @@ -839,7 +836,9 @@ $user_object =& $this->Application->recallObject('u'); $product_table = $this->Application->getUnitOption('p', 'TableName'); - $keywords = $this->Application->GetVar('value'); + $search_keywords = $this->Application->GetVar('value'); // will not be changed + + $keywords = $this->Application->GetVar('value'); // will be changed down there $verbs = $this->Application->GetVar('verb'); $glues = $this->Application->GetVar('andor'); @@ -865,6 +864,7 @@ $join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$product_table.'.ResourceId = custom_data.ResourceId'; } + $search_log = ''; $weight_sum = 0; // processing fields and preparing conditions foreach($search_config as $record) @@ -892,10 +892,7 @@ $exploded = explode(':', $foreign_field, 2); if($exploded[0] == 'CALC') { - $user_groups = $user_object->GetDBField('PortalUserId') ? - implode(',', $this->Conn->GetCol(' SELECT GroupId - FROM '.TABLE_PREFIX.'UserGroup - WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0; + $user_groups = $this->Application->RecallVar('UserGroups'); $field_name = str_replace('{PREFIX}', TABLE_PREFIX, $exploded[1]); $join_clause = str_replace('{PREFIX}', TABLE_PREFIX, $record['JoinClause']); $join_clause = str_replace('{USER_GROUPS}', $user_groups, $join_clause); @@ -1071,8 +1068,16 @@ $or_having_conditions[] = $condition; } } + + // create search log record + $search_log_data = Array('search_config' => $record, 'verb' => getArrayValue($verbs, $field), 'value' => ($record['FieldType'] == 'range') ? $search_keywords[$field.'_from'].'|'.$search_keywords[$field.'_to'] : $search_keywords[$field]); + $search_log[] = $this->Application->Phrase('la_Field').' "'.$this->getHuman('Field', $search_log_data).'" '.$this->getHuman('Verb', $search_log_data).' '.$this->Application->Phrase('la_Value').' '.$this->getHuman('Value', $search_log_data).' '.$this->Application->Phrase($glues[$field] == 1 ? 'lu_And' : 'lu_Or'); } } + + $search_log = implode('
', $search_log); + $search_log = preg_replace('/(.*) '.preg_quote($this->Application->Phrase('lu_and'), '/').'|'.preg_quote($this->Application->Phrase('lu_or'), '/').'$/is', '\\1', $search_log); + $this->saveToSearchLog($search_log, 1); // advanced search $this->Application->StoreVar('highlight_keywords', serialize($highlight_keywords)); @@ -1140,6 +1145,53 @@ $res = $this->Conn->Query($sql); } + + function getHuman($type, $search_data) + { + $type = ucfirst(strtolower($type)); + extract($search_data); + + switch ($type) { + case 'Field': + return $this->Application->Phrase($search_config['DisplayName']); + break; + + case 'Verb': + return $verb ? $this->Application->Phrase('lu_advsearch_'.$verb) : ''; + break; + + case 'Value': + switch ($search_config['FieldType']) { + case 'date': + $values = Array(0 => 'lu_comm_Any', 'today' => 'lu_comm_Today', + 'yesterday' => 'lu_comm_Yesterday', 'last_week' => 'lu_comm_LastWeek', + 'last_month' => 'lu_comm_LastMonth', 'last_3_months' => 'lu_comm_Last3Months', + 'last_6_months' => 'lu_comm_Last6Months', 'last_year' => 'lu_comm_LastYear'); + $ret = $this->Application->Phrase($values[$value]); + break; + + case 'range': + $value = explode('|', $value); + return $this->Application->Phrase('lu_comm_From').' "'.$value[0].'" '.$this->Application->Phrase('lu_comm_To').' "'.$value[1].'"'; + break; + + case 'boolean': + $values = Array(1 => 'lu_comm_Yes', 0 => 'lu_comm_No', -1 => 'lu_comm_Both'); + $ret = $this->Application->Phrase($values[$value]); + break; + + case 'text': + $ret = $value; + break; + + } + return '"'.$ret.'"'; + break; + } + } + + + /** * Set's correct page for list * based on data provided with event