Skip to content

Commit

Permalink
MDL-11145 include orphaned mnet ids from user table into mnetid selec…
Browse files Browse the repository at this point in the history
…tor; merged from MOODLE_19_STABLE
  • Loading branch information
skodak committed Jul 3, 2008
1 parent c74ca0e commit 257d63d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions user/filters/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,30 @@ function get_field($fieldname, $advanced) {
return new user_filter_simpleselect('auth', get_string('authentication'), $advanced, 'auth', $choices);

case 'mnethostid':
// include all hosts even those deleted or otherwise problematic
if (!$hosts = $DB->get_records('mnet_host', null, 'id', 'id, wwwroot, name')) {
return null;
$hosts = array();
}
$choices = array();
foreach ($hosts as $host) {
if (empty($host->wwwroot)) {
continue; // skip all hosts
if ($host->id == $CFG->mnet_localhost_id) {
$choices[$host->id] = format_string($SITE->fullname).' ('.get_string('local').')';
} else if (empty($host->wwwroot)) {
// All hosts
continue;
} else {
$choices[$host->id] = $host->name.' ('.$host->wwwroot.')';
}
$choices[$host->id] = $host->name.' ('.$host->wwwroot.')';
}
if (count($choices < 2)) {
if ($usedhosts = $DB->get_fieldset_sql("SELECT DISTINCT mnethostid FROM {user} WHERE deleted=0")) {
foreach ($usedhosts as $hostid) {
if (empty($hosts[$hostid])) {
$choices[$hostid] = 'id: '.$hostid.' ('.get_string('error').')';
}
}
}
if (count($choices) < 2) {
return null; // filter not needed
}
return new user_filter_simpleselect('mnethostid', 'mnethostid', $advanced, 'mnethostid', $choices);
Expand Down

0 comments on commit 257d63d

Please sign in to comment.