本文整理汇总了PHP中Topxia\Common\ArrayToolkit类的典型用法代码示例。如果您正苦于以下问题:PHP ArrayToolkit类的具体用法?PHP ArrayToolkit怎么用?PHP ArrayToolkit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayToolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFile
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;
}
示例2: listAction
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));
}
示例3: getData
/**
* 获取一个分类下的课程成员列表
*
* 可传入的参数:
* 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;
}
示例4: createOrder
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;
}
}
示例5: showAction
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));
}
示例6: exploreAction
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));
}
示例7: getData
/**
* 获取最热话题
*
* 可传入的参数:
*
* 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;
}
示例8: becomeStudentAndCreateOrder
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);
}
示例9: listAction
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'])));
}
示例10: getData
/**
* 获取最新资讯列表
*
* 可传入的参数:
* 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;
}
示例11: uploadMaterial
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;
}
示例12: saveNote
/**
*类似这样的,提交数据保存到数据的流程是:
*
* 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;
}
示例13: modifyUserInfoAction
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')));
}
示例14: updateSeqsAction
public function updateSeqsAction(Request $request)
{
$data = $request->request->get('data');
$ids = ArrayToolkit::column($data, 'id');
$this->getNavigationService()->updateNavigationsSequenceByIds($ids);
return $this->createJsonResponse(true);
}
示例15: getData
/**
* 获取所有用户的最新动态
*
* 可传入的参数:
* 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;
}