diff --git a/edit.php b/edit.php index 36e4a33..7fbf703 100644 --- a/edit.php +++ b/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; } diff --git a/lib.php b/lib.php index 781fe41..a6b32c0 100644 --- a/lib.php +++ b/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) {