2007-12-12 17:29:16 +01:00
|
|
|
<?php
|
2009-05-19 17:59:55 +02:00
|
|
|
|
2007-12-12 17:29:16 +01: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
|
|
|
|
***************************************************************************/
|
|
|
|
|
2010-02-08 08:32:34 +01:00
|
|
|
require_once 'www-header.php';
|
2007-12-12 17:29:16 +01:00
|
|
|
|
2008-11-25 16:57:29 +01:00
|
|
|
/* Service creation: only useful services are created */
|
2009-10-23 19:13:16 +02:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory :: get('Bookmark');
|
2007-12-12 17:29:16 +01:00
|
|
|
|
2008-11-25 16:57:29 +01: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 17:40:39 +01:00
|
|
|
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
|
2011-03-15 07:53:39 +01:00
|
|
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
|
2008-11-25 16:57:29 +01:00
|
|
|
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 17:29:16 +01:00
|
|
|
// Header variables
|
2009-02-03 10:46:40 +01:00
|
|
|
$tplVars['pagetitle'] = T_('Edit Bookmark');
|
2007-12-12 17:29:16 +01:00
|
|
|
$tplVars['subtitle'] = T_('Edit Bookmark');
|
|
|
|
$tplVars['loadjs'] = true;
|
|
|
|
|
2009-05-19 17:59:55 +02:00
|
|
|
list ($url, $bookmark) = explode('/', $_SERVER['PATH_INFO']);
|
|
|
|
|
2007-12-12 17:29:16 +01: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 17:59:55 +02:00
|
|
|
|
2007-12-12 17:29:16 +01: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 16:57:29 +01:00
|
|
|
} else if (POST_SUBMITTED != '') {
|
2009-05-19 17:59:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-25 16:57:29 +01:00
|
|
|
if (!POST_TITLE || !POST_ADDRESS) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$tplVars['error'] = T_('Your bookmark must have a title and an address');
|
|
|
|
} else {
|
|
|
|
// Update bookmark
|
|
|
|
$bId = intval($bookmark);
|
2008-11-25 16:57:29 +01:00
|
|
|
$address = trim(POST_ADDRESS);
|
|
|
|
$title = trim(POST_TITLE);
|
|
|
|
$description = trim(POST_DESCRIPTION);
|
2009-01-12 17:40:39 +01:00
|
|
|
$privateNote = trim(POST_PRIVATENOTE);
|
2008-11-25 16:57:29 +01:00
|
|
|
$status = intval(POST_STATUS);
|
2009-05-19 17:59:55 +02:00
|
|
|
$tags = trim(POST_TAGS);
|
2008-11-25 16:57:29 +01:00
|
|
|
|
2009-01-12 17:40:39 +01:00
|
|
|
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $privateNote, $status, $tags)) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$tplvars['error'] = T_('Error while saving your bookmark');
|
|
|
|
} else {
|
2008-11-25 16:57:29 +01: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 17:29:16 +01:00
|
|
|
} else {
|
2008-11-25 16:57:29 +01:00
|
|
|
$tplVars['msg'] = T_('Bookmark saved');
|
2008-12-05 08:25:04 +01:00
|
|
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2008-11-25 16:57:29 +01:00
|
|
|
if (POST_DELETE != '') {
|
2007-12-12 17:29:16 +01:00
|
|
|
// Delete bookmark
|
|
|
|
if ($bookmarkservice->deleteBookmark($bookmark)) {
|
2009-02-17 10:36:20 +01:00
|
|
|
if (POST_POPUP != '') {
|
|
|
|
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
|
|
|
|
} elseif (POST_REFERRER != '') {
|
2008-11-25 16:57:29 +01:00
|
|
|
header('Location: '. POST_REFERRER);
|
2007-12-12 17:29:16 +01:00
|
|
|
} else {
|
2008-12-05 08:25:04 +01:00
|
|
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
} else {
|
2008-01-14 11:59:29 +01:00
|
|
|
$tplVars['error'] = T_('Failed to delete bookmark');
|
2007-12-12 17:29:16 +01:00
|
|
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:57:29 +01:00
|
|
|
$tplVars['popup'] = (GET_POPUP) ? GET_POPUP : null;
|
2013-03-20 20:00:25 +01:00
|
|
|
$tplVars['row'] = $row;
|
2007-12-12 17:29:16 +01:00
|
|
|
$tplVars['formaction'] = createURL('edit', $bookmark);
|
|
|
|
$tplVars['btnsubmit'] = T_('Save Changes');
|
|
|
|
$tplVars['showdelete'] = true;
|
2009-09-17 14:31:53 +02:00
|
|
|
$tplVars['referrer'] = '';
|
|
|
|
if (isset($_SERVER['HTTP_REFERER'])) {
|
|
|
|
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
$templateservice->loadTemplate('editbookmark.tpl', $tplVars);
|
|
|
|
}
|
|
|
|
?>
|