forked from GNUsocial/gnu-social
[UI][TWIG] Fixing note actions placement and size, more descriptive rules
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
// }}}
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
/**
|
||||
* User role enum
|
||||
*
|
||||
@@ -29,33 +27,17 @@ namespace App\Core;
|
||||
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
abstract class UserRoles
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use App\Util\Bitmap;
|
||||
|
||||
abstract class UserRoles extends Bitmap
|
||||
{
|
||||
public const ADMIN = 1;
|
||||
public const MODERATOR = 2;
|
||||
public const USER = 4;
|
||||
public const BOT = 8;
|
||||
|
||||
public static $consts = null;
|
||||
|
||||
public static function bitmapToStrings(int $r): array
|
||||
{
|
||||
$roles = [];
|
||||
if (self::$consts == null) {
|
||||
self::$consts = (new \ReflectionClass(__CLASS__))->getConstants();
|
||||
}
|
||||
|
||||
foreach (self::$consts as $c => $v) {
|
||||
if (($r & $v) !== 0) {
|
||||
$r -= $v;
|
||||
$roles[] = "ROLE_{$c}";
|
||||
}
|
||||
}
|
||||
|
||||
if ($r != 0) {
|
||||
Log::error('User roles bitmap to array failed');
|
||||
}
|
||||
|
||||
return $roles;
|
||||
}
|
||||
public const PREFIX = 'ROLE_';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user