Example #1
0
 public function actionDel($cid)
 {
     $articleModel = Article::Model();
     $sql = "SELECT aid FROM {{article}} WHERE cid = {$cid}";
     $aid = $articleModel->findBySql($sql);
     if (is_object($aid)) {
         Yii::app()->user->setFlash('hasArt', '栏目下有文章,请先删除文章');
         $this->redirect(array('index'));
     } else {
         if (Category::model()->deleteByPk($cid)) {
             $this->redirect(array('index'));
         }
     }
 }
Example #2
0
 /**
  * 发送提醒
  */
 public function afterSave()
 {
     parent::afterSave();
     if ($this->model == "answer") {
         $createUser = Answer::Model()->findByPk($this->pk_id)->create_user;
     } else {
         if ($this->model == "article") {
             $createUser = Article::Model()->findByPk($this->pk_id)->create_user;
         } else {
             if ($this->parent_id != 0) {
                 $createUser = Comment::Model()->findByPk($this->parent_id)->user_id;
             }
         }
     }
     $createUserModel = User::model()->findByPk($createUser);
     $recvArray = unserialize($createUserModel->recv_option);
     if ($this->model == "answer" || $this->model == "article") {
         $value = "subscribe_" . $this->model . "_like";
         $inser = false;
         if ($recvArray[$value] == 1 || $recvArray[$value] == 2 && $createUserModel->followees != "" && in_array($this->user_id, explode(",", trim($createUserModel->followees, ",")))) {
             $inser = true;
         }
         $content = User::getName($this->model);
         $notificationData = array("pk_id" => $this->id, "content" => "点评了你的" . $content, "send_time" => $this->create_time, "notification_type" => $this->model);
         NotificationContent::insertNotificationContent($notificationData, $inser);
     }
     if ($this->parent_id != 0) {
         $value = "subscribe_comment_like";
         $inser = false;
         if ($recvArray[$value] == 1 || $recvArray[$value] == 2 && $createUserModel->followees != "" && in_array($this->user_id, explode(",", trim($createUserModel->followees, ",")))) {
             $inser = true;
         }
         $notificationData = array("pk_id" => $this->id, "content" => "回复了你的评论", "send_time" => $this->create_time, "notification_type" => "comment");
         NotificationContent::insertNotificationContent($notificationData, $inser);
     }
 }