From: skodak Date: Thu, 3 Jul 2008 09:29:19 +0000 (+0000) Subject: MDL-11145 include orphaned mnet ids from user table into mnetid selector; merged... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=257d63dfd6cafae51b6af63870d48c26aaf22075;p=moodle.git MDL-11145 include orphaned mnet ids from user table into mnetid selector; merged from MOODLE_19_STABLE --- diff --git a/user/filters/lib.php b/user/filters/lib.php index bcb6624504..d0a0481f81 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -120,17 +120,30 @@ class user_filtering { 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);