Skip to content
Snippets Groups Projects
Commit eb2684cb authored by Olav Morken's avatar Olav Morken
Browse files

discopower: Fix sorting when missing name.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2427 44740490-163a-0410-bde0-09ae8108e29a
parent f20fbcd1
No related branches found
No related tags found
No related merge requests found
...@@ -44,16 +44,32 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { ...@@ -44,16 +44,32 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
protected function log($message) { protected function log($message) {
SimpleSAML_Logger::info('PowerIdPDisco.' . $this->instance . ': ' . $message); SimpleSAML_Logger::info('PowerIdPDisco.' . $this->instance . ': ' . $message);
} }
public static function mcmp($a, $b) { /**
# echo 'aort'; exit; * Compare two entities.
if ($a['name']['en'] == $b['name']['en']) { *
return 0; * This function is used to sort the entity list. It sorts based on english name,
} * and will always put IdP's with names configured before those with only an
return ($a['name']['en'] < $b['name']['en']) ? -1 : 1; * entityID.
*
* @param array $a The metadata of the first entity.
* @param array $b The metadata of the second entity.
* @return int How $a compares to $b.
*/
public static function mcmp(array $a, array $b) {
if (isset($a['name']['en']) && isset($b['name']['en'])) {
return strcasecmp($a['name']['en'], $b['name']['en']);
} elseif (isset($a['name']['en'])) {
return -1; /* Place name before entity ID. */
} elseif (isset($b['name']['en'])) {
return 1; /* Place entity ID after name. */
} else {
return strcasecmp($a['entityid'], $b['entityid']);
}
} }
/* /*
* This function will structure the idp list in a hierarchy based upon the tags. * This function will structure the idp list in a hierarchy based upon the tags.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment