From 21ab92703e5bd0e862b11dfd98a83b0ecabaf164 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 11 Nov 2011 16:19:35 +0100 Subject: [PATCH] User options are now fetched with each user object --- XSD/userOption.xsd | 4 +-- com.woltlab.wcf/userOption.xml | 4 +-- .../files/lib/data/user/User.class.php | 26 ++++++++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/XSD/userOption.xsd b/XSD/userOption.xsd index e29381140b..f2d7c8e765 100644 --- a/XSD/userOption.xsd +++ b/XSD/userOption.xsd @@ -78,7 +78,7 @@ - + @@ -91,4 +91,4 @@ - \ No newline at end of file + diff --git a/com.woltlab.wcf/userOption.xml b/com.woltlab.wcf/userOption.xml index e2be324da7..d9dd004243 100644 --- a/com.woltlab.wcf/userOption.xml +++ b/com.woltlab.wcf/userOption.xml @@ -9,10 +9,10 @@ - \ No newline at end of file + diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index b20e373cc2..69eecd4920 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -18,7 +18,7 @@ use wcf\util\StringUtil; * @subpackage data.user * @category Community Framework */ -class User extends DatabaseObject { +final class User extends DatabaseObject { /** * @see wcf\data\DatabaseObject::$databaseTableName */ @@ -56,6 +56,30 @@ class User extends DatabaseObject { */ protected static $userOptions = null; + /** + * @see wcf\data\DatabaseObject::__construct() + */ + public function __construct($id, $row = null, User $object = null) { + if ($id !== null) { + $sql = "SELECT * + 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.userID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($id)); + $row = $statement->fetchArray(); + + // enforce data type 'array' + if ($row === false) $row = array(); + } + else if ($object !== null) { + $row = $object->data; + } + + $this->handleData($row); + } + /** * Returns true, if the given password is the correct password for this user. * -- 2.20.1