Skip to content
Permalink
Browse files

Merge branch 'w11_MDL-31845_m23_dbenrolcat' of git://github.com/skoda…

…k/moodle
  • Loading branch information...
stronk7 committed Mar 13, 2012
2 parents 7ca5dd8 + b6f7dbe commit 65fc03100dc5d13e7bb84e8d6ee880ff522c915c
@@ -44,12 +44,13 @@
$string['defaultrole_desc'] = 'The role that will be assigned by default if no other role is specified in external table.';
$string['ignorehiddencourses'] = 'Ignore hidden courses';
$string['ignorehiddencourses_desc'] = 'If enabled users will not be enrolled on courses that are set to be unavailable to students.';
$string['localcategoryfield'] = 'Local category field';
$string['localcoursefield'] = 'Local course field';
$string['localrolefield'] = 'Local role field';
$string['localuserfield'] = 'Local user field';
$string['newcoursetable'] = 'Remote new courses table';
$string['newcoursetable_desc'] = 'Specify of the name of the table that contains list of courses that should be created automatically. Empty means no courses are created.';
$string['newcoursecategory'] = 'New course category id field';
$string['newcoursecategory'] = 'New course category field';
$string['newcoursefullname'] = 'New course full name field';
$string['newcourseidnumber'] = 'New course ID number field';
$string['newcourseshortname'] = 'New course short name field';
@@ -622,6 +622,8 @@ public function sync_courses($verbose = false) {
$idnumber = strtolower($this->get_config('newcourseidnumber'));
$category = strtolower($this->get_config('newcoursecategory'));
$localcategoryfield = $this->get_config('localcategoryfield', 'id');
$sqlfields = array($fullname, $shortname);
if ($category) {
$sqlfields[] = $category;
@@ -653,17 +655,17 @@ public function sync_courses($verbose = false) {
}
continue;
}
if ($category and !$DB->record_exists('course_categories', array('id'=>$fields[$category]))) {
if ($category and !$coursecategory = $DB->get_record('course_categories', array($localcategoryfield=>$fields[$category]), 'id')) {
if ($verbose) {
mtrace(' error: invalid category id, can not create course: '.$fields[$shortname]);
mtrace(' error: invalid category '.$localcategoryfield.', can not create course: '.$fields[$shortname]);
}
continue;
}
$course = new stdClass();
$course->fullname = $fields[$fullname];
$course->shortname = $fields[$shortname];
$course->idnumber = $idnumber ? $fields[$idnumber] : NULL;
$course->category = $category ? $fields[$category] : NULL;
$course->idnumber = $idnumber ? $fields[$idnumber] : '';
$course->category = $category ? $coursecategory->id : NULL;
$createcourses[] = $course;
}
}
@@ -66,6 +66,8 @@
$options = array('id'=>'id', 'shortname'=>'shortname', 'fullname'=>'fullname');
$settings->add(new admin_setting_configselect('enrol_database/localrolefield', get_string('localrolefield', 'enrol_database'), '', 'shortname', $options));
$options = array('id'=>'id', 'idnumber'=>'idnumber');
$settings->add(new admin_setting_configselect('enrol_database/localcategoryfield', get_string('localcategoryfield', 'enrol_database'), '', 'id', $options));
$settings->add(new admin_setting_heading('enrol_database_remoteheader', get_string('settingsheaderremote', 'enrol_database'), ''));
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012022700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2012031000; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012022300; // Requires this Moodle version
$plugin->component = 'enrol_database'; // Full name of the plugin (used for diagnostics)
//TODO: should we add cron sync?

0 comments on commit 65fc031

Please sign in to comment.
You can’t perform that action at this time.