Example #1
0
 public function actionLove()
 {
     $record = ManyCategoryUser::model()->deleteAll(array('user_id' => User()->id));
     $nodes = $_POST['nodes'];
     foreach ($nodes as $node) {
         $rel = new ManyCategoryUser();
         $rel->category_id = $node;
         $rel->user_id = User()->id;
         $rel->save();
     }
     $this->redirect(rurl());
 }
Example #2
0
 public function actionLove()
 {
     if ($_GET['f']) {
         $node = Category::model()->findByPk($_GET['f']);
         $record = ManyCategoryUser::model()->findByAttributes(array('category_id' => $node->id, 'user_id' => User()->id));
         if ($record === null) {
             $rel = new ManyCategoryUser();
             $rel->category_id = $node->id;
             $rel->user_id = User()->id;
             $rel->save();
         }
     }
     $this->redirect(rurl());
 }
Example #3
0
 public function getIslove()
 {
     $category_id = $this->id;
     $user_id = User()->id;
     $record = ManyCategoryUser::model()->findByAttributes(array('category_id' => $category_id, 'user_id' => $user_id));
     return $record === null ? false : true;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = ManyCategoryUser::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }