summaryrefslogtreecommitdiff
path: root/edit.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 /edit.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 'edit.php')
-rw-r--r--edit.php59
1 files changed, 40 insertions, 19 deletions
diff --git a/edit.php b/edit.php
index 94af87c..3984c7d 100644
--- a/edit.php
+++ b/edit.php
@@ -21,10 +21,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require_once('header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
+/* Managing all possible inputs */
+isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
+isset($_POST['delete']) ? define('POST_DELETE', $_POST['delete']): define('POST_DELETE', '');
+
+isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
+isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
+isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
+isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
+isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
+
+isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', '');
+isset($_POST['popup']) ? define('POST_POPUP', $_POST['popup']): define('POST_POPUP', '');
+isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
+
+/* Managing current logged user */
+$currentObjectUser = $userservice->getCurrentObjectUser();
+
+
// Header variables
$tplVars['subtitle'] = T_('Edit Bookmark');
$tplVars['loadjs'] = true;
@@ -39,39 +58,41 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
- } else if ($_POST['submitted']) {
- if (!$_POST['title'] || !$_POST['address']) {
+ } else if (POST_SUBMITTED != '') {
+ if (!POST_TITLE || !POST_ADDRESS) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
} else {
// Update bookmark
$bId = intval($bookmark);
- $address = trim($_POST['address']);
- $title = trim($_POST['title']);
- $description = trim($_POST['description']);
- $status = intval($_POST['status']);
- $tags = trim($_POST['tags']);
- $logged_on_user = $userservice->getCurrentUser();
+ $address = trim(POST_ADDRESS);
+ $title = trim(POST_TITLE);
+ $description = trim(POST_DESCRIPTION);
+ $status = intval(POST_STATUS);
+ $tags = trim(POST_TAGS);
+
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $status, $tags)) {
$tplvars['error'] = T_('Error while saving your bookmark');
} else {
- if (isset($_POST['popup'])) {
- $tplVars['msg'] = (isset($_POST['popup'])) ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
- } elseif (isset($_POST['referrer'])) {
- header('Location: '. $_POST['referrer']);
+ if (POST_POPUP != '') {
+ //$tplVars['msg'] = (POST_POPUP != '') ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
+ $tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
+ } elseif (POST_REFERRER != '') {
+ $tplVars['msg'] = T_('Bookmark saved');
+ header('Location: '. POST_REFERRER);
} else {
- header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
+ $tplVars['msg'] = T_('Bookmark saved');
+ header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
}
}
}
} else {
- if ($_POST['delete']) {
+ if (POST_DELETE != '') {
// Delete bookmark
if ($bookmarkservice->deleteBookmark($bookmark)) {
- $logged_on_user = $userservice->getCurrentUser();
- if (isset($_POST['referrer'])) {
- header('Location: '. $_POST['referrer']);
+ if (POST_REFERRER != '') {
+ header('Location: '. POST_REFERRER);
} else {
- header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
+ header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
}
exit();
} else {
@@ -82,7 +103,7 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
}
}
- $tplVars['popup'] = (isset($_GET['popup'])) ? $_GET['popup'] : null;
+ $tplVars['popup'] = (GET_POPUP) ? GET_POPUP : null;
$tplVars['row'] =& $row;
$tplVars['formaction'] = createURL('edit', $bookmark);
$tplVars['btnsubmit'] = T_('Save Changes');