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


PHP api_drh_can_access_all_session_content函数代码示例

本文整理汇总了PHP中api_drh_can_access_all_session_content函数的典型用法代码示例。如果您正苦于以下问题:PHP api_drh_can_access_all_session_content函数的具体用法?PHP api_drh_can_access_all_session_content怎么用?PHP api_drh_can_access_all_session_content使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getStats

 /**
  * @param int $userId
  *
  * @return array
  */
 public static function getStats($userId)
 {
     if (api_is_drh() && api_drh_can_access_all_session_content()) {
         $studentList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, false, null, null, null, null, null, null, null, array(), array(), STUDENT);
         $students = array();
         foreach ($studentList as $studentData) {
             $students[] = $studentData['user_id'];
         }
         $teacherList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, false, null, null, null, null, null, null, null, array(), array(), COURSEMANAGER);
         $teachers = array();
         foreach ($teacherList as $teacherData) {
             $teachers[] = $teacherData['user_id'];
         }
         $humanResources = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, false, null, null, null, null, null, null, null, array(), array(), DRH);
         $humanResourcesList = array();
         foreach ($humanResources as $item) {
             $humanResourcesList[] = $item['user_id'];
         }
         $platformCourses = SessionManager::getAllCoursesFollowedByUser($userId, null, null, null, null, null);
         //$platformCourses = SessionManager::getAllCoursesFromAllSessionFromDrh($userId);
         $courses = array();
         foreach ($platformCourses as $course) {
             $courses[$course['code']] = $course['code'];
         }
         $sessions = SessionManager::get_sessions_followed_by_drh($userId);
     } else {
         $studentList = UserManager::getUsersFollowedByUser($userId, STUDENT, false, false, false, null, null, null, null, null, null, COURSEMANAGER);
         $students = array();
         foreach ($studentList as $studentData) {
             $students[] = $studentData['user_id'];
         }
         $teacherList = UserManager::getUsersFollowedByUser($userId, COURSEMANAGER, false, false, false, null, null, null, null, null, null, COURSEMANAGER);
         $teachers = array();
         foreach ($teacherList as $teacherData) {
             $teachers[] = $teacherData['user_id'];
         }
         $humanResources = UserManager::getUsersFollowedByUser($userId, DRH, false, false, false, null, null, null, null, null, null, COURSEMANAGER);
         $humanResourcesList = array();
         foreach ($humanResources as $item) {
             $humanResourcesList[] = $item['user_id'];
         }
         $platformCourses = CourseManager::getCoursesFollowedByUser($userId, COURSEMANAGER);
         foreach ($platformCourses as $course) {
             $courses[$course['code']] = $course['code'];
         }
         $sessions = SessionManager::getSessionsFollowedByUser($userId, COURSEMANAGER);
     }
     return array('drh' => $humanResourcesList, 'teachers' => $teachers, 'students' => $students, 'courses' => $courses, 'sessions' => $sessions);
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:54,代码来源:tracking.lib.php

示例2: api_is_platform_admin

    api_is_platform_admin() ||
    api_is_allowed_to_create_course() ||
    api_is_session_admin() ||
    api_is_drh() ||
    api_is_course_tutor() ||
    api_is_course_admin();

if (!$is_allowedToTrack) {
    api_not_allowed(true);
    exit;
}

