summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Service/User.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-03 21:52:30 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-03 21:52:30 +0000
commitd5f09b7e4d802cdc2d5f3f876c48ea918c961488 (patch)
treeaa1eb37219c17bef03b1515e5074b4743f89a9a3 /src/SemanticScuttle/Service/User.php
parentb7345f833dea849e94f2ce23fdbe6ab58ba98be3 (diff)
downloadsemanticscuttle-d5f09b7e4d802cdc2d5f3f876c48ea918c961488.tar.gz
semanticscuttle-d5f09b7e4d802cdc2d5f3f876c48ea918c961488.tar.bz2
make the application work again
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@388 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service/User.php')
-rw-r--r--src/SemanticScuttle/Service/User.php111
1 files changed, 61 insertions, 50 deletions
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index 407632b..bc88c0b 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -1,28 +1,39 @@
<?php
-class UserService {
- var $db;
- var $fields = array(
+class SemanticScuttle_Service_User extends SemanticScuttle_Service
+{
+ protected $db;
+ protected $fields = array(
'primary' => 'uId',
'username' => 'username',
'password' => 'password');
- var $profileurl;
- var $tablename;
- var $sessionkey;
- var $cookiekey;
- var $cookietime = 1209600; // 2 weeks
-
- function &getInstance(&$db) {
+ protected $profileurl;
+ protected $tablename;
+ protected $sessionkey;
+ protected $cookiekey;
+ protected $cookietime = 1209600; // 2 weeks
+
+ /**
+ * Returns the single service instance
+ *
+ * @param DB $db Database object
+ *
+ * @return SemanticScuttle_Service
+ */
+ public static function getInstance($db)
+ {
static $instance;
- if (!isset($instance))
- $instance =& new UserService($db);
+ if (!isset($instance)) {
+ $instance = new self($db);
+ }
return $instance;
}
- function UserService(& $db) {
- $this->db =& $db;
- $this->tablename = $GLOBALS['tableprefix'] .'users';
+ protected function __construct($db)
+ {
+ $this->db = $db;
+ $this->tablename = $GLOBALS['tableprefix'] .'users';
$this->sessionkey = INSTALLATION_ID.'-currentuserid';
- $this->cookiekey = INSTALLATION_ID.'-login';
+ $this->cookiekey = INSTALLATION_ID.'-login';
$this->profileurl = createURL('profile', '%2$s');
$this->updateSessionStability();
}
@@ -436,21 +447,21 @@ class UserService {
return true;
}
- function getAllUsers ( ) {
- $query = 'SELECT * FROM '. $this->getTableName();
-
- if (! ($dbresult =& $this->db->sql_query($query)) ) {
- message_die(GENERAL_ERROR, 'Could not get users', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- $rows = array();
-
- while ( $row = $this->db->sql_fetchrow($dbresult) ) {
- $rows[] = $row;
- }
- $this->db->sql_freeresult($dbresult);
- return $rows;
+ function getAllUsers ( ) {
+ $query = 'SELECT * FROM '. $this->getTableName();
+
+ if (! ($dbresult =& $this->db->sql_query($query)) ) {
+ message_die(GENERAL_ERROR, 'Could not get users', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ $rows = array();
+
+ while ( $row = $this->db->sql_fetchrow($dbresult) ) {
+ $rows[] = $row;
+ }
+ $this->db->sql_freeresult($dbresult);
+ return $rows;
}
// Returns an array with admin uIds
@@ -461,18 +472,18 @@ class UserService {
$admins[] = $this->getIdFromUser($adminName);
}
return $admins;
- }
-
- function deleteUser($uId) {
- $query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
-
- if (!($dbresult = & $this->db->sql_query($query))) {
- message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- return true;
- }
+ }
+
+ function deleteUser($uId) {
+ $query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
+
+ if (!($dbresult = & $this->db->sql_query($query))) {
+ message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ return true;
+ }
function sanitisePassword($password) {
@@ -601,7 +612,7 @@ class User {
function getName() {
// Look for value only if not already set
if(!isset($this->name)) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
$user = $userservice->getUser($this->id);
$this->name = $user['name'];
}
@@ -611,7 +622,7 @@ class User {
function getEmail() {
// Look for value only if not already set
if(!isset($this->email)) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
$user = $userservice->getUser($this->id);
$this->email = $user['email'];
}
@@ -621,7 +632,7 @@ class User {
function getHomepage() {
// Look for value only if not already set
if(!isset($this->homepage)) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
$user = $userservice->getUser($this->id);
$this->homepage = $user['homepage'];
}
@@ -631,7 +642,7 @@ class User {
function getContent() {
// Look for value only if not already set
if(!isset($this->content)) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
$user = $userservice->getUser($this->id);
$this->content = $user['uContent'];
}
@@ -641,7 +652,7 @@ class User {
function getDatetime() {
// Look for value only if not already set
if(!isset($this->content)) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
$user = $userservice->getUser($this->id);
$this->datetime = $user['uDatetime'];
}
@@ -651,14 +662,14 @@ class User {
function isAdmin() {
// Look for value only if not already set
if(!isset($this->isAdmin)) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
$this->isAdmin = $userservice->isAdmin($this->id);
}
return $this->isAdmin;
}
function getNbBookmarks($range = 'public') {
- $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
+ $bookmarkservice =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark');
return $bookmarkservice->countBookmarks($this->getId(), $range);
}
}