summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Model/User.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-30 06:05:29 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-30 06:05:29 +0000
commitcc2c8242c76bdb39bc89976fb3425a5a934bf4b9 (patch)
tree1d2a58e521debd946d005f4f71878910b2b4932e /src/SemanticScuttle/Model/User.php
parentcb713ccd7619cb55ce9e948599ad46cdacf6715e (diff)
downloadsemanticscuttle-cc2c8242c76bdb39bc89976fb3425a5a934bf4b9.tar.gz
semanticscuttle-cc2c8242c76bdb39bc89976fb3425a5a934bf4b9.tar.bz2
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/Model/User.php')
-rw-r--r--src/SemanticScuttle/Model/User.php184
1 files changed, 184 insertions, 0 deletions
diff --git a/src/SemanticScuttle/Model/User.php b/src/SemanticScuttle/Model/User.php
new file mode 100644
index 0000000..03af5c7
--- /dev/null
+++ b/src/SemanticScuttle/Model/User.php
@@ -0,0 +1,184 @@
+<?php
+/**
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @author Eric Dane <ericdane@users.sourceforge.net>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+
+/**
+ * SemanticScuttle user object.
+ * Rare fields are filled if required.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @author Eric Dane <ericdane@users.sourceforge.net>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+class SemanticScuttle_Model_User
+{
+ var $id;
+ var $username;
+ var $name;
+ var $email;
+ var $homepage;
+ var $content;
+ var $datetime;
+ var $isAdmin;
+
+ /**
+ * Create a new user object
+ *
+ * @param integer $id User ID
+ * @param string $username Username
+ */
+ public function __construct($id, $username)
+ {
+ $this->id = $id;
+ $this->username = $username;
+ }
+
+ /**
+ * Returns user ID
+ *
+ * @return integer ID
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Returns logon user name
+ *
+ * @return string User name
+ */
+ public function getUsername()
+ {
+ return $this->username;
+ }
+
+ /**
+ * Returns full user name as specified in the profile.
+ *
+ * @return string Full name
+ */
+ public function getName()
+ {
+ // Look for value only if not already set
+ if (!isset($this->name)) {
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $user = $us->getUser($this->id);
+ $this->name = $user['name'];
+ }
+ return $this->name;
+ }
+
+ /**
+ * Returns user email address
+ *
+ * @return string Email address
+ */
+ public function getEmail()
+ {
+ // Look for value only if not already set
+ if (!isset($this->email)) {
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $user = $us->getUser($this->id);
+ $this->email = $user['email'];
+ }
+ return $this->email;
+ }
+
+ /**
+ * Returns user homepage as specified in the profile.
+ *
+ * @return string Homepage
+ */
+ public function getHomepage()
+ {
+ // Look for value only if not already set
+ if(!isset($this->homepage)) {
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $user = $us->getUser($this->id);
+ $this->homepage = $user['homepage'];
+ }
+ return $this->homepage;
+ }
+
+ /**
+ * Returns custom user description as specified in the profile.
+ *
+ * @return string User description
+ */
+ public function getContent()
+ {
+ // Look for value only if not already set
+ if(!isset($this->content)) {
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $user = $us->getUser($this->id);
+ $this->content = $user['uContent'];
+ }
+ return $this->content;
+ }
+
+ /**
+ * Returns user creation time
+ *
+ * @return string Datetime value: "YYYY-MM-DD HH:MM:SS"
+ */
+ public function getDatetime()
+ {
+ // Look for value only if not already set
+ if(!isset($this->content)) {
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $user = $us->getUser($this->id);
+ $this->datetime = $user['uDatetime'];
+ }
+ return $this->datetime;
+ }
+
+ /**
+ * Tells you if the user is an administrator
+ *
+ * @return boolean True if the user is admin
+ */
+ public function isAdmin()
+ {
+ // Look for value only if not already set
+ if(!isset($this->isAdmin)) {
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $this->isAdmin = $us->isAdmin($this->id);
+ }
+ return $this->isAdmin;
+ }
+
+ /**
+ * Returns the number of bookmarks the user owns
+ *
+ * @param string $range Range of bookmarks:
+ * 'public', 'shared', 'private'
+ * or 'all'
+ *
+ * @return integer Number of bookmarks
+ *
+ * @uses SemanticScuttle_Service_Bookmark::countBookmarks()
+ */
+ public function getNbBookmarks($range = 'public')
+ {
+ $bs = SemanticScuttle_Service_Factory::get('Bookmark');
+ return $bs->countBookmarks($this->getId(), $range);
+ }
+
+}
+?> \ No newline at end of file