From: Alexander Ebert Date: Wed, 28 Dec 2011 16:05:21 +0000 (+0100) Subject: Added getList() for WCF.Search.User X-Git-Tag: 2.0.0_Beta_1~1473 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d5cab4424625f8616b4cc7c5160d76d5187aab71;p=GitHub%2FWoltLab%2FWCF.git Added getList() for WCF.Search.User --- diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 560913a818..9bbfa4b76c 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -5,6 +5,7 @@ use wcf\data\user\group\UserGroup; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\ValidateActionException; use wcf\system\WCF; +use wcf\util\StringUtil; /** * Executes user-related actions. @@ -148,4 +149,43 @@ class UserAction extends AbstractDatabaseObjectAction { } } } + + public function validateGetList() { + } + + public function getList() { + $searchString = $this->parameters['data']['searchString']; + $list = array(); + + if ($this->parameters['data']['includeUserGroups']) { + $accessibleGroups = UserGroup::getAccessibleGroups(); + foreach ($accessibleGroups as $group) { + $groupName = WCF::getLanguage()->get($group->groupName); + $pos = StringUtil::indexOfIgnoreCase($groupName, $searchString); + if ($pos !== false && $pos == 0) { + $list[] = array( + 'label' => $groupName, + 'objectID' => $group->groupID, + 'type' => 'group' + ); + } + } + } + + // find users + $sql = "SELECT userID, username + FROM wcf".WCF_N."_user + WHERE username LIKE ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($searchString.'%')); + while ($row = $statement->fetchArray()) { + $list[] = array( + 'label' => $row['username'], + 'objectID' => $row['userID'], + 'type' => 'user' + ); + } + + return $list; + } }