diff options
Diffstat (limited to 'modules/main.inc.php')
-rw-r--r-- | modules/main.inc.php | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/modules/main.inc.php b/modules/main.inc.php index db62096..3b605a3 100644 --- a/modules/main.inc.php +++ b/modules/main.inc.php @@ -35,16 +35,18 @@ class Page_Main extends Page return; } if (!User::isTutor()) { + Message::addError('Sie sind kein Mitarbeiter der Einrichtung "' . User::getOrganizationName() + . '" und können daher die ' . CONFIG_SUITE . '-Suite nicht nutzen.'); return; } // User is not in DB, so he might want so sign up for the service - see if conditions are met - if (User::getOrganization() !== false) { + if (User::getOrganization() !== null) { // Organization is known, show signup form $this->renderShibbolethUnregistered(); return; } // Nothing we can do here, show error message :-( - if (User::getRemoteOrganizationId() !== false) { + if (User::getRemoteOrganizationId() !== null) { // Organization is not known, see if we at least have an idea Message::addWarning('Ihre Hochschule/Einrichtung {{0}} ist leider nicht bekannt. Bitte kontaktieren Sie den Support.', User::getRemoteOrganizationId()); } else { @@ -62,20 +64,24 @@ class Page_Main extends Page { $data = User::getData(); $data['organization'] = User::getOrganizationName(); - // Shoe testacc merge form if organization has test accounts - $res = Database::queryFirst('SELECT Count(*) as cnt FROM user WHERE organizationid = :oid', array( - 'oid' => User::getOrganizationId() - )); - if ($res !== false && $res['cnt'] > 0) { - $data['testacc'] = true; - $mail = trim(User::getMail()); - if (!empty($mail)) { - $existing = Database::queryFirst('SELECT userid FROM user WHERE email = :email LIMIT 1', array( - 'email' => $mail - )); - if ($existing !== false) { - $data['testlogin'] = $existing['userid']; - } + // Show testacc merge form if organization has test accounts + $mail = trim(User::getMail()); + $fn = User::getFirstName(); + $ln = User::getLastName(); + if (!empty($mail) && (!empty($fn) || !empty($ln))) { + $extra = ''; + if (!CONFIG_ALLOW_SHIB_MERGE) { + $extra = ' AND password IS NOT NULL AND Length(password) <> 0 '; + } + $existing = Database::queryFirst('SELECT userid FROM user + WHERE email = :email AND lastname = :ln AND firstname = :fn AND organizationid = :org ' . $extra . ' LIMIT 1', array( + 'email' => $mail, + 'fn' => $fn, + 'ln' => $ln, + 'org' => User::getOrganizationId(), + )); + if ($existing !== false) { + $data['testlogin'] = $existing['userid']; } } $data['suite'] = CONFIG_SUITE; |