// If the user is a HR director (drh)
if (api_is_drh()) {
    // Blocking course for drh
    if (api_drh_can_access_all_session_content()) {
        // If the drh has been configured to be allowed to see all session content, give him access to the session courses
        $coursesFromSession = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null);
        if (!empty($coursesFromSession)) {
            $coursesFromSession = array_keys($coursesFromSession);
        }

        $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
        if (!empty($coursesFollowedList)) {
            $coursesFollowedList = array_keys($coursesFollowedList);
        }
        if (!in_array($courseCode, $coursesFollowedList)) {
            if (!in_array($courseCode, $coursesFromSession)) {
                api_not_allowed();
            }
        }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:courseLog.php

示例3: get_users

function get_users($from, $limit, $column, $direction)
{
    $active = isset($_GET['active']) ? $_GET['active'] : 1;
    $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
    $sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
    $lastConnectionDate = null;
    if (!empty($sleepingDays)) {
        $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays . ' days ago'));
    }
    $is_western_name_order = api_is_western_name_order();
    $coach_id = api_get_user_id();
    $drhLoaded = false;
    if (api_is_drh()) {
        $column = 'u.user_id';
        if (api_drh_can_access_all_session_content()) {
            $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, $from, $limit, $column, $direction, $keyword, $active, $lastConnectionDate, null, null, api_is_student_boss() ? null : STUDENT);
            $drhLoaded = true;
        }
    }
    if ($drhLoaded == false) {
        $students = UserManager::getUsersFollowedByUser(api_get_user_id(), api_is_student_boss() ? null : STUDENT, false, false, false, $from, $limit, $column, $direction, $active, $lastConnectionDate, api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER, $keyword);
    }
    $all_datas = array();
    foreach ($students as $student_data) {
        $student_id = $student_data['user_id'];
        if (isset($_GET['id_session'])) {
            $courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']);
        }
        $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0;
        $nb_courses_student = 0;
        if (!empty($courses)) {
            foreach ($courses as $course_code) {
                $courseInfo = api_get_course_info($course_code);
                $courseId = $courseInfo['real_id'];
                if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
                    $avg_time_spent += Tracking::get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
                    $my_average = Tracking::get_avg_student_score($student_id, $course_code);
                    if (is_numeric($my_average)) {
                        $avg_student_score += $my_average;
                    }
                    $avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
                    $total_assignments += Tracking::count_student_assignments($student_id, $course_code);
                    $total_messages += Tracking::count_student_messages($student_id, $course_code);
                    $nb_courses_student++;
                }
            }
        }
        if ($nb_courses_student > 0) {
            $avg_time_spent = $avg_time_spent / $nb_courses_student;
            $avg_student_score = $avg_student_score / $nb_courses_student;
            $avg_student_progress = $avg_student_progress / $nb_courses_student;
        } else {
            $avg_time_spent = null;
            $avg_student_score = null;
            $avg_student_progress = null;
        }
        $row = array();
        if ($is_western_name_order) {
            $row[] = $student_data['firstname'];
            $row[] = $student_data['lastname'];
        } else {
            $row[] = $student_data['lastname'];
            $row[] = $student_data['firstname'];
        }
        $string_date = Tracking::get_last_connection_date($student_id, true);
        $first_date = Tracking::get_first_connection_date($student_id);
        $row[] = $first_date;
        $row[] = $string_date;
        if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
            $detailsLink = '<a href="myStudents.php?student=' . $student_id . '&id_coach=' . $coach_id . '&id_session=' . $_GET['id_session'] . '">
				          <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        } else {
            $detailsLink = '<a href="myStudents.php?student=' . $student_id . '">
				             <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        }
        $row[] = $detailsLink;
        $all_datas[] = $row;
    }
    return $all_datas;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:80,代码来源:student.php

