summaryrefslogtreecommitdiff
path: root/services/userservice.php
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-01-15 18:05:08 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-01-15 18:05:08 +0000
commit24ab0f6487d7a3883af126cc22f5d9d08acf3a80 (patch)
tree33e842341ca277da4ba757cacf716c796d36c5c9 /services/userservice.php
parenteac302f2255460c6d7e35f1d29c26d488089d6ea (diff)
downloadsemanticscuttle-24ab0f6487d7a3883af126cc22f5d9d08acf3a80.tar.gz
semanticscuttle-24ab0f6487d7a3883af126cc22f5d9d08acf3a80.tar.bz2
Minor Refactoring: add getIdFromUser()
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@238 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'services/userservice.php')
-rw-r--r--services/userservice.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/services/userservice.php b/services/userservice.php
index fa0d5c9..21b9136 100644
--- a/services/userservice.php
+++ b/services/userservice.php
@@ -127,7 +127,25 @@ class UserService {
function getObjectUserByUsername($username) {
$user = $this->_getuser($this->getFieldName('username'), $username);
- return new User($user[$this->getFieldName('primary')], $username);
+ if($user != false) {
+ return new User($user[$this->getFieldName('primary')], $username);
+ } else {
+ return NULL;
+ }
+ }
+
+ /* Takes an numerical "id" or a string "username"
+ and returns the numerical "id" if the user exists else returns NULL */
+ function getIdFromUser($user) {
+ if (is_int($user)) {
+ return intval($user);
+ } else {
+ $objectUser = $this->getObjectUserByUsername($user);
+ if($objectUser != NULL) {
+ return $objectUser->getId();
+ }
+ }
+ return NULL;
}
function getUser($id) {
@@ -465,7 +483,7 @@ class UserService {
// Check if the email domain has a DNS record
//if ($this->_checkdns($emailDomain)) {
- return true;
+ return true;
//}
}
return false;
@@ -520,7 +538,7 @@ class User {
}
return $this->name;
}
-
+
function getEmail() {
// Look for value only if not already set
if(!isset($this->email)) {
@@ -540,7 +558,7 @@ class User {
}
return $this->homepage;
}
-
+
function getContent() {
// Look for value only if not already set
if(!isset($this->content)) {
@@ -549,7 +567,7 @@ class User {
$this->content = $user['uContent'];
}
return $this->content;
- }
+ }
function getDatetime() {
// Look for value only if not already set