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;
* @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
*/
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');
+ }
+ }
}