Skip to content
Snippets Groups Projects
Commit e9d62827 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added workaround for IA2 users

parent dea1fb34
No related branches found
No related tags found
No related merge requests found
...@@ -98,4 +98,19 @@ class Identity { ...@@ -98,4 +98,19 @@ class Identity {
$this->primary = false; $this->primary = false;
} }
private static function endsWith($haystack, $needle) {
return substr($haystack, -strlen($needle)) === $needle;
}
/**
* Workaround for IA2 users
*/
public function getUIType() {
if ($this->eppn !== null && $this->endsWith($this->eppn, '@ia2.inaf.it')) {
return 'IA2';
} else {
return $this->type;
}
}
} }
...@@ -208,13 +208,16 @@ class MySQLDAO implements DAO { ...@@ -208,13 +208,16 @@ class MySQLDAO implements DAO {
. " i.`id`, `type`, `typed_id`, `email`, `name`, `surname`, `institution`, `eppn`" . " i.`id`, `type`, `typed_id`, `email`, `name`, `surname`, `institution`, `eppn`"
. " FROM identity i" . " FROM identity i"
. " JOIN `user` u on u.id = i.user_id" . " JOIN `user` u on u.id = i.user_id"
. " WHERE `email` LIKE :email OR `name` LIKE :name OR `surname` LIKE :surname" . " WHERE `email` LIKE :email OR `email` LIKE :emailPart"
. " OR `name` LIKE :name OR `surname` LIKE :surname"
. " OR CONCAT(`name`,' ',`surname`) LIKE :namesurname"; . " OR CONCAT(`name`,' ',`surname`) LIKE :namesurname";
$stmt = $dbh->prepare($query); $stmt = $dbh->prepare($query);
$searchParam = $searchText . '%'; $searchParam = $searchText . '%';
$emailPartSearchParam = '%.' . $searchText . '%';
$stmt->bindParam(':email', $searchParam); $stmt->bindParam(':email', $searchParam);
$stmt->bindParam(':emailPart', $emailPartSearchParam);
$stmt->bindParam(':name', $searchParam); $stmt->bindParam(':name', $searchParam);
$stmt->bindParam(':surname', $searchParam); $stmt->bindParam(':surname', $searchParam);
$stmt->bindParam(':namesurname', $searchParam); $stmt->bindParam(':namesurname', $searchParam);
......
...@@ -37,7 +37,7 @@ class UserSearchResult { ...@@ -37,7 +37,7 @@ class UserSearchResult {
$email = null; $email = null;
$identityTypes = []; $identityTypes = [];
foreach ($user->identities as $identity) { foreach ($user->identities as $identity) {
array_push($identityTypes, $identity->type); array_push($identityTypes, $identity->getUIType());
if ($nameAndSurname === null && $identity->name !== null && $identity->surname !== null) { if ($nameAndSurname === null && $identity->name !== null && $identity->surname !== null) {
$nameAndSurname = $identity->name . ' ' . $identity->surname; $nameAndSurname = $identity->name . ' ' . $identity->surname;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<?php } ?> <?php } ?>
Type Type
</dt> </dt>
<dd><?php echo $identity->type; ?></dd> <dd><?php echo $identity->getUIType(); ?></dd>
<dt>E-mail</dt> <dt>E-mail</dt>
<dd><?php echo $identity->email; ?></dd> <dd><?php echo $identity->email; ?></dd>
<?php if ($identity->eppn !== null) { ?> <?php if ($identity->eppn !== null) { ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment