private function getOfferUser()
 {
     if (!isset($this->offerUser)) {
         if (!isset($this->args['offer_user_id'])) {
             return null;
         }
         $this->offerUser = OffersUsers::model()->findByPk($this->args['offer_user_id']);
     }
     return $this->offerUser;
 }
示例#2
0
 /**
  *	Check if user is joined this offer
  *	@param int $user_id
  *	@return bool
  **/
 public function isUserJoined($user_id)
 {
     $_criteria = new CDbCriteria();
     $_criteria->addCondition('user_id = :user_id');
     $_criteria->addCondition('offer_id = :offer_id');
     $_criteria->params = array(':offer_id' => $this->id, ':user_id' => $user_id);
     return OffersUsers::model()->exists($_criteria);
 }
示例#3
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $modelC = new Campaigns('search');
     $modelC->unsetAttributes();
     // clear any default values
     if (isset($_GET[get_class($modelC)])) {
         $modelC->attributes = $_GET[get_class($modelC)];
     }
     $this->userData = Users::model()->findByPk($id);
     $list = null;
     switch ($this->userData->role) {
         case Users::ROLE_USER:
             $only_active = false;
             if (isset($_GET[get_class($modelC)])) {
                 $modelC->attributes = $_GET[get_class($modelC)];
                 if (isset($_GET[get_class($modelC)]['is_active']) && $_GET[get_class($modelC)]['is_active'] == 1) {
                     $only_active = true;
                 }
             }
             $list = $modelC->searchForUser($this->userData->id, $only_active);
             break;
         case Users::ROLE_PLATFORM:
             $model = new Platforms('search');
             $model->user_id = $this->userData->id;
             $list = $model->search();
             break;
         case Users::ROLE_WEBMASTER:
             Offers::disableDefaultScope();
             $status = Yii::app()->request->getParam('status', -1);
             $list = OffersUsers::model()->findByUserId($this->userData->id, true, $status === '' ? -1 : $status);
             break;
     }
     $this->render('view', array('model' => $this->loadModel($id), 'modelC' => $modelC, 'list' => $list));
 }