Added user quick search
authorMarcel Werk <burntime@woltlab.com>
Sat, 4 May 2013 18:54:30 +0000 (20:54 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 4 May 2013 18:54:30 +0000 (20:54 +0200)
wcfsetup/install/files/acp/templates/userSearch.tpl
wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 3927e669edffef662e6fabbf4d9e3ce50d3f7c51..44ff97f2dceb10f1afa2566dcefdeedb0e34dbc3 100644 (file)
 <div class="contentNavigation">
        <nav>
                <ul>
+                       <li class="dropdown">
+                               <a class="button dropdownToggle"><span class="icon icon16 icon-search"></span> <span>{lang}wcf.acp.user.quickSearch{/lang}</span></a>
+                               <ul class="dropdownMenu">
+                                       <li><a href="{link controller='UserQuickSearch'}mode=banned{/link}">{lang}wcf.acp.user.quickSearch.banned{/lang}</a></li>
+                                       <li><a href="{link controller='UserQuickSearch'}mode=newest{/link}">{lang}wcf.acp.user.quickSearch.newest{/lang}</a></li>
+                                       
+                                       {event name='quickSearchItems'}
+                               </ul>
+                       </li>
+                       
                        {event name='contentNavigationButtons'}
                </ul>
        </nav>
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 (file)
index 0000000..71cff19
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+namespace wcf\acp\action;
+use wcf\data\search\SearchEditor;
+use wcf\action\AbstractAction;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\NamedUserException;
+use wcf\system\menu\acp\ACPMenu;
+use wcf\system\request\LinkHandler;
+use wcf\system\WCF;
+use wcf\util\HeaderUtil;
+
+/**
+ * Provides special search options.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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<integer>
+        */
+       public $matches = array();
+       
+       /**
+        * results per page
+        * @var integer
+        */
+       public $itemsPerPage = 50;
+       
+       /**
+        * shown columns
+        * @var array<string>
+        */
+       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;
+       }
+}
index d65057636cc9a1b6512dbec3f587470e05e7ecbd..60d2a0124421e7250d7293f02129ec87eb3730cd 100644 (file)
                <item name="wcf.acp.user.sendMail.markedUsers"><![CDATA[E-Mail an folgende Benutzer senden]]></item>
                <item name="wcf.acp.user.sendMail.subject"><![CDATA[Betreff]]></item>
                <item name="wcf.acp.user.sendMail.text"><![CDATA[Nachricht]]></item>
+               <item name="wcf.acp.user.quickSearch"><![CDATA[Schnellsuche]]></item>
+               <item name="wcf.acp.user.quickSearch.banned"><![CDATA[Gesperrte Benutzer]]></item>
+               <item name="wcf.acp.user.quickSearch.newest"><![CDATA[Neueste Benutzer]]></item>
                <item name="wcf.acp.user.option.access"><![CDATA[Zugriff]]></item>
                <item name="wcf.acp.user.option.add"><![CDATA[Benutzerprofilfeld hinzufügen]]></item>
                <item name="wcf.acp.user.option.category.add"><![CDATA[Benutzerprofilfeld-Kategorie hinzufügen]]></item>
index e7af0540fa0e553df3f5b6134ab36947662d28db..159e8871b8f486cd5cf35eb07e1292f2ac490ebf 100644 (file)
                <item name="wcf.acp.user.sendMail.markedUsers"><![CDATA[Send email to following users]]></item>
                <item name="wcf.acp.user.sendMail.subject"><![CDATA[Subject]]></item>
                <item name="wcf.acp.user.sendMail.text"><![CDATA[Text]]></item>
+               <item name="wcf.acp.user.quickSearch"><![CDATA[TODO: Schnellsuche]]></item>
+               <item name="wcf.acp.user.quickSearch.banned"><![CDATA[TODO: Gesperrte Benutzer]]></item>
+               <item name="wcf.acp.user.quickSearch.newest"><![CDATA[TODO: Neueste Benutzer]]></item>
                <item name="wcf.acp.user.option.access"><![CDATA[TODO: Zugriff]]></item>
                <item name="wcf.acp.user.option.add"><![CDATA[Add Custom User Field]]></item>
                <item name="wcf.acp.user.option.category.add"><![CDATA[Add Custom User Field Category]]></item>