示例4: getEvents

 /**
  * Get agenda events
  * @param int $start
  * @param int $end
  * @param int $course_id
  * @param int $groupId
  * @param int $user_id
  * @param string $format
  *
  * @return array|string
  */
 public function getEvents($start, $end, $course_id = null, $groupId = null, $user_id = 0, $format = 'json')
 {
     switch ($this->type) {
         case 'admin':
             $this->getPlatformEvents($start, $end);
             break;
         case 'course':
             $session_id = $this->sessionId;
             $courseInfo = api_get_course_info_by_id($course_id);
             // Session coach can see all events inside a session.
             if (api_is_coach()) {
                 // Own course
                 $this->getCourseEvents($start, $end, $courseInfo, $groupId, $session_id, $user_id);
                 // Others
                 $this->getSessionEvents($start, $end, api_get_session_id(), $user_id, $this->eventOtherSessionColor);
             } else {
                 $this->getCourseEvents($start, $end, $courseInfo, $groupId, $session_id, $user_id);
             }
             break;
         case 'personal':
         default:
             $sessionFilterActive = false;
             if (!empty($this->sessionId)) {
                 $sessionFilterActive = true;
             }
             if ($sessionFilterActive == false) {
                 // Getting personal events
                 $this->getPersonalEvents($start, $end);
                 // Getting platform/admin events
                 $this->getPlatformEvents($start, $end);
             }
             // Getting course events
             $my_course_list = array();
             if (!api_is_anonymous()) {
                 $session_list = SessionManager::get_sessions_by_user(api_get_user_id());
                 $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), false);
             }
             if (api_is_drh()) {
                 if (api_drh_can_access_all_session_content()) {
                     $session_list = array();
                     $sessionList = SessionManager::get_sessions_followed_by_drh(api_get_user_id(), null, null, null, true, false);
                     if (!empty($sessionList)) {
                         foreach ($sessionList as $sessionItem) {
                             $sessionId = $sessionItem['id'];
                             $courses = SessionManager::get_course_list_by_session_id($sessionId);
                             $sessionInfo = array('session_id' => $sessionId, 'courses' => $courses);
                             $session_list[] = $sessionInfo;
                         }
                     }
                 }
             }
             if (!empty($session_list)) {
                 foreach ($session_list as $session_item) {
                     if ($sessionFilterActive) {
                         if ($this->sessionId != $session_item['session_id']) {
                             continue;
                         }
                     }
                     $my_courses = $session_item['courses'];
                     $my_session_id = $session_item['session_id'];
                     if (!empty($my_courses)) {
                         foreach ($my_courses as $course_item) {
                             $courseInfo = api_get_course_info_by_id($course_item['real_id']);
                             $this->getCourseEvents($start, $end, $courseInfo, 0, $my_session_id);
                         }
                     }
                     $this->getSessionEvents($start, $end, $my_session_id, $user_id, $this->eventOtherSessionColor);
                 }
             }
             if (!empty($my_course_list) && $sessionFilterActive == false) {
                 foreach ($my_course_list as $courseInfoItem) {
                     $courseInfo = api_get_course_info_by_id($courseInfoItem['real_id']);
                     if (isset($course_id) && !empty($course_id)) {
                         if ($courseInfo['real_id'] == $course_id) {
                             $this->getCourseEvents($start, $end, $courseInfo);
                         }
                     } else {
                         $this->getCourseEvents($start, $end, $courseInfo);
                     }
                 }
             }
             break;
     }
     if (!empty($this->events)) {
         switch ($format) {
             case 'json':
                 return json_encode($this->events);
                 break;
             case 'array':
//.........这里部分代码省略.........
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:agenda.lib.php

示例5: api_can_login_as

/**
 * Checks if user can login as another user
 *
 * @param int $loginAsUserId the user id to log in
 * @param int $userId my user id
 * @return bool
 */
function api_can_login_as($loginAsUserId, $userId = null)
{
    if (empty($userId)) {
        $userId = api_get_user_id();
    }
    if ($loginAsUserId == $userId) {
        return false;
    }
    if (empty($loginAsUserId)) {
        return false;
    }
    if ($loginAsUserId != strval(intval($loginAsUserId))) {
        return false;
    }
    // Check if the user to login is an admin
    if (api_is_platform_admin_by_id($loginAsUserId)) {
        // Only super admins can login to admin accounts
        if (!api_global_admin_can_edit_admin($loginAsUserId)) {
            return false;
        }
    }
    $userInfo = api_get_user_info($userId);
    $isDrh = function () use($loginAsUserId) {
        if (api_is_drh()) {
            if (api_drh_can_access_all_session_content()) {
                $users = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id());
                $userList = array();
                foreach ($users as $user) {
                    $userList[] = $user['user_id'];
                }
                if (in_array($loginAsUserId, $userList)) {
                    return true;
                }
            } else {
                if (api_is_drh() && UserManager::is_user_followed_by_drh($loginAsUserId, api_get_user_id())) {
                    return true;
                }
            }
        }
        return false;
    };
    return api_is_platform_admin() || api_is_session_admin() && $userInfo['status'] == 5 || $isDrh();
}
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:50,代码来源:api.lib.php

示例6: getTeacherTracking

 /**
  * Get teachers followed by a user
  * @param int $userId
  * @param int $active
  * @param string $lastConnectionDate
  * @param bool $getCount
  * @param array $sessionIdList
  * @return array|int
  */
 public static function getTeacherTracking($userId, $active = 1, $lastConnectionDate = null, $getCount = false, $sessionIdList = array())
 {
     $teacherListId = array();
     if (api_is_drh() || api_is_platform_admin()) {
         // Followed teachers by drh
         if (api_drh_can_access_all_session_content()) {
             if (empty($sessionIdList)) {
                 $sessions = SessionManager::get_sessions_followed_by_drh($userId);
                 $sessionIdList = array();
                 foreach ($sessions as $session) {
                     $sessionIdList[] = $session['id'];
                 }
             }
             $sessionIdList = array_map('intval', $sessionIdList);
             $sessionToString = implode("', '", $sessionIdList);
             $course = Database::get_main_table(TABLE_MAIN_COURSE);
             $sessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
             $courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
             // Select the teachers.
             $sql = "SELECT DISTINCT(cu.user_id) FROM {$course} c\n                        INNER JOIN {$sessionCourse} src ON c.id = src.c_id\n                        INNER JOIN {$courseUser} cu ON (cu.c_id = c.id)\n\t\t                WHERE src.session_id IN ('{$sessionToString}') AND cu.status = 1";
             $result = Database::query($sql);
             while ($row = Database::fetch_array($result, 'ASSOC')) {
                 $teacherListId[$row['user_id']] = $row['user_id'];
             }
         } else {
             $teacherResult = UserManager::get_users_followed_by_drh($userId, COURSEMANAGER);
             foreach ($teacherResult as $userInfo) {
                 $teacherListId[] = $userInfo['user_id'];
             }
         }
     }
     if (!empty($teacherListId)) {
         $tableUser = Database::get_main_table(TABLE_MAIN_USER);
         $select = "SELECT DISTINCT u.* ";
         if ($getCount) {
             $select = "SELECT count(DISTINCT(u.user_id)) as count";
         }
         $sql = "{$select} FROM {$tableUser} u";
         if (!empty($lastConnectionDate)) {
             $tableLogin = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
             //$sql .= " INNER JOIN $tableLogin l ON (l.login_user_id = u.user_id) ";
         }
         $active = intval($active);
         $teacherListId = implode("','", $teacherListId);
         $where = " WHERE u.active = {$active} AND u.user_id IN ('{$teacherListId}') ";
         if (!empty($lastConnectionDate)) {
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
             //$where .= " AND l.login_date <= '$lastConnectionDate' ";
         }
         $sql .= $where;
         $result = Database::query($sql);
         if (Database::num_rows($result)) {
             if ($getCount) {
                 $row = Database::fetch_array($result);
                 return $row['count'];
             } else {
                 return Database::store_result($result, 'ASSOC');
             }
         }
     }
     return 0;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:71,代码来源:sessionmanager.lib.php

示例7: get_courses

function get_courses($from, $limit, $column, $direction)
{
    $userId = api_get_user_id();
    $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
    $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
    $follow = isset($_GET['follow']) ? true : false;
    $drhLoaded = false;
    if (api_is_drh()) {
        if (api_drh_can_access_all_session_content()) {
            $courses = SessionManager::getAllCoursesFollowedByUser($userId, $sessionId, $from, $limit, $column, $direction, false, $keyword);
            $drhLoaded = true;
        }
    }
    if ($drhLoaded == false) {
        $courses = CourseManager::getCoursesFollowedByUser($userId, COURSEMANAGER, $from, $limit, $column, $direction, false, $keyword, $sessionId, $follow);
    }
    $courseList = array();
    if (!empty($courses)) {
        foreach ($courses as $data) {
            $courseCode = $data['code'];
            $courseInfo = api_get_course_info($courseCode);
            $userList = CourseManager::get_user_list_from_course_code($data['code'], $sessionId);
            $userIdList = array();
            if (!empty($userList)) {
                foreach ($userList as $user) {
                    $userIdList[] = $user['user_id'];
                }
            }
            $messagesInCourse = 0;
            $assignmentsInCourse = 0;
            $avgTimeSpentInCourse = 0;
            $avgProgressInCourse = 0;
            if (count($userIdList) > 0) {
                $countStudents = count($userIdList);
                // tracking data
                $avgProgressInCourse = Tracking::get_avg_student_progress($userIdList, $courseCode, array(), $sessionId);
                $avgScoreInCourse = Tracking::get_avg_student_score($userIdList, $courseCode, array(), $sessionId);
                $avgTimeSpentInCourse = Tracking::get_time_spent_on_the_course($userIdList, $courseInfo['real_id'], $sessionId);
                $messagesInCourse = Tracking::count_student_messages($userIdList, $courseCode, $sessionId);
                $assignmentsInCourse = Tracking::count_student_assignments($userIdList, $courseCode, $sessionId);
                $avgTimeSpentInCourse = api_time_to_hms($avgTimeSpentInCourse / $countStudents);
                $avgProgressInCourse = round($avgProgressInCourse / $countStudents, 2);
                if (is_numeric($avgScoreInCourse)) {
                    $avgScoreInCourse = round($avgScoreInCourse / $countStudents, 2) . '%';
                }
            }
            $thematic = new Thematic();
            $tematic_advance = $thematic->get_total_average_of_thematic_advances($courseCode, $sessionId);
            $tematicAdvanceProgress = '-';
            if (!empty($tematic_advance)) {
                $tematicAdvanceProgress = '<a title="' . get_lang('GoToThematicAdvance') . '" href="' . api_get_path(WEB_CODE_PATH) . 'course_progress/index.php?cidReq=' . $courseCode . '&id_session=' . $sessionId . '">' . $tematic_advance . '%</a>';
            }
            $courseIcon = '<a href="' . api_get_path(WEB_CODE_PATH) . 'tracking/courseLog.php?cidReq=' . $courseCode . '&id_session=' . $sessionId . '">
                        ' . Display::return_icon('2rightarrow.png', get_lang('Details')) . '
                      </a>';
            $title = Display::url($data['title'], $courseInfo['course_public_url'] . '?id_session=' . $sessionId);
            $attendanceLink = Display::url(Display::return_icon('attendance_list.png', get_lang('Attendance'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'attendance/index.php?cidReq=' . $courseCode . '&id_session=' . $sessionId . '&action=calendar_logins');
            $courseList[] = array($title, $countStudents, is_null($avgTimeSpentInCourse) ? '-' : $avgTimeSpentInCourse, $tematicAdvanceProgress, is_null($avgProgressInCourse) ? '-' : $avgProgressInCourse . '%', is_null($avgScoreInCourse) ? '-' : $avgScoreInCourse, is_null($messagesInCourse) ? '-' : $messagesInCourse, is_null($assignmentsInCourse) ? '-' : $assignmentsInCourse, $attendanceLink, $courseIcon);
        }
    }
    return $courseList;
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:62,代码来源:course.php


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