From 32b8797f39771c7572971152a2d1c22754176e06 Mon Sep 17 00:00:00 2001 From: Jeffrey Reichardt Date: Fri, 28 Dec 2012 16:01:19 +0100 Subject: [PATCH] Add response fields --- .../files/lib/data/user/User.class.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index 52066c2758..8365402952 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -3,6 +3,7 @@ namespace wcf\data\user; use wcf\data\user\group\UserGroup; use wcf\data\user\UserList; use wcf\data\DatabaseObject; +use wcf\system\api\rest\response\IRESTfulResponse; use wcf\system\cache\CacheHandler; use wcf\system\language\LanguageFactory; use wcf\system\request\IRouteController; @@ -20,7 +21,7 @@ use wcf\util\StringUtil; * @subpackage data.user * @category Community Framework */ -final class User extends DatabaseObject implements IRouteController { +final class User extends DatabaseObject implements IRouteController, IRESTfulResponse { /** * @see wcf\data\DatabaseObject::$databaseTableName */ @@ -376,4 +377,23 @@ final class User extends DatabaseObject implements IRouteController { public function canEdit() { return (WCF::getSession()->getPermission('admin.user.canEditUser') && UserGroup::isAccessibleGroup($this->getGroupIDs())); } + + /** + * @see IRESTfulResponse::getResponseFields() + */ + public function getResponseFields() { + $fields = array('userID', 'username', 'signature', 'profileHits', 'userTitle', 'activityPoints', 'likesReceived'); + + if ($this->canViewEmailAddress == 0) { + $fields[] = 'email'; + } + + if ($this->canViewProfile == 0) { + return $fields; + } + else { + // return only userID so we know there is an user but hidden + return array('userID'); + } + } } -- 2.20.1