New Feature: adding private note to describe a bookmark. Just visible by the author and friends. (Useful for collaborative work)

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@231 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
mensonge 2009-01-12 16:40:39 +00:00
parent 78b493f41c
commit a70b6e9dac
9 changed files with 31 additions and 13 deletions

View file

@ -73,7 +73,7 @@ if (is_null($url) || is_null($description)) {
if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId()))
$added = false;
else
$added = $bookmarkservice->addBookmark($url, $description, $extended, $status, $tags, $dt, true);
$added = $bookmarkservice->addBookmark($url, $description, $extended, '', $status, $tags, $dt, true);
}
// Set up the XML file and output the result.

View file

@ -32,11 +32,13 @@ isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): defi
isset($_GET['title']) ? define('GET_TITLE', $_GET['title']): define('GET_TITLE', '');
isset($_GET['address']) ? define('GET_ADDRESS', $_GET['address']): define('GET_ADDRESS', '');
isset($_GET['description']) ? define('GET_DESCRIPTION', $_GET['description']): define('GET_DESCRIPTION', '');
isset($_GET['privateNote']) ? define('GET_PRIVATENOTE', $_GET['privateNote']): define('GET_PRIVATENOTE', '');
isset($_GET['tags']) ? define('GET_TAGS', $_GET['tags']): define('GET_TAGS', '');
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', '');
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
@ -133,10 +135,11 @@ if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
} else {
$title = trim(POST_TITLE);
$description = trim(POST_DESCRIPTION);
$privateNote = trim(POST_PRIVATENOTE);
$status = intval(POST_STATUS);
$categories = trim(POST_TAGS);
$saved = true;
if ($bookmarkservice->addBookmark($address, $title, $description, $status, $categories)) {
if ($bookmarkservice->addBookmark($address, $title, $description, $privateNote, $status, $categories)) {
if (POST_POPUP != '') {
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
} else {
@ -175,6 +178,7 @@ if ($templatename == 'editbookmark.tpl') {
'bTitle' => stripslashes(POST_TITLE),
'bAddress' => stripslashes(POST_ADDRESS),
'bDescription' => stripslashes(POST_DESCRIPTION),
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()),
'bStatus' => 0,
);
@ -184,6 +188,7 @@ if ($templatename == 'editbookmark.tpl') {
'bTitle' => stripslashes(GET_TITLE),
'bAddress' => stripslashes(GET_ADDRESS),
'bDescription' => stripslashes(GET_DESCRIPTION),
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
'bStatus' => 0
);

View file

@ -31,6 +31,7 @@ isset($_POST['delete']) ? define('POST_DELETE', $_POST['delete']): define('POST_
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', '');
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
@ -62,10 +63,11 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
$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, $status, $tags)) {
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $privateNote, $status, $tags)) {
$tplvars['error'] = T_('Error while saving your bookmark');
} else {
if (POST_POPUP != '') {

View file

@ -100,7 +100,7 @@ function startElement($parser, $name, $attrs) {
$bDatetime = gmdate('Y-m-d H:i:s');
}
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $status, $tags, $bDatetime, true, true))
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $status, $tags, $bDatetime, true, true))
$tplVars['msg'] = T_('Bookmark imported.');
else
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');

View file

