Update User\Promote
This commit is contained in:
parent
6af755988e
commit
68156fe9b7
1 changed files with 4 additions and 12 deletions
|
@ -3,7 +3,6 @@
|
|||
namespace ForkBB\Models\User;
|
||||
|
||||
use ForkBB\Models\Action;
|
||||
use ForkBB\Models\User\Model as User;
|
||||
use ForkBB\Models\Group\Model as Group;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -18,16 +17,12 @@ class Promote extends Action
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function promote(...$args): int
|
||||
public function promote(Group ...$args): int
|
||||
{
|
||||
$count = \count($args);
|
||||
|
||||
// перемещение всех пользователей из группы 0 в группу 1
|
||||
if (
|
||||
2 == $count
|
||||
&& $args[0] instanceof Group
|
||||
&& $args[1] instanceof Group
|
||||
) {
|
||||
if (2 == $count) {
|
||||
$vars = [
|
||||
':old' => $args[0]->g_id,
|
||||
':new' => $args[1]->g_id,
|
||||
|
@ -37,10 +32,7 @@ class Promote extends Action
|
|||
WHERE group_id=?i:old';
|
||||
return $this->c->DB->exec($sql, $vars);
|
||||
// продвижение всех пользователей в группе 0
|
||||
} elseif (
|
||||
1 == $count
|
||||
&& $args[0] instanceof Group
|
||||
) {
|
||||
} elseif (1 == $count) {
|
||||
$vars = [
|
||||
':old' => $args[0]->g_id,
|
||||
':new' => $args[0]->g_promote_next_group,
|
||||
|
@ -51,7 +43,7 @@ class Promote extends Action
|
|||
WHERE group_id=?i:old AND num_posts>=?i:count';
|
||||
return $this->c->DB->exec($sql, $vars);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Unexpected parameters type, Illegal number of parameters ({$count})");
|
||||
throw new RuntimeException("Illegal number of parameters ({$count})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue