当前位置: 首页>>代码示例>>PHP>>正文


PHP EfrontLesson::addUsers方法代码示例

本文整理汇总了PHP中EfrontLesson::addUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontLesson::addUsers方法的具体用法?PHP EfrontLesson::addUsers怎么用?PHP EfrontLesson::addUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EfrontLesson的用法示例。


在下文中一共展示了EfrontLesson::addUsers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addLessons

 /**
  * Assign lessons to user.
  *
  * This function can be used to assign a lesson to the current user. If $userTypes
  * is specified, then the user is assigned to the lesson using the specified type.
  * By default, the user basic type is used.
  * <br/>Example:
  * <code>
  * $user = EfrontUserFactory :: factory('jdoe');
  * $user -> addLessons(23);						 //Add a signle lesson with id 23
  * $user -> addLessons(23, 'professor');			//Add a signle lesson with id 23 and set the user type to 'professor'
  * $user -> addLessons(array(23,24,25));			//Add multiple lessons using an array
  * $user -> addLessons(array(23,24,25), array('professor', 'student', 'professor'));			//Add multiple lessons using an array for lesson ids and another for corresponding user types
  * </code>
  *
  * @param mixed $lessonIds Either a single lesson id, or an array if ids
  * @param mixed $userTypes The corresponding user types for the specified lessons
  * @param boolean $activate Lessons will be set as active or not
  * @return mixed The array of lesson ids or false if the lesson already exists.
  * @since 3.5.0
  * @access public
  */
 public function addLessons($lessonIds, $userTypes, $activate = 1)
 {
     if (sizeof($this->lessons) == 0) {
         $this->getLessons();
     }
     if (!is_array($lessonIds)) {
         $lessonIds = array($lessonIds);
     }
     if (!is_array($userTypes)) {
         $userTypes = array($userTypes);
     }
     if (sizeof($userTypes) < sizeof($lessonIds)) {
         $userTypes = array_pad($userTypes, sizeof($lessonIds), $userTypes[0]);
     }
     if (sizeof($lessonIds) > 0) {
         $lessons = eF_getTableData("lessons", "*", "id in (" . implode(",", $lessonIds) . ")");
         foreach ($lessons as $key => $lesson) {
             $lesson = new EfrontLesson($lesson);
             $lesson->addUsers($this->user['login'], $userTypes[$key], $activate);
         }
         $this->lessons = false;
         //Reset lessons information
     }
     return $this->getLessons();
 }
开发者ID:kaseya-university,项目名称:efront,代码行数:47,代码来源:user.class-backup.php

示例2: addCourseUsersToLesson

 /**
  * Add this course's users to the specified lesson
  *
  * @param EfrontLesson $lesson The lesson to add users to
  * @since 3.6.1
  * @access private
  */
 private function addCourseUsersToLesson($lesson, $usersToAdd = false, $confirmed = true)
 {
     if (!$usersToAdd) {
         $usersToAdd = $this->getUsers();
     }
     $users = $roles = array();
     foreach ($usersToAdd as $login => $user) {
         if ($user['user_type'] != 'administrator') {
             $users[] = $login;
             $roles[] = $user['role'];
         }
     }
     $lesson->addUsers($users, $roles, $confirmed);
 }
开发者ID:kaseya-university,项目名称:efront,代码行数:21,代码来源:course.class.php