@ -84,6 +84,8 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
case "TAGS":
$bCategories = $attrVal;
break;
case "NOTE":
$bPrivateNote = $attrVal;
}
}
$bTitle = trim($titles[$i]);
@ -100,7 +102,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
$bDatetime = gmdate('Y-m-d H:i:s');
}
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $status, $bCategories, $bDatetime, false, true)) {
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $bPrivateNote, $status, $bCategories, $bDatetime, false, true)) {
$countImportedBookmarks++;
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');

View file

@ -108,7 +108,7 @@ class BookmarkService {
// Adds a bookmark to the database.
// Note that date is expected to be a string that's interpretable by strtotime().
function addBookmark($address, $title, $description, $status, $categories, $date = NULL, $fromApi = false, $fromImport = false, $sId = -1) {
function addBookmark($address, $title, $description, $privateNote, $status, $categories, $date = NULL, $fromApi = false, $fromImport = false, $sId = -1) {
if($sId == -1) {
$userservice = & ServiceFactory :: getServiceInstance('UserService');
$sId = $userservice->getCurrentUserId();
@ -134,7 +134,7 @@ class BookmarkService {
$datetime = gmdate('Y-m-d H:i:s', $time);
// Set up the SQL insert statement and execute it.
$values = array('uId' => intval($sId), 'bIp' => $ip, 'bDatetime' => $datetime, 'bModified' => $datetime, 'bTitle' => $title, 'bAddress' => $address, 'bDescription' => $description, 'bStatus' => intval($status), 'bHash' => md5($address));
$values = array('uId' => intval($sId), 'bIp' => $ip, 'bDatetime' => $datetime, 'bModified' => $datetime, 'bTitle' => $title, 'bAddress' => $address, 'bDescription' => $description, 'bPrivateNote' => $privateNote, 'bStatus' => intval($status), 'bHash' => md5($address));
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
$this->db->sql_transaction('begin');
if (!($dbresult = & $this->db->sql_query($sql))) {
@ -154,8 +154,6 @@ class BookmarkService {
$extension = end($uriparts);
unset($uriparts);
trigger_error($GLOBALS['filetypes'].'aaaaaaaaaaaaaaaaaaaaa');
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
if (!$b2tservice->attachTags($bId, $categories, $fromApi, $extension, false, $fromImport)) {
$this->db->sql_transaction('rollback');
@ -167,7 +165,7 @@ class BookmarkService {
return $bId;
}
function updateBookmark($bId, $address, $title, $description, $status, $categories, $date = NULL, $fromApi = false) {
function updateBookmark($bId, $address, $title, $description, $privateNote, $status, $categories, $date = NULL, $fromApi = false) {
if (!is_numeric($bId))
return false;
@ -183,7 +181,7 @@ class BookmarkService {
$moddatetime = gmdate('Y-m-d H:i:s', time());
// Set up the SQL update statement and execute it.
$updates = array('bModified' => $moddatetime, 'bTitle' => $title, 'bAddress' => $address, 'bDescription' => $description, 'bStatus' => $status, 'bHash' => md5($address));
$updates = array('bModified' => $moddatetime, 'bTitle' => $title, 'bAddress' => $address, 'bDescription' => $description, 'bPrivateNote' => $privateNote, 'bStatus' => $status, 'bHash' => md5($address));
if (!is_null($date)) {
$datetime = gmdate('Y-m-d H:i:s', strtotime($date));

View file

@ -15,6 +15,7 @@ CREATE TABLE `sc_bookmarks` (
`bTitle` varchar(255) NOT NULL default '',
`bAddress` text NOT NULL,
`bDescription` varchar(1500) default NULL,
`bPrivateNote` varchar(1500) default NULL,
`bHash` varchar(32) NOT NULL default '',
PRIMARY KEY (`bId`),
KEY `sc_bookmarks_usd` (`uId`,`bStatus`,`bDatetime`),

View file

@ -40,7 +40,10 @@ $this->includeTemplate("dojo.inc");
<td>&larr; <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Description'); ?></th>
<th align="left">
<?php echo T_('Description'); ?>
<a onclick="var nz = document.getElementById('privateNoteZone'); nz.style.display='';this.style.display='none';"><?php echo T_("Add Note"); ?></a>
</th>
<td><textarea name="description" id="description" rows="5" cols="63" ><?php echo filter($row['bDescription'], 'xml'); ?></textarea></td>
<td>&larr; <?php echo T_('You can use anchors to delimite attributes. for example: [publisher]blah[/publisher] '); ?>
<?php if(count($GLOBALS['descriptionAnchors'])>0): ?>
@ -56,6 +59,12 @@ $this->includeTemplate("dojo.inc");
<?php endif; ?>
</td>
</tr>
<tr id="privateNoteZone" <?php if(strlen($row['bPrivateNote'])==0):?>style="display:none"<?php endif; ?>>
<th align="left"><?php echo T_('Private Note'); ?></th>
<td><textarea name="privateNote" id="privateNote" rows="1" cols="63" ><?php echo filter($row['bPrivateNote'], 'xml'); ?></textarea></td>
<td>&larr; <?php echo T_('Just visible by you and your friends.'); ?>
</td>
</tr>
<tr>
<th align="left"><?php echo T_('Tags'); ?></th>
<td class="scuttletheme">

View file

@ -4,7 +4,8 @@
- Backup you database
- Make a copy from your SemanticScuttle Web directory
- Upgrade your database by following instructions ONE after ONE (order is important) :
* NO CHANGE
* ALTER TABLE `sc_bookmarks` ADD `bPrivateNote` VARCHAR( 1500 ) NOT NULL AFTER `bDescription` ;
- Upgrade your current configuration file (config.inc.php) with respect to config.inc.php.example
* Add variable : $descriptionAnchors = array("author", "isbn", "address"=>"[address][street][/street][city][/city][/address]"); #add a possible anchor (structured content) for bookmarks' description field