Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 private function relationUpdate($type = 'in_library')
 {
     if ($id = CHttpRequest::getQuery('id')) {
         if (!($model = User2movie::model()->find('movie_id=:mid AND user_id=:uid', array(':mid' => $id, ':uid' => Yii::app()->user->id)))) {
             $model = new User2movie();
             $model->movie_id = $id;
             $model->user_id = Yii::app()->user->id;
         }
         $model->{$type} = $model->{$type} ? 0 : 1;
         $model->save();
         $this->renderPartial('_relations', array('movie' => $model->movie), false, true);
     } else {
         $this->redirect(array('index'));
     }
 }
Example #2
0
 public function onWishlist()
 {
     return User2movie::model()->exists('user_id=:uid AND movie_id=:mid AND on_wishlist=1', array(':uid' => Yii::app()->user->id, ':mid' => $this->id));
 }