protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_user_session = $this->getState('filter.user_session');
     if (strlen($filter_user_session)) {
         $this->setCondition('session_id_user', $filter_user_session);
     }
     $filter_admin_session = $this->getState('filter.admin_session');
     if (strlen($filter_admin_session)) {
         $this->setCondition('session_id_admin', $filter_admin_session);
     }
     $filter_user_id = $this->getState('filter.user_id');
     if (strlen($filter_user_id)) {
         $this->setCondition('user_id', $filter_user_id);
     }
     $filter_admin_id = $this->getState('filter.admin_id');
     if (strlen($filter_admin_id)) {
         $this->setCondition('admin_id', $filter_admin_id);
     }
     $filter_status = $this->getState('filter.status');
     if (strlen($filter_status)) {
         $this->setCondition('status', $filter_status);
     }
     return $this;
 }
Beispiel #2
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_user_id = $this->getState('filter.user_id');
     if (strlen($filter_user_id)) {
         $this->setCondition('user_id', new \MongoId((string) $filter_user_id));
     }
 }
Beispiel #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));
         }
         $this->setCondition('$or', $where);
     }
     return $this;
 }
Beispiel #4
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', $filter_slug);
     }
     $filter_title = $this->getState('filter.title');
     if (strlen($filter_title)) {
         $this->setCondition('title', $filter_title);
     }
     $filter_root = $this->getState('filter.root');
     if (is_bool($filter_root) && $filter_root) {
         $this->setCondition('is_root', true);
     } elseif (is_bool($filter_root) && !$filter_root) {
         $this->setCondition('is_root', array('$ne' => true));
     }
     $filter_tree_slug = $this->getState('filter.tree_slug');
     if (strlen($filter_tree_slug)) {
         $item = (new static())->setState('filter.slug', $filter_tree_slug)->setState('filter.type', true)->getItem();
         if (empty($item->id)) {
             // filter by a fake tree ID so that no results are returned for an invalid tree_slug
             $mongo_id = new \MongoId();
         } else {
             $mongo_id = $item->id;
         }
         $this->setState('filter.tree', $mongo_id);
     }
     $filter_tree = $this->getState('filter.tree');
     if (!empty($filter_tree)) {
         $this->setCondition('tree', new \MongoId((string) $filter_tree));
     }
     $filter_parent = $this->getState('filter.parent');
     if (!empty($filter_parent)) {
         $this->setCondition('parent', new \MongoId((string) $filter_parent));
     }
     return $this;
 }
Beispiel #5
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_invite_id = $this->getState('filter.invite_id');
     if (strlen($filter_invite_id)) {
         $this->setCondition('invite_id', new \MongoId((string) $filter_invite_id));
     }
     $filter_affiliate_id = $this->getState('filter.affiliate_id');
     if (strlen($filter_affiliate_id)) {
         $this->setCondition('affiliate_id', new \MongoId((string) $filter_affiliate_id));
     }
     $filter_referral_user_id = $this->getState('filter.referral_user_id');
     if (strlen($filter_referral_user_id)) {
         $this->setCondition('referral_user_id', new \MongoId((string) $filter_referral_user_id));
     }
     return $this;
 }
Beispiel #6
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $this->setCondition('type', $this->__type);
     $filter_user = $this->getState('filter.user');
     if (strlen($filter_user)) {
         $this->setCondition('user_id', new \MongoId((string) $filter_user));
     }
     $filter_has_items = $this->getState('filter.has_items');
     if (strlen($filter_has_items)) {
         if (empty($filter_has_items)) {
             $this->setCondition('items_count', array('$in' => array(0, null)));
         } else {
             $this->setCondition('items_count', array('$nin' => array(0, null)));
         }
     }
     return $this;
 }
Beispiel #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();
         $where[] = array('title' => $key);
         $where[] = array('url.alias' => $key);
         $where[] = array('url.redirect' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_id = $this->getState('filter.id');
     if (strlen($filter_id)) {
         $this->setCondition('_id', new \MongoId((string) $filter_id));
     }
     $filter_title = $this->getState('filter.title');
     if (strlen($filter_title)) {
         $this->setCondition('title', new \MongoRegex('/' . $filter_title . '/i'));
     }
     $filter_noredirect = $this->getState('filter.noredirect');
     if (strlen($filter_noredirect)) {
         $this->setCondition('url.redirect', '');
     }
     $filter_url_alias = $this->getState('filter.url.alias');
     if (strlen($filter_url_alias)) {
         $pattern = $filter_url_alias;
         if (strpos($pattern, '/') === 0) {
             $pattern = substr($pattern, 1);
         }
         //$pattern = str_replace( '/', '\/', $pattern );
         //$this->setCondition('url.alias', new \MongoRegex( '/(\/)?' . $pattern . '/' ) );
         $this->setCondition('url.alias', $pattern);
     }
     $filter_ids = $this->getState('filter.ids');
     if (!empty($filter_ids) && is_array($filter_ids)) {
         $ids = array();
         foreach ($filter_ids as $filter_id) {
             $ids[] = new \MongoId((string) $filter_id);
         }
         $this->setCondition('_id', array('$in' => $ids));
     }
     return $this;
 }
