summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/SemanticScuttle/Model')
-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