summaryrefslogtreecommitdiff
path: root/tag2tagadd.php
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-25 15:57:29 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-25 15:57:29 +0000
commit15b91c7e661d928d8b125ec9cfbda1702319c8b4 (patch)
tree092d474c05e414bb04a8c428b8ff6cb9ccab765d /tag2tagadd.php
parent9aafe7551eb5a73739709e72465031db7a1531b4 (diff)
downloadsemanticscuttle-15b91c7e661d928d8b125ec9cfbda1702319c8b4.tar.gz
semanticscuttle-15b91c7e661d928d8b125ec9cfbda1702319c8b4.tar.bz2
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
Diffstat (limited to 'tag2tagadd.php')
-rw-r--r--tag2tagadd.php35
1 files changed, 22 insertions, 13 deletions
diff --git a/tag2tagadd.php b/tag2tagadd.php
index 935cf88..07ce3a9 100644
--- a/tag2tagadd.php
+++ b/tag2tagadd.php
@@ -20,43 +20,52 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
require_once('header.inc.php');
+
+/* Service creation: only useful services are created */
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
+/* 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['tag1']) ? define('POST_TAG1', $_POST['tag1']): define('POST_TAG1', '');
+isset($_POST['linkType']) ? define('POST_LINKTYPE', $_POST['linkType']): define('POST_LINKTYPE', '');
+isset($_POST['tag2']) ? define('POST_TAG2', $_POST['tag2']): define('POST_TAG2', '');
-
-$logged_on_user = $userservice->getCurrentUser();
+/* Managing current logged user */
+$currentObjectUser = $userservice->getCurrentObjectUser();
//permissions
-if($logged_on_user == null) {
+if(!$userservice->isLoggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
-
+/* Managing path info */
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
-if ($_POST['confirm']) {
- $tag1 = $_POST['tag1'];
- $linkType = $_POST['linkType'];
- $tag2 = $_POST['tag2'];
- if ($tag2tagservice->addLinkedTags($tag1, $tag2, $linkType, $userservice->getCurrentUserId())) {
+if (POST_CONFIRM != '') {
+ $tag1 = POST_TAG1;
+ $linkType = POST_LINKTYPE;
+ $tag2 = POST_TAG2;
+ if ($tag2tagservice->addLinkedTags($tag1, $tag2, $linkType, $currentObjectUser->getId())) {
$tplVars['msg'] = T_('Tag link created');
- header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
+ header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
} else {
$tplVars['error'] = T_('Failed to create the link');
$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: '. createURL('bookmarks', $currentObjectUser->getUsername() .'/'. $tags));
}
-$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
+$tplVars['links'] = $tag2tagservice->getLinks($currentObjectUser->getId());
$tplVars['tag1'] = $tag1;
+$tplVars['tag2'] = '';
$tplVars['subtitle'] = T_('Add Tag Link') .': '. $tag1;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag1;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];