diff --git a/classes/Identity.php b/classes/Identity.php index fc82a1d4fd25292f69bf226c9cac978e909ffcf1..500a1aafe2be3183dc3f1c0bd013e607433d34bd 100644 --- a/classes/Identity.php +++ b/classes/Identity.php @@ -98,4 +98,19 @@ class Identity { $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; + } + } + } diff --git a/classes/MySQLDAO.php b/classes/MySQLDAO.php index 02dea0dffc9e672a6d7bed6fe7ded8af2a234ba2..d93d82d2a8f8769d400df956651845cd38601dc2 100644 --- a/classes/MySQLDAO.php +++ b/classes/MySQLDAO.php @@ -208,13 +208,16 @@ class MySQLDAO implements DAO { . " i.`id`, `type`, `typed_id`, `email`, `name`, `surname`, `institution`, `eppn`" . " FROM identity i" . " 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"; $stmt = $dbh->prepare($query); $searchParam = $searchText . '%'; + $emailPartSearchParam = '%.' . $searchText . '%'; $stmt->bindParam(':email', $searchParam); + $stmt->bindParam(':emailPart', $emailPartSearchParam); $stmt->bindParam(':name', $searchParam); $stmt->bindParam(':surname', $searchParam); $stmt->bindParam(':namesurname', $searchParam); diff --git a/classes/UserSearchResult.php b/classes/UserSearchResult.php index 25de1ad65ea0494889ed1603c57fc5c9c27cbfd6..685abc61b1932480412416e60b98f36b03cec843 100644 --- a/classes/UserSearchResult.php +++ b/classes/UserSearchResult.php @@ -37,7 +37,7 @@ class UserSearchResult { $email = null; $identityTypes = []; foreach ($user->identities as $identity) { - array_push($identityTypes, $identity->type); + array_push($identityTypes, $identity->getUIType()); if ($nameAndSurname === null && $identity->name !== null && $identity->surname !== null) { $nameAndSurname = $identity->name . ' ' . $identity->surname; } diff --git a/include/user-data.php b/include/user-data.php index e2e7b4a0dec521da9b321f27ba68a0900b618d72..37c05e194da56aa68d9096dd50caa3795b30a87f 100644 --- a/include/user-data.php +++ b/include/user-data.php @@ -16,7 +16,7 @@ <?php } ?> Type </dt> - <dd><?php echo $identity->type; ?></dd> + <dd><?php echo $identity->getUIType(); ?></dd> <dt>E-mail</dt> <dd><?php echo $identity->email; ?></dd> <?php if ($identity->eppn !== null) { ?>