Browse Source

Fix: Adopt global instance defaults for new course instance.

SABERES_37_STABLE
Johannes Burk 9 years ago
parent
commit
d4cafeeaaf
  1. 2
      edit.php
  2. 21
      lib.php

2
edit.php

@ -38,7 +38,7 @@ if ($instanceid) {
require_capability('moodle/course:enrolconfig', $context);
// no instance yet, we have to add new instance
navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
$instance = new stdClass();
$instance = (object)$plugin->get_instance_defaults();
$instance->id = null;
$instance->courseid = $course->id;
}

21
lib.php

@ -17,10 +17,7 @@ class enrol_apply_plugin extends enrol_plugin {
* @return int id of new instance
*/
public function add_default_instance($course) {
$fields = array(
'status' => $this->get_config('status'),
'roleid' => $this->get_config('roleid', 0)
);
$fields = $this->get_instance_defaults();
return $this->add_instance($course, $fields);
}
@ -236,6 +233,22 @@ class enrol_apply_plugin extends enrol_plugin {
}
return $actions;
}
/**
* Returns defaults for new instances.
* @return array
*/
public function get_instance_defaults() {
$fields = array();
$fields['status'] = $this->get_config('status');
$fields['roleid'] = $this->get_config('roleid', 0);
$fields['customint1'] = $this->get_config('show_standard_user_profile');
$fields['customint2'] = $this->get_config('show_extra_user_profile');
$fields['customint3'] = $this->get_config('sendmailtoteacher');
$fields['customint4'] = $this->get_config('sendmailtomanager');
return $fields;
}
}
function getAllEnrolment($id = null) {

Loading…
Cancel
Save