Promote.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * This file is part of the ForkBB <https://github.com/forkbb>.
  4. *
  5. * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
  6. * @license The MIT License (MIT)
  7. */
  8. declare(strict_types=1);
  9. namespace ForkBB\Models\Pages\Admin\Users;
  10. use ForkBB\Models\Page;
  11. use ForkBB\Models\Pages\Admin\Users;
  12. class Promote extends Users
  13. {
  14. /**
  15. * Продвигает пользователя
  16. */
  17. public function promote(array $args, string $method): Page
  18. {
  19. if (! $this->c->Csrf->verify($args['token'], 'AdminUserPromote', $args)) {
  20. return $this->c->Message->message($this->c->Csrf->getError());
  21. }
  22. $user = $this->c->users->load($args['uid']);
  23. if (0 < $user->g_promote_next_group * $user->g_promote_min_posts) {
  24. $user->group_id = $user->g_promote_next_group;
  25. $this->c->users->update($user);
  26. }
  27. return $this->c->Redirect->page('ViewPost', ['id' => $args['pid']])->message('User promote redirect');
  28. }
  29. }