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;
 }
Esempio n. 2
0
 /**
  *	TODO:: Join user to this offer
  *	@param Users $User
  *	@return bool
  *	@throws Exception
  **/
 public function joinUser($user_id, $description = null)
 {
     $OfferUser = new OffersUsers();
     $OfferUser->offer_id = $this->id;
     $OfferUser->user_id = $user_id;
     $OfferUser->description = $description;
     $OfferUser->save();
     return $OfferUser;
 }
Esempio n. 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));
 }
Esempio n. 4
0
 public function delOfferUser(OffersUsers $offerUser)
 {
     $this->redis()->del($this->getOfferUserKey($offerUser->getEncryptedId()));
 }