當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EfrontUser::isProfessorRole方法代碼示例

本文整理匯總了PHP中EfrontUser::isProfessorRole方法的典型用法代碼示例。如果您正苦於以下問題:PHP EfrontUser::isProfessorRole方法的具體用法?PHP EfrontUser::isProfessorRole怎麽用?PHP EfrontUser::isProfessorRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在EfrontUser的用法示例。


在下文中一共展示了EfrontUser::isProfessorRole方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addUsers

 /**
  * Add users to course
  *
  * This function is used to register one or more users to the current course. A single login
  * or an array of logins may be specified
  * <br/>Example:
  * <code>
  * $course -> addUsers('joe', 'professor');         //Add the user with login 'joe' as a professor to this course
  * $users = array('joe', 'mary', 'mike');
  * $types = array('student', 'student', 'professor');
  * $course -> addUsers($users, $types);             //Add the users in the array $users with roles $types
  * </code>
  *
  * @param mixed $login The user login name
  * @param mixed $role The user role for this course, defaults to 'student'
  * @param boolean $confirmed If false, then the registration is set to 'pending' mode and the administration must confirm it
  * @since 3.5.0
  * @access public
  * @todo deprecated
  */
 public function addUsers($users, $userRoles = 'student', $confirmed = true)
 {
     if ($this->course['supervisor_LOGIN']) {
         $confirmed = false;
     }
     $roles = EfrontUser::getRoles();
     $users = EfrontUser::verifyUsersList($users);
     $userRoles = EfrontUser::verifyRolesList($userRoles, sizeof($users));
     foreach ($userRoles as $key => $value) {
         if (!EfrontUser::isStudentRole($value) && !EfrontUser::isProfessorRole($value)) {
             unset($userRoles[$key]);
             unset($users[$key]);
         }
     }
     if (empty($users)) {
         return false;
     }
     //For a single user, don't retrieve the full list of course users; that can be indefinitely big
     if (sizeof($users) == 1) {
         $result = eF_getTableData("users_to_courses uc, users u", "uc.users_LOGIN, uc.archive, uc.user_type, uc.to_timestamp, u.archive as user_archive, uc.completed", "u.login = '{$users[0]}' and u.login=uc.users_LOGIN and uc.courses_ID=" . $this->course['id']);
     } else {
         $result = eF_getTableData("users_to_courses uc, users u", "uc.users_LOGIN, uc.archive, uc.user_type, uc.to_timestamp, u.archive as user_archive, uc.completed", "u.login=uc.users_LOGIN and uc.courses_ID=" . $this->course['id']);
     }
     $courseUsers = array();
     $courseRoles = $this->getPossibleCourseRoles();
     $courseStudents = 0;
     foreach ($result as $value) {
         $courseUsers[$value['users_LOGIN']] = $value;
         if (!$value['user_archive'] && !$value['archive'] && EfrontUser::isStudentRole($value['user_type'])) {
             $courseStudents++;
         }
     }
     /*This query returns an array like:
     +------------+------------+-------------+-----------+----------------+---------+
     | courses_ID | lessons_ID | users_login | user_type | from_timestamp | archive |
     +------------+------------+-------------+-----------+----------------+---------+
     |          1 |          3 | professor   | professor |     1233140503 |       0 |
     |          1 |          3 | elpapath    | professor |     1233140503 |       0 |
     |          1 |         19 | periklis3   | student   |     1280488977 |       0 |
     |          1 |         20 | NULL        | NULL      |           NULL |    NULL |
     +------------+------------+-------------+-----------+----------------+---------+
     		So that it contains all the course's lessons and NULL for any lesson that does not have a user assigned
     		*/
     $result = eF_getTableData("lessons_to_courses lc left outer join users_to_lessons ul on lc.lessons_ID=ul.lessons_ID", "lc.lessons_ID, ul.users_LOGIN, ul.user_type, ul.from_timestamp, ul.archive, ul.to_timestamp, ul.completed", "courses_ID = " . $this->course['id']);
     $courseLessonsToUsers = array();
     foreach ($result as $value) {
         if (!is_null($value['users_LOGIN'])) {
             $courseLessonsToUsers[$value['lessons_ID']][$value['users_LOGIN']] = $value;
         } else {
             $courseLessonsToUsers[$value['lessons_ID']] = array();
         }
     }
     $courseLessons = array_unique(array_keys($courseLessonsToUsers));
     $result = eF_getTableData("projects", "id, lessons_ID", "auto_assign=1 and deadline >= " . time() . " and lessons_ID in (select lessons_ID from lessons_to_courses where courses_ID=" . $this->course['id'] . ")");
     $newProjectAssignments = $courseLessonsAutoAssignProjects = $assignedProjectsToUsers = array();
     foreach ($result as $value) {
         $courseLessonsAutoAssignProjects[$value['lessons_ID']][] = $value['id'];
     }
     $result = eF_getTableData("users_to_projects up, projects p", "up.users_LOGIN, up.projects_ID", "up.projects_ID=p.id and p.auto_assign=1 and p.deadline >= " . time() . " and p.lessons_ID in (select lessons_ID from lessons_to_courses where courses_ID=" . $this->course['id'] . ")");
     foreach ($result as $value) {
         $assignedProjectsToUsers[$value['users_LOGIN']][$value['projects_ID']] = $value['projects_ID'];
     }
     $newUsers = array();
     $existingUsers = array();
     foreach ($users as $key => $user) {
         $roleInCourse = $userRoles[$key];
         $roles[$roleInCourse] == 'student' ? $isStudentRoleInCourse = true : ($isStudentRoleInCourse = false);
         if ($this->course['max_users'] && $isStudentRoleInCourse && $this->course['max_users'] <= $courseStudents++) {
             throw new EfrontCourseException(str_replace(array("%x", "%y", "%z"), array($this->course['name'], $this->course['max_users'], $GLOBALS['configuration']['system_email']), _MAXSEATSDEPLEATED), EfrontCourseException::MAX_USERS_LIMIT);
         }
         if (!isset($courseUsers[$user])) {
             $newUsers[] = array('users_LOGIN' => $user, 'courses_ID' => $this->course['id'], 'active' => 1, 'archive' => 0, 'from_timestamp' => $confirmed ? time() : 0, 'user_type' => $roleInCourse, 'completed' => 0, 'score' => 0, 'issued_certificate' => '', 'comments' => '', 'to_timestamp' => 0);
         } elseif ($roleInCourse != $courseUsers[$user]['user_type'] || $courseUsers[$user]['archive']) {
             //update from_timestamp value when user reassigned to a course (only if it is not completed)
             if ($courseUsers[$user]['completed']) {
                 $fields = array('archive' => 0, 'user_type' => $roleInCourse);
             } else {
                 $fields = array('archive' => 0, 'user_type' => $roleInCourse, 'from_timestamp' => time());
             }
             //!$courseUsers[$user]['archive'] OR $fields['to_timestamp'] = 0;
//.........這裏部分代碼省略.........
開發者ID:kaseya-university,項目名稱:efront,代碼行數:101,代碼來源:course.class.php


注:本文中的EfrontUser::isProfessorRole方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。