Пример #1
0
 protected function fetchConditions()
 {
     parent::fetchConditions();
     $this->translatableFetchConditions();
     $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('description' => $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;
 }
Пример #2
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('number' => $key);
         $where[] = array('customer_name' => $key);
         $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_status = $this->getState('filter.status');
     if (strlen($filter_status)) {
         $this->setCondition('status', $filter_status);
     }
     $filter_status_excludes = $this->getState('filter.status_excludes');
     if (strlen($filter_status_excludes)) {
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('status' => array('$nin' => array($filter_status_excludes)));
         $this->setCondition('$and', $and);
     }
     $filter_fulfillment_status = $this->getState('filter.fulfillment_status');
     if (strlen($filter_fulfillment_status)) {
         $this->setCondition('fulfillment_status', $filter_fulfillment_status);
     }
     $filter_financial_status = $this->getState('filter.financial_status');
     if (is_array($filter_financial_status)) {
         $this->setCondition('financial_status', array('$in' => $filter_financial_status));
     } elseif (strlen($filter_financial_status)) {
         $this->setCondition('financial_status', $filter_financial_status);
     }
     $filter_coupon_id = $this->getState('filter.coupon_id');
     if (strlen($filter_coupon_id)) {
         $this->setCondition('coupons._id', new \MongoId((string) $filter_coupon_id));
     }
     $filter_coupon_code = $this->getState('filter.coupon_code');
     if (strlen($filter_coupon_code)) {
         $this->setCondition('coupons.code', $filter_coupon_code);
     }
     $filter_product_id = $this->getState('filter.product_id');
     if (strlen($filter_product_id)) {
         $this->setCondition('items.product_id', new \MongoId((string) $filter_product_id));
     }
     return $this;
 }
Пример #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();
         $where[] = array('username' => $key);
         $where[] = array('email' => $key);
         $where[] = array('guest_email' => $key);
         $where[] = array('first_name' => $key);
         $where[] = array('last_name' => $key);
         $where[] = array('full_name' => $key);
         $this->setCondition('$or', $where);
     }
     $filter_username = $this->getState('filter.username', null, 'alnum');
     if (strlen($filter_username)) {
         //$filter_username = strtolower($filter_username);
         $this->setCondition('username', $filter_username);
     }
     $filter_username_contains = $this->getState('filter.username-contains', null, 'alnum');
     if (strlen($filter_username_contains)) {
         $key = new \MongoRegex('/' . $filter_username_contains . '/i');
         $this->setCondition('username', $key);
     }
     $filter_email = $this->getState('filter.email');
     if (strlen($filter_email)) {
         $filter_email = strtolower($filter_email);
         $this->setCondition('email', $filter_email);
     }
     $filter_guest_email = $this->getState('filter.guest_email');
     if (strlen($filter_guest_email)) {
         $filter_guest_email = strtolower($filter_guest_email);
         $this->setCondition('guest_email', $filter_guest_email);
     }
     $filter_email_contains = $this->getState('filter.email-contains');
     if (strlen($filter_email_contains)) {
         $key = new \MongoRegex('/' . $filter_email_contains . '/i');
         $this->setCondition('email', $key);
     }
     $filter_password = $this->getState('filter.password');
     if (strlen($filter_password)) {
         $this->setCondition('password', $filter_password);
     }
     $filter_group = $this->getState('filter.group');
     if (strlen($filter_group)) {
         $this->setCondition('groups.id', new \MongoId((string) $filter_group));
     }
     $filter_forgot_password_token = $this->getState('filter.forgot_password.token');
     if (strlen($filter_forgot_password_token)) {
         $this->setCondition('forgot_password.token', (string) $filter_forgot_password_token);
     }
     $filter_new_email = $this->getState('filter.new_email');
     if (strlen($filter_new_email)) {
         $this->setCondition('change_email.email', $filter_new_email);
     }
     $filter_new_email_token = $this->getState('filter.new_email_token');
     if (strlen($filter_new_email_token)) {
         $this->setCondition('change_email.token', (string) $filter_new_email_token);
     }
     $filter_social_profile = $this->getState('filter.social-profile');
     if (strlen($filter_social_profile)) {
         $this->setCondition('social.' . $filter_social_profile, array('$exists' => true));
     }
     $filter_auto_login_token = $this->getState('filter.auto_login_token');
     if (strlen($filter_auto_login_token)) {
         $this->setCondition('auto_login.token', (string) $filter_auto_login_token);
     }
     $filter_admin_tags = (array) $this->getState('filter.admin_tags');
     if (!empty($filter_admin_tags)) {
         $filter_admin_tags = array_filter(array_values($filter_admin_tags), function ($var) {
             return !empty(trim($var));
         });
         if (!empty($filter_admin_tags)) {
             if (count($filter_admin_tags) == 1 && $filter_admin_tags[0] == '--') {
                 if (!($and = $this->getCondition('$and'))) {
                     $and = array();
                 }
                 $and[] = array('$or' => array(array('admin_tags' => null), array('admin_tags' => array('$size' => 0))));
                 $this->setCondition('$and', $and);
             } else {
                 $this->setCondition('admin_tags', array('$in' => $filter_admin_tags));
             }
         }
     }
     $filter_last_visit_after = $this->getState('filter.last_visit_after');
     if (strlen($filter_last_visit_after)) {
         $filter_last_visit_after = strtotime($filter_last_visit_after);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('last_visit.time' => null), array('last_visit.time' => array('$gte' => $filter_last_visit_after))));
         $this->setCondition('$and', $and);
     }
     $filter_last_visit_before = $this->getState('filter.last_visit_before');
     if (strlen($filter_last_visit_before)) {
         $filter_last_visit_before = strtotime($filter_last_visit_before);
         // add $and conditions to the query stack
         if (!($and = $this->getCondition('$and'))) {
             $and = array();
         }
         $and[] = array('$or' => array(array('last_visit.time' => 0), array('last_visit.time' => array('$lte' => $filter_last_visit_before))));
         $this->setCondition('$and', $and);
     }
     return $this;
 }