summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-25 15:24:35 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-25 15:24:35 +0000
commitda3c422d65973bde257aea24bf05fc55e5e7e63e (patch)
tree6697de51984c2a684bd7c2c6f0bed5557c893ee9
parent9f53c3325c99c1602f570efdaf0b6e0df2944f95 (diff)
downloadsemanticscuttle-da3c422d65973bde257aea24bf05fc55e5e7e63e.tar.gz
semanticscuttle-da3c422d65973bde257aea24bf05fc55e5e7e63e.tar.bz2
delete votes when deleting bookmark
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@408 b3834d28-1941-0410-a4f8-b48e95affb8f
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index 9cf5c70..3e5e79f 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -613,27 +613,53 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
- public function deleteBookmark($bookmarkid)
+ /**
+ * Delete the bookmark with the given id.
+ * Also deletes tags and votes for the given bookmark.
+ *
+ * @param integer $bookmark Bookmark ID
+ *
+ * @return boolean True if all went well, false if not
+ */
+ public function deleteBookmark($bookmark)
{
- $query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'bookmarks WHERE bId = '. intval($bookmarkid);
+ $bookmark = (int)$bookmark;
+
+ $query = 'DELETE FROM ' . $GLOBALS['tableprefix'] . 'bookmarks WHERE bId = '. $bookmark;
$this->db->sql_transaction('begin');
- if (!($dbresult = & $this->db->sql_query($query))) {
+ if (!($dbres = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback');
- message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
+ message_die(
+ GENERAL_ERROR, 'Could not delete bookmark',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
return false;
}
+ $query = 'DELETE FROM ' . $GLOBALS['tableprefix'] . 'bookmarks2tags WHERE bId = '. $bookmark;
+ $this->db->sql_transaction('begin');
+ if (!($dbres = $this->db->sql_query($query))) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not delete tags for bookmark',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
+ return false;
+ }
-
- $query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'bookmarks2tags WHERE bId = '. intval($bookmarkid);
+ $query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'votes WHERE bid = '. $bookmark;
$this->db->sql_transaction('begin');
- if (!($dbresult = & $this->db->sql_query($query))) {
+ if (!($dbres = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback');
- message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
+ message_die(
+ GENERAL_ERROR, 'Could not delete votes for bookmark',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
return false;
}
$this->db->sql_transaction('commit');
+
return true;
}