* Abstract implementation of a condition.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
*/
abstract class AbstractCondition extends AbstractObjectTypeProcessor implements ICondition {
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
// does nothing
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
// does nothing
* Abstract implementation of a condition for an integer value.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
protected $propertyName = '';
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
- $data = array();
+ $data = [];
if ($this->lessThan !== null) {
$data['lessThan'] = $this->lessThan;
}
/**
- * @see \wcf\system\condition\AbstractMultipleFieldsCondition::getData()
+ * @inheritDoc
*/
protected function getErrorMessageElement() {
if ($this->errorMessage) {
$errorMessage = '';
switch ($this->errorMessage) {
case 'wcf.condition.greaterThan.error.maxValue':
- $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
+ $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [
'maxValue' => $this->maxValue - 1
- ));
+ ]);
break;
case 'wcf.condition.lessThan.error.maxValue':
- $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
+ $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [
'maxValue' => $this->maxValue
- ));
+ ]);
break;
case 'wcf.condition.greaterThan.error.minValue':
- $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
+ $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [
'minValue' => $this->minValue
- ));
+ ]);
break;
case 'wcf.condition.lessThan.error.minValue':
- $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
+ $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [
'minValue' => $this->minValue + 1
- ));
+ ]);
break;
default:
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
public function getFieldElement() {
$greaterThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.greaterThan');
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['lessThan_'.$this->getIdentifier()]) && strlen($_POST['lessThan_'.$this->getIdentifier()])) $this->lessThan = intval($_POST['lessThan_'.$this->getIdentifier()]);
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->lessThan = null;
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
$this->lessThan = $condition->lessThan;
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
if ($this->lessThan !== null) {
abstract class AbstractMultiSelectCondition extends AbstractSelectCondition {
/**
* selected values
- * @var mixed[]
+ * @var array
*/
protected $fieldValue = [];
* Abstract implementation of a condition for multiple fields.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
abstract class AbstractMultipleFieldsCondition extends AbstractCondition {
/**
* language items of the input element descriptions
- * @var string
+ * @var string[]
*/
- protected $descriptions = array();
+ protected $descriptions = [];
/**
* error messages if the validation failed
- * @var string
+ * @var string[]
*/
- protected $errorMessages = array();
+ protected $errorMessages = [];
/**
* language items of the input element labels
- * @var string
+ * @var string[]
*/
- protected $labels = array();
+ protected $labels = [];
/**
* Returns the description element for the HTML output.
namespace wcf\system\condition;
use wcf\data\DatabaseObject;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
/**
* Abstract condition implementation for check a text-typed property of a database
* object.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
protected $propertyName = '';
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
$className = $this->getListClassName();
- if (!($objectList instanceof $className)) return;
+ if (!($objectList instanceof $className)) {
+ throw new InvalidArgumentException("Object list is no instance of '{$className}', instance of '".get_class($objectList)."' given.");
+ }
if ($this->supportsMultipleValues) {
$objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' IN (?)', [$conditionData[$this->fieldName]]);
}
/**
- * @see \wcf\system\condition\IObjectCondition::checkObject()
+ * @inheritDoc
*/
public function checkObject(DatabaseObject $object, array $conditionData) {
$className = $this->getClassName();
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
$value = parent::getData();
abstract protected function getFieldElement();
/**
- * @see \wcf\system\condition\ICondition::getHTML()
+ * @inheritDoc
*/
public function getHTML() {
return <<<HTML
* Abstract implementation of a text condition.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
protected $fieldValue = '';
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
if (mb_strlen($this->fieldValue)) {
- return [
- $this->fieldName => $this->fieldValue
- ];
+ return [$this->fieldName => $this->fieldValue];
}
return null;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
protected function getFieldElement() {
return '<input type="text" name="'.$this->fieldName.'" value="'.StringUtil::encodeHTML($this->fieldValue).'" class="long" />';
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST[$this->fieldName])) $this->fieldValue = StringUtil::trim($_POST[$this->fieldName]);
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->fieldValue = '';
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
$this->fieldValue = $condition->conditionData[$this->fieldName];
use wcf\data\condition\Condition;
use wcf\data\DatabaseObject;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
protected $startTime = '';
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
$className = $this->getListClassName();
- if (!($objectList instanceof $className)) return;
+ if (!($objectList instanceof $className)) {
+ throw new InvalidArgumentException("Object list is no instance of '{$className}', instance of '".get_class($objectList)."' given.");
+ }
$objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' <> ?', [0]);
if (isset($conditionData['endTime'])) {
}
/**
- * @see \wcf\system\condition\IObjectCondition::checkObject()
+ * @inheritDoc
*/
public function checkObject(DatabaseObject $object, array $conditionData) {
$className = $this->getClassName();
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
- $data = array();
+ $data = [];
if (strlen($this->startTime)) {
$data['startTime'] = $this->startTime;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
protected function getFieldElement() {
$start = WCF::getLanguage()->get('wcf.date.period.start');
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getLabel()
+ * @inheritDoc
*/
protected function getLabel() {
return WCF::getLanguage()->get($this->getLanguageItemPrefix().'.'.$this->getPropertyName());
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST[$this->getPropertyName().'EndTime'])) $this->endTime = $_POST[$this->getPropertyName().'EndTime'];
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->endTime = '';
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
if ($condition->endTime) {
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
$endTime = $startTime = null;
* Condition implementation for the days of the week.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
*/
class DaysOfWeekCondition extends AbstractMultiSelectCondition implements IContentCondition {
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $description = 'wcf.global.multiSelect';
/**
- * @see wcf\system\condition\AbstractSelectCondition::$fieldName
+ * @inheritDoc
*/
protected $fieldName = 'daysOfWeek';
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.date.daysOfWeek';
/**
- * @see \wcf\system\condition\AbstractSelectCondition::getOptions()
+ * @inheritDoc
*/
protected function getOptions() {
- $options = array();
+ $options = [];
$daysOfWeek = DateUtil::getWeekDays();
foreach ($daysOfWeek as $index => $day) {
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
$date = DateUtil::getDateTimeByTimestamp(TIME_NOW);
* Every implementation for content conditions needs to implements this interface.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
* All necessary data to check the condition needs to be globally available
* like the active user object via WCF::getUser().
*
- * @param \wcf\data\condition\Condition $condition
+ * @param Condition $condition
* @return boolean
*/
public function showContent(Condition $condition);
* this interface.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
* Returns true if the given object fulfills the condition specified by
* the given condition data returned by \wcf\system\condition\ICondition::getData().
*
- * @param \wcf\data\DatabaseObject $object
- * @param array $conditionData
+ * @param DatabaseObject $object
+ * @param array $conditionData
* @return boolean
*/
public function checkObject(DatabaseObject $object, array $conditionData);
* Adds a condition to the given object list based on the given condition
* data returned by \wcf\system\condition\ICondition::getData().
*
- * @param \wcf\data\DatabaseObjectList $objectList
- * @param array $conditionData
+ * @param DatabaseObjectList $objectList
+ * @param array $conditionData
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData);
}
* Every implementation for user conditions needs to implements this interface.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
* Adds the condition to the given user list to fetch the users which fulfill
* the given condition.
*
- * @param \wcf\data\condition\Condition $condition
- * @param \wcf\data\user\UserList $userList
+ * @param Condition $condition
+ * @param UserList $userList
*/
public function addUserCondition(Condition $condition, UserList $userList);
/**
* Returns true if the given user fulfills the given condition.
*
- * @param \wcf\data\condition\Condition $condition
- * @param \wcf\data\user\User $user
+ * @param Condition $condition
+ * @param User $user
* @return boolean
*/
public function checkUser(Condition $condition, User $user);
* IObjectListCondition::addObjectListCondition().
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
*/
trait TObjectListUserCondition {
/**
- * @see \wcf\system\condition\IUserCondition::addUserCondition()
+ * @inheritDoc
*/
public function addUserCondition(Condition $condition, UserList $userList) {
$this->addObjectListCondition($userList, $condition->conditionData);
* Redirects IUserCondition::checkUser() calls to the more general IObjectCondition::checkObject().
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
*/
trait TObjectUserCondition {
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
$this->checkObject($user, $condition->conditionData);
* Condition implementation for the current time.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
protected $endTime = '00:00';
/**
- * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$label
+ * @inheritDoc
*/
- protected $labels = array(
+ protected $labels = [
'time' => 'wcf.date.time',
'timezone' => 'wcf.date.timezone'
- );
+ ];
/**
* start time
protected $timezone = 0;
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
- $data = array();
+ $data = [];
if ($this->startTime) {
$data['startTime'] = $this->startTime;
}
/**
- * @see \wcf\system\condition\ICondition::getHTML()
+ * @inheritDoc
*/
public function getHTML() {
$start = WCF::getLanguage()->get('wcf.date.period.start');
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['endTime'])) $this->endTime = StringUtil::trim($_POST['endTime']);
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->endTime = '00:00';
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
if ($condition->endTime) {
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
if ($this->startTime == '00:00' && $this->endTime == '00:00') {
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
$timezone = WCF::getUser()->getTimeZone();
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\WCF;
/**
* Condition implementation for the avatar of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see wcf\system\condition\AbstractSelectCondition::$fieldName
+ * @inheritDoc
*/
protected $fieldName = 'userAvatar';
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.condition.avatar';
const GRAVATAR = 2;
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
switch ($conditionData['userAvatar']) {
case self::NO_AVATAR:
$objectList->getConditionBuilder()->add('user_table.avatarID IS NULL');
- $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', array(0));
+ $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', [0]);
break;
case self::AVATAR:
break;
case self::GRAVATAR:
- $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', array(1));
+ $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', [1]);
break;
}
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
switch ($condition->userAvatar) {
}
/**
- * @see \wcf\system\condition\AbstractSelectCondition::getOptions()
+ * @inheritDoc
*/
protected function getOptions() {
- return array(
+ return [
self::NO_SELECTION_VALUE => 'wcf.global.noSelection',
self::NO_AVATAR => 'wcf.user.condition.avatar.noAvatar',
self::AVATAR => 'wcf.user.condition.avatar.avatar',
self::GRAVATAR => 'wcf.user.condition.avatar.gravatar'
- );
+ ];
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
* Condition implementation if it is the active user's birthday today.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
protected $birthdayToday = 0;
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
if ($this->birthdayToday) {
- return array(
- 'birthdayToday' => 1
- );
+ return ['birthdayToday' => 1];
}
return null;
}
/**
- * @see \wcf\system\condition\ICondition::getHTML()
+ * @inheritDoc
*/
public function getHTML() {
$label = WCF::getLanguage()->get('wcf.user.birthdayToday');
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['birthdayToday'])) $this->birthdayToday = 1;
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->birthdayToday = 0;
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
$this->birthdayToday = $condition->birthdayToday;
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\WCF;
/**
* Condition implementation for the email address of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractTextCondition::$fieldName
+ * @inheritDoc
*/
protected $fieldName = 'email';
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.email';
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
- $objectList->getConditionBuilder()->add('user_table.email LIKE ?', array('%'.addcslashes($conditionData['email'], '_%').'%'));
+ $objectList->getConditionBuilder()->add('user_table.email LIKE ?', ['%'.addcslashes($conditionData['email'], '_%').'%']);
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
return mb_strpos($user->email, $condition->email) !== false;
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
* of and the user groups a user may not be a member of.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$descriptions
+ * @inheritDoc
*/
- protected $descriptions = array(
+ protected $descriptions = [
'groupIDs' => 'wcf.user.condition.groupIDs.description',
'notGroupIDs' => 'wcf.user.condition.notGroupIDs.description'
- );
+ ];
/**
* ids of the selected user groups the user has to be member of
* @var integer[]
*/
- protected $groupIDs = array();
+ protected $groupIDs = [];
/**
- * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$labels
+ * @inheritDoc
*/
- protected $labels = array(
+ protected $labels = [
'groupIDs' => 'wcf.user.condition.groupIDs',
'notGroupIDs' => 'wcf.user.condition.notGroupIDs'
- );
+ ];
/**
* ids of the selected user groups the user may not be member of
* @var integer[]
*/
- protected $notGroupIDs = array();
+ protected $notGroupIDs = [];
/**
* selectable user groups
* @var UserGroup[]
*/
- protected $userGroups = null;
+ protected $userGroups;
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
if (isset($conditionData['groupIDs'])) {
- $objectList->getConditionBuilder()->add('user_table.userID IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?) GROUP BY userID HAVING COUNT(userID) = ?)', array($conditionData['groupIDs'], count($conditionData['groupIDs'])));
+ $objectList->getConditionBuilder()->add('user_table.userID IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?) GROUP BY userID HAVING COUNT(userID) = ?)', [$conditionData['groupIDs'], count($conditionData['groupIDs'])]);
}
if (isset($conditionData['notGroupIDs'])) {
- $objectList->getConditionBuilder()->add('user_table.userID NOT IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?))', array($conditionData['notGroupIDs']));
+ $objectList->getConditionBuilder()->add('user_table.userID NOT IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?))', [$conditionData['notGroupIDs']]);
}
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
$groupIDs = $user->getGroupIDs();
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
- $data = array();
+ $data = [];
if (!empty($this->groupIDs)) {
$data['groupIDs'] = $this->groupIDs;
}
/**
- * @see \wcf\system\condition\ICondition::getHTML()
+ * @inheritDoc
*/
public function getHTML() {
return <<<HTML
*/
protected function getUserGroups() {
if ($this->userGroups == null) {
- $invalidGroupTypes = array(
+ $invalidGroupTypes = [
UserGroup::EVERYONE,
UserGroup::USERS
- );
+ ];
if (!$this->includeguests) {
$invalidGroupTypes[] = UserGroup::GUESTS;
}
- $this->userGroups = UserGroup::getAccessibleGroups(array(), $invalidGroupTypes);
+ $this->userGroups = UserGroup::getAccessibleGroups([], $invalidGroupTypes);
uasort($this->userGroups, function(UserGroup $groupA, UserGroup $groupB) {
return strcmp($groupA->getName(), $groupB->getName());
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['groupIDs'])) $this->groupIDs = ArrayUtil::toIntegerArray($_POST['groupIDs']);
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
- $this->groupIDs = array();
- $this->notGroupIDs = array();
+ $this->groupIDs = [];
+ $this->notGroupIDs = [];
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
if ($condition->groupIDs !== null) {
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
$userGroups = $this->getUserGroups();
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
return $this->checkUser($condition, WCF::getUser());
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\WCF;
/**
* Condition implementation for an integer property of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
if (isset($conditionData['greaterThan'])) {
- $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' > ?', array($conditionData['greaterThan']));
+ $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' > ?', [$conditionData['greaterThan']]);
}
if (isset($conditionData['lessThan'])) {
- $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' < ?', array($conditionData['lessThan']));
+ $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' < ?', [$conditionData['lessThan']]);
}
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
if ($condition->greaterThan !== null && $user->{$this->getDecoratedObject()->propertyname} <= $condition->greaterThan) {
}
/**
- * @see \wcf\system\condition\AbstractIntegerCondition::getIdentifier()
+ * @inheritDoc
*/
protected function getIdentifier() {
return 'user_'.$this->getDecoratedObject()->propertyname;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getLabel()
+ * @inheritDoc
*/
protected function getLabel() {
return WCF::getLanguage()->get('wcf.user.condition.'.$this->getDecoratedObject()->propertyname);
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\exception\UserInputException;
use wcf\system\language\LanguageFactory;
use wcf\system\WCF;
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.condition.languages';
* ids of the selected languages
* @var integer[]
*/
- protected $languageIDs = array();
+ protected $languageIDs = [];
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
- $objectList->getConditionBuilder()->add('user_table.languageID IN (?)', array($conditionData['languageIDs']));
+ $objectList->getConditionBuilder()->add('user_table.languageID IN (?)', [$conditionData['languageIDs']]);
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
if (!empty($condition->conditionData['languageIDs']) && !in_array($user->languageID, $condition->languageIDs)) {
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
if (!empty($this->languageIDs)) {
- return array(
+ return [
'languageIDs' => $this->languageIDs
- );
+ ];
}
return null;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
protected function getFieldElement() {
$returnValue = "";
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['languageIDs']) && is_array($_POST['languageIDs'])) $this->languageIDs = ArrayUtil::toIntegerArray($_POST['languageIDs']);
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
- $this->languageIDs = array();
+ $this->languageIDs = [];
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
if (!empty($condition->conditionData['languageIDs'])) {
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
foreach ($this->languageIDs as $languageID) {
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (WCF::getUser()->userID) {
* Condition implementation if it is the active user uses a mobile browser.
*
* @author Joshua Ruesweg, Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
*/
class UserMobileBrowserCondition extends AbstractSingleFieldCondition implements IContentCondition {
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.condition.mobileBrowser';
protected $usesNoMobileBrowser = 0;
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
if ($this->usesMobileBrowser || $this->usesNoMobileBrowser) {
- return array(
+ return [
// if notUseMobileBrowser is selected usesMobileBrowser is 0
// otherwise notUseMobileBrowser is 1
'usesMobileBrowser' => $this->usesMobileBrowser
- );
+ ];
}
return null;
}
/**
- * @see \wcf\system\condition\ICondition::getHTML()
+ * @inheritDoc
*/
public function getFieldElement() {
$usesMobileBrowserLabel = WCF::getLanguage()->get('wcf.user.condition.mobileBrowser.usesMobileBrowser');
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['usesMobileBrowser'])) $this->usesMobileBrowser = 1;
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->usesMobileBrowser = 0;
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
$this->usesMobileBrowser = $condition->usesMobileBrowser;
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
if ($this->usesMobileBrowser && $this->usesNoMobileBrowser) {
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
return (($condition->usesMobileBrowser && UserUtil::usesMobileBrowser()) || (!$condition->usesMobileBrowser && !UserUtil::usesMobileBrowser()));
use wcf\data\user\UserList;
use wcf\data\DatabaseObject;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\option\user\UserOptionHandler;
use wcf\system\WCF;
* Condition implementation for the options of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
/**
* user option handler object
- * @var \wcf\system\option\user\UserOptionHandler
+ * @var UserOptionHandler
*/
- protected $optionHandler = null;
+ protected $optionHandler;
/**
- * @see \wcf\data\DatabaseObjectDecorator::__construct()
+ * @inheritDoc
*/
public function __construct(DatabaseObject $object) {
parent::__construct($object);
}
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
$optionValues = $conditionData['optionValues'];
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
$optionValues = $condition->optionValues;
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
$optionValues = $this->optionHandler->getOptionValues();
- $data = array();
+ $data = [];
foreach ($this->optionHandler->getCategoryOptions('profile') as $option) {
$option = $option['object'];
}
if (!empty($data)) {
- return array(
+ return [
'optionValues' => $data
- );
+ ];
}
return null;
}
/**
- * @see \wcf\system\condition\ICondition::getHTML()
+ * @inheritDoc
*/
public function getHTML() {
- return WCF::getTPL()->fetch('userOptionsCondition', 'wcf', array(
+ return WCF::getTPL()->fetch('userOptionsCondition', 'wcf', [
'optionTree' => $this->optionHandler->getOptionTree('profile')
- ));
+ ]);
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
$this->optionHandler->readUserInput($_POST);
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
- $this->optionHandler->setOptionValues(array());
+ $this->optionHandler->setOptionValues([]);
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
$this->optionHandler->setOptionValues($condition->conditionData['optionValues']);
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
* Condition implementation for the registration date of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.condition.registrationDate';
protected $registrationDateStart = '';
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
if (isset($conditionData['registrationDateEnd'])) {
- $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', array(strtotime($conditionData['registrationDateEnd']) + 86400));
+ $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', [strtotime($conditionData['registrationDateEnd']) + 86400]);
}
if (isset($conditionData['registrationDateStart'])) {
- $objectList->getConditionBuilder()->add('user_table.registrationDate >= ?', array(strtotime($conditionData['registrationDateStart'])));
+ $objectList->getConditionBuilder()->add('user_table.registrationDate >= ?', [strtotime($conditionData['registrationDateStart'])]);
}
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
if ($condition->registrationDateStart !== null && $user->registrationDate < strtotime($condition->registrationDateStart)) {
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
- $data = array();
+ $data = [];
if (strlen($this->registrationDateStart)) {
$data['registrationDateStart'] = $this->registrationDateStart;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
protected function getFieldElement() {
$start = WCF::getLanguage()->get('wcf.date.period.start');
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['registrationDateEnd'])) $this->registrationDateEnd = $_POST['registrationDateEnd'];
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->registrationDateEnd = '';
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
if ($condition->registrationDateEnd) {
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
$registrationDateEnd = $registrationDateStart = null;
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\WCF;
/**
* a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$languageItemPrefix
+ * @inheritDoc
*/
protected $label = 'wcf.user.condition.registrationDateInterval';
/**
- * @see \wcf\system\condition\AbstractIntegerCondition::$minValue
+ * @inheritDoc
*/
protected $minValue = 0;
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
if ($conditionData['greaterThan'] !== null) {
- $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', array(TIME_NOW - $conditionData['greaterThan'] * 86400));
+ $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', [TIME_NOW - $conditionData['greaterThan'] * 86400]);
}
if ($conditionData['lessThan'] !== null) {
- $objectList->getConditionBuilder()->add('user_table.registrationDate > ?', array(TIME_NOW - $conditionData['lessThan'] * 86400));
+ $objectList->getConditionBuilder()->add('user_table.registrationDate > ?', [TIME_NOW - $conditionData['lessThan'] * 86400]);
}
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
if ($condition->greaterThan !== null && $user->registrationDate >= TIME_NOW - $condition->greaterThan * 86400) {
}
/**
- * @see \wcf\system\condition\AbstractIntegerCondition::getIdentifier()
+ * @inheritDoc
*/
protected function getIdentifier() {
return 'user_registrationDateInterval';
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
* Condition implementation for the state (banned, enabled) of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.condition.state';
protected $userIsNotBanned = 0;
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
if (isset($conditionData['userIsBanned'])) {
- $objectList->getConditionBuilder()->add('user_table.banned = ?', array($conditionData['userIsBanned']));
+ $objectList->getConditionBuilder()->add('user_table.banned = ?', [$conditionData['userIsBanned']]);
}
if ($conditionData['userIsEnabled']) {
if ($conditionData['userIsEnabled']) {
- $objectList->getConditionBuilder()->add('user_table.activationCode = ?', array(0));
+ $objectList->getConditionBuilder()->add('user_table.activationCode = ?', [0]);
}
else {
- $objectList->getConditionBuilder()->add('user_table.activationCode <> ?', array(0));
+ $objectList->getConditionBuilder()->add('user_table.activationCode <> ?', [0]);
}
}
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
if ($condition->userIsBanned !== null && $user->banned != $condition->userIsBanned) {
}
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
- $data = array();
+ $data = [];
if ($this->userIsBanned) {
$data['userIsBanned'] = 1;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
protected function getFieldElement() {
$userIsNotBanned = WCF::getLanguage()->get('wcf.user.condition.state.isNotBanned');
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['userIsBanned'])) $this->userIsBanned = 1;
}
/**
- * @see \wcf\system\condition\ICondition::reset()
+ * @inheritDoc
*/
public function reset() {
$this->userIsBanned = 0;
}
/**
- * @see \wcf\system\condition\ICondition::setData()
+ * @inheritDoc
*/
public function setData(Condition $condition) {
if ($condition->userIsBanned !== null) {
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
if ($this->userIsBanned && $this->userIsNotBanned) {
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use TObjectUserCondition;
/**
- * @see \wcf\system\condition\AbstractTimestampCondition::$className
+ * @inheritDoc
*/
protected $className = User::class;
/**
- * @see \wcf\system\condition\AbstractTimestampCondition::getLanguageItemPrefix()
+ * @inheritDoc
*/
protected function getLanguageItemPrefix() {
return 'wcf.user.condition';
}
/**
- * @see \wcf\system\condition\AbstractTimestampCondition::getPropertyName()
+ * @inheritDoc
*/
protected function getPropertyName() {
return $this->getDecoratedObject()->propertyname;
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;
use wcf\data\user\User;
use wcf\data\user\UserList;
use wcf\data\DatabaseObjectList;
+use wcf\system\exception\InvalidArgumentException;
use wcf\system\WCF;
/**
* Condition implementation for the username of a user.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
use TObjectListUserCondition;
/**
- * @see \wcf\system\condition\AbstractTextCondition::$fieldName
+ * @inheritDoc
*/
protected $fieldName = 'username';
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
protected $label = 'wcf.user.username';
/**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
+ * @inheritDoc
*/
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof UserList)) return;
+ if (!($objectList instanceof UserList)) {
+ throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given.");
+ }
- $objectList->getConditionBuilder()->add('user_table.username LIKE ?', array('%'.addcslashes($conditionData['username'], '_%').'%'));
+ $objectList->getConditionBuilder()->add('user_table.username LIKE ?', ['%'.addcslashes($conditionData['username'], '_%').'%']);
}
/**
- * @see \wcf\system\condition\IUserCondition::checkUser()
+ * @inheritDoc
*/
public function checkUser(Condition $condition, User $user) {
return mb_strpos($user->username, $condition->username) !== false;
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
if (!WCF::getUser()->userID) return false;