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 --- tagrename.php | 102 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 45 deletions(-) (limited to 'tagrename.php') diff --git a/tagrename.php b/tagrename.php index 29b44fb..3dde296 100644 --- a/tagrename.php +++ b/tagrename.php @@ -1,68 +1,80 @@ getCurrentObjectUser(); + +/* Managing path info */ list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']); //$tag = isset($_GET['query']) ? $_GET['query'] : NULL; $template = 'tagrename.tpl'; -if ($_POST['confirm']) { - if (isset($_POST['old']) && trim($_POST['old']) != '') - $old = trim($_REQUEST['old']); - else - $old = NULL; +if (POST_CONFIRM) { + if (trim(POST_OLD) != '') { + $old = trim(POST_OLD); + } else { + $old = NULL; + } - if (isset($_POST['new']) && trim($_POST['new']) != '') - $new = trim($_POST['new']); - else - $new = NULL; + if (trim(POST_NEW) != '') { + $new = trim(POST_NEW); + } else { + $new = NULL; + } - if ( - !is_null($old) && - !is_null($new) && - $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) && - $b2tservice->renameTag($userservice->getCurrentUserId(), $old, $new) && - $tag2tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) - ) { - $tplVars['msg'] = T_('Tag renamed'); - $logged_on_user = $userservice->getCurrentUser(); - header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')])); - } else { - $tplVars['error'] = T_('Failed to rename the tag'); - $template = 'error.500.tpl'; - } -} elseif ($_POST['cancel']) { - $logged_on_user = $userservice->getCurrentUser(); - header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags)); + if ( + !is_null($old) && + !is_null($new) && + $tagservice->renameTag($currentUser->getId(), $old, $new) && + $b2tservice->renameTag($currentUser->getId(), $old, $new) && + $tag2tagservice->renameTag($currentUser->getId(), $old, $new) + ) { + $tplVars['msg'] = T_('Tag renamed'); + header('Location: '. createURL('bookmarks', $currentUser->getUsername())); + } else { + $tplVars['error'] = T_('Failed to rename the tag'); + $template = 'error.500.tpl'; + } +} elseif (POST_CANCEL) { + header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags)); } else { - $tplVars['subtitle'] = T_('Rename Tag') .': '. $tag; - $tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag; - $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; - $tplVars['old'] = $tag; + $tplVars['subtitle'] = T_('Rename Tag') .': '. $tag; + $tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag; + $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; + $tplVars['old'] = $tag; } $templateservice->loadTemplate($template, $tplVars); ?> -- cgit v1.2.3