From d582054c77b22daeb08d2bff17794b9a69a20dd4 Mon Sep 17 00:00:00 2001 From: mensonge Date: Wed, 12 Dec 2007 16:29:16 +0000 Subject: import of scuttle 0.7.2 git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@1 b3834d28-1941-0410-a4f8-b48e95affb8f --- edit.php | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 edit.php (limited to 'edit.php') diff --git a/edit.php b/edit.php new file mode 100644 index 0000000..028e8ba --- /dev/null +++ b/edit.php @@ -0,0 +1,93 @@ +getBookmark(intval($bookmark), true))) { + $tplVars['error'] = sprintf(T_('Bookmark with id %s not was not found'), $bookmark); + $templateservice->loadTemplate('error.404.tpl', $tplVars); + exit(); +} else { + if (!$bookmarkservice->editAllowed($row)) { + $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']) { + $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(); + 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'])) ? '' : T_('Bookmark saved'); + } elseif (isset($_POST['referrer'])) { + header('Location: '. $_POST['referrer']); + } else { + header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')])); + } + } + } + } else { + if ($_POST['delete']) { + // Delete bookmark + if ($bookmarkservice->deleteBookmark($bookmark)) { + $logged_on_user = $userservice->getCurrentUser(); + if (isset($_POST['referrer'])) { + header('Location: '. $_POST['referrer']); + } else { + header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')])); + } + exit(); + } else { + $tplVars['error'] = T_('Failed to delete the bookmark'); + $templateservice->loadTemplate('error.500.tpl', $tplVars); + exit(); + } + } + } + + $tplVars['popup'] = (isset($_GET['popup'])) ? $_GET['popup'] : null; + $tplVars['row'] =& $row; + $tplVars['formaction'] = createURL('edit', $bookmark); + $tplVars['btnsubmit'] = T_('Save Changes'); + $tplVars['showdelete'] = true; + $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; + $templateservice->loadTemplate('editbookmark.tpl', $tplVars); +} +?> -- cgit v1.2.3-54-g00ecf