aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/bookmarkservice.php26
-rw-r--r--services/userservice.php5
-rw-r--r--templates/admin.tpl.php3
3 files changed, 31 insertions, 3 deletions
diff --git a/services/bookmarkservice.php b/services/bookmarkservice.php
index e77e40d..635d8ed 100644
--- a/services/bookmarkservice.php
+++ b/services/bookmarkservice.php
@@ -71,8 +71,30 @@ class BookmarkService {
return $this->_getbookmark('bHash', $hash, true);
}
- function countBookmarks($uId) {
-
+ /* Counts bookmarks for a user. $range = {'public', 'shared', 'private', 'all'}*/
+ function countBookmarks($uId, $range = 'public') {
+ $sql = 'SELECT COUNT(*) FROM '. $GLOBALS['tableprefix'] .'bookmarks';
+ $sql.= ' WHERE uId = '.$uId;
+ switch ($range) {
+ case 'all':
+ //no constraints
+ break;
+ case 'private':
+ $sql.= ' AND bStatus = 2';
+ break;
+ case 'shared':
+ $sql.= ' AND bStatus = 1';
+ break;
+ 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);
+ }
+ return $this->db->sql_fetchfield(0, 0);
}
function editAllowed($bookmark) {
diff --git a/services/userservice.php b/services/userservice.php
index 7f0382d..a4ed3ac 100644
--- a/services/userservice.php
+++ b/services/userservice.php
@@ -592,5 +592,10 @@ class User {
}
return $this->isAdmin;
}
+
+ function getNbBookmarks($range = 'public') {
+ $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
+ return $bookmarkservice->countBookmarks($this->getId(), $range);
+ }
}
?>
diff --git a/templates/admin.tpl.php b/templates/admin.tpl.php
index ac288bd..c8d47e8 100644
--- a/templates/admin.tpl.php
+++ b/templates/admin.tpl.php
@@ -10,7 +10,8 @@ foreach($users as $user) {
echo '<li class="xfolkentry">'."\n";
echo '<div class="link">';
- echo '<a href="'.createURL('profile', $user->getUsername()).'">'.$user->getUsername().'</a>';
+ echo '<a href="'.createURL('profile', $user->getUsername()).'">'.$user->getUsername().'</a>';
+ echo ' - <span title='. T_('Public/Shared/Private') .'>'. $user->getNbBookmarks('public') .' / '. $user->getNbBookmarks('shared') .' / '. $user->getNbBookmarks('private') .' '. T_('bookmark(s)') .'</span>';
echo '</div>';
if($user->getUsername() != $currentUser->getUsername()) {