libdir . '/adminlib.php'; include_once $CFG->dirroot . '/mnet/lib.php'; admin_externalpage_setup('ssoaccesscontrol'); admin_externalpage_print_header(); $addcategory = optional_param('addcategory', 0, PARAM_BOOL); $removecategory = optional_param('removecategory', 0, PARAM_BOOL); $addcourse = optional_param('addcourse', 0, PARAM_BOOL); $removecourse = optional_param('removecourse', 0, PARAM_BOOL); $sitecontext = get_context_instance(CONTEXT_SYSTEM); $sesskey = sesskey(); $formerror = array(); require_capability('moodle/user:delete', $sitecontext); // process returned form data if ($form = data_submitted() and confirm_sesskey()) { // add and remove categories as needed if (!empty($CFG->enrol_mnet_allowed_categories)) { $allowedcategories = explode(',', $CFG->enrol_mnet_allowed_categories); } if ($addcategory and !empty($form->addcategories)) { foreach ($form->addcategories as $category) { if (!$category = clean_param($category, PARAM_INT)) { continue; } $allowedcategories[] = $category; } } if ($removecategory and !empty($form->removecategories)) { foreach ($form->removecategories as $category) { if ($category = clean_param($category, PARAM_INT)) { $removedcategories[] = $category; } } $allowedcategories = array_diff($allowedcategories, $removedcategories); } // add and remove courses as needed if (!empty($CFG->enrol_mnet_allowed_courses)) { $allowedcourses = explode(',', $CFG->enrol_mnet_allowed_courses); } if ($addcourse and !empty($form->addcourses)) { foreach ($form->addcourses as $course) { if ($course = clean_param($course, PARAM_INT)) { $allowedcourses[] = $course; } } } if ($removecourse and !empty($form->removecourses)) { foreach ($form->removecourses as $course) { if (!$course = clean_param($course, PARAM_INT)) { continue; } $removedcourses[] = $course; } $allowedcourses = array_diff($allowedcourses, $removedcourses); } // save config $cfg = empty($allowedcategories) ? '' : implode(',', $allowedcategories); set_config('enrol_mnet_allowed_categories', $cfg); $cfg = empty($allowedcourses) ? '' : implode(',', $allowedcourses); set_config('enrol_mnet_allowed_courses', $cfg); // redirect('allowed_courses.php', get_string('changessaved')); } // setup arrays for allowed categories and courses $categories = array(); if ($categories = get_records('course_categories', '', '', 'name', 'id, name')) { $allowedcategories = array(); if (empty($CFG->enrol_mnet_allowed_categories)) { $potentialcategories = $categories; } else { $potentialcategories = array(); $explode_categories = explode(',', $CFG->enrol_mnet_allowed_categories); foreach($categories as $category) { if (in_array($category->id, $explode_categories)) { $allowedcategories[] = $category; } else { $potentialcategories[] = $category; } } } } $courses = array(); if ($courses = get_records('course', '', '', 'shortname', 'id, shortname')) { unset($courses[SITEID]); // never list or offer the siteid $allowedcourses = array(); if (empty($CFG->enrol_mnet_allowed_courses)) { $potentialcourses = $courses; } else { $potentialcourses = array(); $explode_courses = explode(',', $CFG->enrol_mnet_allowed_courses); foreach($courses as $course) { if (in_array($course->id, $explode_courses)) { $allowedcourses[] = $course; } else { $potentialcourses[] = $course; } } } } // output the form print_simple_box_start('center','90%','','20'); ?>
wwwroot/course/index.php?categoryedit=on"); } else { ?>