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);
$privateNote = trim(POST_PRIVATENOTE);
$status = intval(POST_STATUS);
$tags = trim(POST_TAGS);
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $privateNote, $status, $tags)) {
$tplvars['error'] = T_('Error while saving your bookmark');
} else {
if (POST_POPUP != '') {
//$tplVars['msg'] = (POST_POPUP != '') ? '' : T_('Bookmark saved');
$tplVars['msg'] = '';
} elseif (POST_REFERRER != '') {
$tplVars['msg'] = T_('Bookmark saved');
header('Location: '. POST_REFERRER);
} else {
$tplVars['msg'] = T_('Bookmark saved');
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
}
}
}
} else {
if (POST_DELETE != '') {
// Delete bookmark
if ($bookmarkservice->deleteBookmark($bookmark)) {
if (POST_POPUP != '') {
$tplVars['msg'] = '';
} elseif (POST_REFERRER != '') {
header('Location: '. POST_REFERRER);
} else {
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
}
} else {
$tplVars['error'] = T_('Failed to delete bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
}
}
$tplVars['popup'] = (GET_POPUP) ? GET_POPUP : null;
$tplVars['row'] = $row;
$tplVars['formaction'] = createURL('edit', $bookmark);
$tplVars['btnsubmit'] = T_('Save Changes');
$tplVars['showdelete'] = true;
$tplVars['referrer'] = '';
if (isset($_SERVER['HTTP_REFERER'])) {
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
}
$templateservice->loadTemplate('editbookmark.tpl', $tplVars);
}
?>