]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Interface Fix: add bookmarks counting into admin page
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Wed, 11 Feb 2009 12:39:44 +0000 (12:39 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Wed, 11 Feb 2009 12:39:44 +0000 (12:39 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@273 b3834d28-1941-0410-a4f8-b48e95affb8f

services/bookmarkservice.php
services/userservice.php
templates/admin.tpl.php

index e77e40d302144f151fef58ace8d3827a9cc2afed..635d8edc3f961ce8352df099f2a1625755bd0930 100644 (file)
@@ -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) {
index 7f0382de9a928c856ae6764b99d2af0b2d5e8990..a4ed3acb5dd885ed67395f6998d1b2ddbe687110 100644 (file)
@@ -592,5 +592,10 @@ class User {
                }
                return $this->isAdmin;
        }
+       
+       function getNbBookmarks($range = 'public') {
+               $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
+               return $bookmarkservice->countBookmarks($this->getId(), $range);
+       }
 }
 ?>
index ac288bdab27ecc2fd99d842b9eec1cec426a9f73..c8d47e8f560ee8e2772a5bbf7f38b6bcd09fd95f 100644 (file)
@@ -10,7 +10,8 @@ foreach($users as $user) {
        echo '<li class="xfolkentry">'."\n";\r
 \r
        echo '<div class="link">';\r
-       echo '<a href="'.createURL('profile', $user->getUsername()).'">'.$user->getUsername().'</a>';\r
+       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>';\r
        echo '</div>';\r
 
        if($user->getUsername() != $currentUser->getUsername()) {\r