Removed HasRankInterface.

This commit is contained in:
flash 2023-07-29 17:31:43 +00:00
parent 61daa21d3a
commit e3c0ae662e
4 changed files with 3 additions and 16 deletions

View file

@ -39,7 +39,7 @@ try {
return;
}
$canEdit = $canManageUsers && $currentUser->hasAuthorityOver($userInfo);
$canEdit = $canManageUsers && ($currentUser->isSuper() || $currentUser->getId() === $userInfo->getId() || $currentUser->getRank() > $userInfo->getRank());
$canEditPerms = $canEdit && $canManagePerms;
$permissions = $canEditPerms ? manage_perms_list(perms_get_user_raw($userId)) : [];

View file

@ -47,7 +47,7 @@ $userPerms = perms_get_user($currentUserId)[MSZ_PERMS_USER];
$canManageWarnings = perms_check($userPerms, MSZ_PERM_USER_MANAGE_WARNINGS);
$canEdit = !$viewingAsGuest && ((!$isBanned && $viewingOwnProfile) || $currentUser->isSuper() || (
perms_check($userPerms, MSZ_PERM_USER_MANAGE_USERS)
&& $currentUser->hasAuthorityOver($profileUser)
&& ($currentUser->getId() === $profileUser->getId() || $currentUser->getRank() > $profileUser->getRank())
));
if($isEditing) {

View file

@ -1,7 +0,0 @@
<?php
namespace Misuzu;
interface HasRankInterface {
public function getRank(): int;
public function hasAuthorityOver(self $other): bool;
}

View file

@ -9,7 +9,6 @@ use Index\XString;
use Index\Colour\Colour;
use Misuzu\DateCheck;
use Misuzu\DB;
use Misuzu\HasRankInterface;
use Misuzu\Memoizer;
use Misuzu\Pagination;
use Misuzu\TOTP;
@ -26,7 +25,7 @@ use Misuzu\Users\Assets\UserBackgroundAsset;
// - Move background settings and about shit to a separate users_profiles table (should birthdate be profile specific?)
// - Create a users_stats table containing static counts for things like followers, followings, topics, posts, etc.
class User implements HasRankInterface {
class User {
public const NAME_MIN_LENGTH = 3; // Minimum username length
public const NAME_MAX_LENGTH = 16; // Maximum username length, unless your name is Flappyzor(WorldwideOnline2018through2019through2020)
public const NAME_REGEX = '[A-Za-z0-9-_]+'; // Username character constraint
@ -173,11 +172,6 @@ class User implements HasRankInterface {
)->bind('user', $this->getId())->fetchColumn();
return $this->userRank;
}
public function hasAuthorityOver(HasRankInterface $other): bool {
return $this->isSuper()
|| $other instanceof self && $other->getId() === $this->getId()
|| $this->getRank() > $other->getRank();
}
public function getDisplayRoleId(): int {
return $this->display_role < 1 ? -1 : $this->display_role;