Example #1
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_user = $this->getState('filter.user');
     if (strlen($filter_user)) {
         if (static::isValidId($filter_user)) {
             $this->setCondition('user_id', new \MongoId((string) $filter_user));
         }
     }
     $filter_site = $this->getState('filter.site');
     if (strlen($filter_site)) {
         $this->setCondition('site_id', $filter_site);
     }
     $filter_session = $this->getState('filter.session');
     if (strlen($filter_session)) {
         $this->setCondition('session_id', $filter_session);
     }
     $filter_active_after = $this->getState('filter.active_after');
     if (strlen($filter_active_after)) {
         $this->setCondition('$and', array('timestamp' => array('$gt' => $filter_active_after)), 'append');
     }
     $filter_active_before = $this->getState('filter.active_before');
     if (strlen($filter_active_before)) {
         $this->setCondition('$and', array('timestamp' => array('$lt' => $filter_active_before)), 'append');
     }
     $filter_is_user = $this->getState('filter.is_user');
     if (is_bool($filter_is_user) && !empty($filter_is_user)) {
         $this->setCondition('user_id', array('$exists' => true, '$nin' => array('', null)));
     } else {
         if (is_bool($filter_is_user) && empty($filter_is_user)) {
             $this->setCondition('user_id', array('$in' => array('', null)));
         }
     }
     return $this;
 }
Example #2
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $regex = '/^[0-9a-z]{24}$/';
         if (preg_match($regex, (string) $filter_keyword)) {
             $where[] = array('_id' => new \MongoId((string) $filter_keyword));
         }
         $where[] = array('title' => $key);
         $where[] = array('type' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_priority = $this->getState('filter.priority');
     if (strlen($filter_priority)) {
         $this->setCondition('priority', $filter_priority);
     }
     $filter_type = $this->getState('filter.type');
     if (strlen($filter_type)) {
         $this->setCondition('type', $filter_type);
     }
     return $this;
 }
Example #3
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $regex = '/^[0-9a-z]{24}$/';
         if (preg_match($regex, (string) $filter_keyword)) {
             $where[] = array('_id' => new \MongoId((string) $filter_keyword));
         }
         $where[] = array('slug' => $key);
         $where[] = array('title' => $key);
         $where[] = array('copy' => $key);
         $where[] = array('description' => $key);
         $where[] = array('metadata.creator.name' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_copy_contains = $this->getState('filter.copy-contains');
     if (strlen($filter_copy_contains)) {
         $key = new \MongoRegex('/' . $filter_copy_contains . '/i');
         $this->setCondition('copy', $key);
     }
     $this->ancestorsFetchConditions();
     return $this;
 }
 protected function fetchConditions()
 {
     parent::fetchConditions();
     if ($this->getState('filter.amountpositive')) {
         $this->setCondition('amount', array('$gt' => 0));
     }
     return $this;
 }
Example #5
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $where[] = array('name' => $key);
         $where[] = array('session_id' => $key);
         $where[] = array('fingerprints' => $key);
         $where[] = array('ips' => $key);
         $where[] = array('agents' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_user = $this->getState('filter.user');
     if (strlen($filter_user)) {
         $regex = '/^[0-9a-z]{24}$/';
         if (preg_match($regex, (string) $filter_user)) {
             $this->setCondition('user_id', new \MongoId((string) $filter_user));
         }
     }
     $filter_excluded = $this->getState('filter.excluded');
     if (is_bool($filter_excluded) && !empty($filter_excluded)) {
         $this->setCondition('is_excluded', true);
     } else {
         if (is_bool($filter_excluded) && empty($filter_excluded)) {
             $this->setCondition('is_excluded', array('$in' => array(null, false)));
         }
     }
     $filter_bot = $this->getState('filter.bot');
     if (is_bool($filter_bot) && !empty($filter_bot)) {
         $this->setCondition('is_bot', true);
     } else {
         if (is_bool($filter_bot) && empty($filter_bot)) {
             $this->setCondition('is_bot', array('$in' => array(null, false)));
         }
     }
     $filter_active_after = $this->getState('filter.active_after');
     if (strlen($filter_active_after)) {
         $this->setCondition('$and', array('last_activity' => array('$gt' => $filter_active_after)), 'append');
     }
     $filter_active_before = $this->getState('filter.active_before');
     if (strlen($filter_active_before)) {
         $this->setCondition('$and', array('last_activity' => array('$lt' => $filter_active_before)), 'append');
     }
     $filter_is_user = $this->getState('filter.is_user');
     if (is_bool($filter_is_user) && !empty($filter_is_user)) {
         $this->setCondition('user_id', array('$exists' => true, '$nin' => array('', null)));
     } else {
         if (is_bool($filter_is_user) && empty($filter_is_user)) {
             $this->setCondition('user_id', array('$in' => array('', null)));
         }
     }
     return $this;
 }
