示例#1
0
 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));
 }
示例#2
0
<?php

/* @var $this NoticeController */
/* @var $data Notice */
$comment = LessonComment::model()->findByPk($data['commentId']);
if (!$comment) {
    return false;
}
?>


	<?php 
echo CHtml::link($comment->user->name, array("//u/index", 'id' => $comment->userId));
echo Yii::t('app', '回复了你发表在');
?>
	<?php 
echo CHtml::link($comment->lesson->title, array('lesson/view', 'id' => $comment->lesson->lessonid));
?>
	<?php 
echo Yii::t('app', '的评论');