mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-26066 fix invalid type comparison when course id used and typo fix
This commit is contained in:
parent
17e03900c9
commit
87e88690b2
@ -74,7 +74,7 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
|
||||
$localrolefield = $this->get_config('localrolefield');
|
||||
$localuserfield = $this->get_config('localuserfield');
|
||||
$localcoursefiled = $this->get_config('localcoursefield');
|
||||
$localcoursefield = $this->get_config('localcoursefield');
|
||||
|
||||
$unenrolaction = $this->get_config('unenrolaction');
|
||||
$defaultrole = $this->get_config('defaultrole');
|
||||
@ -117,7 +117,7 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
// missing course info
|
||||
continue;
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array($localcoursefiled=>$fields[$coursefield]), 'id,visible')) {
|
||||
if (!$course = $DB->get_record('course', array($localcoursefield=>$fields[$coursefield]), 'id,visible')) {
|
||||
continue;
|
||||
}
|
||||
if (!$course->visible and $ignorehidden) {
|
||||
@ -265,7 +265,7 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
|
||||
$localrolefield = $this->get_config('localrolefield');
|
||||
$localuserfield = $this->get_config('localuserfield');
|
||||
$localcoursefiled = $this->get_config('localcoursefield');
|
||||
$localcoursefield = $this->get_config('localcoursefield');
|
||||
|
||||
$unenrolaction = $this->get_config('unenrolaction');
|
||||
$defaultrole = $this->get_config('defaultrole');
|
||||
@ -308,7 +308,7 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
|
||||
// first find all existing courses with enrol instance
|
||||
$existing = array();
|
||||
$sql = "SELECT c.id, c.visible, c.$localcoursefiled AS mapping, e.id AS enrolid
|
||||
$sql = "SELECT c.id, c.visible, c.$localcoursefield AS mapping, e.id AS enrolid
|
||||
FROM {course} c
|
||||
JOIN {enrol} e ON (e.courseid = c.id AND e.enrol = 'database')";
|
||||
$rs = $DB->get_recordset_sql($sql); // watch out for idnumber duplicates
|
||||
@ -321,11 +321,17 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
$rs->close();
|
||||
|
||||
// add necessary enrol instances that are not present yet
|
||||
$sql = "SELECT c.id, c.visible, c.$localcoursefiled AS mapping
|
||||
$params = array();
|
||||
$localnotempty = "";
|
||||
if ($localcoursefield !== 'id') {
|
||||
$localnotempty = "AND c.$localcoursefield <> :lcfe";
|
||||
$params['lcfe'] = $DB->sql_empty();
|
||||
}
|
||||
$sql = "SELECT c.id, c.visible, c.$localcoursefield AS mapping
|
||||
FROM {course} c
|
||||
LEFT JOIN {enrol} e ON (e.courseid = c.id AND e.enrol = 'database')
|
||||
WHERE e.id IS NULL AND c.$localcoursefiled <> ?";
|
||||
$rs = $DB->get_recordset_sql($sql, array($DB->sql_empty()));
|
||||
WHERE e.id IS NULL $localnotempty";
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($rs as $course) {
|
||||
if (empty($course->mapping)) {
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user