Example #6
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $where[] = array('name' => $key);
         $where[] = array('email' => $key);
         $where[] = array('cite' => $key);
         $where[] = array('state' => $key);
         $where[] = array('phone_number' => $key);
         $this->setCondition('$or', $where);
     }
     return $this;
 }
Example #7
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $regex = '/^[0-9a-z]{24}$/';
         if (preg_match($regex, (string) $filter_keyword)) {
             $where[] = array('_id' => new \MongoId((string) $filter_keyword));
             $where[] = array('resource_id' => new \MongoId((string) $filter_keyword));
             $where[] = array('actor_id' => new \MongoId((string) $filter_keyword));
         }
         $where[] = array('message' => $key);
         $where[] = array('priority' => $key);
         $where[] = array('category' => $key);
         $where[] = array('resource_type' => $key);
         $where[] = array('action' => $key);
         $where[] = array('diff' => $key);
         $where[] = array('actor_type' => $key);
         $where[] = array('actor_name' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_resource_type = $this->getState('filter.resource_type');
     if (strlen($filter_resource_type)) {
         $this->setCondition('resource_type', $filter_resource_type);
     }
     $filter_resource_id = $this->getState('filter.resource_id');
     if (strlen($filter_resource_id)) {
         $this->setCondition('resource_id', $filter_resource_id);
     }
     $filter_action = $this->getState('filter.action');
     if (strlen($filter_action)) {
         $this->setCondition('action', $filter_action);
     }
     $filter_actor_type = $this->getState('filter.actor_type');
     if (strlen($filter_actor_type)) {
         $this->setCondition('actor_type', $filter_actor_type);
     }
     $filter_actor_id = $this->getState('filter.actor_id');
     if (strlen($filter_actor_id)) {
         $this->setCondition('actor_id', $filter_actor_id);
     }
     return $this;
 }
Example #8
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $where[] = array('name' => $key);
         $where[] = array('isocode_2' => $key);
         $where[] = array('isocode_3' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_only_enabled = $this->getState('filter.enabled', null);
     if (strlen($filter_only_enabled)) {
         $this->setCondition("enabled", (int) $filter_only_enabled);
     }
     return $this;
 }
Example #9
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_namespace = $this->getState('filter.namespace');
     if (strlen($filter_namespace)) {
         $this->setCondition('namespace', $filter_namespace);
     }
     $filter_identifier = $this->getState('filter.identifier');
     if (strlen($filter_identifier)) {
         $this->setCondition('identifier', $filter_identifier);
     }
     $filter_enabled = $this->getState('filter.enabled');
     if (strlen($filter_enabled) && !empty($filter_enabled)) {
         $this->setCondition('enabled', array('$in' => array(true, '1', 1)));
     } elseif (isset($filter_enabled) && is_bool($filter_enabled)) {
         $this->setCondition('enabled', array('$nin' => array(true, '1', 1)));
     }
     return $this;
 }
Example #10
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $where[] = array('title' => $key);
         $where[] = array('slug' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_slug = $this->getState('filter.slug');
     if (strlen($filter_slug)) {
         $this->setCondition('slug', strtolower($filter_slug));
     }
     $filter_title = $this->getState('filter.title');
     if (strlen($filter_title)) {
         $this->setCondition('title', $filter_title);
     }
     return $this;
 }
Example #11
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $where[] = array('name' => $key);
         $where[] = array('country_isocode_2' => $key);
         $where[] = array('code' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_country_isocode_2 = $this->getState('filter.country.isocode_2');
     if (strlen($filter_country_isocode_2)) {
         $this->setCondition('country_isocode_2', $filter_country_isocode_2);
     }
     $filter_code = $this->getState('filter.code');
     if (strlen($filter_code)) {
         $this->setCondition('code', $filter_code);
     }
     return $this;
 }
