Пример #1
0
<?php

/* @var $this NoticeController */
/* @var $data Notice */
$vote = LessonNote::model()->with('user', 'lesson')->findByPk($data['voteid']);
if (!$vote) {
    return false;
}
?>


	<?php 
echo CHtml::link($vote->user->name, array("/u/index", 'id' => $vote->userId));
?>
觉得你在
	<?php 
echo CHtml::link($vote->lesson->title, array('lesson/view', 'id' => $vote->lesson->lessonid));
?>
 写的个人笔记对他/她有用
Пример #2
0
 /**
  * 为个人笔记投票
  * 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));
 }