Esempio n. 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());
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ManyCategoryUser();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ManyCategoryUser'])) {
         $model->attributes = $_POST['ManyCategoryUser'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Esempio n. 3
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());
 }