<conditiongroup>userOptions</conditiongroup>
</type>
<!-- /user bulk processing conditions -->
+
+ <!-- user search conditions -->
+ <type>
+ <name>com.woltlab.wcf.username</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserUsernameCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.email</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserEmailCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.userGroup</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserGroupCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.languages</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserLanguageCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.registrationDate</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserRegistrationDateCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.registrationDateInterval</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserRegistrationDateIntervalCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.avatar</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserAvatarCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.state</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserStateCondition]]></classname>
+ <conditiongroup>general</conditiongroup>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.activityPoints</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserIntegerPropertyCondition]]></classname>
+ <conditiongroup>contents</conditiongroup>
+ <propertyname>activityPoints</propertyname>
+ <minvalue>0</minvalue>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.likesReceived</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserIntegerPropertyCondition]]></classname>
+ <conditiongroup>contents</conditiongroup>
+ <propertyname>likesReceived</propertyname>
+ <minvalue>0</minvalue>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.userOptions</name>
+ <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
+ <classname><![CDATA[wcf\system\condition\UserOptionsCondition]]></classname>
+ <conditiongroup>userOptions</conditiongroup>
+ </type>
+ <!-- /user search conditions -->
</import>
</data>
</div>
<form method="post" action="{link controller='UserSearch'}{/link}">
- <div class="tabMenuContainer">
- <nav class="tabMenu">
- <ul>
- <li><a href="{@$__wcf->getAnchor('conditions')}">{lang}wcf.acp.user.search.conditions{/lang}</a></li>
-
- {if $optionTree|count}
- <li><a href="{@$__wcf->getAnchor('profile')}">{lang}wcf.acp.user.search.conditions.profile{/lang}</a></li>
- {/if}
-
- {event name='tabMenuTabs'}
-
- <li><a href="{@$__wcf->getAnchor('resultOptions')}">{lang}wcf.acp.user.search.display{/lang}</a></li>
- </ul>
- </nav>
-
- <div id="conditions" class="container containerPadding tabMenuContent hidden">
- <fieldset>
- <legend>{lang}wcf.acp.user.search.conditions{/lang}</legend>
-
- <dl>
- <dt><label for="username">{lang}wcf.user.username{/lang}</label></dt>
- <dd>
- <input type="text" id="username" name="username" value="{$username}" class="medium" />
- </dd>
- </dl>
-
- <dl>
- <dt><label for="userID">{lang}wcf.user.userID{/lang}</label></dt>
- <dd>
- <input type="number" id="userID" name="userID" value="{$userID}" class="short" />
- </dd>
- </dl>
-
- {if $__wcf->session->getPermission('admin.user.canEditMailAddress')}
- <dl>
- <dt><label for="email">{lang}wcf.user.email{/lang}</label></dt>
- <dd>
- <input type="text" id="email" name="email" value="{$email}" class="medium" />
- </dd>
- </dl>
- {/if}
-
- {if $availableGroups|count}
- <dl>
- <dt>
- <label>{lang}wcf.acp.user.groups{/lang}</label>
- </dt>
- <dd>
- {htmlCheckboxes options=$availableGroups name='groupIDs' selected=$groupIDs}
-
- <label class="marginTop"><input type="checkbox" name="invertGroupIDs" value="1" {if $invertGroupIDs == 1}checked="checked" {/if}/> {lang}wcf.acp.user.groups.invertSearch{/lang}</label>
- </dd>
- </dl>
- {/if}
-
- {if $availableLanguages|count > 1}
- <dl>
- <dt>
- <label>{lang}wcf.user.language{/lang}</label>
- </dt>
- <dd>
- {htmlCheckboxes options=$availableLanguages name='languageIDs' selected=$languageIDs disableEncoding=true}
- </dd>
- </dl>
- {/if}
-
- <dl>
- <dt><label for="registrationDateStart">{lang}wcf.user.registrationDate{/lang}</label></dt>
- <dd>
- <input type="date" id="registrationDateStart" name="registrationDateStart" value="{$registrationDateStart}" placeholder="{lang}wcf.date.period.start{/lang}" />
- <input type="date" id="registrationDateEnd" name="registrationDateEnd" value="{$registrationDateEnd}" placeholder="{lang}wcf.date.period.end{/lang}" />
- </dd>
- </dl>
-
- <dl>
- <dt><label for="lastActivityTimeStart">{lang}wcf.user.lastActivityTime{/lang}</label></dt>
- <dd>
- <input type="date" id="lastActivityTimeStart" name="lastActivityTimeStart" value="{$lastActivityTimeStart}" placeholder="{lang}wcf.date.period.start{/lang}" />
- <input type="date" id="lastActivityTimeEnd" name="lastActivityTimeEnd" value="{$lastActivityTimeEnd}" placeholder="{lang}wcf.date.period.end{/lang}" />
- </dd>
- </dl>
-
- {event name='conditionFields'}
- </fieldset>
+ <header class="boxHeadline boxSubHeadline">
+ <h2>{lang}wcf.acp.user.search.conditions{/lang}</h2>
+ </header>
+
+ {include file='userConditions'}
+
+ <header class="boxHeadline boxSubHeadline">
+ <h2>{lang}wcf.acp.user.search.display{/lang}</h2>
+ </header>
+
+ <div class="container containerPadding marginTop">
+ <fieldset>
+ <legend>{lang}wcf.acp.user.search.display.general{/lang}</legend>
- <fieldset>
- <legend>{lang}wcf.acp.user.search.conditions.states{/lang}</legend>
-
- <dl>
- <dt></dt>
- <dd>
- <label><input type="checkbox" name="banned" value="1" {if $banned == 1}checked="checked" {/if}/> {lang}wcf.acp.user.search.conditions.state.banned{/lang}</label>
- <label><input type="checkbox" name="notBanned" value="1" {if $notBanned == 1}checked="checked" {/if}/> {lang}wcf.acp.user.search.conditions.state.notBanned{/lang}</label>
- <label><input type="checkbox" name="enabled" value="1" {if $enabled == 1}checked="checked" {/if}/> {lang}wcf.acp.user.search.conditions.state.enabled{/lang}</label>
- <label><input type="checkbox" name="disabled" value="1" {if $disabled == 1}checked="checked" {/if}/> {lang}wcf.acp.user.search.conditions.state.disabled{/lang}</label>
+ <dl>
+ <dt><label for="sortField">{lang}wcf.acp.user.search.display.sort{/lang}</label></dt>
+ <dd>
+ <select id="sortField" name="sortField">
+ <option value="userID"{if $sortField == 'userID'} selected="selected"{/if}>{lang}wcf.user.userID{/lang}</option>
+ <option value="username"{if $sortField == 'username'} selected="selected"{/if}>{lang}wcf.user.username{/lang}</option>
+ <option value="email"{if $sortField == 'email'} selected="selected"{/if}>{lang}wcf.user.email{/lang}</option>
+ <option value="registrationDate"{if $sortField == 'registrationDate'} selected="selected"{/if}>{lang}wcf.user.registrationDate{/lang}</option>
- {event name='states'}
- </dd>
- </dl>
-
- {event name='stateFields'}
- </fieldset>
+ {if $additionalSortFields|isset}{@$additionalSortFields}{/if}
+ </select>
+
+ <select id="sortOrder" name="sortOrder">
+ <option value="ASC"{if $sortOrder == 'ASC'} selected="selected"{/if}>{lang}wcf.global.sortOrder.ascending{/lang}</option>
+ <option value="DESC"{if $sortOrder == 'DESC'} selected="selected"{/if}>{lang}wcf.global.sortOrder.descending{/lang}</option>
+ </select>
+ </dd>
+ </dl>
- {event name='conditionFieldsets'}
- </div>
-
- {if $optionTree|count}
- <div id="profile" class="container containerPadding tabMenuContent hidden">
- {foreach from=$optionTree[0][categories] item=category}
- <fieldset>
- <legend>{lang}wcf.user.option.category.{@$category[object]->categoryName}{/lang}</legend>
- {hascontent}<p>{content}{lang __optional=true}wcf.user.option.category.{@$category[object]->categoryName}.description{/lang}{/content}</p>{/hascontent}
-
- {include file='optionFieldList' options=$category[options] langPrefix='wcf.user.option.' isSearchMode=true}
- </fieldset>
- {/foreach}
-
- {event name='profileFieldsets'}
- </div>
- {/if}
-
- {event name='tabMenuContent'}
+ <dl>
+ <dt><label for="itemsPerPage">{lang}wcf.acp.user.search.display.itemsPerPage{/lang}</label></dt>
+ <dd>
+ <input type="number" id="itemsPerPage" name="itemsPerPage" value="{@$itemsPerPage}" class="tiny" />
+ </dd>
+ </dl>
+
+ {event name='searchDisplayFields'}
+ </fieldset>
- <div id="resultOptions" class="container containerPadding tabMenuContent hidden">
- <fieldset>
- <legend>{lang}wcf.acp.user.search.display.general{/lang}</legend>
-
- <dl>
- <dt><label for="sortField">{lang}wcf.acp.user.search.display.sort{/lang}</label></dt>
- <dd>
- <select id="sortField" name="sortField">
- <option value="userID"{if $sortField == 'userID'} selected="selected"{/if}>{lang}wcf.user.userID{/lang}</option>
- <option value="username"{if $sortField == 'username'} selected="selected"{/if}>{lang}wcf.user.username{/lang}</option>
- <option value="email"{if $sortField == 'email'} selected="selected"{/if}>{lang}wcf.user.email{/lang}</option>
- <option value="registrationDate"{if $sortField == 'registrationDate'} selected="selected"{/if}>{lang}wcf.user.registrationDate{/lang}</option>
-
- {if $additionalSortFields|isset}{@$additionalSortFields}{/if}
- </select>
-
- <select id="sortOrder" name="sortOrder">
- <option value="ASC"{if $sortOrder == 'ASC'} selected="selected"{/if}>{lang}wcf.global.sortOrder.ascending{/lang}</option>
- <option value="DESC"{if $sortOrder == 'DESC'} selected="selected"{/if}>{lang}wcf.global.sortOrder.descending{/lang}</option>
- </select>
- </dd>
- </dl>
-
- <dl>
- <dt><label for="itemsPerPage">{lang}wcf.acp.user.search.display.itemsPerPage{/lang}</label></dt>
- <dd>
- <input type="number" id="itemsPerPage" name="itemsPerPage" value="{@$itemsPerPage}" class="tiny" />
- </dd>
- </dl>
-
- {event name='searchDisplayFields'}
- </fieldset>
+ <fieldset>
+ <legend>{lang}wcf.acp.user.search.display.columns{/lang}</legend>
- <fieldset>
- <legend>{lang}wcf.acp.user.search.display.columns{/lang}</legend>
-
- {if $columnOptions|count}
- <dl>
- <dt>
- <label>{lang}wcf.acp.user.search.display.columns.profile{/lang}</label>
- </dt>
- <dd>
- {foreach from=$columnOptions item=optionData}
- {assign var='option' value=$optionData.object}
- <label><input type="checkbox" name="columns[]" value="{$option->optionName}" {if $option->optionName|in_array:$columns}checked="checked" {/if}/> {lang}wcf.user.option.{$option->optionName}{/lang}</label>
- {/foreach}
- </dd>
- </dl>
- {/if}
-
+ {if $columnOptions|count}
<dl>
- <dt><label>{lang}wcf.acp.user.search.display.columns.other{/lang}</label></dt>
+ <dt>
+ <label>{lang}wcf.acp.user.search.display.columns.profile{/lang}</label>
+ </dt>
<dd>
- {if $__wcf->session->getPermission('admin.user.canEditMailAddress')}
- <label><input type="checkbox" name="columns[]" value="email" {if "email"|in_array:$columns}checked="checked" {/if}/> {lang}wcf.user.email{/lang}</label>
- {/if}
- <label><input type="checkbox" name="columns[]" value="registrationDate" {if "registrationDate"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.registrationDate{/lang}</label>
- <label><input type="checkbox" name="columns[]" value="lastActivityTime" {if "lastActivityTime"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.lastActivityTime{/lang}</label>
- <label><input type="checkbox" name="columns[]" value="profileHits" {if "profileHits"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.profileHits{/lang}</label>
- <label><input type="checkbox" name="columns[]" value="activityPoints" {if "activityPoints"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.activityPoint{/lang}</label>
- {if MODULE_LIKE}
- <label><input type="checkbox" name="columns[]" value="likesReceived" {if "likesReceived"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.like.likesReceived{/lang}</label>
- {/if}
- {event name='searchDisplayColumns'}
+ {foreach from=$columnOptions item=optionData}
+ {assign var='option' value=$optionData.object}
+ <label><input type="checkbox" name="columns[]" value="{$option->optionName}" {if $option->optionName|in_array:$columns}checked="checked" {/if}/> {lang}wcf.user.option.{$option->optionName}{/lang}</label>
+ {/foreach}
</dd>
</dl>
-
- {event name='searchDisplayColumnFields'}
- </fieldset>
+ {/if}
- {event name='resultOptionFieldsets'}
- </div>
+ <dl>
+ <dt><label>{lang}wcf.acp.user.search.display.columns.other{/lang}</label></dt>
+ <dd>
+ {if $__wcf->session->getPermission('admin.user.canEditMailAddress')}
+ <label><input type="checkbox" name="columns[]" value="email" {if "email"|in_array:$columns}checked="checked" {/if}/> {lang}wcf.user.email{/lang}</label>
+ {/if}
+ <label><input type="checkbox" name="columns[]" value="registrationDate" {if "registrationDate"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.registrationDate{/lang}</label>
+ <label><input type="checkbox" name="columns[]" value="lastActivityTime" {if "lastActivityTime"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.lastActivityTime{/lang}</label>
+ <label><input type="checkbox" name="columns[]" value="profileHits" {if "profileHits"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.profileHits{/lang}</label>
+ <label><input type="checkbox" name="columns[]" value="activityPoints" {if "activityPoints"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.user.activityPoint{/lang}</label>
+ {if MODULE_LIKE}
+ <label><input type="checkbox" name="columns[]" value="likesReceived" {if "likesReceived"|in_array:$columns}checked="checked"{/if}/> {lang}wcf.like.likesReceived{/lang}</label>
+ {/if}
+ {event name='searchDisplayColumns'}
+ </dd>
+ </dl>
+
+ {event name='searchDisplayColumnFields'}
+ </fieldset>
+
+ {event name='resultOptionFieldsets'}
</div>
<div class="formSubmit">
<?php
namespace wcf\acp\form;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\UserList;
use wcf\data\search\SearchEditor;
use wcf\form\AbstractForm;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
use wcf\system\exception\UserInputException;
use wcf\system\language\LanguageFactory;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
-use wcf\util\ArrayUtil;
use wcf\util\HeaderUtil;
-use wcf\util\StringUtil;
/**
* Shows the user search form.
*
- * @author Marcel Werk
+ * @author Matthias Schmidt, Marcel Werk
* @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
public $neededPermissions = array('admin.user.canSearchUser');
/**
- * username
- * @var string
- */
- public $username = '';
-
- /**
- * email address
- * @var string
- */
- public $email = '';
-
- /**
- * user id
- * @var integer
- */
- public $userID = null;
-
- /**
- * group ids
- * @var array<integer>
- */
- public $groupIDs = array();
-
- /**
- * true to invert the given group ids
- * @var boolean
- */
- public $invertGroupIDs = 0;
-
- /**
- * language ids
- * @var array<integer>
- */
- public $languageIDs = array();
-
- /**
- * registration start date
- * @var string
- */
- public $registrationDateStart = '';
-
- /**
- * registration start date
- * @var string
- */
- public $registrationDateEnd = '';
-
- /**
- * banned state
- * @var boolean
+ * list of grouped user group assignment condition object types
+ * @var array
*/
- public $banned = 0;
+ public $conditions = array();
/**
- * not banned state
- * @var boolean
+ * list with searched users
+ * @var \wcf\data\user\UserList
*/
- public $notBanned = 0;
-
- /**
- * last activity start time
- * @var string
- */
- public $lastActivityTimeStart = '';
-
- /**
- * last activity end time
- * @var string
- */
- public $lastActivityTimeEnd = '';
-
- /**
- * enabled state
- * @var boolean
- */
- public $enabled = 0;
-
- /**
- * disabled state
- * @var boolean
- */
- public $disabled = 0;
-
- /**
- * matches
- * @var array<integer>
- */
- public $matches = array();
-
- /**
- * condtion builder object
- * @var \wcf\system\database\condition\PreparedStatementConditionBuilder
- */
- public $conditions = null;
+ public $userList = null;
/**
* search id
public function readFormParameters() {
parent::readFormParameters();
- if (isset($_POST['username'])) $this->username = StringUtil::trim($_POST['username']);
- if (isset($_POST['email'])) $this->email = StringUtil::trim($_POST['email']);
- if (!empty($_POST['userID'])) $this->userID = intval($_POST['userID']);
- if (isset($_POST['groupIDs']) && is_array($_POST['groupIDs'])) $this->groupIDs = ArrayUtil::toIntegerArray($_POST['groupIDs']);
- if (isset($_POST['languageIDs']) && is_array($_POST['languageIDs'])) $this->languageIDs = ArrayUtil::toIntegerArray($_POST['languageIDs']);
- if (isset($_POST['invertGroupIDs'])) $this->invertGroupIDs = intval($_POST['invertGroupIDs']);
- if (isset($_POST['registrationDateStart'])) $this->registrationDateStart = $_POST['registrationDateStart'];
- if (isset($_POST['registrationDateEnd'])) $this->registrationDateEnd = $_POST['registrationDateEnd'];
- if (isset($_POST['banned'])) $this->banned = intval($_POST['banned']);
- if (isset($_POST['notBanned'])) $this->notBanned = intval($_POST['notBanned']);
- if (isset($_POST['lastActivityTimeStart'])) $this->lastActivityTimeStart = $_POST['lastActivityTimeStart'];
- if (isset($_POST['lastActivityTimeEnd'])) $this->lastActivityTimeEnd = $_POST['lastActivityTimeEnd'];
- if (isset($_POST['enabled'])) $this->enabled = intval($_POST['enabled']);
- if (isset($_POST['disabled'])) $this->disabled = intval($_POST['disabled']);
+ foreach ($this->conditions as $conditions) {
+ foreach ($conditions as $condition) {
+ $condition->getProcessor()->readFormParameters();
+ }
+ }
if (isset($_POST['itemsPerPage'])) $this->itemsPerPage = intval($_POST['itemsPerPage']);
if (isset($_POST['sortField'])) $this->sortField = $_POST['sortField'];
if (isset($_POST['columns']) && is_array($_POST['columns'])) $this->columns = $_POST['columns'];
}
- /**
- * @see \wcf\acp\form\AbstractOptionListForm::initOptionHandler()
- */
- protected function initOptionHandler() {
- $this->optionHandler->enableSearchMode();
- $this->optionHandler->init();
- }
-
/**
* @see \wcf\page\IPage::readData()
*/
public function readData() {
+ $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.condition.userSearch');
+ foreach ($objectTypes as $objectType) {
+ if (!$objectType->conditiongroup) continue;
+
+ if (!isset($this->conditions[$objectType->conditiongroup])) {
+ $this->conditions[$objectType->conditiongroup] = [ ];
+ }
+
+ $this->conditions[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
+ }
+
parent::readData();
// add email column for authorized users
if (WCF::getSession()->getPermission('admin.user.canEditMailAddress')) {
array_unshift($this->columns, 'email');
}
-
- $this->readOptionTree();
- }
-
- /**
- * Reads option tree on page init.
- */
- protected function readOptionTree() {
- $this->optionTree = $this->optionHandler->getOptionTree();
}
/**
parent::assignVariables();
WCF::getTPL()->assign(array(
- 'username' => $this->username,
- 'email' => $this->email,
- 'userID' => $this->userID,
- 'groupIDs' => $this->groupIDs,
- 'languageIDs' => $this->languageIDs,
- 'optionTree' => $this->optionTree,
- 'availableGroups' => $this->getAvailableGroups(),
- 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
- 'invertGroupIDs' => $this->invertGroupIDs,
- 'registrationDateStart' => $this->registrationDateStart,
- 'registrationDateEnd' => $this->registrationDateEnd,
- 'banned' => $this->banned,
- 'notBanned' => $this->notBanned,
+ 'groupedObjectTypes' => $this->conditions,
'sortField' => $this->sortField,
'sortOrder' => $this->sortOrder,
'itemsPerPage' => $this->itemsPerPage,
'columns' => $this->columns,
- 'lastActivityTimeStart' => $this->lastActivityTimeStart,
- 'lastActivityTimeEnd' => $this->lastActivityTimeEnd,
- 'enabled' => $this->enabled,
- 'disabled' => $this->disabled,
'columnOptions' => $this->optionHandler->getCategoryOptions('profile')
));
}
parent::save();
// store search result in database
- $data = serialize(array(
- 'matches' => $this->matches,
+ $data = serialize([
+ 'matches' => $this->userList->getObjectIDs(),
'itemsPerPage' => $this->itemsPerPage,
'columns' => $this->columns
- ));
+ ]);
$search = SearchEditor::create(array(
'userID' => WCF::getUser()->userID,
$this->saved();
// forward to result page
- $url = LinkHandler::getInstance()->getLink('UserList', array('id' => $this->searchID), 'sortField='.rawurlencode($this->sortField).'&sortOrder='.rawurlencode($this->sortOrder));
- HeaderUtil::redirect($url);
+ HeaderUtil::redirect(LinkHandler::getInstance()->getLink('UserList', [
+ 'id' => $this->searchID
+ ], 'sortField='.rawurlencode($this->sortField).'&sortOrder='.rawurlencode($this->sortOrder)));
exit;
}
public function validate() {
AbstractForm::validate();
- // remove email column for not authorized users
+ // remove email column for non-authorized users
if (!WCF::getSession()->getPermission('admin.user.canEditMailAddress') && ($key = array_search('email', $this->columns)) !== false) {
- unset($this->columns[$key]);
+ unset($this->columns[$key]);
+ }
+
+ foreach ($this->conditions as $conditions) {
+ foreach ($conditions as $condition) {
+ $condition->getProcessor()->validate();
+ }
}
- // do search
$this->search();
- if (empty($this->matches)) {
+ if (!count($this->userList->getObjectIDs())) {
throw new UserInputException('search', 'noMatches');
}
}
* Search for users which fit to the search values.
*/
protected function search() {
- $this->matches = array();
- $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)";
-
- // build search condition
- $this->conditions = new PreparedStatementConditionBuilder();
-
- // static fields
- $this->buildStaticConditions();
-
- // dynamic fields
- $this->buildDynamicConditions();
-
- // call buildConditions event
- EventHandler::getInstance()->fireAction($this, 'buildConditions');
-
- // do search
- $statement = WCF::getDB()->prepareStatement($sql.$this->conditions, $this->maxResults);
- $statement->execute($this->conditions->getParameters());
- while ($row = $statement->fetchArray()) {
- $this->matches[] = $row['userID'];
- }
- }
-
- /**
- * Builds the static conditions.
- */
- protected function buildStaticConditions() {
- if (!empty($this->username)) {
- $this->conditions->add("user_table.username LIKE ?", array('%'.addcslashes($this->username, '_%').'%'));
- }
- if (!empty($this->userID)) {
- $this->conditions->add("user_table.userID = ?", array($this->userID));
- }
- if (!empty($this->email)) {
- $this->conditions->add("user_table.email LIKE ?", array('%'.addcslashes($this->email, '_%').'%'));
- }
- if (!empty($this->groupIDs)) {
- $this->conditions->add("user_table.userID ".($this->invertGroupIDs == 1 ? 'NOT ' : '')."IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", array($this->groupIDs));
- }
- if (!empty($this->languageIDs)) {
- $this->conditions->add("user_table.languageID IN (?)", array($this->languageIDs));
- }
+ $this->userList = new UserList();
- // registration date
- if ($startDate = @strtotime($this->registrationDateStart)) {
- $this->conditions->add('user_table.registrationDate >= ?', array($startDate));
- }
- if ($endDate = @strtotime($this->registrationDateEnd)) {
- $this->conditions->add('user_table.registrationDate <= ?', array($endDate));
- }
+ EventHandler::getInstance()->fireAction($this, 'search');
- if ($this->banned) {
- $this->conditions->add('user_table.banned = ?', array(1));
- }
- if ($this->notBanned) {
- $this->conditions->add('user_table.banned = ?', array(0));
- }
-
- // last activity time
- if ($startDate = @strtotime($this->lastActivityTimeStart)) {
- $this->conditions->add('user_table.lastActivityTime >= ?', array($startDate));
- }
- if ($endDate = @strtotime($this->lastActivityTimeEnd)) {
- $this->conditions->add('user_table.lastActivityTime <= ?', array($endDate));
- }
-
- if ($this->enabled) {
- $this->conditions->add('user_table.activationCode = ?', array(0));
- }
- if ($this->disabled) {
- $this->conditions->add('user_table.activationCode <> ?', array(0));
- }
- }
-
- /**
- * Builds the dynamic conditions.
- */
- protected function buildDynamicConditions() {
- foreach ($this->optionHandler->getCategoryOptions('profile') as $option) {
- $option = $option['object'];
-
- $value = isset($this->optionHandler->optionValues[$option->optionName]) ? $this->optionHandler->optionValues[$option->optionName] : null;
- $this->optionHandler->getTypeObject($option->optionType)->getCondition($this->conditions, $option, $value);
+ // read user ids
+ foreach ($this->conditions as $groupedObjectTypes) {
+ foreach ($groupedObjectTypes as $objectType) {
+ $data = $objectType->getProcessor()->getData();
+ if ($data !== null) {
+ $objectType->getProcessor()->addObjectListCondition($this->userList, $data);
+ }
+ }
}
+ $this->userList->readObjectIDs();
}
}