예제 #1
0
     }
     $outcome->response = $subgroupoptions;
     break;
 case 'enrolilios':
     require_capability('moodle/course:enrolconfig', $context);
     require_capability('enrol/ilios:config', $context);
     $roleid = required_param('roleid', PARAM_INT);
     $cohortid = required_param('cohortid', PARAM_INT);
     $roles = $manager->get_assignable_roles();
     if (!enrol_ilios_can_view_cohort($cohortid) || !array_key_exists($roleid, $roles)) {
         throw new enrol_ajax_exception('errorenrolilios');
     }
     $enrol = enrol_get_plugin('ilios');
     $enrol->add_instance($manager->get_course(), array('customint1' => $cohortid, 'roleid' => $roleid));
     $trace = new null_progress_trace();
     enrol_ilios_sync($trace, $manager->get_course()->id);
     $trace->finished();
     break;
 case 'enroliliosusers':
     //TODO: this should be moved to enrol_manual, see MDL-35618.
     require_capability('enrol/manual:enrol', $context);
     $roleid = required_param('roleid', PARAM_INT);
     $cohortid = required_param('cohortid', PARAM_INT);
     $roles = $manager->get_assignable_roles();
     if (!enrol_ilios_can_view_cohort($cohortid) || !array_key_exists($roleid, $roles)) {
         throw new enrol_ajax_exception('errorenrolilios');
     }
     $result = enrol_ilios_enrol_all_users($manager, $cohortid, $roleid);
     if ($result === false) {
         throw new enrol_ajax_exception('errorenroliliosusers');
     }
예제 #2
0
            $syncinfo["subGroup"] = array("id" => $subgroupid, "title" => $subgrouptitle);
        }
        if ($data->id) {
            // NOTE: no cohort or learner group changes here!!!
            if ($data->roleid != $instance->roleid) {
                // The sync script can only add roles, for perf reasons it does not modify them.
                role_unassign_all(array('contextid' => $context->id, 'roleid' => $instance->roleid, 'component' => 'enrol_ilios', 'itemid' => $instance->id));
            }
            $instance->name = $data->name;
            $instance->status = $data->status;
            $instance->roleid = $data->roleid;
            $instance->customchar1 = $synctype;
            $instance->customint1 = $syncid;
            $instance->customtext1 = json_encode($syncinfo);
            $instance->customint6 = $data->customint6;
            $instance->timemodified = time();
            $DB->update_record('enrol', $instance);
        } else {
            $enrol->add_instance($course, array('name' => $data->name, 'status' => $data->status, 'customchar1' => $synctype, 'customint1' => $syncid, 'customtext1' => json_encode($syncinfo), 'roleid' => $data->roleid, 'customint6' => $data->customint6));
        }
        $trace = new null_progress_trace();
        enrol_ilios_sync($trace, $course->id);
        $trace->finished();
        redirect($returnurl);
    }
}
$PAGE->set_heading($course->fullname);
$PAGE->set_title(get_string('pluginname', 'enrol_ilios'));
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
예제 #3
0
 /**
  * Restore instance and map settings.
  *
  * @param restore_enrolments_structure_step $step
  * @param stdClass $data
  * @param stdClass $course
  * @param int $oldid
  */
 public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid)
 {
     global $DB, $CFG;
     if (!$step->get_task()->is_samesite()) {
         // No ilios restore from other sites.
         $step->set_mapping('enrol', $oldid, 0);
         return;
     }
     if (!empty($data->customint6)) {
         $data->customint6 = $step->get_mappingid('group', $data->customint6);
     }
     // if ($data->roleid and $DB->record_exists('cohort', array('id'=>$data->customint1))) {
     if ($data->roleid) {
         $instance = $DB->get_record('enrol', array('roleid' => $data->roleid, 'customint1' => $data->customint1, 'customchar1' => $data->customchar1, 'courseid' => $course->id, 'enrol' => $this->get_name()));
         if ($instance) {
             $instanceid = $instance->id;
         } else {
             $instanceid = $this->add_instance($course, (array) $data);
         }
         $step->set_mapping('enrol', $oldid, $instanceid);
         require_once "{$CFG->dirroot}/enrol/ilios/locallib.php";
         $trace = new null_progress_trace();
         enrol_ilios_sync($trace, $course->id);
         $trace->finished();
     } else {
         if ($this->get_config('unenrolaction') == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
             $instance = $DB->get_record('enrol', array('roleid' => $data->roleid, 'customint1' => $data->customint1, 'customerchar1' => $data->customchar1, 'courseid' => $course->id, 'enrol' => $this->get_name()));
             if ($instance) {
                 $instanceid = $instance->id;
             } else {
                 $data->status = ENROL_INSTANCE_DISABLED;
                 $instanceid = $this->add_instance($course, (array) $data);
             }
             $step->set_mapping('enrol', $oldid, $instanceid);
             require_once "{$CFG->dirroot}/enrol/ilios/locallib.php";
             $trace = new null_progress_trace();
             enrol_ilios_sync($trace, $course->id);
             $trace->finished();
         } else {
             $step->set_mapping('enrol', $oldid, 0);
         }
     }
 }