From: Marcel Werk Date: Sat, 4 May 2013 18:54:30 +0000 (+0200) Subject: Added user quick search X-Git-Tag: 2.0.0_Beta_1~258 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ccff359f0ee0be6730e83d3510c0b5921dae3bb0;p=GitHub%2FWoltLab%2FWCF.git Added user quick search --- diff --git a/wcfsetup/install/files/acp/templates/userSearch.tpl b/wcfsetup/install/files/acp/templates/userSearch.tpl index 3927e669ed..44ff97f2dc 100644 --- a/wcfsetup/install/files/acp/templates/userSearch.tpl +++ b/wcfsetup/install/files/acp/templates/userSearch.tpl @@ -20,6 +20,16 @@
diff --git a/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php b/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php new file mode 100644 index 0000000000..71cff1930b --- /dev/null +++ b/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php @@ -0,0 +1,142 @@ + + * @package com.woltlab.wcf + * @subpackage acp.action + * @category Community Framework + */ +class UserQuickSearchAction extends AbstractAction { + /** + * @see wcf\action\AbstractAction::$neededPermissions + */ + public $neededPermissions = array('admin.user.canEditUser'); + + /** + * search mode + * @var string + */ + public $mode = ''; + + /** + * matches + * @var array + */ + public $matches = array(); + + /** + * results per page + * @var integer + */ + public $itemsPerPage = 50; + + /** + * shown columns + * @var array + */ + public $columns = array('email', 'registrationDate'); + + /** + * sort field + * @var string + */ + public $sortField = 'username'; + + /** + * sort order + * @var string + */ + public $sortOrder = 'ASC'; + + /** + * number of results + * @var integer + */ + public $maxResults = 500; + + /** + * @see wcf\action\IAction::readParameters() + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['mode'])) $this->mode = $_REQUEST['mode']; + } + + /** + * @see wcf\action\IAction::execute(); + */ + public function execute() { + ACPMenu::getInstance()->setActiveMenuItem('wcf.acp.menu.link.user.search'); + + parent::execute(); + + switch ($this->mode) { + case 'banned': + $sql = "SELECT user_table.userID + FROM wcf".WCF_N."_user user_table + LEFT JOIN wcf".WCF_N."_user_option_value option_value + ON (option_value.userID = user_table.userID) + WHERE banned = ?"; + $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults); + $statement->execute(array(1)); + while ($row = $statement->fetchArray()) { + $this->matches[] = $row['userID']; + } + break; + + case 'newest': + $this->maxResults = 100; + $this->sortField = 'registrationDate'; + $this->sortOrder = 'DESC'; + $sql = "SELECT user_table.userID + FROM wcf".WCF_N."_user user_table + LEFT JOIN wcf".WCF_N."_user_option_value option_value + ON (option_value.userID = user_table.userID) + ORDER BY user_table.registrationDate DESC"; + $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults); + $statement->execute(); + while ($row = $statement->fetchArray()) { + $this->matches[] = $row['userID']; + } + break; + } + + if (empty($this->matches)) { + throw new NamedUserException(WCF::getLanguage()->get('wcf.acp.user.search.error.noMatches')); + } + + // store search result in database + $data = serialize(array( + 'matches' => $this->matches, + 'itemsPerPage' => $this->itemsPerPage, + 'columns' => $this->columns + )); + + $search = SearchEditor::create(array( + 'userID' => WCF::getUser()->userID, + 'searchData' => $data, + 'searchTime' => TIME_NOW, + 'searchType' => 'users' + )); + $this->executed(); + + // forward to result page + $url = LinkHandler::getInstance()->getLink('UserList', array('id' => $search->searchID), 'sortField='.rawurlencode($this->sortField).'&sortOrder='.rawurlencode($this->sortOrder)); + HeaderUtil::redirect($url); + exit; + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index d65057636c..60d2a01244 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -724,6 +724,9 @@ + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index e7af0540fa..159e8871b8 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -724,6 +724,9 @@ + + +