summaryrefslogtreecommitdiffstatshomepage
path: root/src/SemanticScuttle/Service/Bookmark.php
diff options
context:
space:
mode:
authorGravatar cweiske2009-10-30 06:05:29 +0000
committerGravatar cweiske2009-10-30 06:05:29 +0000
commitcc2c8242c76bdb39bc89976fb3425a5a934bf4b9 (patch)
tree1d2a58e521debd946d005f4f71878910b2b4932e /src/SemanticScuttle/Service/Bookmark.php
parentcb713ccd7619cb55ce9e948599ad46cdacf6715e (diff)
downloadscuttle-cc2c8242c76bdb39bc89976fb3425a5a934bf4b9.tar.gz
scuttle-cc2c8242c76bdb39bc89976fb3425a5a934bf4b9.zip
move user class into own file
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@473 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service/Bookmark.php')
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index 287994d..2ac77a4 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -154,29 +154,41 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
- /* Counts bookmarks for a user. $range = {'public', 'shared', 'private', 'all'}*/
- function countBookmarks($uId, $range = 'public')
+ /**
+ * Counts bookmarks for a user.
+ *
+ * @param integer $uId User ID
+ * @param string $range Range of bookmarks:
+ * 'public', 'shared', 'private'
+ * or 'all'
+ *
+ * @return integer Number of bookmarks
+ */
+ public function countBookmarks($uId, $range = 'public')
{
- $sql = 'SELECT COUNT(*) FROM '. $GLOBALS['tableprefix'] .'bookmarks';
- $sql.= ' WHERE uId = '.$uId;
+ $sql = 'SELECT COUNT(*) FROM '. $this->getTableName();
+ $sql.= ' WHERE uId = ' . intval($uId);
switch ($range) {
- case 'all':
+ case 'all':
//no constraints
break;
- case 'private':
- $sql.= ' AND bStatus = 2';
+ case 'private':
+ $sql .= ' AND bStatus = 2';
break;
- case 'shared':
- $sql.= ' AND bStatus = 1';
+ case 'shared':
+ $sql .= ' AND bStatus = 1';
break;
- case 'public':
- default:
- $sql.= ' AND bStatus = 0';
+ case 'public':
+ default:
+ $sql .= ' AND bStatus = 0';
break;
}
- if (!($dbresult = & $this->db->sql_query($sql))) {
- message_die(GENERAL_ERROR, 'Could not get vars', '', __LINE__, __FILE__, $sql, $this->db);
+ if (!($dbresult = $this->db->sql_query($sql))) {
+ message_die(
+ GENERAL_ERROR, 'Could not get vars',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
}
return $this->db->sql_fetchfield(0, 0);
}
@@ -227,7 +239,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$address = $this->normalize($address);
- $crit = array ('bHash' => md5($address));
+ $crit = array('bHash' => md5($address));
if (isset ($uid)) {
$crit['uId'] = $uid;
}