From f20135d16a0fa2bb8cd2820323052fccab8f3451 Mon Sep 17 00:00:00 2001
From: cweiske
Date: Tue, 28 Sep 2010 22:08:58 +0000
Subject: add gettext changelog entry
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@764 b3834d28-1941-0410-a4f8-b48e95affb8f
---
doc/ChangeLog | 1 +
1 file changed, 1 insertion(+)
(limited to 'doc')
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 2633fc8..e2562e4 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -6,6 +6,7 @@ ChangeLog for SemantiScuttle
- Fix bug getTagsForBookmarks() that fetched all tags
- Show error message on mysqli connection errors
- Implement patch #3059829: update FR_CA translation
+- Update php-gettext library to 1.0.10
- Fix bug #3073215: Updating bookmark time does not work
- Fix bug #3074816: French translation breaks edit javascript
--
cgit v1.3-2-g0d8e
From 70c39a8eea7896271c0ad3f0c435ec06c64074d1 Mon Sep 17 00:00:00 2001
From: cweiske
Date: Wed, 29 Sep 2010 20:49:14 +0000
Subject: delicious returns a proper error message when deleting non-existant
items, which we do now, too
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@770 b3834d28-1941-0410-a4f8-b48e95affb8f
---
doc/developers/api | 10 ++++++++++
tests/Api/PostsDeleteTest.php | 2 +-
www/api/posts_delete.php | 14 +++++---------
3 files changed, 16 insertions(+), 10 deletions(-)
create mode 100644 doc/developers/api
(limited to 'doc')
diff --git a/doc/developers/api b/doc/developers/api
new file mode 100644
index 0000000..efa05fe
--- /dev/null
+++ b/doc/developers/api
@@ -0,0 +1,10 @@
+SemanticScuttle API
+===================
+
+SemanticScuttle tries to implement the delicious API v1 as closely as sensible.
+
+Where it makes sense and the delicious API just does things plainly wrong
+(i.e. when returning a wrong status code on an error), we do it better.
+
+- http://www.delicious.com/help/api
+- http://support.delicious.com/forum/comments.php?DiscussionID=5286&page=1
diff --git a/tests/Api/PostsDeleteTest.php b/tests/Api/PostsDeleteTest.php
index 626746f..d9fb6cd 100644
--- a/tests/Api/PostsDeleteTest.php
+++ b/tests/Api/PostsDeleteTest.php
@@ -215,7 +215,7 @@ class Api_PostsDeleteTest extends TestBaseApi
$this->assertTag(
array(
'tag' => 'result',
- 'attributes' => array('code' => 'something went wrong')
+ 'attributes' => array('code' => 'item not found')
),
$res->getBody(),
'', false
diff --git a/www/api/posts_delete.php b/www/api/posts_delete.php
index 982b686..03cc968 100644
--- a/www/api/posts_delete.php
+++ b/www/api/posts_delete.php
@@ -4,8 +4,6 @@
* The delicious API is implemented here.
*
* The delicious API behaves like that:
- * - returns "done" even if the bookmark doesn't exist
- * - we do it correctly
* - does NOT allow the hash for the url parameter
* - doesn't set the Content-Type to text/xml
* - we do it correctly, too
@@ -35,26 +33,24 @@ $uId = $userservice->getCurrentUserId();
if (!isset($_REQUEST['url'])
|| $_REQUEST['url'] == ''
) {
- $deleted = false;
+ $msg = 'something went wrong';
} else if (!$bs->bookmarkExists($_REQUEST['url'], $uId)) {
//the user does not have such a bookmark
- // Note that del.icio.us only errors out if no URL was passed in;
- // there's no error on attempting to delete a bookmark you don't have.
- // this sucks, and I don't care about being different but correct here.
header('HTTP/1.0 404 Not Found');
- $deleted = false;
-
+ $msg = 'item not found';
} else {
$bookmark = $bs->getBookmarkByAddress($_REQUEST['url'], false);
$bId = $bookmark['bId'];
$deleted = $bs->deleteBookmark($bId);
+ $msg = 'done';
if (!$deleted) {
//something really went wrong
header('HTTP/1.0 500 Internal Server Error');
+ $msg = 'something really went wrong';
}
}
// Set up the XML file and output the result.
echo '\r\n";
-echo '';
+echo '';
?>
\ No newline at end of file
--
cgit v1.3-2-g0d8e
From 8e2b25a095ab769146ac7fa672d7a4c4eda32ab4 Mon Sep 17 00:00:00 2001
From: cweiske
Date: Wed, 29 Sep 2010 20:57:30 +0000
Subject: api/posts/add respects the "replace" parameter now
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@777 b3834d28-1941-0410-a4f8-b48e95affb8f
---
doc/ChangeLog | 7 +--
tests/Api/PostsAddTest.php | 121 +++++++++++++++++++++++++++++++++++++++++++++
www/api/posts_add.php | 24 +++++++--
3 files changed, 145 insertions(+), 7 deletions(-)
(limited to 'doc')
diff --git a/doc/ChangeLog b/doc/ChangeLog
index e2562e4..d711dd4 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -3,12 +3,13 @@ ChangeLog for SemantiScuttle
0.9X.X - 2010-XX-XX
-------------------
-- Fix bug getTagsForBookmarks() that fetched all tags
+- Fix bug in getTagsForBookmarks() that fetched all tags
+- Fix bug #3073215: Updating bookmark time does not work
+- Fix bug #3074816: French translation breaks edit javascript
- Show error message on mysqli connection errors
- Implement patch #3059829: update FR_CA translation
- Update php-gettext library to 1.0.10
-- Fix bug #3073215: Updating bookmark time does not work
-- Fix bug #3074816: French translation breaks edit javascript
+- api/posts/add respects the "replace" parameter now
0.97.0 - 2010-06-09
diff --git a/tests/Api/PostsAddTest.php b/tests/Api/PostsAddTest.php
index dea002e..1f21d04 100644
--- a/tests/Api/PostsAddTest.php
+++ b/tests/Api/PostsAddTest.php
@@ -306,6 +306,127 @@ TXT;
$data = $this->bs->getBookmarks(0, null, $uId);
$this->assertEquals(0, $data['total']);
}
+
+ /**
+ * Test that the replace=no parameter prevents the bookmark from being
+ * overwritten.
+ */
+ public function testReplaceNo()
+ {
+ $this->bs->deleteAll();
+
+ $url = 'http://example.org/tag2';
+ $title1 = 'foo bar 1';
+ $title2 = 'bar 2 foo';
+
+ list($req, $uId) = $this->getAuthRequest();
+ $req->setMethod(HTTP_Request2::METHOD_POST);
+ $req->addPostParameter('url', $url);
+ $req->addPostParameter('description', $title1);
+ $res = $req->send();
+
+ //all should be well
+ $this->assertEquals(200, $res->getStatus());
+
+ //send it a second time, with different title
+ list($req, $dummy) = $this->getAuthRequest();
+ $req->setMethod(HTTP_Request2::METHOD_POST);
+ $req->addPostParameter('url', $url);
+ $req->addPostParameter('description', $title2);
+ $req->addPostParameter('replace', 'no');
+ $res = $req->send();
+
+ //this time we should get an error
+ $this->assertEquals(409, $res->getStatus());
+ //verify MIME content type
+ $this->assertEquals(
+ 'text/xml; charset=utf-8',
+ $res->getHeader('content-type')
+ );
+
+ //verify xml
+ $this->assertTag(
+ array(
+ 'tag' => 'result',
+ 'attributes' => array('code' => 'bookmark does already exist')
+ ),
+ $res->getBody(),
+ null, false
+ );
+
+ //user still has 1 bookmark now
+ $data = $this->bs->getBookmarks(0, null, $uId);
+ $this->assertEquals(1, $data['total']);
+ $this->assertEquals($title1, $data['bookmarks'][0]['bTitle']);
+
+ //send it a third time, without the replace parameter
+ // it defaults to "no", so the bookmark should not get overwritten
+ list($req, $dummy) = $this->getAuthRequest();
+ $req->setMethod(HTTP_Request2::METHOD_POST);
+ $req->addPostParameter('url', $url);
+ $req->addPostParameter('description', $title2);
+ $res = $req->send();
+
+ //this time we should get an error
+ $this->assertEquals(409, $res->getStatus());
+
+ //bookmark should not have changed
+ $data = $this->bs->getBookmarks(0, null, $uId);
+ $this->assertEquals(1, $data['total']);
+ $this->assertEquals($title1, $data['bookmarks'][0]['bTitle']);
+ }
+
+ /**
+ * Test that the replace=yes parameter causes the bookmark to be updated.
+ */
+ public function testReplaceYes()
+ {
+ $this->bs->deleteAll();
+
+ $url = 'http://example.org/tag2';
+ $title1 = 'foo bar 1';
+ $title2 = 'bar 2 foo';
+
+ list($req, $uId) = $this->getAuthRequest();
+ $req->setMethod(HTTP_Request2::METHOD_POST);
+ $req->addPostParameter('url', $url);
+ $req->addPostParameter('description', $title1);
+ $res = $req->send();
+
+ //all should be well
+ $this->assertEquals(200, $res->getStatus());
+
+ //send it a second time, with different title
+ list($req, $dummy) = $this->getAuthRequest();
+ $req->setMethod(HTTP_Request2::METHOD_POST);
+ $req->addPostParameter('url', $url);
+ $req->addPostParameter('description', $title2);
+ $req->addPostParameter('replace', 'yes');
+ $res = $req->send();
+
+ //no error
+ $this->assertEquals(200, $res->getStatus());
+ //verify MIME content type
+ $this->assertEquals(
+ 'text/xml; charset=utf-8',
+ $res->getHeader('content-type')
+ );
+
+ //verify xml
+ $this->assertTag(
+ array(
+ 'tag' => 'result',
+ 'attributes' => array('code' => 'done')
+ ),
+ $res->getBody(),
+ null, false
+ );
+
+ //user still has 1 bookmark now, but with the new title
+ $data = $this->bs->getBookmarks(0, null, $uId);
+ $this->assertEquals(1, $data['total']);
+ $this->assertEquals($title2, $data['bookmarks'][0]['bTitle']);
+ }
}
if (PHPUnit_MAIN_METHOD == 'Api_PostsAddTest::main') {
diff --git a/www/api/posts_add.php b/www/api/posts_add.php
index 0e06d50..7f9dc59 100644
--- a/www/api/posts_add.php
+++ b/www/api/posts_add.php
@@ -16,6 +16,8 @@
* - 0 or 'public': Everyone can see the bookmark
* @param string $shared "no" or "yes": Switches between private and
* public (optional)
+ * @param string $replace "yes" or "no" - replaces a bookmark with the
+ * same URL (optional)
*
* Notes:
* - tags cannot have spaces
@@ -23,7 +25,6 @@
* - delicious "description" is the "title" in SemanticScuttle
* - delicious "extended" is the "description" in SemanticScuttle
* - "status" is a SemanticScuttle addition to this API method
- * - SemanticScuttle currently ignores the "replace" parameter
*
* SemanticScuttle - your social bookmark manager.
*
@@ -78,6 +79,8 @@ if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != '')) {
$dt = null;
}
+$replace = isset($_REQUEST['replace']) && ($_REQUEST['replace'] == 'yes');
+
$status = 0;
if (isset($_REQUEST['status'])) {
$status_str = trim($_REQUEST['status']);
@@ -114,9 +117,22 @@ if (is_null($url)) {
$msg = 'Description missing';
} else {
// We're good with info; now insert it!
- if ($bs->bookmarkExists($url, $userservice->getCurrentUserId())) {
- $msg = 'something went wrong';
- } else {
+ $exists = $bs->bookmarkExists($url, $userservice->getCurrentUserId());
+ if ($exists) {
+ if (!$replace) {
+ header('HTTP/1.0 409 Conflict');
+ $msg = 'bookmark does already exist';
+ } else {
+ //delete it before we re-add it
+ $bookmark = $bs->getBookmarkByAddress($url, false);
+ $bId = $bookmark['bId'];
+ $bs->deleteBookmark($bId);
+
+ $exists = false;
+ }
+ }
+
+ if (!$exists) {
$added = $bs->addBookmark(
$url, $description, $extended, '', $status, $tags, null, $dt, true
);
--
cgit v1.3-2-g0d8e
From e1f9d9e3a07652d4ec668a2337d8b788e031ab9f Mon Sep 17 00:00:00 2001
From: cweiske
Date: Wed, 29 Sep 2010 22:01:29 +0000
Subject: merge changelog from 0.97 branch
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@781 b3834d28-1941-0410-a4f8-b48e95affb8f
---
doc/ChangeLog | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'doc')
diff --git a/doc/ChangeLog b/doc/ChangeLog
index d711dd4..0a60bff 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -12,6 +12,14 @@ ChangeLog for SemantiScuttle
- api/posts/add respects the "replace" parameter now
+0.97.1 - 2010-09-30
+-------------------
+This is a security release! We do highly recommend to update
+your SemanticScuttle installations!
+
+- Fix bug #3077187: Permission problem when deleting bookmarks
+
+
0.97.0 - 2010-06-09
-------------------
- Many SQL optimizations - SemanticScuttle shows bookmarks 4 times faster now
--
cgit v1.3-2-g0d8e