2007-12-12 16:29:16 +00:00
|
|
|
<?php
|
2009-05-19 15:59:55 +00:00
|
|
|
|
2007-12-12 16:29:16 +00:00
|
|
|
/***************************************************************************
|
|
|
|
Copyright (C) 2004 - 2006 Scuttle project
|
|
|
|
http://sourceforge.net/projects/scuttle/
|
|
|
|
http://scuttle.org/
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
require_once('header.inc.php');
|
|
|
|
|
2008-11-25 15:57:29 +00:00
|
|
|
/* Service creation: only useful services are created */
|
2007-12-12 16:29:16 +00:00
|
|
|
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
|
|
|
|
2008-11-25 15:57:29 +00:00
|
|
|
/* 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', '');
|
2009-01-12 16:40:39 +00:00
|
|
|
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
|
2008-11-25 15:57:29 +00:00
|
|
|
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', '');
|
|
|
|
|
2007-12-12 16:29:16 +00:00
|
|
|
// Header variables
|
2009-02-03 09:46:40 +00:00
|
|
|
$tplVars['pagetitle'] = T_('Edit Bookmark');
|
2007-12-12 16:29:16 +00:00
|
|
|
$tplVars['subtitle'] = T_('Edit Bookmark');
|
|
|
|
$tplVars['loadjs'] = true;
|
|
|
|
|
2009-05-19 15:59:55 +00:00
|
|
|
list ($url, $bookmark) = explode('/', $_SERVER['PATH_INFO']);
|
|
|
|
|
2007-12-12 16:29:16 +00:00
|
|
|
if (!($row = $bookmarkservice->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 {
|
2009-05-19 15:59:55 +00:00
|
|
|
|
2007-12-12 16:29:16 +00:00
|
|
|
if (!$bookmarkservice->editAllowed($row)) {
|
|
|
|
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
|
|
|
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
|
|
|
exit();
|
2008-11-25 15:57:29 +00:00
|
|
|
} else if (POST_SUBMITTED != '') {
|
2009-05-19 15:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-25 15:57:29 +00:00
|
|
|
if (!POST_TITLE || !POST_ADDRESS) {
|
2007-12-12 16:29:16 +00:00
|
|
|
$tplVars['error'] = T_('Your bookmark must have a title and an address');
|
|
|
|
} else {
|
|
|
|
// Update bookmark
|
|
|
|
$bId = intval($bookmark);
|
2008-11-25 15:57:29 +00:00
|
|
|
$address = trim(POST_ADDRESS);
|
|
|
|
$title = trim(POST_TITLE);
|
|
|
|
$description = trim(POST_DESCRIPTION);
|
2009-01-12 16:40:39 +00:00
|
|
|
$privateNote = trim(POST_PRIVATENOTE);
|
2008-11-25 15:57:29 +00:00
|
|
|
$status = intval(POST_STATUS);
|
2009-05-19 15:59:55 +00:00
|
|
|
$tags = trim(POST_TAGS);
|
2008-11-25 15:57:29 +00:00
|
|
|
|
2009-01-12 16:40:39 +00:00
|
|
|
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $privateNote, $status, $tags)) {
|
2007-12-12 16:29:16 +00:00
|
|
|
$tplvars['error'] = T_('Error while saving your bookmark');
|
|
|
|
} else {
|
2008-11-25 15:57:29 +00:00
|
|
|
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);
|
2007-12-12 16:29:16 +00:00
|
|
|
} else {
|
2008-11-25 15:57:29 +00:00
|
|
|
$tplVars['msg'] = T_('Bookmark saved');
|
2008-12-05 07:25:04 +00:00
|
|
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2008-11-25 15:57:29 +00:00
|
|
|
if (POST_DELETE != '') {
|
2007-12-12 16:29:16 +00:00
|
|
|
// Delete bookmark
|
|
|
|
if ($bookmarkservice->deleteBookmark($bookmark)) {
|
2009-02-17 09:36:20 +00:00
|
|
|
if (POST_POPUP != '') {
|
|
|
|
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
|
|
|
|
} elseif (POST_REFERRER != '') {
|
2008-11-25 15:57:29 +00:00
|
|
|
header('Location: '. POST_REFERRER);
|
2007-12-12 16:29:16 +00:00
|
|
|
} else {
|
2008-12-05 07:25:04 +00:00
|
|
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-01-14 10:59:29 +00:00
|
|
|
$tplVars['error'] = T_('Failed to delete bookmark');
|
2007-12-12 16:29:16 +00:00
|
|
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-25 15:57:29 +00:00
|
|
|
$tplVars['popup'] = (GET_POPUP) ? GET_POPUP : null;
|
2007-12-12 16:29:16 +00:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
?>
|