* Changed the behavior of the models for the correct work of the moderator

This commit is contained in:
Visman 2018-11-05 18:46:39 +07:00
parent cf7efe963a
commit 420f9e6191
8 changed files with 21 additions and 9 deletions

View file

@ -17,7 +17,7 @@ class Stat extends Users
*/
public function view(array $args, $method)
{
$stat = $this->c->posts->userStat($args['id']);
$stat = $this->c->posts->userStat((int) $args['id']);
$number = \count($stat);
$page = isset($args['page']) ? (int) $args['page'] : 1;

View file

@ -147,7 +147,9 @@ class Auth extends Page
public function vLoginProcess(Validator $v, $password)
{
if (! empty($v->getErrors())) {
} elseif (! ($user = $this->c->users->load($v->username, 'username')) instanceof User) {
} elseif (! ($user = $this->c->users->load($v->username, 'username')) instanceof User
|| $user->isGuest
) {
$v->addError('Wrong user/pass');
} elseif ($user->isUnverified) {
$v->addError('Account is not activated', 'w');
@ -308,6 +310,7 @@ class Auth extends Page
{
if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['email'] . $args['key']))
|| ! ($user = $this->c->users->load($args['email'], 'email')) instanceof User
|| $user->isGuest
|| empty($user->activate_string)
|| ! \hash_equals($user->activate_string, $args['key'])
) {

View file

@ -19,7 +19,10 @@ abstract class Profile extends Page
{
$this->curUser = $this->c->users->load((int) $id);
if (! $this->curUser instanceof User || ($this->curUser->isUnverified && ! $this->user->isAdmMod)) {
if (! $this->curUser instanceof User
|| $this->curUser->isGuest
|| ($this->curUser->isUnverified && ! $this->user->isAdmMod)
) {
return false;
}

View file

@ -241,6 +241,7 @@ class Register extends Page
{
if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
|| ! ($user = $this->c->users->load($args['id'])) instanceof User
|| $user->isGuest
|| empty($user->activate_string)
|| ! \hash_equals($user->activate_string, $args['key'])
) {

View file

@ -483,7 +483,7 @@ class Search extends Page
break;
}
$user = $this->c->users->load($uid);
if (! $user instanceof User) {
if (! $user instanceof User || $user->isGuest) {
break;
}
if ($asTopicsList) {

View file

@ -43,7 +43,7 @@ class Model extends DataModel
*/
protected function getuser() //????
{
$user = $this->c->users->get($this->poster_id);
$user = $this->c->users->load($this->poster_id);
if (! $user instanceof User) {
throw new RuntimeException('No user data in post number ' . $this->id);

View file

@ -4,6 +4,8 @@ namespace ForkBB\Models\User;
use ForkBB\Models\Action;
use ForkBB\Models\User\Model as User;
use ForkBB\Models\Forum\Model as Forum;
use ForkBB\Models\Forum\Manager as ForumManager;
use InvalidArgumentException;
use RuntimeException;
@ -41,9 +43,12 @@ class Delete extends Action
}
if (! empty($moderators)) {
$root = $this->c->forums->get(0); //???? вызов от группы админов?
$forums = new ForumManager($this->c);
$forums->init($this->c->groups->get($this->c->GROUP_ADMIN));
$root = $forums->get(0);
if ($root instanceof Forum) {
foreach ($this->c->forums->depthList($root, 0) as $forum) {
foreach ($root->descendants as $forum) {
$forum->modDelete(...$moderators);
$this->c->forums->update($forum);
}

View file

@ -59,8 +59,8 @@ class Load extends Action
return $result;
} else {
$count = \count($data);
// число найденных пользователей отлично от одного или гость
if (1 !== $count || 1 === $data[0]['id']) {
// число найденных пользователей отлично от одного
if (1 !== $count) {
return $count;
}
return $this->manager->create($data[0]);