فهرست منبع

Update Core\Router

Now, to automatically calculate token, it does not need to be passed in arguments with a value equal to null.
Visman 4 سال پیش
والد
کامیت
d303f1a002

+ 2 - 2
app/Core/Router.php

@@ -144,15 +144,15 @@ class Router
             return $result . $data . $anchor;
         }
 
+        list($link, $names) = $data;
         // автоматическое вычисление токена
         if (
-            \array_key_exists('token', $args)
+            isset($names['token'])
             && ! isset($args['token'])
         ) {
             $args['token'] = $this->csrf->create($marker, $args);
         }
 
-        list($link, $names) = $data;
         $data = [];
         // перечисление имен переменных для построения ссылки
         foreach ($names as $name => $need) {

+ 8 - 10
app/Models/Forum/Model.php

@@ -146,7 +146,7 @@ class Model extends DataModel
                 'SearchAction',
                 [
                     'action' => 'new',
-                    'forum' => $this->id,
+                    'forum'  => $this->id,
                 ]
             );
         }
@@ -188,9 +188,9 @@ class Model extends DataModel
     protected function getlinkMarkRead(): string
     {
         return $this->c->Router->link(
-            'MarkRead', [
-                'id'    => $this->id,
-                'token' => null,
+            'MarkRead',
+            [
+                'id' => $this->id,
             ]
         );
     }
@@ -206,9 +206,8 @@ class Model extends DataModel
             return $this->c->Router->link(
                 'ForumSubscription',
                 [
-                    'fid'   => $this->id,
-                    'type'  => 'subscribe',
-                    'token' => null,
+                    'fid'  => $this->id,
+                    'type' => 'subscribe',
                 ]
             );
         }
@@ -225,9 +224,8 @@ class Model extends DataModel
             return $this->c->Router->link(
                 'ForumSubscription',
                 [
-                    'fid'   => $this->id,
-                    'type'  => 'unsubscribe',
-                    'token' => null,
+                    'fid'  => $this->id,
+                    'type' => 'unsubscribe',
                 ]
             );
         }

+ 1 - 6
app/Models/Page.php

@@ -225,12 +225,7 @@ abstract class Page extends Model
             }
 
             $navUser['logout'] = [
-                $r->link(
-                    'Logout',
-                    [
-                        'token' => null,
-                    ]
-                ),
+                $r->link('Logout'),
                 'Logout',
                 'Logout',
             ];

+ 1 - 2
app/Models/Pages/Admin/Bans.php

@@ -505,8 +505,7 @@ class Bans extends Admin
                 'link'    => $this->c->Router->link(
                     'AdminBansDelete',
                     [
-                        'id'    => $ban['id'],
-                        'token' => null,
+                        'id' => $ban['id'],
                     ]
                 ),
             ];

+ 2 - 4
app/Models/Pages/Admin/Parser/BBCode.php

@@ -182,8 +182,7 @@ class BBCode extends Parser
                 'link'      => $this->c->Router->link(
                     'AdminBBCodeDelete',
                     [
-                        'id'    => $id,
-                        'token' => null,
+                        'id' => $id,
                     ]
                 ),
                 'disabled'  => 1 !== $tagData['bb_delete'],
@@ -411,8 +410,7 @@ class BBCode extends Parser
                     'link'  => $this->c->Router->link(
                         'AdminBBCodeDefault',
                         [
-                            'id'    => $id,
-                            'token' => null,
+                            'id' => $id,
                         ]
                     ),
                 ],

+ 2 - 4
app/Models/Pages/Admin/Parser/Smilies.php

@@ -204,8 +204,7 @@ class Smilies extends Parser
                 'link'      => $this->c->Router->link(
                     'AdminSmiliesDelete',
                     [
-                        'name'  => $id,
-                        'token' => null,
+                        'name' => $id,
                     ]
                 ),
             ];
@@ -291,8 +290,7 @@ class Smilies extends Parser
                 'href'    => $this->c->Router->link(
                     'AdminSmiliesDelete',
                     [
-                        'name'  => $name,
-                        'token' => null,
+                        'name' => $name,
                     ]
                 ),
             ];

+ 1 - 2
app/Models/Pages/Index.php

@@ -61,8 +61,7 @@ class Index extends Page
             $this->linkMarkRead = $this->c->Router->link(
                 'MarkRead',
                 [
-                    'id'    => 0,
-                    'token' => null,
+                    'id' => 0,
                 ]
             );
         }

+ 2 - 4
app/Models/Pages/Profile.php

@@ -94,9 +94,8 @@ abstract class Profile extends Page
                     $this->c->Router->link(
                         'AdminBansDelete',
                         [
-                            'id'    => $id,
-                            'uid'   => $this->curUser->id,
-                            'token' => null,
+                            'id'  => $id,
+                            'uid' => $this->curUser->id,
                         ]
                     ),
                     __('Unban user'),
@@ -174,7 +173,6 @@ abstract class Profile extends Page
             [
                 'action' => 'change_group',
                 'ids'    => $this->curUser->id,
-                'token'  => null,
             ]
         );
     }

+ 1 - 2
app/Models/Report/Model.php

@@ -125,8 +125,7 @@ class Model extends DataModel
             return $this->c->Router->link(
                 'AdminReportsZap',
                 [
-                    'id'    => $this->id,
-                    'token' => null,
+                    'id' => $this->id,
                 ]
             );
         } else {

+ 4 - 6
app/Models/Topic/Model.php

@@ -168,9 +168,8 @@ class Model extends DataModel
         return $this->c->Router->link(
             'TopicSubscription',
             [
-                'tid'   => $this->id,
-                'type'  => 'subscribe',
-                'token' => null,
+                'tid'  => $this->id,
+                'type' => 'subscribe',
             ]
         );
     }
@@ -183,9 +182,8 @@ class Model extends DataModel
         return $this->c->Router->link(
             'TopicSubscription',
             [
-                'tid'   => $this->id,
-                'type'  => 'unsubscribe',
-                'token' => null,
+                'tid'  => $this->id,
+                'type' => 'unsubscribe',
             ]
         );
     }

+ 2 - 3
app/Models/User/Model.php

@@ -348,9 +348,8 @@ class Model extends DataModel
             return $this->c->Router->link(
                 'AdminUserPromote',
                 [
-                    'uid'   => $post->user->id,
-                    'pid'   => $post->id,
-                    'token' => null,
+                    'uid' => $post->user->id,
+                    'pid' => $post->id,
                 ]
             );
         } else {