From 15b91c7e661d928d8b125ec9cfbda1702319c8b4 Mon Sep 17 00:00:00 2001 From: mensonge Date: Tue, 25 Nov 2008 15:57:29 +0000 Subject: Major refactoring: transform user into object, define parameters used into each file, ... git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@173 b3834d28-1941-0410-a4f8-b48e95affb8f --- tagdelete.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'tagdelete.php') diff --git a/tagdelete.php b/tagdelete.php index efdca16..8c4b1af 100644 --- a/tagdelete.php +++ b/tagdelete.php @@ -20,25 +20,36 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ require_once('header.inc.php'); + +/* Service creation: only useful services are created */ $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); $templateservice = & ServiceFactory :: getServiceInstance('TemplateService'); $userservice = & ServiceFactory :: getServiceInstance('UserService'); -$logged_on_user = $userservice->getCurrentUser(); +/* Managing all possible inputs */ +isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', ''); +isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', ''); +isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', ''); + +/* Managing current logged user */ +$currentUser = $userservice->getCurrentObjectUser(); +/* Managing path info */ list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']); -if ($_POST['confirm']) { - if ($b2tservice->deleteTag($logged_on_user['uId'], $tag)) { + + +if (POST_CONFIRM) { + if ($b2tservice->deleteTag($currentUser->getId(), $tag)) { $tplVars['msg'] = T_('Tag deleted'); - header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')])); + header('Location: '. createURL('bookmarks', $currentUser->getUsername())); } else { $tplVars['error'] = T_('Failed to delete the tag'); $templateservice->loadTemplate('error.500.tpl', $tplVars); exit(); } -} elseif ($_POST['cancel']) { - header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags)); +} elseif (POST_CANCEL) { + header('Location: '. POST_REFERRER); } $tplVars['subtitle'] = T_('Delete Tag') .': '. $tag; -- cgit v1.2.3