From afb129685d900cf20f1a102e310a3dd5c6d03d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ou=C5=A1ek?= <brousek@ics.muni.cz> Date: Tue, 28 Jun 2022 18:31:11 +0200 Subject: [PATCH] feat: logos option for searchbox --- README.md | 2 ++ config-templates/module_campusmultiauth.php | 3 +++ www/idpSearch.php | 4 ++-- www/selectsource.php | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d5b1b97..1507796 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,8 @@ Here you can specify some identity providers to display them as a list of button `identities` - list of identity providers to display as buttons. Each identity provider has some configuration options available. For further information, see the [identities](#identities) section below. +`logos` - optional map with keys of entity IDs and values of URLs to logos. This option can be used to override logos for some identity providers, which are expected to be used often but do not have a suitable (square) logo in their metadata. + ##### identities Each identity is a map with the following possible options: diff --git a/config-templates/module_campusmultiauth.php b/config-templates/module_campusmultiauth.php index d620ab8..9b5c718 100644 --- a/config-templates/module_campusmultiauth.php +++ b/config-templates/module_campusmultiauth.php @@ -47,6 +47,9 @@ $config = [ 'tags' => [], 'registration_authorities' => [] ], + 'logos' => [ + 'https://idp2.ics.muni.cz/idp/shibboleth' => 'https://id.muni.cz/android-chrome-192x192.png', + ], ], [ 'name' => 'individual_identities', diff --git a/www/idpSearch.php b/www/idpSearch.php index 09da519..bc0e4ee 100644 --- a/www/idpSearch.php +++ b/www/idpSearch.php @@ -124,11 +124,11 @@ $data['items'] = []; foreach ($filteredData as $entityid => $idpentry) { $item['idpentityid'] = $entityid; - $item['image'] = Campusidp::getMostSquareLikeImg($idpentry); + $item['image'] = $searchBox['logos'][$entityid] ?? Campusidp::getMostSquareLikeImg($idpentry); if (!empty($idpentry['name'][$_GET['language']])) { $item['text'] = $idpentry['name'][$_GET['language']]; - } elseif (!empty($item['text'] = $idpentry['name']['en'])) { + } elseif (!empty($idpentry['name']['en'])) { $item['text'] = $idpentry['name']['en']; } elseif (reset($idpentry['name'])) { $item['text'] = reset($idpentry['name']); diff --git a/www/selectsource.php b/www/selectsource.php index 6d1dbc2..f17124a 100644 --- a/www/selectsource.php +++ b/www/selectsource.php @@ -50,7 +50,8 @@ if (array_key_exists('source', $_POST)) { $chosenIdp = []; $chosenIdp['entityid'] = $_POST['searchbox']; $chosenIdp['name'] = $metadata[$_POST['searchbox']]['name']; - $chosenIdp['img'] = Campusidp::getMostSquareLikeImg($metadata[$_POST['searchbox']]); + $chosenIdp['img'] = $wayfConfig['components'][$_POST['componentIndex']]['logos'][$_POST['searchbox']] + ?? Campusidp::getMostSquareLikeImg($metadata[$_POST['searchbox']]); $chosenIdp['index'] = $_POST['componentIndex']; $prevIdps = Campusidp::getCookie(Campusidp::COOKIE_PREVIOUS_IDPS) === null ? [] : json_decode(gzinflate(base64_decode(Campusidp::getCookie(Campusidp::COOKIE_PREVIOUS_IDPS)))); -- GitLab