]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/user/class_BaseUser.php
Again, a commit! ;-)
[shipsimu.git] / inc / classes / main / user / class_BaseUser.php
index 0a3432de390c06c6729bc4ff4760a5f6009b6071..b3fc24d717409210fba85d3165f371ca220a658b 100644 (file)
@@ -32,6 +32,11 @@ class BaseUser extends BaseFrameworkSystem {
         */
        private $userName = "";
 
+       /**
+        * User id of current user
+        */
+       private $userId = 0;
+
        /**
         * Email of current user
         */
@@ -59,26 +64,46 @@ class BaseUser extends BaseFrameworkSystem {
         * @return      void
         */
        public final function setUserName ($userName) {
-               $this->userName = $userName;
+               $this->userName = (string) $userName;
        }
 
        /**
-        * Setter for email
+        * Getter for username
         *
-        * @param       $email  The email to set
+        * @return      $userName       The username to get
+        */
+       public final function getUserName () {
+               return $this->userName;
+       }
+
+       /**
+        * Setter for user id
+        *
+        * @param       $userId         The user id to set
         * @return      void
+        * @todo        Find a way of casting here. "(int)" might destroy the user id > 32766
         */
-       protected final function setEmail ($email) {
-               $this->email = $email;
+       public final function setUserId ($userId) {
+               $this->userId = $userId;
        }
 
        /**
-        * Getter for username
+        * Getter for user id
         *
-        * @return      $userName       The username to get
+        * @return      $userId The user id to get
         */
-       public final function getUsername () {
-               return $this->userName;
+       public final function getUserId () {
+               return $this->userId;
+       }
+
+       /**
+        * Setter for email
+        *
+        * @param       $email  The email to set
+        * @return      void
+        */
+       protected final function setEmail ($email) {
+               $this->email = (string) $email;
        }
 
        /**
@@ -108,7 +133,8 @@ class BaseUser extends BaseFrameworkSystem {
                        $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                        // Add the username as a criteria and set limit to one entry
-                       $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
+                       $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+                       $criteriaInstance->setIndexSolution(UserDatabaseWrapper::DB_COLUMN_USERID, array($this, 'setUserId'));
                        $criteriaInstance->setLimit(1);
 
                        // Get a search result
@@ -147,6 +173,7 @@ class BaseUser extends BaseFrameworkSystem {
 
                        // Add the username as a criteria and set limit to one entry
                        $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
+                       $criteriaInstance->setIndexSolution(UserDatabaseWrapper::DB_COLUMN_USERID, array($this, 'setUserId'));
                        $criteriaInstance->setLimit(1);
 
                        // Get a search resultInstance
@@ -194,6 +221,7 @@ class BaseUser extends BaseFrameworkSystem {
 
                // Add the username as a criteria and set limit to one entry
                $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+               $criteriaInstance->setIndexSolution(UserDatabaseWrapper::DB_COLUMN_USERID, array($this, 'setUserId'));
                $criteriaInstance->setLimit(1);
 
                // Get a search resultInstance