resolved todo & improved auth level methods

This commit is contained in:
Steffen Schröder 2014-04-30 02:14:12 +02:00
parent 5c4c3149ed
commit ba41cb3456
2 changed files with 31 additions and 35 deletions

View File

@ -157,7 +157,6 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
$rightLabel->setX($x + 13.9); $rightLabel->setX($x + 13.9);
$rightLabel->setTextSize(0.8); $rightLabel->setTextSize(0.8);
$rightLabel->setZ(10); $rightLabel->setZ(10);
//FIXME, getAuthLevelAbbrev fails
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($admin)); $rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($admin));
$description = $this->maniaControl->authenticationManager->getAuthLevelName($admin) . " " . $admin->nickname; $description = $this->maniaControl->authenticationManager->getAuthLevelName($admin) . " " . $admin->nickname;
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description); $rightLabel->addTooltipLabelFeature($descriptionLabel, $description);

View File

@ -238,17 +238,15 @@ class AuthenticationManager implements CallbackListener {
*/ */
public static function getAuthLevelName($authLevelInt) { public static function getAuthLevelName($authLevelInt) {
$authLevelInt = self::getAuthLevelInt($authLevelInt); $authLevelInt = self::getAuthLevelInt($authLevelInt);
if ($authLevelInt === self::AUTH_LEVEL_MASTERADMIN) { switch ($authLevelInt) {
return self::AUTH_NAME_MASTERADMIN; case self::AUTH_LEVEL_MASTERADMIN:
} return self::AUTH_NAME_MASTERADMIN;
if ($authLevelInt === self::AUTH_LEVEL_SUPERADMIN) { case self::AUTH_LEVEL_SUPERADMIN:
return self::AUTH_NAME_SUPERADMIN; return self::AUTH_NAME_SUPERADMIN;
} case self::AUTH_LEVEL_ADMIN:
if ($authLevelInt === self::AUTH_LEVEL_ADMIN) { return self::AUTH_NAME_ADMIN;
return self::AUTH_NAME_ADMIN; case self::AUTH_LEVEL_MODERATOR:
} return self::AUTH_NAME_MODERATOR;
if ($authLevelInt === self::AUTH_LEVEL_MODERATOR) {
return self::AUTH_NAME_MODERATOR;
} }
return self::AUTH_NAME_PLAYER; return self::AUTH_NAME_PLAYER;
} }
@ -261,17 +259,15 @@ class AuthenticationManager implements CallbackListener {
*/ */
public static function getAuthLevelAbbreviation($authLevelInt) { public static function getAuthLevelAbbreviation($authLevelInt) {
$authLevelInt = self::getAuthLevelInt($authLevelInt); $authLevelInt = self::getAuthLevelInt($authLevelInt);
if ($authLevelInt === self::AUTH_LEVEL_MASTERADMIN) { switch ($authLevelInt) {
return 'MA'; case self::AUTH_LEVEL_MASTERADMIN:
} return 'MA';
if ($authLevelInt === self::AUTH_LEVEL_SUPERADMIN) { case self::AUTH_LEVEL_SUPERADMIN:
return 'SA'; return 'SA';
} case self::AUTH_LEVEL_ADMIN:
if ($authLevelInt === self::AUTH_LEVEL_ADMIN) { return 'AD';
return 'AD'; case self::AUTH_LEVEL_MODERATOR:
} return 'MOD';
if ($authLevelInt === self::AUTH_LEVEL_MODERATOR) {
return 'MOD';
} }
return ''; return '';
} }
@ -283,18 +279,16 @@ class AuthenticationManager implements CallbackListener {
* @return int * @return int
*/ */
public static function getAuthLevel($authLevelName) { public static function getAuthLevel($authLevelName) {
$authLevelName = strtolower($authLevelName); $authLevelName = (string) $authLevelName;
if ($authLevelName === self::AUTH_NAME_MASTERADMIN) { switch ($authLevelName) {
return self::AUTH_LEVEL_MASTERADMIN; case self::AUTH_NAME_MASTERADMIN:
} return self::AUTH_LEVEL_MASTERADMIN;
if ($authLevelName === self::AUTH_NAME_SUPERADMIN) { case self::AUTH_NAME_SUPERADMIN:
return self::AUTH_LEVEL_SUPERADMIN; return self::AUTH_LEVEL_SUPERADMIN;
} case self::AUTH_NAME_ADMIN:
if ($authLevelName === self::AUTH_NAME_ADMIN) { return self::AUTH_LEVEL_ADMIN;
return self::AUTH_LEVEL_ADMIN; case self::AUTH_NAME_MODERATOR:
} return self::AUTH_LEVEL_MODERATOR;
if ($authLevelName === self::AUTH_NAME_MODERATOR) {
return self::AUTH_LEVEL_MODERATOR;
} }
return self::AUTH_LEVEL_PLAYER; return self::AUTH_LEVEL_PLAYER;
} }
@ -309,6 +303,9 @@ class AuthenticationManager implements CallbackListener {
if (is_object($authLevelParam) && property_exists($authLevelParam, 'authLevel')) { if (is_object($authLevelParam) && property_exists($authLevelParam, 'authLevel')) {
return (int) $authLevelParam->authLevel; return (int) $authLevelParam->authLevel;
} }
if (is_string($authLevelParam)) {
return self::getAuthLevel($authLevelParam);
}
return (int) $authLevelParam; return (int) $authLevelParam;
} }
} }