diff --git a/TracyDebugger.module.php b/TracyDebugger.module.php index 384f50d..d57c650 100644 --- a/TracyDebugger.module.php +++ b/TracyDebugger.module.php @@ -27,7 +27,7 @@ public static function getModuleInfo() { 'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__), 'author' => 'Adrian Jones', 'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/', - 'version' => '4.26.36', + 'version' => '4.26.37', 'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first 'singular' => true, 'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4', @@ -1801,6 +1801,12 @@ public function ready() { $pass = new Password(); $challenge = $pass->randomBase64String(32); $this->wire('session')->tracyUserSwitcherId = $challenge; + + $configData = $this->wire('modules')->getModuleConfigData("TracyDebugger"); + $this->data['originalUserSwitcher'][$this->wire('session')->tracyUserSwitcherId] = $this->wire('user')->name; + $configData['originalUserSwitcher'] = $this->data['originalUserSwitcher']; + $this->wire('modules')->saveModuleConfigData($this, $configData); + } // save session ID and expiry time in module config settings $configData = $this->wire('modules')->getModuleConfigData("TracyDebugger"); @@ -1831,6 +1837,18 @@ public function ready() { $this->wire('modules')->saveModuleConfigData($this, $configData); $this->wire('session')->redirect($this->httpReferer); } + // if session not expired, switch to original user + elseif($this->wire('input')->post->revertOriginalUserSwitcher && $this->wire('session')->CSRF->validate()) { + if(isset($this->data['userSwitchSession'][$this->wire('session')->tracyUserSwitcherId]) && $this->data['userSwitchSession'][$this->wire('session')->tracyUserSwitcherId] > time() && $this->wire('session')->tracyUserSwitcherId) { + // if session variable exists, grab it and add to the new session after logging out + // and forceLogin the original user + $tracyUserSwitcherId = $this->wire('session')->tracyUserSwitcherId; + if($this->wire('user')->isLoggedin()) $this->wire('session')->logout(); + $this->wire('session')->forceLogin($this->data['originalUserSwitcher'][$tracyUserSwitcherId]); + $this->wire('session')->tracyUserSwitcherId = $tracyUserSwitcherId; + } + $this->wire('session')->redirect($this->httpReferer); + } // if session not expired, switch to requested user elseif($this->wire('input')->post->userSwitcher && $this->wire('session')->CSRF->validate()) { if(isset($this->data['userSwitchSession'][$this->wire('session')->tracyUserSwitcherId]) && $this->data['userSwitchSession'][$this->wire('session')->tracyUserSwitcherId] > time() && $this->wire('session')->tracyUserSwitcherId) { @@ -1838,7 +1856,7 @@ public function ready() { // and forceLogin the new switched user $tracyUserSwitcherId = $this->wire('session')->tracyUserSwitcherId; if($this->wire('user')->isLoggedin()) $this->wire('session')->logout(); - $user = $this->wire('session')->forceLogin($this->wire('input')->post->userSwitcher); + $this->wire('session')->forceLogin($this->wire('input')->post->userSwitcher); $this->wire('session')->tracyUserSwitcherId = $tracyUserSwitcherId; } $this->wire('session')->redirect($this->httpReferer); diff --git a/panels/RequestInfoPanel.php b/panels/RequestInfoPanel.php index a714d95..4122db8 100644 --- a/panels/RequestInfoPanel.php +++ b/panels/RequestInfoPanel.php @@ -439,7 +439,7 @@ public function getPanel() { process - '.$this->wire('page')->process.' + '.(isset($this->wire('page')->process) ? $this->wire('page')->process : $this->wire('process')).' class @@ -511,15 +511,19 @@ public function getPanel() { '.date("Y-m-d H:i:s", $p->modified).' - Hidden (status) + Hidden '. ($p->isHidden() ? "✔" : "✘") .' - Unpublished (status) + Unpublished '. ($p->isUnpublished() ? "✔" : "✘") .' - Locked (status) + Trashed + '. ($p->isTrash() ? "✔" : "✘") .' + + + Locked '. ($p->is(Page::statusLocked) ? "✔" : "✘") .' '; diff --git a/panels/UserSwitcherPanel.php b/panels/UserSwitcherPanel.php index acbd66b..4d95084 100644 --- a/panels/UserSwitcherPanel.php +++ b/panels/UserSwitcherPanel.php @@ -48,7 +48,7 @@ public function getPanel() { $out = '

' . $this->icon . ' User Switcher

-
+

' . $this->wire('user')->name . '

@@ -81,7 +81,7 @@ public function getPanel() { if(\TracyDebugger::$allowedSuperuser || $remainingSessionLength > 0) { $out .= ' -

'; +

+ + '; } if($this->wire('user')->isLoggedin()) $out .= ' '; + if($this->switchedUser && \TracyDebugger::getDataValue('originalUserSwitcher')) $out .= ' '; if($this->switchedUser) $out .= ''; $out .= '