Example #12
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_type = $this->getState('filter.type');
     if ($filter_type) {
         if (is_bool($filter_type) && $filter_type) {
             $this->setCondition('type', $this->type());
         } elseif (strlen($filter_type)) {
             $this->setCondition('type', $filter_type);
         }
     }
     $filter_types = $this->getState('filter.types');
     if (!empty($filter_types) && is_array($filter_types)) {
         $this->setCondition('types', array('$in' => $filter_types));
     }
     $filter_creator_id = $this->getState('filter.creator.id');
     if (strlen($filter_creator_id)) {
         $this->setCondition('metadata.creator.id', new \MongoId((string) $filter_creator_id));
     }
     $filter_created_after = $this->getState('filter.created_after');
     if (strlen($filter_created_after)) {
         $filter_created_after = strtotime($filter_created_after);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('metadata.created.time' => 0), array('metadata.created.time' => array('$gte' => $filter_created_after))));
         $this->setCondition('$and', $and);
     }
     $filter_created_before = $this->getState('filter.created_before');
     if (strlen($filter_created_before)) {
         $filter_created_before = strtotime($filter_created_before);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('metadata.created.time' => 0), array('metadata.created.time' => array('$lte' => $filter_created_before))));
         $this->setCondition('$and', $and);
     }
     $filter_last_modified_after = $this->getState('filter.last_modified_after');
     if (strlen($filter_last_modified_after)) {
         $filter_last_modified_after = strtotime($filter_last_modified_after);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('metadata.last_modified.time' => null), array('metadata.last_modified.time' => array('$gte' => $filter_last_modified_after))));
         $this->setCondition('$and', $and);
     }
     $filter_last_modified_before = $this->getState('filter.last_modified_before');
     if (strlen($filter_last_modified_before)) {
         $filter_last_modified_before = strtotime($filter_last_modified_before);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('metadata.last_modified.time' => null), array('metadata.last_modified.time' => array('$lt' => $filter_last_modified_before))));
         $this->setCondition('$and', $and);
     }
     return $this;
 }
Example #13
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_keyword = $this->getState('filter.keyword');
     if ($filter_keyword && is_string($filter_keyword)) {
         $key = new \MongoRegex('/' . $filter_keyword . '/i');
         $where = array();
         $where[] = array('actor_name' => $key);
         $where[] = array('action' => $key);
         // get an array of actor_ids based on this keyword search, then add them as an OR
         $conditions = (new \Activity\Models\Actors())->setState('filter.keyword', $filter_keyword)->conditions();
         if ($actor_ids = \Activity\Models\Actors::collection()->distinct("_id", $conditions)) {
             $where[] = array('actor_id' => array('$in' => $actor_ids));
         }
         $this->setCondition('$or', $where);
     }
     $filter_action = $this->getState('filter.action');
     if (strlen($filter_action)) {
         $this->setCondition('action', $filter_action);
     }
     $filter_excluded_actors = $this->getState('filter.excluded_actors');
     if (strlen($filter_excluded_actors)) {
         // get an array of actor_ids, then add them as a filter
         $conditions = (new \Activity\Models\Actors())->setState('filter.excluded', true)->conditions();
         $actor_ids = \Activity\Models\Actors::collection()->distinct("_id", $conditions);
         if ($filter_excluded_actors == 'included_actors') {
             $this->setCondition('$and', array('actor_id' => array('$nin' => $actor_ids)), 'append');
         } elseif ($filter_excluded_actors == 'excluded_actors') {
             $this->setCondition('$and', array('actor_id' => array('$in' => $actor_ids)), 'append');
         }
     }
     $filter_bots = $this->getState('filter.bots');
     if (strlen($filter_bots)) {
         // get an array of actor_ids, then add them as a filter
         $conditions = (new \Activity\Models\Actors())->setState('filter.bot', true)->conditions();
         $actor_ids = \Activity\Models\Actors::collection()->distinct("_id", $conditions);
         if ($filter_bots == 'exclude_bots') {
             $this->setCondition('$and', array('actor_id' => array('$nin' => $actor_ids)), 'append');
         } elseif ($filter_bots == 'only_bots') {
             $this->setCondition('$and', array('actor_id' => array('$in' => $actor_ids)), 'append');
         }
     }
     $filter_created_after = $this->getState('filter.created_after');
     if (strlen($filter_created_after)) {
         $filter_created_after = strtotime($filter_created_after);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('created' => 0), array('created' => array('$gte' => $filter_created_after))));
         $this->setCondition('$and', $and);
     }
     $filter_created_before = $this->getState('filter.created_before');
     if (strlen($filter_created_before)) {
         $filter_created_before = strtotime($filter_created_before);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('created' => 0), array('created' => array('$lte' => $filter_created_before))));
         $this->setCondition('$and', $and);
     }
     return $this;
 }