mnet/login: MDL-21018 - be a bit more picky about when to show the link to mnet_emai...
authorPenny Leach <penny@liip.ch>
Mon, 11 Jan 2010 22:05:45 +0000 (22:05 +0000)
committerPenny Leach <penny@liip.ch>
Mon, 11 Jan 2010 22:05:45 +0000 (22:05 +0000)
Merged from MOODLE_19_STABLE

login/index.php

index b223ab45e978e8f09e8f058d1a78ad2ed88fe63f..8fbd5d62f00c1bcc0a8c4e4ce6269b7e8e8b40b9 100644 (file)
@@ -236,10 +236,16 @@ if (empty($CFG->usesid) and $testcookies and (get_moodle_cookie() == '')) {    /
             $errorcode = 3;
         }
 
-        // TODO: if the user failed to authenticate, check if the username corresponds to a remote mnet user
         if ( !empty($CFG->mnet_dispatcher_mode)
              && $CFG->mnet_dispatcher_mode === 'strict'
-             && is_enabled_auth('mnet')) {
+             && is_enabled_auth('mnet')
+             && $DB->record_exists_sql('SELECT h.id FROM {mnet_host} h
+                INNER JOIN {mnet_host2service} m ON h.id=m.hostid
+                INNER JOIN {mnet_service} s ON s.id=m.serviceid
+                WHERE s.name=? AND h.deleted=? AND m.publish = ?',
+                array('sso_sp', 0, 1))
+            && $DB->record_exists_select('user', 'username = ? AND mnethostid != ?', array($frm->username, $CFG->mnet_localhost_id))
+        ) {
             $errormsg .= get_string('loginlinkmnetuser', 'mnet', "mnet_email.php?u=$frm->username");
         }
     }