Permalink
Browse files

MDL-30687 use course defaults when template not set in ldap enrol

  • Loading branch information...
1 parent acb3bf8 commit 8d7ec82427e2bde1e7821c73bbfe2787989532ab @skodak skodak committed Dec 11, 2011
Showing with 21 additions and 3 deletions.
  1. +21 −3 enrol/ldap/lib.php
View
@@ -885,16 +885,34 @@ function create_course($course_ext, $skip_fix_course_sortorder=false) {
require_once("$CFG->dirroot/course/lib.php");
// Override defaults with template course
- $course = new stdClass();
+ $template = false;
if ($this->get_config('template')) {
- if($template = $DB->get_record('course', array('shortname'=>$this->get_config('template')))) {
+ if ($template = $DB->get_record('course', array('shortname'=>$this->get_config('template')))) {
unset($template->id); // So we are clear to reinsert the record
unset($template->fullname);
unset($template->shortname);
unset($template->idnumber);
- $course = $template;
}
}
+ if (!$template) {
+ $courseconfig = get_config('moodlecourse');
+ $template = new stdClass();
+ $template->summary = '';
+ $template->summaryformat = FORMAT_HTML;
+ $template->format = $courseconfig->format;
+ $template->numsections = $courseconfig->numsections;
+ $template->hiddensections = $courseconfig->hiddensections;
+ $template->newsitems = $courseconfig->newsitems;
+ $template->showgrades = $courseconfig->showgrades;
+ $template->showreports = $courseconfig->showreports;
+ $template->maxbytes = $courseconfig->maxbytes;
+ $template->groupmode = $courseconfig->groupmode;
+ $template->groupmodeforce = $courseconfig->groupmodeforce;
+ $template->visible = $courseconfig->visible;
+ $template->lang = $courseconfig->lang;
+ $template->groupmodeforce = $courseconfig->groupmodeforce;
+ }
+ $course = $template;
$course->category = $this->get_config('category');
if (!$DB->record_exists('course_categories', array('id'=>$this->get_config('category')))) {

0 comments on commit 8d7ec82

Please sign in to comment.