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


PHP course_enrolment_manager::get_user_enrolments方法代码示例

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


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

示例1: is_available

 public function is_available($not, \core_availability\info $info, $grabthelot, $userid)
 {
     global $PAGE, $CFG;
     require_once $CFG->dirroot . '/enrol/locallib.php';
     $course = $info->get_course();
     $enrolmanager = new \course_enrolment_manager($PAGE, $course);
     $allow = true;
     if (!($enrolments = $enrolmanager->get_user_enrolments($userid))) {
         $allow = false;
     }
     foreach ($enrolments as $enrol) {
         if (time() - $enrol->timestart < $this->mintimesinceenrol) {
             $allow = false;
         }
     }
     if (!$not) {
         $allow = !$allow;
     }
     return $allow;
 }
开发者ID:danielneis,项目名称:moodle-availability_timesinceenrol,代码行数:20,代码来源:condition.php

示例2: unenrol

 /**
  * Unenrol a user from a courses
  * @param object $user
  * @param array $courseids
  * @param int $companyid
  * @return void
  */
 public static function unenrol($user, $courseids, $companyid = null)
 {
     global $DB, $PAGE;
     foreach ($courseids as $courseid) {
         if (!$DB->get_record('iomad_courses', array('courseid' => $courseid, 'shared' => 0))) {
             $shared = true;
         } else {
             $shared = false;
         }
         $course = $DB->get_record('course', array('id' => $courseid));
         $courseenrolmentmanager = new course_enrolment_manager($PAGE, $course);
         $ues = $courseenrolmentmanager->get_user_enrolments($user->id);
         foreach ($ues as $ue) {
             if ($ue->enrolmentinstance->courseid == $courseid) {
                 $courseenrolmentmanager->unenrol_user($ue);
                 if ($shared) {
                     if (!empty($companyid)) {
                         company::remove_user_from_shared_course($courseid, $user->id, $companyid);
                     }
                 }
             }
         }
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:user.php

示例3: facetoface_user_signup

/**
 * Add a record to the facetoface submissions table and sends out an
 * email confirmation
 *
 * @param class $session record from the facetoface_sessions table
 * @param class $facetoface record from the facetoface table
 * @param class $course record from the course table
 * @param string $discountcode code entered by the user
 * @param integer $notificationtype type of notifications to send to user
 * @see {{MDL_F2F_INVITE}}
 * @param integer $statuscode Status code to set
 * @param integer $userid user to signup
 * @param bool $notifyuser whether or not to send an email confirmation
 * @param bool $displayerrors whether or not to return an error page on errors
 */
function facetoface_user_signup($session, $facetoface, $course, $discountcode, $notificationtype, $statuscode, $userid = false, $notifyuser = true)
{
    global $CFG, $DB, $PAGE;
    // Get user ID.
    if (!$userid) {
        global $USER;
        $userid = $USER->id;
    }
    $return = false;
    $timenow = time();
    // Check to see if user is already enrolled, if not. Enrol user
    $ehelper = new course_enrolment_manager($PAGE, $course);
    $enrolinstances = $ehelper->get_enrolment_instances();
    $enrolments = $ehelper->get_user_enrolments($userid);
    if (empty($enrolments)) {
        foreach ($enrolinstances as $instance) {
            if ($instance->enrol == 'manual') {
                $emp = new enrol_manual_plugin();
                $emp->enrol_user($instance, $userid, 5, $timenow);
                break;
            }
        }
    }
    // Check to see if a signup already exists.
    if ($existingsignup = $DB->get_record('facetoface_signups', array('sessionid' => $session->id, 'userid' => $userid))) {
        $usersignup = $existingsignup;
    } else {
        // Otherwise, prepare a signup object.
        $usersignup = new stdclass();
        $usersignup->sessionid = $session->id;
        $usersignup->userid = $userid;
    }
    $usersignup->mailedreminder = 0;
    $usersignup->notificationtype = $notificationtype;
    $usersignup->discountcode = trim(strtoupper($discountcode));
    if (empty($usersignup->discountcode)) {
        $usersignup->discountcode = null;
    }
    // Update/insert the signup record.
    if (!empty($usersignup->id)) {
        $success = $DB->update_record('facetoface_signups', $usersignup);
    } else {
        $usersignup->id = $DB->insert_record('facetoface_signups', $usersignup);
        $success = (bool) $usersignup->id;
    }
    if (!$success) {
        print_error('error:couldnotupdatef2frecord', 'facetoface');
        return false;
    }
    // Work out which status to use.
    // If approval not required.
    if (!$facetoface->approvalreqd) {
        $newstatus = $statuscode;
    } else {
        // If approval required.
        // Get current status (if any).
        $currentstatus = $DB->get_field('facetoface_signups_status', 'statuscode', array('signupid' => $usersignup->id, 'superceded' => 0));
        // If approved, then no problem.
        if ($currentstatus == MDL_F2F_STATUS_APPROVED) {
            $newstatus = $statuscode;
        } else {
            if ($session->datetimeknown) {
                // Otherwise, send manager request.
                $newstatus = MDL_F2F_STATUS_REQUESTED;
            } else {
                $newstatus = MDL_F2F_STATUS_WAITLISTED;
            }
        }
    }
    // Update status.
    if (!facetoface_update_signup_status($usersignup->id, $newstatus, $userid)) {
        print_error('error:f2ffailedupdatestatus', 'facetoface');
        return false;
    }
    // Add to user calendar -- if facetoface usercalentry is set to true.
    if ($facetoface->usercalentry) {
        if (in_array($newstatus, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_WAITLISTED))) {
            facetoface_add_session_to_calendar($session, $facetoface, 'user', $userid, 'booking');
        }
    }
    // Course completion.
    if (in_array($newstatus, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_WAITLISTED))) {
        $completion = new completion_info($course);
        if ($completion->is_enabled()) {
            $ccdetails = array('course' => $course->id, 'userid' => $userid);
//.........这里部分代码省略.........
开发者ID:eSrem,项目名称:facetoface-2.0,代码行数:101,代码来源:lib.php

示例4: unenroll_all

 private function unenroll_all($id)
 {
     global $DB, $PAGE;
     // Unenroll everybody from given course.
     // Get list of enrollments.
     $course = $DB->get_record('course', array('id' => $id));
     $courseenrolment = new course_enrolment_manager($PAGE, $course);
     $userlist = $courseenrolment->get_users('', 'ASC', 0, 0);
     foreach ($userlist as $user) {
         $ues = $courseenrolment->get_user_enrolments($user->id);
         foreach ($ues as $ue) {
             $courseenrolment->unenrol_user($ue);
         }
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:15,代码来源:company_courses_form.php


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