示例#1
0
 /**
  *	Handle processing for the equals / range filters
  * @param object $criteria vB_Search_Criteria
  * @param array $filter_method string The name of the method to call to create a
  *		where snippet for this kind of filter (currently equals and range -- not planning
  *		to add more).  This should be the name of a private method on this class.
  * @param bool $excludeUserSpecific Exclude user specific queries. Used for precaching
  */
 private function process_filters(vB_Search_Criteria &$criteria, $filter_method, &$db, $excludeUserSpecific = false)
 {
     foreach ($this->filters[$filter_method] as $field => $value) {
         //if this is a null filter we that forces a 0-result query
         switch ($field) {
             case 'null':
                 $this->where[] = "false /** Field is NULL in process_filters **/";
                 break;
             case 'tag':
                 $this->process_tag_filters($value);
                 break;
             case 'channelid':
                 $this->process_channel_filters($value, $criteria->getDepth(), $criteria->getIncludeStarter(), $criteria->getDepthExact(), $excludeUserSpecific);
                 break;
             case 'exclude':
                 $this->process_exclude_filters($value);
                 break;
             case 'follow':
                 $this->process_follow_filters($value, $criteria);
                 break;
             case 'unpublishdate':
                 $this->where[] = "(node.showpublished = 1)";
                 break;
             case 'publishdate':
                 // skip adding a date restriction, workaround for activity stream
                 if ($value != 'all') {
                     $this->where[] = $this->{$filter_method}('node', 'publishdate', $value);
                 }
                 break;
             case 'starter_only':
                 $this->process_starter_only_filter($value);
                 break;
             case 'reply_only':
                 $this->process_reply_only_filter($value);
                 break;
             case 'comment_only':
                 $this->process_comment_only_filter($value);
                 break;
             case 'include_visitor_messages':
                 $this->process_visitor_message_filter($value, 'include');
                 break;
             case 'visitor_messages_only':
                 $this->process_visitor_message_filter($value, 'only');
                 break;
             case 'sentto':
                 $this->process_visitor_message_filter($value, 'for');
                 break;
             case 'exclude_visitor_messages':
                 $this->process_visitor_message_filter($value, 'exclude');
                 break;
             case 'include_private_messages':
                 $this->process_private_message_filter($value, 'include');
                 break;
             case 'private_messages_only':
                 $this->process_private_message_filter($value, 'only');
                 break;
             case 'OR':
                 foreach ($value as $fld => $val) {
                     $fld = $this->db->clean_identifier($fld);
                     $qbits[] = $this->make_equals_filter('node', $fld, $val);
                 }
                 $this->where[''] = "(" . implode(' OR ', $qbits) . ")";
                 break;
             case 'marked':
                 $this->process_marked_filter($value);
                 break;
             case 'my_channels':
                 $this->process_my_channels_filter($value);
                 break;
             default:
                 $dbfield = $field;
                 if (isset(self::$field_map[$field])) {
                     $dbfield = self::$field_map[$field];
                 }
                 $dbfield = $this->db->clean_identifier($dbfield);
                 $where = $this->{$filter_method}('node', $dbfield, $value);
                 $this->where[] = $where;
                 break;
         }
     }
 }
示例#2
0
 /**
  *	Handle processing for the equals / range filters
  * @param object $criteria vB_Search_Criteria
  * @param array $filter_method string The name of the method to call to create a
  *		where snippet for this kind of filter (currently equals and range -- not planning
  *		to add more).  This should be the name of a private method on this class.
  * @param  bool $excludeUserSpecific Exclude user specific queries. Used for precaching
  */
 private function process_filters(vB_Search_Criteria &$criteria, $filter_method, $excludeUserSpecific = false)
 {
     foreach ($this->filters[$filter_method] as $field => $value) {
         switch ($field) {
             //if this is a null filter we that forces a 0-result query
             case 'prefixid':
                 if (is_array($value)) {
                     $value = array_map(array($this, 'crc_uint_string'), $value);
                 } else {
                     $value = $this->crc_uint_string($value);
                 }
                 $where = $this->{$filter_method}('prefixid', $value);
                 $this->where[] = $where;
                 break;
             case 'null':
                 $this->where[] = "id = 0 /** field is null **/";
                 break;
             case 'tag':
                 $this->process_tag_filters($value);
                 break;
             case 'channelid':
                 $this->process_channel_filters($value, $criteria->getDepth(), $criteria->getIncludeStarter(), $criteria->getDepthExact(), $excludeUserSpecific);
                 break;
             case 'exclude':
                 $this->process_exclude_filters($value);
                 break;
             case 'follow':
                 $this->process_follow_filters($value, $criteria);
                 break;
             case 'unpublishdate':
                 $this->where[] = "(node.showpublished = 1)";
                 break;
             case 'publishdate':
                 // skip adding a date restriction, workaround for activity stream
                 if ($value != 'all') {
                     $this->where[] = $this->{$filter_method}('publishdate', $value);
                 }
                 break;
             case 'starter_only':
                 $this->process_starter_only_filter($value);
                 break;
             case 'reply_only':
                 $this->process_reply_only_filter($value);
                 break;
             case 'comment_only':
                 $this->process_comment_only_filter($value);
                 break;
             case 'include_visitor_messages':
                 $this->process_visitor_message_filter($value, 'include');
                 break;
             case 'visitor_messages_only':
                 $this->process_visitor_message_filter($value, 'only');
                 break;
             case 'sentto':
                 $this->process_visitor_message_filter($value, 'for');
                 break;
             case 'exclude_visitor_messages':
                 $this->process_visitor_message_filter($value, 'exclude');
                 break;
             case 'include_private_messages':
                 $this->process_private_message_filter($value, 'include');
                 break;
             case 'private_messages_only':
                 $this->process_private_message_filter($value, 'only');
                 break;
                 /** @todo OR operator is not supported by sphinx*/
             /** @todo OR operator is not supported by sphinx*/
             case 'OR':
                 // 					foreach ($value as $fld => $val)
                 // 					{
                 // 						$fld = $this->sphinxDB->clean_identifier($fld);
                 // 						$qbits[] = $this->make_equals_filter($fld, $val);
                 // 					}
                 // 					$this->where[''] = "(" . implode(' OR ', $qbits) . ")";
                 break;
             case 'marked':
                 $this->process_marked_filter($value);
                 if ($value == vB_API_Search::FILTER_MARKED_UNREAD) {
                     $criteria->add_post_processors('postProcessorMarkedUnreadFilter');
                     // only required in sphinx search, not DB search.
                 }
                 break;
             case 'my_channels':
                 $this->process_my_channels_filter($value);
                 break;
             default:
                 $dbfield = $field;
                 if (isset(self::$field_map[$field])) {
                     $dbfield = self::$field_map[$field];
                 }
                 $dbfield = $this->sphinxDB->clean_identifier($dbfield);
                 $where = $this->{$filter_method}($dbfield, $value);
                 $this->where[] = $where;
                 break;
         }
     }
 }