Beispiel #8
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $this->setCondition('type', $this->__type);
     $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('user_id' => new \MongoId((string) $filter_keyword));
         }
         $where[] = array('user_email' => $key);
         $where[] = array('items.product.title' => $key);
         $where[] = array('items.sku' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_user = $this->getState('filter.user');
     if (strlen($filter_user)) {
         $this->setCondition('user_id', new \MongoId((string) $filter_user));
     }
     $filter_cart_type = $this->getState('filter.cart_type');
     if (strlen($filter_cart_type)) {
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         switch ($filter_cart_type) {
             case "session":
                 $and[] = array('user_id' => array('$in' => array('', null)));
                 $this->setCondition('$and', $and);
                 break;
             case "user":
                 $and[] = array('user_id' => array('$nin' => array('', null)));
                 $this->setCondition('$and', $and);
                 break;
             default:
                 break;
         }
     }
     return $this;
 }
Beispiel #9
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('Subject' => $key);
         $where[] = array('Body' => $key);
         $where[] = array('AltBody' => $key);
         $where[] = array('metadata.creator.name' => $key);
         $where[] = array('all_recipients' => $key);
         $this->setCondition('$or', $where);
     }
     return $this;
 }
Beispiel #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('recipient_email' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_affiliate_id = $this->getState('filter.affiliate_id');
     if (strlen($filter_affiliate_id)) {
         $this->setCondition('affiliate_id', new \MongoId((string) $filter_affiliate_id));
     }
     $filter_recipient_email = $this->getState('filter.recipient_email');
     if (strlen($filter_recipient_email)) {
         $this->setCondition('recipient_email', $filter_recipient_email);
     }
     return $this;
 }
Beispiel #11
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $filter_tag = trim($this->getState('filter.tag'));
     if (strlen($filter_tag)) {
         $this->setCondition('tags', $filter_tag);
     }
     $filter_tags = (array) $this->getState('filter.tags');
     if (!empty($filter_tags)) {
         $filter_tags = array_filter(array_values($filter_tags), function ($var) {
             return !empty(trim($var));
         });
         if (!empty($filter_tags)) {
             if (count($filter_tags) == 1 && $filter_tags[0] == '--') {
                 $this->setCondition('tags', array('$size' => 0));
             } else {
                 $this->setCondition('tags', array('$in' => $filter_tags));
             }
         }
     }
     return $this;
 }
Beispiel #12
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $this->ancestorsFetchConditions();
     $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);
         $where[] = array('path' => $key);
         $where[] = array('description' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_slug = $this->getState('filter.slug');
     if (strlen($filter_slug)) {
         $this->setCondition('slug', $filter_slug);
     }
     $filter_title = $this->getState('filter.title');
     if (strlen($filter_title)) {
         $this->setCondition('title', $filter_title);
     }
     $filter_parent = $this->getState('filter.parent');
     if (!empty($filter_parent)) {
         $this->setCondition('parent', new \MongoId((string) $filter_parent));
     }
     $filter_path = $this->getState('filter.path');
     if (strlen($filter_path)) {
         // if the path doesn't begin with /, prefix it with a /
         if (substr($filter_path, 0, 1) !== '/') {
             $filter_path = '/' . $filter_path;
         }
         $this->setCondition('path', $filter_path);
     }
     return $this;
 }
Beispiel #13
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $this->setCondition('type', $this->__type);
     return $this;
 }
Beispiel #14
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $this->describableFetchConditions();
     $this->publishableFetchConditions();
     $filter_product_id = $this->getState('filter.product_id');
     if (!empty($filter_product_id)) {
         $this->setCondition('product_id', new \MongoId((string) $filter_product_id));
     }
     $filter_product_ids = $this->getState('filter.product_ids');
     if (!empty($filter_product_ids)) {
         if (!is_array($filter_product_ids)) {
             $filter_product_ids = array();
             foreach (explode(",", $this->getState('filter.product_ids')) as $product_id) {
                 $filter_product_ids[] = new \MongoId((string) $product_id);
             }
         }
         $this->setCondition('product_id', array('$in' => $filter_product_ids));
     }
     $filter_user_id = $this->getState('filter.user_id');
     if (!empty($filter_user_id)) {
         $this->setCondition('user_id', new \MongoId((string) $filter_user_id));
     }
     $filter_has_image = $this->getState('filter.has_image');
     if (!empty($filter_has_image)) {
         $this->setCondition('images', array('$not' => array('$size' => 0)));
     }
     return $this;
 }
Beispiel #15
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
 }