public function showAction(Request $request, $courseId, $threadId)
 {
     list($course, $member) = $this->buildLayoutDataWithTakenAccess($request, $courseId);
     $user = $this->getCurrentUser();
     if ($member && !$this->getCourseService()->isMemberNonExpired($course, $member)) {
         $isMemberNonExpired = false;
     } else {
         $isMemberNonExpired = true;
     }
     $thread = $this->getThreadService()->getThread($course['id'], $threadId);
     if (empty($thread)) {
         throw $this->createNotFoundException("话题不存在,或已删除。");
     }
     $paginator = new Paginator($request, $this->getThreadService()->getThreadPostCount($course['id'], $thread['id']), 30);
     $posts = $this->getThreadService()->findThreadPosts($thread['courseId'], $thread['id'], 'default', $paginator->getOffsetCount(), $paginator->getPerPageCount());
     if ($thread['type'] == 'question' && $paginator->getCurrentPage() == 1) {
         $elitePosts = $this->getThreadService()->findThreadElitePosts($thread['courseId'], $thread['id'], 0, 10);
     } else {
         $elitePosts = array();
     }
     $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($posts, 'userId'));
     $this->getThreadService()->hitThread($courseId, $threadId);
     $isManager = $this->getCourseService()->canManageCourse($course['id']);
     $lesson = $this->getCourseService()->getCourseLesson($course['id'], $thread['lessonId']);
     return $this->render("TopxiaWebBundle:CourseThread:show.html.twig", array('course' => $course, 'member' => $member, 'lesson' => $lesson, 'thread' => $thread, 'author' => $this->getUserService()->getUser($thread['userId']), 'posts' => $posts, 'elitePosts' => $elitePosts, 'users' => $users, 'isManager' => $isManager, 'isMemberNonExpired' => $isMemberNonExpired, 'paginator' => $paginator));
 }
 public function showAction(Request $request, $courseId, $id)
 {
     $user = $this->getCurrentUser();
     if (!$user->isLogin()) {
         return $this->createMessageResponse('info', '你好像忘了登录哦?', null, 3000, $this->generateUrl('login'));
     }
     $course = $this->getCourseService()->getCourse($courseId);
     if (empty($course)) {
         throw $this->createNotFoundException("课程不存在,或已删除。");
     }
     if (!$this->getCourseService()->canTakeCourse($course)) {
         return $this->createMessageResponse('info', "您还不是课程《{$course['title']}》的学员,请先购买或加入学习。", null, 3000, $this->generateUrl('course_show', array('id' => $courseId)));
     }
     list($course, $member) = $this->getCourseService()->tryTakeCourse($courseId);
     if ($member && !$this->getCourseService()->isMemberNonExpired($course, $member)) {
         // return $this->redirect($this->generateUrl('course_threads',array('id' => $courseId)));
         $isMemberNonExpired = false;
     } else {
         $isMemberNonExpired = true;
     }
     $thread = $this->getThreadService()->getThread($course['id'], $id);
     if (empty($thread)) {
         throw $this->createNotFoundException();
     }
     $paginator = new Paginator($request, $this->getThreadService()->getThreadPostCount($course['id'], $thread['id']), 30);
     $posts = $this->getThreadService()->findThreadPosts($thread['courseId'], $thread['id'], 'default', $paginator->getOffsetCount(), $paginator->getPerPageCount());
     if ($thread['type'] == 'question' and $paginator->getCurrentPage() == 1) {
         $elitePosts = $this->getThreadService()->findThreadElitePosts($thread['courseId'], $thread['id'], 0, 10);
     } else {
         $elitePosts = array();
     }
     $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($posts, 'userId'));
     $this->getThreadService()->hitThread($courseId, $id);
     $isManager = $this->getCourseService()->canManageCourse($course['id']);
     $lesson = $this->getCourseService()->getCourseLesson($course['id'], $thread['lessonId']);
     return $this->render("TopxiaWebBundle:CourseThread:show.html.twig", array('course' => $course, 'lesson' => $lesson, 'thread' => $thread, 'author' => $this->getUserService()->getUser($thread['userId']), 'posts' => $posts, 'elitePosts' => $elitePosts, 'users' => $users, 'isManager' => $isManager, 'isMemberNonExpired' => $isMemberNonExpired, 'paginator' => $paginator));
 }
Beispiel #3
0
 public function smsBillAction(Request $request)
 {
     try {
         $api = CloudAPIFactory::create('root');
         $loginToken = $this->getAppService()->getLoginToken();
         $account = $api->get('/accounts');
         $result = $api->get('/bills', array('type' => 'sms', 'page' => 1, 'limit' => 20));
         $paginator = new Paginator($this->get('request'), $result["total"], 20);
         $result = $api->get('/bills', array('type' => 'sms', 'page' => $paginator->getCurrentPage(), 'limit' => $paginator->getPerPageCount()));
         $bills = $result['items'];
     } catch (\RuntimeException $e) {
         return $this->render('TopxiaAdminBundle:EduCloud:api-error.html.twig', array());
     }
     return $this->render('TopxiaAdminBundle:EduCloud:sms-bill.html.twig', array('account' => $account, 'token' => isset($loginToken) && isset($loginToken["token"]) ? $loginToken["token"] : '', 'bills' => $bills, 'paginator' => $paginator));
 }