示例#1
0
/**
 * Check if cohort exists and user is allowed to enrol it.
 *
 * This function is deprecated, use {@link cohort_can_view_cohort()} instead since it also
 * takes into account current context
 *
 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
 *
 * @param int $cohortid Cohort ID
 * @return boolean
 */
function enrol_cohort_can_view_cohort($cohortid)
{
    global $CFG;
    require_once $CFG->dirroot . '/cohort/lib.php';
    debugging('Function enrol_cohort_can_view_cohort() is deprecated, use cohort_can_view_cohort() instead', DEBUG_DEVELOPER);
    return cohort_can_view_cohort($cohortid, null);
}
示例#2
0
     $addedenrollment = optional_param('enrolcount', 0, PARAM_INT);
     $perpage = optional_param('perpage', 25, PARAM_INT);
     //  This value is hard-coded to 25 in quickenrolment.js
     $outcome->response = enrol_moodec_get_potential_cohorts($context, $enrolid, $search, $page, $perpage, $addedenrollment);
     $outcome->success = true;
     break;
 case 'enrol':
     $enrolid = required_param('enrolid', PARAM_INT);
     $cohort = $user = null;
     $cohortid = optional_param('cohortid', 0, PARAM_INT);
     if (!$cohortid) {
         $userid = required_param('userid', PARAM_INT);
         $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
     } else {
         $cohort = $DB->get_record('cohort', array('id' => $cohortid), '*', MUST_EXIST);
         if (!cohort_can_view_cohort($cohort, $context)) {
             throw new enrol_ajax_exception('invalidenrolinstance');
             // TODO error text!
         }
     }
     $roleid = optional_param('role', null, PARAM_INT);
     $duration = optional_param('duration', 0, PARAM_INT);
     $startdate = optional_param('startdate', 0, PARAM_INT);
     $recovergrades = optional_param('recovergrades', 0, PARAM_INT);
     if (empty($roleid)) {
         $roleid = null;
     }
     switch ($startdate) {
         case 2:
             $timestart = $course->startdate;
             break;