Beispiel #1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($access = null)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     if (!empty($access)) {
         $this->role_id = $access;
     }
     if (!empty($_GET['User']['contragent_id'])) {
         $arrID = array();
         if (is_array($_GET['User']['contragent_id'])) {
             $contragent_id = array();
             foreach ($_GET['User']['contragent_id'] as $value) {
                 $contragent_id[] = $value;
             }
             foreach (UserAccess::model()->findAll('type = 1 AND access_id in (' . implode(",", $contragent_id) . ')') as $data) {
                 $arrID[] = $data->user_id;
             }
         } else {
             foreach (UserAccess::model()->findAll('type = 1 AND access_id in (' . (int) $_GET['User']['contragent_id'] . ')') as $data) {
                 $arrID[] = $data->user_id;
             }
         }
         if (!empty($arrID)) {
             $criteria->condition = 'id in (' . implode(",", $arrID) . ')';
         }
     }
     //compare roles
     //$criteria->with = array('role');
     $criteria->together = true;
     $criteria->compare('id', $this->id, true);
     $criteria->compare('subscribe', $this->subscribe, true);
     $criteria->compare('role_id', $this->role_id, true);
     $criteria->compare('email', $this->email, true);
     $criteria->compare('username', $this->username, true);
     $criteria->compare('score', $this->score);
     $criteria->compare('birthday', strtotime($this['birthday']), true);
     $criteria->compare('created_at', $this->created_at, true);
     $criteria->compare('state', $this->state);
     $criteria->compare('email_group', $this->email_group, true);
     $criteria->compare('organization', $this->organization, true);
     $criteria->compare('ur_addres', $this->ur_addres, true);
     $criteria->compare('fiz_addres', $this->fiz_addres, true);
     $criteria->compare('inn', $this->inn, true);
     $criteria->compare('kpp', $this->kpp, true);
     $criteria->compare('okpo', $this->okpo, true);
     return $criteria;
 }