summaryrefslogtreecommitdiffstatshomepage
path: root/src/SemanticScuttle/Service/Bookmark.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/SemanticScuttle/Service/Bookmark.php')
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index 39ec4f0..7eb1174 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -138,7 +138,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
if ($GLOBALS['enableVoting'] && $userservice->isLoggedOn()) {
$cuid = $userservice->getCurrentUserId();
$vs = SemanticScuttle_Service_Factory::get('Vote');
- $query_1 .= ', !ISNULL(V.bId) as hasVoted, V.vote as vote';
+ $query_1 .= ', ' . $this->db->QueryBuilder->isNotNull('V.bId') . ' as hasVoted, V.vote as vote';
$query_2 .= ' LEFT JOIN ' . $vs->getTableName() . ' AS V'
. ' ON B.bId = V.bId'
. ' AND V.uId = ' . (int)$cuid;
@@ -504,7 +504,9 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
'bPrivateNote' => $privateNote,
'bStatus' => intval($status),
'bHash' => $this->getHash($address),
- 'bShort' => $short
+ 'bShort' => $short,
+ 'bVotes' => 0,
+ 'bVoting' => 0,
);
$sql = 'INSERT INTO '. $this->getTableName()
@@ -547,7 +549,15 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
'', __LINE__, __FILE__, $sql, $this->db
);
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR,
+ 'Could not commit bookmark',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ }
// Everything worked out, so return the new bookmark's bId.
return $bId;
@@ -651,7 +661,13 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
);
}
- $this->db->sql_transaction('commit');
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit bookmark update',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ }
// Everything worked out, so return true.
return true;
}
@@ -787,7 +803,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
if ($GLOBALS['enableVoting'] && $userservice->isLoggedOn()) {
$cuid = $userservice->getCurrentUserId();
$vs = SemanticScuttle_Service_Factory::get('Vote');
- $query_1 .= ', !ISNULL(V.bId) as hasVoted, V.vote as vote';
+ $query_1 .= ', ' . $this->db->QueryBuilder->isNotNull('V.bId') . ' as hasVoted, V.vote as vote';
$query_2 .= ' LEFT JOIN ' . $vs->getTableName() . ' AS V'
. ' ON B.bId = V.bId'
. ' AND V.uId = ' . (int)$cuid;
@@ -1001,7 +1017,13 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
);
}
- $this->db->sql_transaction('commit');
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit deleting votes for bookmark',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
+ }
return true;
}
@@ -1136,7 +1158,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
// Delete final /
if (substr($address, -1) == '/') {
- $address = substr($address, 0, strlen($address)-2);
+ $address = substr($address, 0, -1);
}
return $address;