Add getUserByAuthData method to the User data object
authorSergey Fayngold <sergey@faynhost.com>
Fri, 11 Mar 2016 22:40:47 +0000 (23:40 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 13 Mar 2016 11:50:42 +0000 (12:50 +0100)
wcfsetup/install/files/lib/data/user/User.class.php

index 59fca7298e61f6ebc054b781399bb920f7345a87..ec9a26ae119b6edf3c43342e7434bf8bc2c89500 100644 (file)
@@ -314,6 +314,26 @@ final class User extends DatabaseObject implements IRouteController, IUserConten
                
                return new User(null, $row);
        }
+
+       /**
+        * Returns the user with the given authData.
+        *
+        * @param       string          $authData
+        * @return      \wcf\data\user\User
+        */
+       public static function getUserByAuthData($authData) {
+               $sql = "SELECT          user_option_value.*, user_table.*
+                       FROM            wcf".WCF_N."_user user_table
+                       LEFT JOIN       wcf".WCF_N."_user_option_value user_option_value
+                       ON              (user_option_value.userID = user_table.userID)
+                       WHERE           user_table.authData = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($authData));
+               $row = $statement->fetchArray();
+               if (!$row) $row = array();
+
+               return new User(null, $row);
+       }
        
        /**
         * Returns true if this user is marked.