作者:stylin
项目:LeesPhar
public function addFile($targetType, $targetId, array $fileInfo = array(), UploadedFile $originalFile = null)
{
if (!ArrayToolkit::requireds($fileInfo, array('filename', 'key', 'size'))) {
throw $this->createServiceException('参数缺失,添加用户文件失败!');
}
$uploadFile = array();
$uploadFile['targetId'] = $targetId;
$uploadFile['targetType'] = $targetType;
$uploadFile['hashId'] = $fileInfo['key'];
$uploadFile['filename'] = $fileInfo['filename'];
$uploadFile['ext'] = pathinfo($uploadFile['filename'], PATHINFO_EXTENSION);
$uploadFile['size'] = (int) $fileInfo['size'];
$uploadFile['etag'] = empty($fileInfo['etag']) ? '' : $fileInfo['etag'];
$uploadFile['length'] = empty($fileInfo['length']) ? 0 : intval($fileInfo['length']);
$uploadFile['metas'] = $this->encodeMetas(empty($fileInfo['metas']) ? array() : $fileInfo['metas']);
$uploadFile['metas2'] = $this->encodeMetas(empty($fileInfo['metas2']) ? array() : $fileInfo['metas2']);
if (empty($fileInfo['convertHash'])) {
$uploadFile['convertHash'] = "ch-{$uploadFile['hashId']}";
$uploadFile['convertStatus'] = 'none';
$uploadFile['convertParams'] = '';
} else {
$uploadFile['convertHash'] = "{$fileInfo['convertHash']}";
$uploadFile['convertStatus'] = 'waiting';
$uploadFile['convertParams'] = $fileInfo['convertParams'];
}
$uploadFile['type'] = FileToolkit::getFileTypeByMimeType($fileInfo['mimeType']);
$uploadFile['canDownload'] = empty($uploadFile['canDownload']) ? 0 : 1;
$uploadFile['storage'] = 'cloud';
$uploadFile['createdUserId'] = $this->getCurrentUser()->id;
$uploadFile['updatedUserId'] = $uploadFile['createdUserId'];
$uploadFile['updatedTime'] = $uploadFile['createdTime'] = time();
return $uploadFile;
}
作者:ZHONG-GU
项目:EduSoh
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));
}
作者:ccq1
项目:EduSoh
/**
* 获取一个分类下的课程成员列表
*
* 可传入的参数:
* 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;
}
作者:liugang1989071
项目:www.zesow.co
public function createOrder($info)
{
$connection = ServiceKernel::instance()->getConnection();
try {
$connection->beginTransaction();
$user = $this->getCurrentUser();
if (!$user->isLogin()) {
throw $this->createServiceException('用户未登录,不能创建订单');
}
if (!ArrayToolkit::requireds($info, array('targetId', 'payment'))) {
throw $this->createServiceException('订单数据缺失,创建课程订单失败。');
}
// 获得锁
$user = $this->getUserService()->getUser($user['id'], true);
if ($this->getClassroomService()->isClassroomStudent($info['targetId'], $user['id'])) {
throw $this->createServiceException('已经是班级学员,创建订单失败。');
}
$classroom = $this->getClassroomService()->getClassroom($info['targetId']);
if (empty($classroom)) {
throw $this->createServiceException('班级不存在,创建课程订单失败。');
}
if ($classroom['private'] == 1) {
throw $this->createServiceException('该班级是封闭班级,学员不能自行加入!');
}
$order = array();
$order['userId'] = $user['id'];
$order['title'] = "购买班级《{$classroom['title']}》";
$order['targetType'] = 'classroom';
$order['targetId'] = $classroom['id'];
$order['payment'] = $info['payment'];
$order['amount'] = empty($info['amount']) ? 0 : $info['amount'];
$order['priceType'] = $info['priceType'];
$order['totalPrice'] = $info["totalPrice"];
$order['coinRate'] = $info['coinRate'];
$order['coinAmount'] = $info['coinAmount'];
$order['snPrefix'] = 'CR';
if (!empty($info['note'])) {
$order['data'] = array('note' => $info['note']);
}
if (!empty($info['coupon'])) {
$order['coupon'] = $info['coupon'];
$order['couponDiscount'] = $info['couponDiscount'];
}
$order = $this->getOrderService()->createOrder($order);
if (empty($order)) {
throw $this->createServiceException('创建订单失败!');
}
// 免费班级,就直接将订单置为已购买
if (intval($order['amount'] * 100) == 0 && intval($order['coinAmount'] * 100) == 0 && empty($order['coupon'])) {
list($success, $order) = $this->getOrderService()->payOrder(array('sn' => $order['sn'], 'status' => 'success', 'amount' => $order['amount'], 'paidTime' => time()));
$info = array('orderId' => $order['id'], 'remark' => empty($order['data']['note']) ? '' : $order['data']['note']);
$this->getClassroomService()->becomeStudent($order['targetId'], $order['userId'], $info);
}
$connection->commit();
return $order;
} catch (\Exception $e) {
$connection->rollBack();
throw $e;
}
}
作者:liugang1989071
项目:www.zesow.co
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));
}
作者:liugang1989071
项目:www.zesow.co
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));
}
作者:Loyalsoldie
项目:8000wei-v
/**
* 获取最热话题
*
* 可传入的参数:
*
* 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;
}
作者:lattice
项目:EduSoho_jb5
public function becomeStudentAndCreateOrder($userId, $courseId, $data)
{
if (!ArrayToolkit::requireds($data, array("price", "remark"))) {
throw $this->createServiceException("参数不对!");
}
$user = $this->getUserService()->getUser($userId);
if (empty($user)) {
throw $this->createNotFoundException("用户{$user['nickname']}不存在");
}
$course = $this->getCourseService()->getCourse($courseId);
if (empty($course)) {
throw $this->createNotFoundException("课程{$course['title']}不存在");
}
if ($this->getCourseService()->isCourseStudent($course['id'], $user['id'])) {
throw $this->createNotFoundException("用户已经是学员,不能添加!");
}
$orderTitle = "购买课程《{$course['title']}》";
if (isset($data["isAdminAdded"]) && $data["isAdminAdded"] == 1) {
$orderTitle = $orderTitle . "(管理员添加)";
}
$order = $this->getOrderService()->createOrder(array('userId' => $user['id'], 'title' => $orderTitle, 'targetType' => 'course', 'targetId' => $course['id'], 'amount' => $data['price'], 'totalPrice' => $data['price'], 'payment' => 'none', 'snPrefix' => 'C'));
$this->getOrderService()->payOrder(array('sn' => $order['sn'], 'status' => 'success', 'amount' => $order['amount'], 'paidTime' => time()));
$info = array('orderId' => $order['id'], 'note' => $data['remark']);
$this->getCourseService()->becomeStudent($order['targetId'], $order['userId'], $info);
$member = $this->getCourseService()->getCourseMember($course['id'], $user['id']);
if (isset($data["isAdminAdded"]) && $data["isAdminAdded"] == 1) {
$this->getNotificationService()->notify($member['userId'], 'student-create', array('courseId' => $course['id'], 'courseTitle' => $course['title']));
}
$this->getLogService()->info('course', 'add_student', "课程《{$course['title']}》(#{$course['id']}),添加学员{$user['nickname']}(#{$user['id']}),备注:{$data['remark']}");
return array($course, $member, $order);
}
作者:robert-li-201
项目:EduSoh
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'])));
}
作者:ccq1
项目:EduSoh
/**
* 获取最新资讯列表
*
* 可传入的参数:
* 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;
}
作者:stylin
项目:LeesPhar
public function uploadMaterial($material)
{
if (!ArrayToolkit::requireds($material, array('courseId', 'fileId'))) {
throw $this->createServiceException('参数缺失,上传失败!');
}
$course = $this->getCourseService()->getCourse($material['courseId']);
if (empty($course)) {
throw $this->createServiceException('课程不存在,上传资料失败!');
}
$fields = array('courseId' => $material['courseId'], 'lessonId' => empty($material['lessonId']) ? 0 : $material['lessonId'], 'description' => empty($material['description']) ? '' : $material['description'], 'userId' => $this->getCurrentUser()->id, 'createdTime' => time());
if (empty($material['fileId'])) {
if (empty($material['link'])) {
throw $this->createServiceException('资料链接地址不能为空,添加资料失败!');
}
$fields['fileId'] = 0;
$fields['link'] = $material['link'];
$fields['title'] = empty($material['description']) ? $material['link'] : $material['description'];
} else {
$fields['fileId'] = (int) $material['fileId'];
$file = $this->getUploadFileService()->getFile($material['fileId']);
if (empty($file)) {
throw $this->createServiceException('文件不存在,上传资料失败!');
}
$fields['link'] = '';
$fields['title'] = $file['filename'];
$fields['fileSize'] = $file['size'];
}
$material = $this->getMaterialDao()->addMaterial($fields);
$this->getCourseService()->increaseLessonMaterialCount($fields['lessonId']);
return $material;
}
作者:stylin
项目:LeesPhar
/**
*类似这样的,提交数据保存到数据的流程是:
*
* 1. 检查参数是否正确,不正确就抛出异常
* 2. 过滤数据
* 3. 插入到数据库
* 4. 更新其他相关的缓存字段
*/
public function saveNote(array $note)
{
if (!ArrayToolkit::requireds($note, array('lessonId', 'courseId', 'content'))) {
throw $this->createServiceException('缺少必要的字段,保存笔记失败');
}
list($course, $member) = $this->getCourseService()->tryTakeCourse($note['courseId']);
$user = $this->getCurrentUser();
if (!$this->getCourseService()->getCourseLesson($note['courseId'], $note['lessonId'])) {
throw $this->createServiceException('课时不存在,保存笔记失败');
}
$note = ArrayToolkit::filter($note, array('courseId' => 0, 'lessonId' => 0, 'content' => ''));
$note['content'] = $this->purifyHtml($note['content']) ?: '';
$note['length'] = $this->calculateContnentLength($note['content']);
$existNote = $this->getUserLessonNote($user['id'], $note['lessonId']);
if (!$existNote) {
$note['userId'] = $user['id'];
$note['createdTime'] = time();
$note = $this->getNoteDao()->addNote($note);
} else {
$note['updatedTime'] = time();
$note = $this->getNoteDao()->updateNote($existNote['id'], $note);
}
$this->getCourseService()->setMemberNoteNumber($note['courseId'], $note['userId'], $this->getNoteDao()->getNoteCountByUserIdAndCourseId($note['userId'], $note['courseId']));
return $note;
}
作者:piaolankek
项目:EduSoh
public function modifyUserInfoAction(Request $request)
{
$formData = $request->request->all();
$user = $this->getCurrentUser();
if (empty($user)) {
return $this->createMessageResponse('error', '用户未登录,不能购买。');
}
$course = $this->getCourseService()->getCourse($formData['targetId']);
if (empty($course)) {
return $this->createMessageResponse('error', '课程不存在,不能购买。');
}
$userInfo = ArrayToolkit::parts($formData, array('truename', 'mobile', 'qq', 'company', 'weixin', 'weibo', 'idcard', 'gender', 'job', 'intField1', 'intField2', 'intField3', 'intField4', 'intField5', 'floatField1', 'floatField2', 'floatField3', 'floatField4', 'floatField5', 'dateField1', 'dateField2', 'dateField3', 'dateField4', 'dateField5', 'varcharField1', 'varcharField2', 'varcharField3', 'varcharField4', 'varcharField5', 'varcharField10', 'varcharField6', 'varcharField7', 'varcharField8', 'varcharField9', 'textField1', 'textField2', 'textField3', 'textField4', 'textField5', 'textField6', 'textField7', 'textField8', 'textField9', 'textField10'));
$userInfo = $this->getUserService()->updateUserProfile($user['id'], $userInfo);
$coinSetting = $this->setting("coin");
if (isset($coinSetting["coin_enabled"]) && $coinSetting["coin_enabled"] == 1 && isset($coinSetting["price_type"]) && $coinSetting["price_type"] == "Coin" && $course['coinPrice'] == 0 || $course['price'] == 0) {
$formData['amount'] = 0;
$formData['totalPrice'] = 0;
$formData['priceType'] = empty($coinSetting["priceType"]) ? 'RMB' : $coinSetting["priceType"];
$formData['coinRate'] = empty($coinSetting["coinRate"]) ? 1 : $coinSetting["coinRate"];
$formData['coinAmount'] = 0;
$order = $this->getCourseOrderService()->createOrder($formData);
if ($order['status'] == 'paid') {
return $this->redirect($this->generateUrl('course_show', array('id' => $order['targetId'])));
}
}
return $this->redirect($this->generateUrl('order_show', array('targetId' => $formData['targetId'], 'targetType' => 'course')));
}
作者:ccq1
项目:EduSoh
public function updateSeqsAction(Request $request)
{
$data = $request->request->get('data');
$ids = ArrayToolkit::column($data, 'id');
$this->getNavigationService()->updateNavigationsSequenceByIds($ids);
return $this->createJsonResponse(true);
}
作者:ccq1
项目:EduSoh
/**
* 获取所有用户的最新动态
*
* 可传入的参数:
* 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;
}
作者:jonesgithu
项目:EduSoh
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));
}
作者:robert-li-201
项目:EduSoh
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));
}
作者:ccq1
项目:EduSoh
/**
* 获取加精的课程话题列表
*
* 可传入的参数:
* 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;
}
作者:stylin
项目:LeesPhar
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));
}
作者:stylin
项目:LeesPhar
public function createMoneyCard(array $moneyCardData)
{
$batch = ArrayToolkit::parts($moneyCardData, array('money', 'cardPrefix', 'cardLength', 'number', 'note', 'deadline'));
$batch['money'] = (int) $batch['money'];
$batch['cardLength'] = (int) $batch['cardLength'];
$batch['number'] = (int) $batch['number'];
if ($batch['money'] <= 0) {
throw $this->createServiceException('ERROR! Money Value Less Than Zero!');
}
if ($batch['cardLength'] <= 0) {
throw $this->createServiceException('ERROR! CardLength Less Than Zero!');
}
if ($batch['number'] <= 0) {
throw $this->createServiceException('ERROR! Card Number Less Than Zero!');
}
$batch['rechargedNumber'] = 0;
$batch['userId'] = $this->getCurrentUser()->id;
$batch['createdTime'] = time();
$moneyCardIds = $this->makeRands($batch['cardLength'], $batch['number'], $batch['cardPrefix'], $moneyCardData['passwordLength']);
if (!$this->getMoneyCardDao()->isCardIdAvaliable($moneyCardIds)) {
throw $this->createServiceException('卡号有重复,生成失败,请重新生成!');
}
$batch = $this->getMoneyCardBatchDao()->addBatch($batch);
$moneyCards = array();
foreach ($moneyCardIds as $cardid => $cardPassword) {
$moneyCards[] = array('cardId' => $cardid, 'password' => $cardPassword, 'deadline' => $moneyCardData['deadline'], 'cardStatus' => 'normal', 'batchId' => $batch['id']);
}
$this->getMoneyCardDao()->addMoneyCard($moneyCards);
$this->getLogService()->info('money_card_batch', 'create', "创建新批次充值卡,卡号前缀为({$batch['cardPrefix']}),批次为({$batch['id']})");
return $batch;
}