From cc2c8242c76bdb39bc89976fb3425a5a934bf4b9 Mon Sep 17 00:00:00 2001 From: cweiske Date: Fri, 30 Oct 2009 06:05:29 +0000 Subject: move user class into own file git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@473 b3834d28-1941-0410-a4f8-b48e95affb8f --- src/SemanticScuttle/Model/User.php | 184 +++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 src/SemanticScuttle/Model/User.php (limited to 'src/SemanticScuttle/Model') 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 @@ + + * @author Christian Weiske + * @author Eric Dane + * @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 + * @author Christian Weiske + * @author Eric Dane + * @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 -- cgit v1.2.3