浏览代码

* Changed redirect after refusing to change user group

Visman 6 年之前
父节点
当前提交
34a35e827d
共有 1 个文件被更改,包括 15 次插入7 次删除
  1. 15 7
      app/Models/Pages/Admin/Users/Action.php

+ 15 - 7
app/Models/Pages/Admin/Users/Action.php

@@ -238,6 +238,13 @@ class Action extends Users
      */
     protected function change(array $args, $method, $profile)
     {
+        if ($profile) {
+            $user = $this->c->users->load((int) $args['ids']);
+            $link = $this->c->Router->link('EditUserProfile', ['id' => $user->id]);
+        } else {
+            $link = $this->c->Router->link('AdminUsers');
+        }
+
         if ('POST' === $method) {
             $v = $this->c->Validator->reset()
                 ->addRules([
@@ -250,8 +257,10 @@ class Action extends Users
                     'token' => $args,
                 ]);
 
+            $redirect = $this->c->Redirect;
+
             if (! $v->validation($_POST) || $v->confirm !== 1) {
-                return $this->c->Redirect->page('AdminUsers')->message('No confirm redirect');
+                return $redirect->url($link)->message('No confirm redirect');
             }
 
             $this->c->users->changeGroup($v->new_group, ...$this->userList);
@@ -259,11 +268,9 @@ class Action extends Users
             $this->c->Cache->delete('stats');       //???? перенести в manager
             $this->c->Cache->delete('forums_mark'); //???? с авто обновлением кеша
 
-            $redirect = $this->c->Redirect;
             if ($profile) {
-                $user = $this->c->users->load((int) $args['ids']);
                 if ($this->c->ProfileRules->setUser($user)->editProfile) {
-                    $redirect->page('EditUserProfile', ['id' => $user->id]);
+                    $redirect->url($link);
                 } else {
                     $redirect->page('User', ['id' => $user->id, 'name' => $user->username]);
                 }
@@ -277,7 +284,7 @@ class Action extends Users
         $this->classForm  = 'change-group';
         $this->titleForm  = \ForkBB\__('Change user group');
         $this->aCrumbs[]  = [$this->c->Router->link('AdminUsersAction', $args), \ForkBB\__('Change user group')];
-        $this->form       = $this->formChange($args, $profile);
+        $this->form       = $this->formChange($args, $profile, $link);
 
         return $this;
     }
@@ -287,10 +294,11 @@ class Action extends Users
      *
      * @param array $args
      * @param bool $profile
+     * @param string $linkCancel
      *
      * @return array
      */
-    protected function formChange(array $args, $profile)
+    protected function formChange(array $args, $profile, $linkCancel)
     {
         $yn    = [1 => \ForkBB\__('Yes'), 0 => \ForkBB\__('No')];
         $names = \implode(', ', $this->nameList($this->userList));
@@ -327,7 +335,7 @@ class Action extends Users
                 'cancel'  => [
                     'type'      => 'btn',
                     'value'     => \ForkBB\__('Cancel'),
-                    'link'      => $this->c->Router->link('AdminUsers'),
+                    'link'      => $linkCancel,
                 ],
             ],
         ];