public function detail() { $id = $_GET['id']; $video = M('V')->findById($id); if (empty($video)) { $this->error('该视频不存在或已被删除'); } if ($video['checked'] != 1) { $this->error('该视频未通过审核'); } $video['is_favour'] = M('V')->is_favour($id, $this->mid); $this->assign('video', $video); //$this->ajaxReturn($video); $user = M('V')->findWriter($video['uid']); $this->assign('writer', model('User')->formatForApi($user, $user['uid'])); $this->assign('works', M('V')->findWorks($video['uid'])); $comments = VideoCommentModel::selectByVID($video['id']); if (!empty($comments)) { foreach ($comments as &$comment) { $comment = model('User')->formatForApi($comment, $comment['uid']); $comment['content'] = htmlspecialchars_decode($comment['content']); } } $this->assign('comments', $comments); $followers = M('Follower')->followers($id); if (!empty($followers)) { foreach ($followers as &$follower) { $follower = model('User')->formatForApi($follower, $follower['uid']); } } $this->assign('followers', $followers); M('V')->updatePlayCount($id); $this->display(); }
public function publish() { $params = $_REQUEST; $video_id = $params['id']; unset($params['id']); $video = M('V')->findById($video_id); //if ($video['uid'] == $this->uid) // $this->_error('禁止评论自己的视频'); if (VideoCommentModel::getCommentCountOfUser($video_id, $this->uid) > 10) { $this->_error('评论过多'); } $params['video_id'] = $video_id; $params['uid'] = $this->uid; $params['addtime'] = time(); $info = M('VideoComment')->publish($params); if (is_string($info)) { $this->_error($info); } M('V')->updateCommentCount($video_id); $this->_success(null, '评论成功'); }