private function filterItem($items) { $questionIds = ArrayToolkit::column($items, "questionId"); $questions = $this->getQuestionService()->findQuestionsByIds($questionIds); $materialMap = array(); $itemIndexMap = array(); $newItems = array(); foreach ($items as &$item) { unset($item['answer']); unset($item['userId']); $question = $questions[$item['questionId']]; $item['questionType'] = $question['type']; $item['questionParentId'] = $question['parentId']; if ('material' == $item['questionType']) { $itemIndexMap[$item['questionId']] = $item['id']; $materialMap[$item['questionId']] = array(); } if ($item['questionParentId'] != 0 && isset($materialMap[$item['questionParentId']])) { $materialMap[$item['questionParentId']][] = $item; continue; } $newItems[$item['id']] = $item; } foreach ($materialMap as $id => $material) { $newItems[$itemIndexMap[$id]]['items'] = $material; } return array_values($newItems); }
public function listAction(Request $request, $classroomId) { $classroom = $this->getClassroomService()->getClassroom($classroomId); $headTeacher = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'headTeacher', 0, 1); $assistants = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'assistant', 0, PHP_INT_MAX); $studentAssistants = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'studentAssistant', 0, PHP_INT_MAX); $members = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'teacher', 0, PHP_INT_MAX); $members = array_merge($headTeacher, $members, $assistants, $studentAssistants); $members = ArrayToolkit::index($members, 'userId'); $teacherIds = ArrayToolkit::column($members, 'userId'); $teachers = $this->getUserService()->findUsersByIds($teacherIds); $teachers = $this->sort($teachers, $members); $profiles = $this->getUserService()->findUserProfilesByIds($teacherIds); $user = $this->getCurrentUser(); $myfollowings = $this->getUserService()->filterFollowingIds($user['id'], $teacherIds); $member = $user ? $this->getClassroomService()->getClassroomMember($classroom['id'], $user['id']) : null; $layout = 'ClassroomBundle:Classroom:layout.html.twig'; if ($member && !$member['locked']) { $layout = 'ClassroomBundle:Classroom:join-layout.html.twig'; } if (!$classroom) { $classroomDescription = array(); } else { $classroomDescription = $classroom['about']; $classroomDescription = strip_tags($classroomDescription, ''); $classroomDescription = preg_replace("/ /", "", $classroomDescription); } return $this->render('ClassroomBundle:Classroom\\Teacher:list.html.twig', array('layout' => $layout, 'canLook' => $this->getClassroomService()->canLookClassroom($classroom['id']), 'classroom' => $classroom, 'teachers' => $teachers, 'profiles' => $profiles, 'member' => $member, 'members' => $members, 'Myfollowings' => $myfollowings, 'classroomDescription' => $classroomDescription)); }
public function indexAction(Request $request, $courseId) { $course = $this->getCourseService()->tryManageCourse($courseId); $conditions = $request->query->all(); if (empty($conditions['target'])) { $conditions['targetPrefix'] = "course-{$course['id']}"; } if (!empty($conditions['keyword'])) { $conditions['stem'] = $conditions['keyword']; } //现实所有的题目包括设置为中间题的题目 $conditions['isMiddle'] = 'all'; if (!empty($conditions['parentId'])) { $parentQuestion = $this->getQuestionService()->getQuestion($conditions['parentId']); if (empty($parentQuestion)) { return $this->redirect($this->generateUrl('course_manage_question', array('courseId' => $courseId))); } $orderBy = array('createdTime', 'ASC'); } else { $conditions['parentId'] = 0; $parentQuestion = null; $orderBy = array('createdTime', 'DESC'); } $paginator = new Paginator($this->get('request'), $this->getQuestionService()->searchQuestionsCount($conditions), 10); $questions = $this->getQuestionService()->searchQuestions($conditions, $orderBy, $paginator->getOffsetCount(), $paginator->getPerPageCount()); $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($questions, 'userId')); $targets = $this->get('topxia.target_helper')->getTargets(ArrayToolkit::column($questions, 'target')); return $this->render('TopxiaWebBundle:CourseQuestionManage:index.html.twig', array('course' => $course, 'questions' => $questions, 'users' => $users, 'targets' => $targets, 'paginator' => $paginator, 'parentQuestion' => $parentQuestion, 'conditions' => $conditions, 'targetChoices' => $this->getQuestionTargetChoices($course))); }
/** * 获取最热话题 * * 可传入的参数: * * count 必需 话题数量,取值不能超过100 * * @param array $arguments 参数 * @return array 最热话题 */ public function getData(array $arguments) { $groupSetting = $this->getSettingService()->get('group', array()); $time = 7 * 24 * 60 * 60; if (isset($groupSetting['threadTime_range'])) { $time = $groupSetting['threadTime_range'] * 24 * 60 * 60; } $hotThreads = $this->getThreadService()->searchThreads(array('createdTime' => time() - $time, 'status' => 'open'), array(array('isStick', 'DESC'), array('postNum', 'DESC'), array('createdTime', 'DESC')), 0, $arguments['count']); $ownerIds = ArrayToolkit::column($hotThreads, 'userId'); $groupIds = ArrayToolkit::column($hotThreads, 'groupId'); $userIds = ArrayToolkit::column($hotThreads, 'lastPostMemberId'); $lastPostMembers = $this->getUserService()->findUsersByIds($userIds); $owners = $this->getUserService()->findUsersByIds($ownerIds); $groups = $this->getGroupService()->getGroupsByids($groupIds); foreach ($hotThreads as $key => $thread) { if ($thread['userId'] == $owners[$thread['userId']]['id']) { $hotThreads[$key]['user'] = $owners[$thread['userId']]; } if ($thread['lastPostMemberId'] > 0 && $thread['lastPostMemberId'] == $lastPostMembers[$thread['lastPostMemberId']]['id']) { $hotThreads[$key]['lastPostMember'] = $lastPostMembers[$thread['lastPostMemberId']]; } if ($thread['groupId'] == $groups[$thread['groupId']]['id']) { $hotThreads[$key]['group'] = $groups[$thread['groupId']]; } } return $hotThreads; }
public function showAction(Request $request, $id) { $buyer = $this->getCurrentUser(); $ex = $request->query->all(); $myexchangeid = $ex['ex']; $applyid = $ex[applyid]; $exchange = $this->getExchangeService()->getExchange($id); $condition = array('exchangeId' => $exchange['id'], 'userId' => $buyer['id']); $buyerapplys = $this->getApplyService()->searchApplys($condition, 'latest', 0, 10); $buyerapplyIds = ArrayToolkit::column($buyerapplys, 'id'); $sellerId = $exchange['userId']; $seller = $this->getUserService()->getUser($sellerId); if (empty($exchange)) { throw $this->createNotFoundException("宝贝不存在"); } $conditions = array('exchangeId' => $exchange['id']); $paginator = new Paginator($this->get('request'), $this->getApplyService()->searchApplyCount($conditions), 5); $applys = $this->getApplyService()->searchApplys($conditions, 'latest', $paginator->getOffsetCount(), $paginator->getPerPageCount()); $applysIds = ArrayToolkit::column($applys, 'id'); // dump($applysIds); // die; $flag = 0; if (!empty($applysIds)) { foreach ($buyerapplyIds as $val) { if (in_array($val, $applysIds)) { $flag = 1; break; } } } $userIds = ArrayToolkit::column($applys, 'userId'); $users = $this->getUserService()->findUsersByIds($userIds); return $this->render("TopxiaWebBundle:Exchange:show.html.twig", array('flag' => $flag, 'seller' => $seller, 'applyid' => $applyid, 'myexchangeid' => $myexchangeid, 'exchange' => $exchange, 'applys' => $applys, 'users' => $users, 'paginator' => $paginator)); }
/** * 获取所有用户的最新动态 * * 可传入的参数: * mode 必需 动态的模式(simple, full) * count 必需 获取动态数量 * objectType 可选 动态所属对象类型 * objectId 可选 动态所属对象编号 * * @param array $arguments 参数 * @return array 用户列表 */ public function getData(array $arguments) { $conditions = array(); if (isset($arguments['private'])) { if ($arguments['private'] == 0) { $conditions['private'] = 0; } } if (isset($arguments['objectType']) && isset($arguments['objectId'])) { if ($arguments['objectType'] == 'course') { $conditions['courseIds'] = array($arguments['objectId']); } else { $courses = $this->getClassroomService()->findActiveCoursesByClassroomId($classroom['id']); if ($courses) { $courseIds = ArrayToolkit::column($courses, 'id'); $conditions['classroomCourseIds'] = $courseIds; $conditions['classroomId'] = $arguments['objectId']; } else { $conditions['onlyClassroomId'] = $arguments['objectId']; } } } $statuses = $this->getStatusService()->searchStatuses($conditions, array('createdTime', 'DESC'), 0, $arguments['count']); if ($statuses) { $userIds = ArrayToolkit::column($statuses, 'userId'); $users = $this->getUserService()->findUsersByIds($userIds); $manager = ExtensionManager::instance(); foreach ($statuses as &$status) { $status['user'] = $users[$status['userId']]; $status['message'] = $manager->renderStatus($status, $arguments['mode']); unset($status); } } return $statuses; }
public function exploreAction(Request $request) { if (!$this->setting('course.live_course_enabled')) { return $this->createMessageResponse('info', '直播频道已关闭'); } $recenntLessonsCondition = array('status' => 'published', 'endTimeGreaterThan' => time()); $paginator = new Paginator($this->get('request'), $this->getCourseService()->searchLessonCount($recenntLessonsCondition), 30); $recentlessons = $this->getCourseService()->searchLessons($recenntLessonsCondition, array('startTime', 'ASC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); $courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($recentlessons, 'courseId')); $recentCourses = array(); foreach ($recentlessons as $lesson) { $course = $courses[$lesson['courseId']]; if ($course['status'] != 'published') { continue; } $course['lesson'] = $lesson; $recentCourses[] = $course; } $liveCourses = $this->getCourseService()->searchCourses(array('status' => 'published', 'type' => 'live'), 'lastest', 0, 10); $userIds = array(); foreach ($liveCourses as $course) { $userIds = array_merge($userIds, $course['teacherIds']); } $users = $this->getUserService()->findUsersByIds($userIds); $default = $this->getSettingService()->get('default', array()); return $this->render('TopxiaWebBundle:LiveCourse:index.html.twig', array('recentCourses' => $recentCourses, 'liveCourses' => $liveCourses, 'users' => $users, 'paginator' => $paginator, 'default' => $default)); }
/** * 获取一个分类下的课程成员列表 * * 可传入的参数: * categoryId 选填 分类ID * count 必需 学员数量,取值不能超过100 * * @param array $arguments 参数 * @return array 课程成员列表 */ public function getData(array $arguments) { $this->checkCount($arguments); $conditions = array('status' => 'paid'); $orders = $this->getGiftOrdersService()->searchOrders($conditions, 'latest', 0, 1000); return $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($orders, 'userId')); }
public function indexAction(Request $request, $postStatus) { $conditions = $request->query->all(); if (isset($conditions['keywordType']) && $conditions['keywordType'] == 'courseTitle') { $courses = $this->getCourseService()->findCoursesByLikeTitle(trim($conditions['keyword'])); $conditions['courseIds'] = ArrayToolkit::column($courses, 'id'); if (count($conditions['courseIds']) == 0) { return $this->render('TopxiaAdminBundle:CourseQuestion:index.html.twig', array('paginator' => new Paginator($request, 0, 20), 'questions' => array(), 'users' => array(), 'courses' => array(), 'lessons' => array(), 'type' => $postStatus)); } } $conditions['type'] = 'question'; $paginator = new Paginator($request, $this->getThreadService()->searchThreadCount($conditions), 20); $questions = $this->getThreadService()->searchThreads($conditions, 'createdNotStick', $paginator->getOffsetCount(), $paginator->getPerPageCount()); $unPostedQuestion = array(); foreach ($questions as $key => $value) { if ($value['postNum'] == 0) { $unPostedQuestion[] = $value; } else { $threadPostsNum = $this->getThreadService()->getThreadPostCountByThreadId($value['id']); $userPostsNum = $this->getThreadService()->getPostCountByuserIdAndThreadId($value['userId'], $value['id']); if ($userPostsNum == $threadPostsNum) { $unPostedQuestion[] = $value; } } } if ($postStatus == 'unPosted') { $questions = $unPostedQuestion; } $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($questions, 'userId')); $courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($questions, 'courseId')); $lessons = $this->getCourseService()->findLessonsByIds(ArrayToolkit::column($questions, 'lessonId')); return $this->render('TopxiaAdminBundle:CourseQuestion:index.html.twig', array('paginator' => $paginator, 'questions' => $questions, 'users' => $users, 'courses' => $courses, 'lessons' => $lessons, 'type' => $postStatus)); }
public function defaultCoursePictureCropAction(Request $request) { if ($request->getMethod() == 'POST') { $options = $request->request->all(); $data = $options["images"]; $fileIds = ArrayToolkit::column($data, "id"); $files = $this->getFileService()->getFilesByIds($fileIds); $files = ArrayToolkit::index($files, "id"); $fileIds = ArrayToolkit::index($data, "type"); $setting = $this->getSettingService()->get("default", array()); $oldAvatars = array('course.png' => !empty($setting['course.png']) ? $setting['course.png'] : null); $setting['defaultCoursePicture'] = 1; unset($setting['defaultCoursePictureFileName']); $setting['course.png'] = $files[$fileIds["course.png"]["id"]]["uri"]; $this->getSettingService()->set("default", $setting); $fileService = $this->getFileService(); array_map(function ($oldAvatar) use($fileService) { if (!empty($oldAvatar)) { $fileService->deleteFileByUri($oldAvatar); } }, $oldAvatars); return $this->redirect($this->generateUrl('admin_setting_course_avatar')); } $fileId = $request->getSession()->get("fileId"); list($pictureUrl, $naturalSize, $scaledSize) = $this->getFileService()->getImgFileMetaInfo($fileId, 480, 270); return $this->render('TopxiaAdminBundle:System:default-course-picture-crop.html.twig', array('pictureUrl' => $pictureUrl, 'naturalSize' => $naturalSize, 'scaledSize' => $scaledSize)); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->initServiceKernel(); $connection = $this->getContainer()->get('database_connection'); $tomorrow = date("Y-m-d", strtotime("+1 day")); $startDate = $tomorrow . " 0:00:00"; $endDate = $tomorrow . " 24:00:00"; $conditions['startTimeLessThan'] = strtotime($endDate); $conditions['startTimeGreaterThan'] = strtotime($startDate); $total = $this->getCourseService()->searchLessonCount($conditions); $liveLessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'ASC'), 0, $total); $courseIds = ArrayToolkit::column($liveLessons, 'courseId'); $courseIds = array_unique($courseIds); $courseIds = array_values($courseIds); if ($courseIds) { $courseMembers = $this->getCourseService()->findCourseStudentsByCourseIds($courseIds); foreach ($courseMembers as $key => $value) { $minStartTime = $this->getCourseService()->findMinStartTimeByCourseId($value['courseId']); if (time() >= strtotime($startDate)) { $noticeDay = "今天"; } else { $noticeDay = "明天"; } $minStartTime = date("Y-m-d H:i:s", $minStartTime[0]['startTime']); $message = array('noticeDay' => $noticeDay, 'minStartTime' => $minStartTime); $this->getNotificationService()->notify($value['userId'], "live-course", $message); } $output->writeln('<info>消息发布完成</info>'); } else { $output->writeln('<info>没有消息可以发布</info>'); } }
public function editAction(Request $request, $id) { $article = $this->getArticleService()->getArticle($id); if (empty($article)) { throw $this->createNotFoundException('文章已删除或者未发布!'); } if (empty($article['tagIds'])) { $article['tagIds'] = array(); } $tags = $this->getTagService()->findTagsByIds($article['tagIds']); $tagNames = ArrayToolkit::column($tags, 'name'); $categoryId = $article['categoryId']; $category = $this->getCategoryService()->getCategory($categoryId); $categoryTree = $this->getCategoryService()->getCategoryTree(); if ($request->getMethod() == 'POST') { $formData = $request->request->all(); $article = $this->getArticleService()->updateArticle($id, $formData); return $this->redirect($this->generateUrl('admin_article')); } //添加报名人数 $ArticleService = $this->getServiceKernel()->createService('Article.ArticleService'); $temp_count = $ArticleService->getArticleLikesCountByArticleId($article['id']); $article['enroll'] = $temp_count; return $this->render('TopxiaAdminBundle:Article:article-modal.html.twig', array('article' => $article, 'categoryTree' => $categoryTree, 'category' => $category, 'tagNames' => $tagNames)); }
protected function assemblyArticles(&$articles) { $tagIds = array(); foreach ($articles as $article) { $tagIds = array_merge($tagIds, $article['tagIds']); } $tags = $this->getTagService()->findTagsByIds($tagIds); $categoryIds = ArrayToolkit::column($articles, 'categoryId'); $categories = $this->getCategoryService()->findCategoriesByIds($categoryIds); foreach ($articles as &$article) { $article['tags'] = array(); if (empty($article['tagIds'])) { continue; } foreach ($article['tagIds'] as $tagId) { if (empty($tags[$tagId])) { continue; } $article['tags'][] = array('id' => $tagId, 'name' => $tags[$tagId]['name']); } } foreach ($articles as &$article) { if (isset($categories[$article['categoryId']])) { $article['category'] = array('id' => $categories[$article['categoryId']]['id'], 'name' => $categories[$article['categoryId']]['name']); } else { $article['category'] = array(); } } return $articles; }
public function indexAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $type = $request->query->get('type'); $type = in_array($type, array('courselesson', 'coursematerial')) ? $type : 'courselesson'; $conditions = array('targetType' => $type, 'targetId' => $course['id']); if (array_key_exists('targetId', $conditions) && !empty($conditions['targetId'])) { $course = $this->getCourseService()->getCourse($conditions['targetId']); if ($course['parentId'] > 0 && $course['locked'] == 1) { $conditions['targetId'] = $course['parentId']; } } $paginator = new Paginator($request, $this->getUploadFileService()->searchFileCount($conditions), 20); $files = $this->getUploadFileService()->searchFiles($conditions, 'latestCreated', $paginator->getOffsetCount(), $paginator->getPerPageCount()); foreach ($files as $key => $file) { $files[$key]['metas2'] = json_decode($file['metas2'], true) ?: array(); $files[$key]['convertParams'] = json_decode($file['convertParams']) ?: array(); $useNum = $this->getCourseService()->searchLessonCount(array('mediaId' => $file['id'])); $manageFilesUseNum = $this->getMaterialService()->getMaterialCountByFileId($file['id']); if ($files[$key]['targetType'] == 'coursematerial') { $files[$key]['useNum'] = $manageFilesUseNum; } else { $files[$key]['useNum'] = $useNum; } } $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($files, 'updatedUserId')); $storageSetting = $this->getSettingService()->get("storage"); return $this->render('TopxiaWebBundle:CourseFileManage:index.html.twig', array('type' => $type, 'course' => $course, 'courseLessons' => $files, 'users' => ArrayToolkit::index($users, 'id'), 'paginator' => $paginator, 'now' => time(), 'storageSetting' => $storageSetting)); }
public function latestReviewsBlockAction($number) { $reviews = $this->getReviewService()->searchReviews(array(), 'latest', 0, $number); $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($reviews, 'userId')); $courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($reviews, 'courseId')); return $this->render('TopxiaWebBundle:Default:latest-reviews-block.html.twig', array('reviews' => $reviews, 'users' => $users, 'courses' => $courses)); }
public function updateSeqsAction(Request $request) { $data = $request->request->get('data'); $ids = ArrayToolkit::column($data, 'id'); $this->getNavigationService()->updateNavigationsSequenceByIds($ids); return $this->createJsonResponse(true); }
public function showAllAction(Request $request, $targetType, $targetId) { $conditions = array('targetType' => $targetType, 'targetId' => $targetId); $announcements = $this->getAnnouncementService()->searchAnnouncements($conditions, array('createdTime', 'DESC'), 0, 10000); $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($announcements, 'userId')); return $this->render('TopxiaWebBundle:Announcement:announcement-show-all-modal.html.twig', array('announcements' => $announcements, 'users' => $users)); }
/** * 获取最新资讯列表 * * 可传入的参数: * count 必需 课程数量,取值不能超过100 * * type: featured 可选 是否头条 * promoted 可选 是否推荐 * sticky 可选 是否置顶 * categoryId: 分类ID * * @param array $arguments 参数 * @return array 资讯列表 */ public function getData(array $arguments) { $this->checkCount($arguments); $conditions = array(); if (!empty($arguments['type']) && $arguments['type'] == 'featured') { $conditions['featured'] = 1; } if (!empty($arguments['type']) && $arguments['type'] == 'promoted') { $conditions['promoted'] = 1; } if (!empty($arguments['type']) && $arguments['type'] == 'sticky') { $conditions['sticky'] = 1; } if (!empty($arguments['categoryId'])) { $conditions['categoryId'] = (int) $arguments['categoryId']; $conditions['includeChildren'] = 1; } $conditions['status'] = 'published'; $articles = $this->getArticleService()->searchArticles($conditions, 'created', 0, $arguments['count']); $categorise = $this->getCategoryService()->findCategoriesByIds(ArrayToolkit::column($articles, 'categoryId')); foreach ($articles as $key => $article) { if (empty($article['categoryId'])) { continue; } if ($article['categoryId'] == $categorise[$article['categoryId']]['id']) { $articles[$key]['category'] = $categorise[$article['categoryId']]; } } return $articles; }
public function listAction(Request $request) { $user = $this->getCurrentUser(); list($course, $member) = $this->getCourseService()->tryTakeCourse($request->query->get('courseId')); $items = $this->getCourseService()->getCourseItems($course['id']); $learnStatuses = $this->getCourseService()->getUserLearnLessonStatuses($user['id'], $course['id']); $homeworkPlugin = $this->getAppService()->findInstallApp('Homework'); $homeworkLessonIds = array(); $exercisesLessonIds = array(); $testpaperIds = array(); array_walk($items, function ($item, $key) use(&$testpaperIds) { if ($item['type'] == 'testpaper') { array_push($testpaperIds, $item['mediaId']); } }); $testpapers = $this->getTestpaperService()->findTestpapersByIds($testpaperIds); if ($homeworkPlugin) { $lessons = $this->getCourseService()->getCourseLessons($course['id']); $lessonIds = ArrayToolkit::column($lessons, 'id'); $homeworks = $this->getHomeworkService()->findHomeworksByCourseIdAndLessonIds($course['id'], $lessonIds); $exercises = $this->getExerciseService()->findExercisesByLessonIds($lessonIds); $homeworkLessonIds = ArrayToolkit::column($homeworks, 'lessonId'); $exercisesLessonIds = ArrayToolkit::column($exercises, 'lessonId'); } return $this->render('TopxiaWebBundle:LessonLessonPlugin:list.html.twig', array('course' => $course, 'items' => $items, 'learnStatuses' => $learnStatuses, 'currentTime' => time(), 'weeks' => array("日", "一", "二", "三", "四", "五", "六"), 'homeworkLessonIds' => $homeworkLessonIds, 'exercisesLessonIds' => $exercisesLessonIds, 'member' => $member, 'testpapers' => $testpapers)); }
public function listAction(Request $request, $id) { $classroom = $this->getClassroomService()->getClassroom($id); $courses = $this->getClassroomService()->findActiveCoursesByClassroomId($id); $coursesNum = count($courses); $user = $this->getCurrentUser(); $member = $user ? $this->getClassroomService()->getClassroomMember($classroom['id'], $user['id']) : null; if (!$this->getClassroomService()->canLookClassroom($classroom['id'])) { return $this->createMessageResponse('info', "非常抱歉,您无权限访问该{$classroomSetting['name']},如有需要请联系客服", '', 3, $this->generateUrl('homepage')); } $conditions = array('classroomId' => $id); $reviewsNum = $this->getClassroomReviewService()->searchReviewCount($conditions); $paginator = new Paginator($this->get('request'), $reviewsNum, 20); $reviews = $this->getClassroomReviewService()->searchReviews($conditions, array('createdTime', 'DESC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); $reviewUserIds = ArrayToolkit::column($reviews, 'userId'); $reviewUsers = $this->getUserService()->findUsersByIds($reviewUserIds); $classroom = $this->getClassroomService()->getClassroom($id); $review = $this->getClassroomReviewService()->getUserClassroomReview($user['id'], $classroom['id']); $layout = 'ClassroomBundle:Classroom:layout.html.twig'; if ($member && !$member['locked']) { $layout = 'ClassroomBundle:Classroom:join-layout.html.twig'; } if (!$classroom) { $classroomDescription = array(); } else { $classroomDescription = $classroom['about']; $classroomDescription = strip_tags($classroomDescription, ''); $classroomDescription = preg_replace("/ /", "", $classroomDescription); } return $this->render("ClassroomBundle:Classroom\\Review:list.html.twig", array('classroom' => $classroom, 'courses' => $courses, 'paginator' => $paginator, 'reviewsNum' => $reviewsNum, 'reviews' => $reviews, 'userReview' => $review, 'reviewSaveUrl' => $this->generateUrl('classroom_review_create', array('id' => $id)), 'users' => $reviewUsers, 'member' => $member, 'layout' => $layout, 'classroomDescription' => $classroomDescription, 'canReview' => $this->isClassroomMember($classroom, $user['id']))); }
public function indexAction(Request $request, $status) { $courses = $this->getCourseService()->searchCourses(array('type' => 'live', 'status' => 'published'), $sort = 'latest', 0, 1000); $courseIds = ArrayToolkit::column($courses, 'id'); $courses = ArrayToolkit::index($courses, 'id'); $conditions['type'] = "live"; switch ($status) { case 'coming': $conditions['startTimeGreaterThan'] = time(); break; case 'end': $conditions['endTimeLessThan'] = time(); break; case 'underway': $conditions['startTimeLessThan'] = time(); $conditions['endTimeGreaterThan'] = time(); break; } $conditions['courseIds'] = $courseIds; $conditions['status'] = 'published'; $paginator = new Paginator($request, $this->getCourseService()->searchLessonCount($conditions), 20); if ($status == 'end') { $lessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'DESC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); } else { $lessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'ASC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); } return $this->render('TopxiaAdminBundle:LiveCourse:index.html.twig', array('status' => $status, 'lessons' => $lessons, 'courses' => $courses, 'paginator' => $paginator)); }
public function recommendClassroomsAction($course) { $classrooms = array(); $classrooms = array_merge($classrooms, array_values($this->getClassroomService()->findClassroomsByCourseId($course['id']))); $belongCourseClassroomIds = ArrayToolkit::column($classrooms, 'id'); if ($course['categoryId'] > 0) { $classrooms = array_merge($classrooms, $this->getClassroomService()->searchClassrooms(array('categoryIds' => array($course['categoryId']), 'private' => 0), array('recommendedSeq', 'ASC'), 0, 8)); } $classrooms = array_merge($classrooms, $this->getClassroomService()->searchClassrooms(array('recommended' => 1, 'private' => 0, 'status' => 'published'), array('recommendedSeq', 'ASC'), 0, 11)); $recommends = array(); foreach ($classrooms as $key => $classroom) { if (isset($recommends[$classroom['id']])) { continue; } if (count($recommends) >= 8) { break; } if (in_array($classroom['id'], $belongCourseClassroomIds)) { $classroom['belogCourse'] = true; } if ($classroom['status'] == 'published') { $recommends[$classroom['id']] = $classroom; } } return $this->render('TopxiaWebBundle:Course/Part:normal-header-recommend-classrooms.html.twig', array('classrooms' => $recommends)); }
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)); }
/** * 获取加精的课程话题列表 * * 可传入的参数: * type 选填 话题类型 * count 必需 课程话题数量,取值不能超过100 * * @param array $arguments 参数 * @return array 课程话题 */ public function getData(array $arguments) { $this->checkCount($arguments); if (empty($arguments['type'])) { $type = ""; } else { $type = $arguments['type']; } $arguments['status'] = '1'; $threads = $this->getThreadService()->findEliteThreadsByType($type, $arguments['status'], 0, $arguments['count']); $courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($threads, 'courseId')); $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($threads, 'userId')); $latestPostUsers = $this->getUserService()->findUsersByIds(ArrayToolkit::column($threads, 'latestPostUserId')); foreach ($threads as $key => $thread) { if ($thread['courseId'] == $courses[$thread['courseId']]['id']) { $threads[$key]['course'] = $courses[$thread['courseId']]; } if ($thread['userId'] == $users[$thread['userId']]['id']) { $threads[$key]['user'] = $users[$thread['userId']]; } if ($thread['latestPostUserId'] == $latestPostUsers[$thread['latestPostUserId']]['id']) { $threads[$key]['latestPostUser'] = $latestPostUsers[$thread['latestPostUserId']]; } } return $threads; }
public function logsAction(Request $request) { $paginator = new Paginator($this->get('request'), $this->getAppService()->findLogCount(), 30); $logs = $this->getAppService()->findLogs($paginator->getOffsetCount(), $paginator->getPerPageCount()); $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($logs, 'userId')); return $this->render('TopxiaAdminBundle:App:logs.html.twig', array('logs' => $logs, 'users' => $users)); }
public function indexAction(Request $request) { $fields = $request->query->all(); $conditions = array('roles' => '', 'keywordType' => '', 'keyword' => '', 'keywordUserType' => ''); if (empty($fields)) { $fields = array(); } $conditions = array_merge($conditions, $fields); //根据mobile查询user_profile获得userIds if (isset($conditions['keywordType']) && $conditions['keywordType'] == 'verifiedMobile') { $profilesCount = $this->getUserService()->searchUserProfileCount(array('mobile' => $conditions['keyword'])); $userProfiles = $this->getUserService()->searchUserProfiles(array('mobile' => $conditions['keyword']), array('id', 'DESC'), 0, $profilesCount); $userIds = ArrayToolkit::column($userProfiles, 'id'); if (!empty($userIds)) { unset($conditions['keywordType']); unset($conditions['keyword']); $conditions['userIds'] = $userIds; } } $userCount = $this->getUserService()->searchUserCount($conditions); $paginator = new Paginator($this->get('request'), $userCount, 20); $users = $this->getUserService()->searchUsers($conditions, array('createdTime', 'DESC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); $app = $this->getAppService()->findInstallApp("UserImporter"); $showUserExport = false; if (!empty($app) && array_key_exists('version', $app)) { $showUserExport = version_compare($app['version'], "1.0.2", ">="); } $userIds = ArrayToolkit::column($users, 'id'); $profiles = $this->getUserService()->findUserProfilesByIds($userIds); return $this->render('TopxiaAdminBundle:User:index.html.twig', array('users' => $users, 'userCount' => $userCount, 'paginator' => $paginator, 'profiles' => $profiles, 'showUserExport' => $showUserExport)); }
/** * 获取最高解决的悬赏 * * 可传入的参数: * * count 个娄 * * @param array $arguments 参数 * @return array 悬赏数 */ public function getData(array $arguments) { $conditions = array('sort' => 'reward', 'rewardType' => $arguments['rewardType'], 'solved' => 1); $threads = $this->getThreadService()->searchThreads($conditions, $conditions['sort'], 0, 10); $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($threads, 'userId')); return $threads; }
public function indexAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $courseItems = $this->getCourseService()->getCourseItems($course['id']); $lessonIds = ArrayToolkit::column($courseItems, 'id'); if ($this->isPluginInstalled('Homework')) { $exercises = $this->getServiceKernel()->createService('Homework:Homework.ExerciseService')->findExercisesByLessonIds($lessonIds); $homeworks = $this->getServiceKernel()->createService('Homework:Homework.HomeworkService')->findHomeworksByCourseIdAndLessonIds($course['id'], $lessonIds); } $mediaMap = array(); foreach ($courseItems as $item) { if ($item['itemType'] != 'lesson') { continue; } if (empty($item['mediaId'])) { continue; } if (empty($mediaMap[$item['mediaId']])) { $mediaMap[$item['mediaId']] = array(); } $mediaMap[$item['mediaId']][] = $item['id']; } $mediaIds = array_keys($mediaMap); $files = $this->getUploadFileService()->findFilesByIds($mediaIds); foreach ($files as $file) { $lessonIds = $mediaMap[$file['id']]; foreach ($lessonIds as $lessonId) { $courseItems["lesson-{$lessonId}"]['mediaStatus'] = $file['convertStatus']; } } $default = $this->getSettingService()->get('default', array()); return $this->render('TopxiaWebBundle:CourseLessonManage:index.html.twig', array('course' => $course, 'items' => $courseItems, 'exercises' => empty($exercises) ? array() : $exercises, 'homeworks' => empty($homeworks) ? array() : $homeworks, 'files' => ArrayToolkit::index($files, 'id'), 'default' => $default)); }
/** * 获取一个分类下的课程成员列表 * * 可传入的参数: * categoryId 选填 分类ID * count 必需 学员数量,取值不能超过100 * * @param array $arguments 参数 * @return array 课程成员列表 */ public function getData(array $arguments) { $this->checkCount($arguments); if (empty($arguments['categoryId'])) { $conditions = array('status' => 'published'); } else { $conditions = array('status' => 'published', 'categoryId' => $arguments['categoryId']); } $courses = $this->getCourseService()->searchCourses($conditions, 'latest', 0, 1000); $courseIds = ArrayToolkit::column($courses, 'id'); $conditions = array('courseIds' => $courseIds, 'unique' => true, 'role' => 'student'); $members = $this->getCourseService()->searchMembers($conditions, array('createdTime', 'DESC'), 0, $arguments['count']); $courseIds = ArrayToolkit::column($members, 'courseId'); $userIds = ArrayToolkit::column($members, 'userId'); $users = $this->getUserService()->findUsersByIds($userIds); $users = ArrayToolkit::index($users, 'id'); $this->unsetUserPasswords($users); $courses = $this->getCourseService()->findCoursesByIds($courseIds); $courses = ArrayToolkit::index($courses, 'id'); foreach ($members as &$member) { $member['course'] = $courses[$member["courseId"]]; $member['user'] = $users[$member["userId"]]; } return $members; }
protected function convertConditions($conditions) { if (!empty($conditions['nickname'])) { $userConditions['nickname'] = trim($conditions['nickname']); $userCount = $this->getUserService()->searchUserCount($userConditions); if ($userCount) { $users = $this->getUserService()->searchUsers($userConditions, array('createdTime', 'DESC'), 0, $userCount); $conditions['fromIds'] = ArrayToolkit::column($users, 'id'); } } unset($conditions['nickname']); if (empty($conditions['content'])) { unset($conditions['content']); } if (empty($conditions['startDate'])) { unset($conditions['startDate']); } if (empty($conditions['endDate'])) { unset($conditions['endDate']); } if (isset($conditions['startDate'])) { $conditions['startDate'] = strtotime($conditions['startDate']); } if (isset($conditions['endDate'])) { $conditions['endDate'] = strtotime($conditions['endDate']); } return $conditions; }