[Jaws-commits] r13315 - trunk/jaws/html/include/Jaws

afz at jaws-project.com afz at jaws-project.com
Wed Aug 8 06:03:58 UTC 2012


Author: afz
Date: 2012-08-08 06:03:58 +0000 (Wed, 08 Aug 2012)
New Revision: 13315

Modified:
   trunk/jaws/html/include/Jaws/User.php
Log:
Update Jaws_User for applying new changes

Modified: trunk/jaws/html/include/Jaws/User.php
===================================================================
--- trunk/jaws/html/include/Jaws/User.php	2012-08-08 06:03:39 UTC (rev 13314)
+++ trunk/jaws/html/include/Jaws/User.php	2012-08-08 06:03:58 UTC (rev 13315)
@@ -51,12 +51,12 @@
 
         $sql = "
             SELECT [id], [passwd], [superadmin], [bad_passwd_count], [concurrent_logins],
-                   [last_access], [enabled]
+                   [last_access], [status]
             FROM [[users]]
             WHERE $username = {user}";
 
         $types = array('integer', 'text', 'boolean', 'integer', 'integer',
-                       'integer', 'boolean');
+                       'integer', 'integer');
         $result = $GLOBALS['db']->queryRow($sql, $params, $types);
         if (Jaws_Error::IsError($result)) {
             return $result;
@@ -81,8 +81,8 @@
             if ($result['passwd'] === Jaws_User::GetHashedPassword($password, $result['passwd']) ||
                 trim($result['passwd']) === md5($password))
             {
-                if (!$result['enabled']) {
-                    return Jaws_Error::raiseError(_t('GLOBAL_ERROR_LOGIN_DISABLED'),
+                if ($result['status'] !== 1) {
+                    return Jaws_Error::raiseError(_t('GLOBAL_ERROR_LOGIN_STATUS_'. $result['status']),
                                                   __FUNCTION__,
                                                   JAWS_ERROR_NOTICE);
                 }
@@ -152,8 +152,8 @@
         $types = array('integer');
 
         if ($account) {
-            $sql .= ', [username], [nickname], [email], [superadmin], [concurrent_logins], [enabled]';
-            $types = array_merge($types, array('text', 'text', 'text', 'boolean', 'integer', 'boolean'));
+            $sql .= ', [username], [nickname], [email], [superadmin], [concurrent_logins], [status]';
+            $types = array_merge($types, array('text', 'text', 'text', 'boolean', 'integer', 'integer'));
         }
         if ($personal) {
             $sql .= ', [fname], [lname], [gender], [dob], [url]';
@@ -221,8 +221,8 @@
         $types = array('integer');
 
         if ($account) {
-            $sql .= ', [username], [nickname], [email], [superadmin], [concurrent_logins], [enabled]';
-            $types = array_merge($types, array('text', 'text', 'text', 'boolean', 'integer', 'boolean'));
+            $sql .= ', [username], [nickname], [email], [superadmin], [concurrent_logins], [status]';
+            $types = array_merge($types, array('text', 'text', 'text', 'boolean', 'integer', 'integer'));
         }
         if ($personal) {
             $sql .= ', [fname], [lname], [gender], [dob], [url]';
@@ -263,11 +263,11 @@
         $email = $GLOBALS['db']->dbc->function->lower('[email]');
 
         $sql = "
-            SELECT [id], [username], [nickname], [email], [superadmin], [enabled]
+            SELECT [id], [username], [nickname], [email], [superadmin], [status]
             FROM [[users]]
             WHERE $email = {email}";
 
-        $types = array('integer', 'text', 'text', 'text', 'boolean', 'boolean');
+        $types = array('integer', 'text', 'text', 'text', 'boolean', 'integer');
         return $GLOBALS['db']->queryAll($sql, $params, $types);
     }
 
@@ -349,11 +349,11 @@
      * @access  public
      * @param   mixed   $group      Group ID of users
      * @param   mixed   $superadmin Type of user(null = all types, true = superadmin, false = normal)
-     * @param   boolean $enabled    enabled users?(null for both)
+     * @param   int     $status     user's status (null: all users, 0: disabled, 1: active, 2: pending)
      * @param   string  $orderBy    field to order by
      * @return  array   Returns an array of the available users and false on error
      */
-    function GetUsers($group = false, $superadmin = null, $enabled = null, $orderBy = 'nickname',
+    function GetUsers($group = false, $superadmin = null, $status = null, $orderBy = 'nickname',
                       $limit = 0, $offset = null)
     {
         $fields  = array('id', 'username', 'email', 'nickname');
@@ -366,16 +366,16 @@
         $params = array();
         $params['gid']        = $group;
         $params['superadmin'] = (bool)$superadmin;
-        $params['enabled']    = (bool)$enabled;
+        $params['status']     = (int)$status;
 
         $sql = '
             SELECT
                 [[users]].[id], [username], [email], [url], [nickname], [fname], [lname],
-                [superadmin], [language], [theme], [editor], [timezone], [[users]].[enabled]
+                [superadmin], [language], [theme], [editor], [timezone], [[users]].[status]
             FROM [[users]]';
 
         $types = array('integer', 'text', 'text', 'text', 'text', 'text', 'text',
-                       'boolean', 'text', 'text', 'text', 'text', 'boolean');
+                       'boolean', 'text', 'text', 'text', 'text', 'integer');
         if ($group !== false) {
             $sql .= '
                 INNER JOIN [[users_groups]] ON [[users_groups]].[user_id] = [[users]].[id]
@@ -391,12 +391,12 @@
             }
         }
 
-        if (!is_null($enabled)) {
+        if (!is_null($status)) {
             if ($group === false && is_null($superadmin)) {
                 $sql .= '
-                    WHERE [[users]].[enabled] = {enabled}';
+                    WHERE [[users]].[status] = {status}';
             } else {
-                $sql .= ' AND [[users]].[enabled] = {enabled}';
+                $sql .= ' AND [[users]].[status] = {status}';
             }
         }
 
@@ -424,15 +424,15 @@
      * @access  public
      * @param   mixed   $group      Group ID of users
      * @param   mixed   $superadmin Type of user(null = all types, true = superadmin, false = normal)
-     * @param   boolean $enabled    enabled users?(null for both)
+     * @param   int     $status     user's status (null: all users, 0: disabled, 1: active, 2: pending)
      * @return  integer Returns users count
      */
-    function GetUsersCount($group = false, $superadmin = null, $enabled = null)
+    function GetUsersCount($group = false, $superadmin = null, $status = null)
     {
         $params = array();
         $params['gid']        = $group;
         $params['superadmin'] = (bool)$superadmin;
-        $params['enabled']    = (bool)$enabled;
+        $params['status']     = (int)$status;
 
         $sql = '
             SELECT
@@ -454,12 +454,12 @@
             }
         }
 
-        if (!is_null($enabled)) {
+        if (!is_null($status)) {
             if ($group === false && is_null($superadmin)) {
                 $sql .= '
-                    WHERE [[users]].[enabled] = {enabled}';
+                    WHERE [[users]].[status] = {status}';
             } else {
-                $sql .= ' AND [[users]].[enabled] = {enabled}';
+                $sql .= ' AND [[users]].[status] = {status}';
             }
         }
 
@@ -475,7 +475,7 @@
      * Get a list of all groups
      *
      * @access  public
-     * @param   boolean $enabled    enabled groups?(null for both)
+     * @param   bool    $enabled    enabled groups?(null for both)
      * @param   string  $orderBy    field to order by
      * @return  array   Returns an array of the available groups and false on error
      */
@@ -516,7 +516,7 @@
      * Get count of groups
      *
      * @access  public
-     * @param   boolean $enabled    enabled groups?(null for both)
+     * @param   bool    $enabled    enabled groups?(null for both)
      * @return  integer Returns groups count
      */
     function GetGroupsCount($enabled = null)
@@ -579,11 +579,11 @@
      * @param   string  $password   User's password
      * @param   string  $superadmin Is superadmin (superadmin or normal)
      * @param   int     $concurrent_logins  Concurrent logins limitation
-     * @param   boolean $enabled    Enabled/Disabled
+     * @param   int     $status     User's status
      * @return  boolean Returns true if user was successfully added, false if not
      */
     function AddUser($username, $nickname, $email, $password, $superadmin = false,
-                     $concurrent_logins = 0, $enabled = true)
+                     $concurrent_logins = 0, $status = 1)
     {
         $username = trim($username);
         if (!preg_match('/^[[:alnum:]-_.@]{3,24}$/', $username)) {
@@ -630,15 +630,15 @@
         $params['superadmin']        = (bool)$superadmin;
         $params['now']               = $GLOBALS['db']->Date();
         $params['concurrent_logins'] = (int)$concurrent_logins;
-        $params['enabled']           = (bool)$enabled;
+        $params['status']            = (int)$status;
 
         $sql = '
             INSERT INTO [[users]]
                 ([username], [nickname], [email], [passwd], [superadmin],
-                 [createtime], [updatetime], [concurrent_logins], [enabled])
+                 [createtime], [updatetime], [concurrent_logins], [status])
             VALUES
                 ({username}, {nickname}, {email}, {password}, {superadmin},
-                 {now}, {now}, {concurrent_logins}, {enabled})';
+                 {now}, {now}, {concurrent_logins}, {status})';
 
         $result = $GLOBALS['db']->query($sql, $params);
         if (Jaws_Error::IsError($result)) {
@@ -670,13 +670,13 @@
      * @param   string  $nickname   User's display name
      * @param   string  $email      User's email
      * @param   string  $password   User's password
-     * @param   boolean $superadmin Is superadmin
+     * @param   bool    $superadmin Is superadmin
      * @param   int     $concurrent_logins   Concurrent logins limitation
-     * @param   boolean $enabled    enable/disable user
+     * @param   int     $status     User's status
      * @return  boolean Returns true if user was successfully updated, false if not
      */
     function UpdateUser($id, $username, $nickname, $email, $password = null, $superadmin = null,
-                        $concurrent_logins = null, $enabled = null)
+                        $concurrent_logins = null, $status = null)
     {
         $username = trim($username);
         if (!preg_match('/^[[:alnum:]-_.@]{3,24}$/', $username)) {
@@ -725,7 +725,7 @@
         $params['superadmin']        = (bool)$superadmin;
         $params['updatetime']        = $GLOBALS['db']->Date();
         $params['concurrent_logins'] = $concurrent_logins;
-        $params['enabled']           = (bool)$enabled;
+        $params['status']            = (int)$status;
 
         $sql = '
             UPDATE [[users]] SET
@@ -742,8 +742,8 @@
         if (!is_null($concurrent_logins)) {
             $sql .= ', [concurrent_logins] = {concurrent_logins} ';
         }
-        if (!is_null($enabled)) {
-            $sql .= ', [enabled] = {enabled} ';
+        if (!is_null($status)) {
+            $sql .= ', [status] = {status} ';
         }
 
         $sql .= 'WHERE [id] = {id}';
@@ -855,7 +855,7 @@
      * @param   string  $name        Group's name
      * @param   string  $title       Group's title
      * @param   string  $description Group's description
-     * @param   boolean $removable   (Optional) Can the group be removed by users (via UI)?
+     * @param   bool    $removable   (Optional) Can the group be removed by users (via UI)?
      * @return  boolean Returns true if group  was sucessfully added, false if not
      */
     function AddGroup($name, $title, $description, $removable = true)
@@ -1130,13 +1130,13 @@
     }
 
     /**
-     * Returns the ID of a user by a certain validation key
+     * Returns the ID of a user by a certain verification key
      *
      * @access  public
      * @param   string  $key  Secret key
      * @return  boolean Success/Failure
      */
-    function GetIDByValidationKey($key)
+    function GetIDByVerificationKey($key)
     {
         $key = trim($key);
         if (empty($key)) {
@@ -1146,7 +1146,7 @@
         $params        = array();
         $params['key'] = $key;
 
-        $sql = ' SELECT [id] FROM [[users]] WHERE [validation_key] = {key}';
+        $sql = ' SELECT [id] FROM [[users]] WHERE [verification_key] = {key}';
         $uid = $GLOBALS['db']->queryOne($sql, $params);
         if (Jaws_Error::IsError($uid) || empty($uid)) {
             return false;
@@ -1164,7 +1164,7 @@
      * @param   string  $key  (Optional) Secret key
      * @return  boolean Success/Failure
      */
-    function UpdateValidationKey($uid, $key = '')
+    function UpdateVerificationKey($uid, $key = '')
     {
         if (empty($key)) {
             $key = md5(uniqid(rand(), true)) . time() . floor(microtime()*1000);
@@ -1176,7 +1176,7 @@
 
         $sql = '
             UPDATE [[users]] SET
-                [validation_key] = {key}
+                [verification_key] = {key}
             WHERE [id] = {id}';
         $result = $GLOBALS['db']->query($sql, $params);
         if (Jaws_Error::isError($result)) {



More information about the Jaws-commits mailing list