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->setTextSize(0.8);
$rightLabel->setZ(10);
//FIXME, getAuthLevelAbbrev fails
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($admin));
$description = $this->maniaControl->authenticationManager->getAuthLevelName($admin) . " " . $admin->nickname;
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);

View File

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