From 5db7f0f7fb4f6b77715c5bb467193e67e82aa68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Mon, 5 Nov 2007 17:41:11 +0100 Subject: [PATCH] objectManager: Restructure some form processing code --- objectManager.php | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/objectManager.php b/objectManager.php index 4b74ac2..46894d8 100644 --- a/objectManager.php +++ b/objectManager.php @@ -75,15 +75,28 @@ $oOtherObject = new $sClass($oObject->getId()); on failure */ $sErrors = $oObject->processForm($aClean); -if(isset($aClean['sAction']) && $aClean['sAction'] == "add") - $oObject->handle_anonymous_submission(); +if(array_key_exists("sAction", $aClean)) + $sAction = $aClean['sAction']; +else + $sAction = ""; -/* Provided the necessary values are present, an object's children may be moved - without any confirmation */ -if($oObject->getId() && $aClean['sAction'] == "moveChildren" && $aClean['iNewId']) - $oObject->move_children($aClean['iNewId']); +/* Handle things that need to be done before showing any output */ +if($sAction) +{ + switch($aClean['sAction']) + { + case 'add': + $oObject->handle_anonymous_submission(); + break; -$sAction = $aClean['sAction']; + case 'moveChildren': + /* Provided the necessary values are present, an object's children may be moved + without any confirmation */ + if($oObject->getId() && $aClean['iNewId']) + $oObject->move_children($aClean['iNewId']); + break; + } +} /* If no action is specified, use a default depending on other parameters */ if(!$sAction) @@ -119,12 +132,17 @@ if($oObject->getId() && $sAction != "add") $oObject->view($_SERVER['REQUEST_URI'], $aClean); break; } -} else if ($sAction == "add") -{ - $oObject->add_entry($aClean, $sErrors); } else { - $oObject->display_table($aClean); + switch($sAction) + { + case 'add': + $oObject->add_entry($aClean, $sErrors); + break; + + default: + $oObject->display_table($aClean); + } } apidb_footer();