getBookmark(intval($bookmark), true))) { $tplVars['error'] = sprintf(T_('Bookmark with id %s 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); }