示例3: foreach

                                                                 						}
                                                                 					}
                                                                 				}
                                                                 			}          			
                                                     */
                                                     if ($currentGroup->group['user_types_ID'] == '0') {
                                                         foreach ($groupUsers as $user) {
                                                             $user = EfrontUserFactory::factory($user);
                                                             $user->user['user_types_ID'] ? $userType[] = $user->user['user_types_ID'] : ($userType[] = $user->user['user_type']);
                                                         }
                                                     } else {
                                                         $userType = $currentGroup->group['user_types_ID'];
                                                     }
                                                     foreach ($lessonIds as $id) {
                                                         $lesson = new EfrontLesson($id);
                                                         $lesson->addUsers($groupUsers, $userType, true, true);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         exit;
     }
 } catch (Exception $e) {
开发者ID:jiangjunt,项目名称:efront_open_source,代码行数:31,代码来源:groups.php

示例4: importData

 protected function importData($line, $type, $data)
 {
     //pr($line);exit;
     try {
         switch ($type) {
             case "users":
                 $newUser = EfrontUser::createUser($data);
                 $this->log["success"][] = _LINE . " {$line}: " . _IMPORTEDUSER . " " . $newUser->login;
                 break;
             case "users_to_courses":
                 //Check if a user exists and whether it has the same case
                 $userFound = false;
                 if (!in_array($data['users_login'], $this->allUserLogins)) {
                     //For case-insensitive matches
                     foreach ($this->allUserLogins as $login) {
                         if (mb_strtolower($data['users_login']) == mb_strtolower($login)) {
                             $data['users_login'] = $login;
                             $userFound = true;
                         }
                     }
                 } else {
                     $userFound = true;
                 }
                 if ($userFound) {
                     $courses_name = trim($data['course_name']);
                     $courses_ID = $this->getCourseByName($courses_name);
                     unset($data['course_name']);
                     if ($courses_ID) {
                         foreach ($courses_ID as $course_ID) {
                             $data['courses_ID'] = $course_ID;
                             $course = new EfrontCourse($course_ID);
                             if (is_null($this->course_users[$course_ID])) {
                                 $result = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID={$course_ID} AND archive=0");
                                 $this->course_users[$course_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
                             }
                             if (isset($this->course_users[$course_ID][$data['users_login']])) {
                                 throw new Exception("User is already assigned to the course", self::USER_TO_COURSE_EXISTS);
                             }
                             //$course -> addUsers($data['users_login'], (isset($data['user_type']) && $data['user_type']?$data['user_type']:"student"));
                             $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
                             $where = "users_login = '" . $data['users_login'] . "' AND courses_ID = " . $data['courses_ID'];
                             $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0);
                             EfrontCourse::persistCourseUsers($data, $where, $data['courses_ID'], $data['users_login']);
                             if ($data['active']) {
                                 $course->confirm($data['users_login']);
                             } else {
                                 $course->unconfirm($data['users_login']);
                             }
                             $this->course_users[$course_ID][$data['users_login']] = $data['users_login'];
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login'];
                         }
                     } else {
                         if ($courses_name != "") {
                             $course = EfrontCourse::createCourse(array("name" => $courses_name));
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSE . " " . $courses_name;
                             $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
                             $courses_ID = $course->course['id'];
                             $this->courseNamesToIds[$courses_name] = array($courses_ID);
                             $where = "users_login = '" . $data['users_login'] . "' AND courses_ID = " . $courses_ID;
                             EfrontCourse::persistCourseUsers($data, $where, $courses_ID, $data['users_login']);
                             if ($data['active']) {
                                 $course->confirm($data['users_login']);
                             } else {
                                 $course->unconfirm($data['users_login']);
                             }
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login'];
                         } else {
                             $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDCOURSE . " " . $courses_name;
                         }
                     }
                 } else {
                     $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login'];
                 }
                 break;
             case "users_to_lessons":
                 //Check if a user exists and whether it has the same case
                 $userFound = false;
                 if (!in_array($data['users_login'], $this->allUserLogins)) {
                     //For case-insensitive matches
                     foreach ($this->allUserLogins as $login) {
                         if (mb_strtolower($data['users_login']) == mb_strtolower($login)) {
                             $data['users_login'] = $login;
                             $userFound = true;
                         }
                     }
                 } else {
                     $userFound = true;
                 }
                 if ($userFound) {
                     $lessons_name = trim($data['lesson_name']);
                     $lessons_ID = $this->getLessonByName($lessons_name);
                     unset($data['lesson_name']);
                     if ($lessons_ID) {
                         foreach ($lessons_ID as $lesson_ID) {
                             $data['lessons_ID'] = $lesson_ID;
                             $lesson = new EfrontLesson($lesson_ID);
                             if (is_null($this->lesson_users[$lesson_ID])) {
                                 $result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0");
                                 $this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
                             }
//.........这里部分代码省略.........
开发者ID:bqq1986,项目名称:efront,代码行数:101,代码来源:import_export.class.php

示例5: EfrontLesson

     echo "</xml>";
     exit;
 }
 try {
     $lesson = new EfrontLesson($_GET['lesson']);
     $user = EfrontUserFactory::factory($_GET['login']);
     $_GET['type'] != "professor" && $_GET['type'] != 'student' ? $_GET['type'] = 'student' : null;
     if ($lesson->isStudentInLesson($_GET['login']) === true && $_GET['type'] == 'student' || $lesson->isProfessorInLesson($_GET['login']) === true && $_GET['type'] == 'professor') {
         echo "<xml>";
         echo "<status>error</status>";
         echo "<message>Assignment already exists</message>";
         echo "</xml>";
         exit;
     }
     if (isset($_GET['type'])) {
         $lesson->addUsers($_GET['login'], $_GET['type']);
     } else {
         $lesson->addUsers($_GET['login']);
     }
     echo "<xml>";
     echo "<status>ok</status>";
     echo "</xml>";
 } catch (Exception $e) {
     if ($e->getCode() == EfrontUserException::USER_NOT_EXISTS) {
         echo "<xml>";
         echo "<status>error</status>";
         echo "<message>User does not exist</message>";
         echo "</xml>";
         exit;
     } elseif ($e->getCode() == EfrontCourseException::MAX_USERS_LIMIT) {
         echo "<xml>";
开发者ID:jiangjunt,项目名称:efront_open_source,代码行数:31,代码来源:api2.php


注:本文中的EfrontLesson::addUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。