/** * set status * @param integer $id * @param integer $status */ public function actionSetStatus($id, $status) { $group = Group::model()->findByPk($id); $oldState = $group->status; $group->status = $status; $result = $group->save(); if ($result && ($oldState == "apply" && $status == "ok")) { $notice = new Notice(); $notice->type = 'group_publish'; $notice->setData(array('groupId' => $id)); $notice->userId = $group->userId; $notice->save(); } if ($result) { Yii::app()->user->setFlash('success', '操作成功'); } $this->redirect(array('index')); }
public function actionSetStatus($id, $status) { $course = Course::model()->findByPk($id); $oldState = $course->status; $course->status = $status; $result = $course->save(); if ($result && ($oldState == "apply" && $status == Course::STATUS_OK)) { $notice = new Notice(); $notice->type = 'course_publish'; $notice->setData(array('courseId' => $id)); $notice->userId = $course->userId; $notice->save(); } if ($result) { Yii::app()->user->setFlash('success', '操作成功'); } $this->redirect(array('index')); }
public function actionComment() { $comment = new LessonComment(); if (isset($_POST['LessonComment'])) { $comment->attributes = $_POST['LessonComment']; $comment->userId = Yii::app()->user->id; $comment->addTime = time(); if ($comment->save()) { $comment = LessonComment::model()->findByPk($comment->getPrimaryKey()); if ($comment->referid) { $notice = new Notice(); $notice->type = 'lesson_recomment'; $notice->setData(array('commentId' => $comment->commentId)); $notice->userId = $comment->refer->userId; $result = $notice->save(); } $commentDataProvider = new CArrayDataProvider($comment->lesson->comments, array('keyField' => 'commentId', 'pagination' => array('pageSize' => 20))); $feed = new Feed(); $feed->type = 'lesson_comment'; $feed->setData(array('commentId' => $comment->getPrimaryKey())); $feed->save(); $feed->dispatch(array('user' => array('userId' => $comment->userId), 'course' => array('courseId' => $comment->lesson->courseId))); $this->renderPartial('_comment', array('commentDataProvider' => $commentDataProvider)); } } // $this->redirect(array('view','id'=>$comment->lessonid)); }
/** * 发送系统提醒消息 * @param iint $userId 消息接收人 * @param string $type 消息类型,用于确定消息填充的template * @param array $data 消息填充所需要的数据 */ public static function send($userId, $type, $data) { $notice = new Notice(); $notice->type = $type; $notice->setData($data); $notice->userId = $userId; return $notice->save(); }
public function actionApplyPublish($courseId) { $course = $this->loadModel($courseId); if ($course->userId == Yii::app()->user->id) { $course->status = "applying"; if ($course->save()) { //通知#1用户 $notice = new Notice(); $notice->userId = 1; $notice->type = "apply_publish_course"; $notice->setData(array('courseId' => $courseId)); $notice->save(); echo true; } } }
/** * 为个人笔记投票 * Enter description here ... * @param unknown_type $lessonid * @param unknown_type $value */ public function actionLessonNote($noteid) { //$vote = new PostVote; $vote = LessonNoteVote::model()->findByAttributes(array('userId' => Yii::app()->user->id, 'noteid' => $noteid)); if ($vote) { $result = $vote->delete(); } else { $vote or $vote = new LessonNoteVote(); $vote->noteid = $noteid; $vote->userId = Yii::app()->user->id; $vote->addTime = time(); if ($vote->save()) { //发送提醒 $notice = new Notice(); $notice->type = 'vote_lesson_note'; $notice->setData(array('voteId' => $vote->getPrimaryKey())); $notice->userId = $vote->userId; $notice->save(); } } $note = LessonNote::model()->findByPk($vote->noteid); $score = $note->voteCount; $this->renderPartial('thanks_result', array('score' => $score, 'voteupers' => $note->voteupers)); }