Admin: query string is now preserved on redirect to login
authorDan
Fri, 17 Jul 2009 20:28:24 -0400
changeset 1067 4058c844ee38
parent 1066 bead71f28f63
child 1068 4bcefa85649c
Admin: query string is now preserved on redirect to login
plugins/SpecialAdmin.php
--- a/plugins/SpecialAdmin.php	Fri Jul 17 20:23:48 2009 -0400
+++ b/plugins/SpecialAdmin.php	Fri Jul 17 20:28:24 2009 -0400
@@ -2055,7 +2055,12 @@
   
   if ( $session->auth_level < USER_LEVEL_ADMIN )
   {
-    redirect(makeUrlNS('Special', 'Login/'.$paths->page, 'level='.USER_LEVEL_ADMIN), 'Not authorized', 'You need an authorization level of '.USER_LEVEL_ADMIN.' to use this page, your auth level is: ' . $session->auth_level, 0);
+    $query_string = 'level=' . USER_LEVEL_ADMIN;
+    if ( !empty($_SERVER['QUERY_STRING']) )
+    {
+      $query_string .= '&' . trim(preg_replace('/(?:&|^)title=.+?(?:&|$)/', '&', $_SERVER['QUERY_STRING']), '&');
+    }
+    redirect(makeUrlNS('Special', 'Login/'.$paths->page, $query_string), 'Not authorized', 'You need an authorization level of '.USER_LEVEL_ADMIN.' to use this page, your auth level is: ' . $session->auth_level, 0);
     exit;
   }
   else