Проверка на модераторство прямиком из класса User.

This commit is contained in:
Ivor Barhansky 2023-10-16 13:58:02 +03:00
parent 4113c4a1da
commit 2abd435798

View File

@ -37,19 +37,7 @@ if ($u->info['online'] < time() - 60) {
$filter->setOnline($u->info['online'], $u->info['id']); $filter->setOnline($u->info['online'], $u->info['id']);
} }
function isModerOrAdmin($uinfo): bool if (isset($_POST['delMsg']) && $u->isModerator()) {
{
return $uinfo['admin'] > 0 ||
(
$uinfo['align'] > 1 &&
$uinfo['align'] < 2) ||
(
$uinfo['align'] > 3 &&
$uinfo['align'] < 4
);
}
if (isset($_POST['delMsg']) && isModerOrAdmin($u->info)) {
$delmsgid = (int)$_POST['delMsg']; $delmsgid = (int)$_POST['delMsg'];
if ($delmsgid > 0) { if ($delmsgid > 0) {
Db::sql('update chat set `delete` = ? where id = ?', [$u->info['id'], $delmsgid]); Db::sql('update chat set `delete` = ? where id = ?', [$u->info['id'], $delmsgid]);
@ -687,7 +675,7 @@ while ($pl = mysql_fetch_array($sp)) {
$see = 1; $see = 1;
if ($pl['type'] == 8 && isModerOrAdmin($u->info)) { if ($pl['type'] == 8 && $u->isModerator()) {
$see = 0; $see = 0;
} }
@ -713,7 +701,7 @@ while ($pl = mysql_fetch_array($sp)) {
$pl['type'] == 5 || $pl['type'] == 5 ||
$pl['type'] == 6 || $pl['type'] == 6 ||
( (
$pl['type'] == 8 && isModerOrAdmin($u->info) $pl['type'] == 8 && $u->isModerator()
) )
) && ) &&
( (
@ -820,7 +808,7 @@ while ($pl = mysql_fetch_array($sp)) {
$modr = 0; $modr = 0;
if (isModerOrAdmin($u->info)) { if ($u->isModerator()) {
$modr = 1; $modr = 1;
} }