From e40aec5d8404f00601c42ff65a0d5b132b193c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Sat, 8 Aug 2009 23:09:32 +0200 Subject: [PATCH] objectManager: Avoid losing data when session times out while filling out a form --- include/objectManager.php | 18 ++++++++++++++++-- objectManager.php | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/objectManager.php b/include/objectManager.php index 593c0d2..182b373 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -406,8 +406,10 @@ class ObjectManager } /* Only show the edit screen if the user has sufficient rights */ - if(!$oObject->canEdit()) + if(!$oObject->canEdit() && !getInput('sSubmit', $aClean)) $this->error_exit('You do not have sufficient privileges to edit this entry'); + else if(!$oObject->canEdit()) + $this->show_form_help_session_timeout(); /* Display errors, if any, and fetch form data */ if($this->displayErrors($sErrors)) @@ -1214,12 +1216,24 @@ class ObjectManager echo ''; } - public function handle_anonymous_submission() + public function show_form_help_session_timeout() + { + $this->error_exit("Your session has timed out. Log in and then refresh thise page."); + } + + public function handle_anonymous_submission($aClean) { $oObject = new $this->sClass(); if($oObject->allowAnonymousSubmissions() || $_SESSION['current']->isLoggedIn()) return; + // Allow the user to continue filling out a form + if(getInput('sSubmit', $aClean)) + { + apidb_header($this->get_title(getInput($sAction, $aClean))); + $this->show_form_help_session_timeout(); + } + login_form(); exit; } diff --git a/objectManager.php b/objectManager.php index aa1db6d..65b867d 100644 --- a/objectManager.php +++ b/objectManager.php @@ -82,7 +82,7 @@ if($sAction) switch($aClean['sAction']) { case 'add': - $oObject->handle_anonymous_submission(); + $oObject->handle_anonymous_submission($aClean); break; case 'changeParent':