Skip to content

Commit

Permalink
Adding CAT realms to IdP keawords, they will enable realm-based selec…
Browse files Browse the repository at this point in the history
…tion in download IdP list
  • Loading branch information
Tomasz Wolniewicz committed Nov 25, 2024
1 parent 8f50f23 commit 7d6c04c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions core/IdPlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public static function listAllIdentityProviders($activeOnly = 0, $country = "")
$allIDPs = ($country != "" ? $handle->exec($query, "s", $country) : $handle->exec($query));
$idpArray = [];
// SELECTs never return a booleans, always an object
$allIdPresults = [];
while ($queryResult = mysqli_fetch_object(/** @scrutinizer ignore-type */ $allIDPs)) {
$allIdPresults[] = $queryResult;
}
foreach ($allIdPresults as $queryResult) {
$options = IdPlist::setIdentityProviderAttributes($queryResult);
$oneInstitutionResult = [];
$oneInstitutionResult['entityID'] = $queryResult->inst_id;
Expand All @@ -82,17 +86,23 @@ public static function listAllIdentityProviders($activeOnly = 0, $country = "")
$name = $langObject->getLocalisedValue($options['names']);
}
$oneInstitutionResult['title'] = $name;
$keywords = [];
foreach ($options['names'] as $keyword) {
$value = $keyword['value'];
$keywords[$keyword['lang']] = $keyword['value'];
$keywords[$keyword['lang'].'_7'] =
iconv('UTF-8', 'ASCII//TRANSLIT', $value);
}

if (\config\ConfAssistant::USE_KEYWORDS) {
$keywords = [];
foreach ($options['names'] as $keyword) {
$value = $keyword['value'];
$keywords[$keyword['lang']] = $keyword['value'];
$keywords[$keyword['lang'].'_7'] =
iconv('UTF-8', 'ASCII//TRANSLIT', $value);
}
$q ="SELECT DISTINCT realm FROM profile WHERE inst_id=? AND realm NOT LIKE '%hosted.eduroam.org'";
$realms = $handle->exec($q,'i', $queryResult->inst_id);
while ($outerId = mysqli_fetch_row(/** @scrutinizer ignore-type */ $realms)) {
if (preg_match('/.*@(.*)$/', $outerId[0], $matches)) {
$keywords[] = $matches[1];
}
}
$keywords_final = array_unique($keywords);

if (!empty($keywords_final)) {
$oneInstitutionResult['keywords'] = [];
foreach (array_keys($keywords_final) as $key) {
Expand Down

0 comments on commit 7d6c04c

Please sign in to comment.