set_error_handler('handleError', E_ALL);
// define list of needed file
-$neededFilesPattern = array(
+$neededFilesPattern = [
'!^setup/.*!',
'!^install/files/acp/images/wcfLogo.*!',
'!^install/files/acp/style/setup/.*!',
'!^install/files/lib/system/.*!',
'!^install/files/lib/util/.*!',
'!^install/lang/.*!',
- '!^install/packages/.*!');
+ '!^install/packages/.*!'];
// define needed functions and classes
/**
*/
class Tar {
protected $archiveName = '';
- protected $contentList = array();
+ protected $contentList = [];
protected $opened = false;
protected $read = false;
protected $file = null;
* This does not get the entire to memory but only parts of it.
*/
protected function readContent() {
- $this->contentList = array();
+ $this->contentList = [];
$this->read = true;
$i = 0;
return false;
}
- $header = array();
+ $header = [];
$checksum = 0;
// First part of the header
for ($i = 0; $i < 148; $i++) {
*/
// list of known font types
-$types = array(
+$types = [
'eot' => 'application/vnd.ms-fontobject',
'ttf' => 'application/octet-stream',
'woff' => 'application/x-woff', // best supported, but this is not the right one according to http://www.w3.org/TR/WOFF/#appendix-b
'woff2' => 'font/woff2' // the specs at http://dev.w3.org/webfonts/WOFF2/spec/ are not perfectly clear, but font/woff2 seems to be the most sane one and is currently used by Google Fonts
-);
+];
// get parameters
$type = $_GET['type'];
/**
* @see \wcf\action\AbstractAction::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canViewLog');
+ public $neededPermissions = ['admin.management.canViewLog'];
/**
* @see \wcf\action\IAction::execute()
$queueID = $this->installation->nodeBuilder->getQueueByNode($this->installation->queue->processNo, $step->getNode());
if ($step->hasDocument()) {
- $this->data = array(
+ $this->data = [
'currentAction' => $this->getCurrentAction($queueID),
'innerTemplate' => $step->getTemplate(),
'node' => $step->getNode(),
'progress' => $this->installation->nodeBuilder->calculateProgress($this->node),
'step' => 'install',
'queueID' => $queueID
- );
+ ];
}
else {
if ($step->getNode() == '') {
FROM wcf".WCF_N."_application
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($packageID));
+ $statement->execute([$packageID]);
$application = $statement->fetchObject('wcf\data\application\Application');
// build redirect location
WCF::resetZendOpcache();
// show success
- $this->data = array(
+ $this->data = [
'currentAction' => $this->getCurrentAction(null),
'progress' => 100,
'redirectLocation' => $location,
'step' => 'success'
- );
+ ];
return;
}
WCF::resetZendOpcache();
// continue with next node
- $this->data = array(
+ $this->data = [
'currentAction' => $this->getCurrentAction($queueID),
'step' => 'install',
'node' => $step->getNode(),
'progress' => $this->installation->nodeBuilder->calculateProgress($this->node),
'queueID' => $queueID
- );
+ ];
}
}
$nextNode = $this->installation->nodeBuilder->getNextNode();
$queueID = $this->installation->nodeBuilder->getQueueByNode($this->installation->queue->processNo, $nextNode);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'installationType' => $this->queue->action,
'packageName' => $this->installation->queue->packageName
- ));
+ ]);
- $this->data = array(
+ $this->data = [
'template' => WCF::getTPL()->fetch($this->templateName),
'step' => 'install',
'node' => $nextNode,
'currentAction' => $this->getCurrentAction($queueID),
'progress' => 0,
'queueID' => $queueID
- );
+ ];
}
/**
* @return array
*/
protected function stepRollback() {
- $this->data = array(
+ $this->data = [
'packageID' => $this->queue->packageID,
'step' => 'rollback'
- );
+ ];
}
/**
// build package name
$packageName = $this->installation->nodeBuilder->getPackageNameByQueue($queueID);
$installationType = $this->installation->nodeBuilder->getInstallationTypeByQueue($queueID);
- $currentAction = WCF::getLanguage()->getDynamicVariable('wcf.acp.package.installation.step.'.$installationType, array('packageName' => $packageName));
+ $currentAction = WCF::getLanguage()->getDynamicVariable('wcf.acp.package.installation.step.'.$installationType, ['packageName' => $packageName]);
}
return $currentAction;
$processNo = PackageInstallationQueue::getNewProcessNo();
// create queue
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'processNo' => $processNo,
'userID' => WCF::getUser()->userID,
'packageName' => $package->getName(),
'packageID' => $package->packageID,
'action' => 'uninstall'
- ));
+ ]);
// initialize uninstallation
$this->installation = new PackageUninstallationDispatcher($queue);
$this->installation->nodeBuilder->purgeNodes();
$this->installation->nodeBuilder->buildNodes();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'queue' => $queue
- ));
+ ]);
$queueID = $this->installation->nodeBuilder->getQueueByNode($queue->processNo, $this->installation->nodeBuilder->getNextNode());
- $this->data = array(
+ $this->data = [
'template' => WCF::getTPL()->fetch($this->templateName),
'step' => 'uninstall',
'node' => $this->installation->nodeBuilder->getNextNode(),
'currentAction' => $this->getCurrentAction($queueID),
'progress' => 0,
'queueID' => $queueID
- );
+ ];
}
/**
FROM wcf".WCF_N."_application
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($packageID));
+ $statement->execute([$packageID]);
$application = $statement->fetchObject('wcf\data\application\Application');
// build redirect location
$location = $application->getPageURL() . 'acp/index.php?package-list/';
// show success
- $this->data = array(
+ $this->data = [
'currentAction' => WCF::getLanguage()->get('wcf.acp.package.uninstallation.step.success'),
'progress' => 100,
'redirectLocation' => $location,
'step' => 'success'
- );
+ ];
return;
}
// continue with next node
$queueID = $this->installation->nodeBuilder->getQueueByNode($this->installation->queue->processNo, $this->installation->nodeBuilder->getNextNode($this->node));
- $this->data = array(
+ $this->data = [
'step' => 'uninstall',
'node' => $node,
'progress' => $this->installation->nodeBuilder->calculateProgress($this->node),
'queueID' => $queueID
- );
+ ];
}
/**
// build package name
$packageName = $this->installation->nodeBuilder->getPackageNameByQueue($queueID);
$installationType = $this->installation->nodeBuilder->getInstallationTypeByQueue($queueID);
- $currentAction = WCF::getLanguage()->getDynamicVariable('wcf.acp.package.uninstallation.step.'.$installationType, array('packageName' => $packageName));
+ $currentAction = WCF::getLanguage()->getDynamicVariable('wcf.acp.package.uninstallation.step.'.$installationType, ['packageName' => $packageName]);
}
return $currentAction;
/**
* @see \wcf\action\AbstractAction::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditUser');
+ public $neededPermissions = ['admin.user.canEditUser'];
/**
* search mode
* matches
* @var integer[]
*/
- public $matches = array();
+ public $matches = [];
/**
* results per page
* shown columns
* @var string[]
*/
- public $columns = array('registrationDate', 'lastActivityTime');
+ public $columns = ['registrationDate', 'lastActivityTime'];
/**
* sort field
ON (option_value.userID = user_table.userID)
WHERE banned = ?";
$statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
- $statement->execute(array(1));
+ $statement->execute([1]);
$this->matches = $statement->fetchAll(\PDO::FETCH_COLUMN);
break;
WHERE activationCode <> ?
ORDER BY user_table.registrationDate DESC";
$statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
- $statement->execute(array(0));
+ $statement->execute([0]);
$this->matches = $statement->fetchAll(\PDO::FETCH_COLUMN);
break;
ON (option_value.userID = user_table.userID)
WHERE disableAvatar = ?";
$statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
- $statement->execute(array(1));
+ $statement->execute([1]);
$this->matches = $statement->fetchAll(\PDO::FETCH_COLUMN);
break;
ON (option_value.userID = user_table.userID)
WHERE disableSignature = ?";
$statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
- $statement->execute(array(1));
+ $statement->execute([1]);
$this->matches = $statement->fetchAll(\PDO::FETCH_COLUMN);
break;
}
}
// store search result in database
- $data = serialize(array(
+ $data = serialize([
'matches' => $this->matches,
'itemsPerPage' => $this->itemsPerPage,
'columns' => $this->columns
- ));
+ ]);
- $search = SearchEditor::create(array(
+ $search = SearchEditor::create([
'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));
+ $url = LinkHandler::getInstance()->getLink('UserList', ['id' => $search->searchID], 'sortField='.rawurlencode($this->sortField).'&sortOrder='.rawurlencode($this->sortOrder));
HeaderUtil::redirect($url);
exit;
}
* parameters for worker action
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* worker object
*/
protected $worker = null;
- public static $allowInvoke = array();
+ public static $allowInvoke = [];
/**
* @see \wcf\action\IAction::readParameters()
if ($parameters === null) $parameters = $this->parameters;
// build return values
- $returnValues = array(
+ $returnValues = [
'className' => $this->className,
'loopCount' => ($this->loopCount + 1),
'parameters' => $parameters,
'proceedURL' => $proceedURL,
'progress' => $progress
- );
+ ];
// include template on startup
if ($this->loopCount == -1) {
* object action object type types
* @var ObjectType[]
*/
- public $actions = array();
+ public $actions = [];
/**
* number of objects affected by bulk processing
* object condition object type types
* @var ObjectType[]
*/
- public $conditions = array();
+ public $conditions = [];
/**
* list with bulk processed objects
/**
* @see \wcf\form\AbstractForm::$errorField
*/
- public $errorField = array();
+ public $errorField = [];
/**
* @see \wcf\form\AbstractForm::$errorType
*/
- public $errorType = array();
+ public $errorType = [];
/**
* name of the active option category
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.ad.canManageAd');
+ public $neededPermissions = ['admin.ad.canManageAd'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_WCF_AD');
+ public $neededModules = ['MODULE_WCF_AD'];
/**
* html code of the ad
* grouped ad condition object types
* @var array
*/
- public $groupedConditionObjectTypes = array();
+ public $groupedConditionObjectTypes = [];
/**
* 1 if the ad is disabled
* list of available location object types
* @var ObjectType[]
*/
- public $locationObjectTypes = array();
+ public $locationObjectTypes = [];
/**
* list of available locations
* @var string[]
*/
- public $locations = array();
+ public $locations = [];
/**
* id of the selected location's object type
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'ad' => $this->ad,
'adName' => $this->adName,
'groupedConditionObjectTypes' => $this->groupedConditionObjectTypes,
'objectTypeID' => $this->objectTypeID,
'showOrder' => $this->showOrder
- ));
+ ]);
}
/**
if (!$objectType->conditionobject) continue;
if (!isset($this->groupedConditionObjectTypes[$objectType->conditionobject])) {
- $this->groupedConditionObjectTypes[$objectType->conditionobject] = array();
+ $this->groupedConditionObjectTypes[$objectType->conditionobject] = [];
}
if ($objectType->conditiongroup) {
if (!isset($this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup])) {
- $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup] = array();
+ $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup] = [];
}
$this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
public function save() {
parent::save();
- $this->objectAction = new AdAction(array(), 'create', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new AdAction([], 'create', [
+ 'data' => array_merge($this->additionalFields, [
'ad' => $this->ad,
'adName' => $this->adName,
'isDisabled' => $this->isDisabled,
'objectTypeID' => $this->objectTypeID,
'showOrder' => $this->showOrder
- ))
- ));
+ ])
+ ]);
$returnValues = $this->objectAction->executeAction();
// transform conditions array into one-dimensional array
- $conditions = array();
+ $conditions = [];
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
foreach ($groupedObjectTypes as $objectTypes) {
if (is_array($objectTypes)) {
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'adObject' => $this->adObject
- ));
+ ]);
}
/**
$this->showOrder = $this->adObject->showOrder;
$conditions = $this->adObject->getConditions();
- $conditionsByObjectTypeID = array();
+ $conditionsByObjectTypeID = [];
foreach ($conditions as $condition) {
$conditionsByObjectTypeID[$condition->objectTypeID] = $condition;
}
public function save() {
AbstractForm::save();
- $this->objectAction = new AdAction(array($this->adObject), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new AdAction([$this->adObject], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'ad' => $this->ad,
'adName' => $this->adName,
'isDisabled' => $this->isDisabled,
'objectTypeID' => $this->objectTypeID,
'showOrder' => $this->showOrder
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
// transform conditions array into one-dimensional array
- $conditions = array();
+ $conditions = [];
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
foreach ($groupedObjectTypes as $objectTypes) {
if (is_array($objectTypes)) {
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.canManageApplication');
+ public $neededPermissions = ['admin.configuration.canManageApplication'];
/**
* application package id
AND domainPath = ?
AND packageID <> ?";
$statement = WCF::getDB()->prepareStatement($sql, 1);
- $statement->execute(array(
+ $statement->execute([
$this->domainName,
$this->domainPath,
$this->application->packageID
- ));
+ ]);
$row = $statement->fetchArray();
if ($row) {
WCF::getTPL()->assign('conflictApplication', PackageCache::getInstance()->getPackage($row['packageID']));
parent::save();
// save application
- $this->objectAction = new ApplicationAction(array($this->application->getDecoratedObject()), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new ApplicationAction([$this->application->getDecoratedObject()], 'update', ['data' => array_merge($this->additionalFields, [
'cookieDomain' => $this->cookieDomain,
'domainName' => $this->domainName,
'domainPath' => $this->domainPath
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
ApplicationHandler::rebuild();
// show success.
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'application' => $this->application,
'cookieDomain' => $this->cookieDomain,
'domainName' => $this->domainName,
'domainPath' => $this->domainPath,
'packageID' => $this->packageID
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.bbcode.canManageBBCode');
+ public $neededPermissions = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\page\AbstractPage::$templateName
parent::save();
// save media provider
- $this->objectAction = new BBCodeMediaProviderAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new BBCodeMediaProviderAction([], 'create', ['data' => array_merge($this->additionalFields, [
'title' => $this->title,
'regex' => $this->regex,
'html' => $this->html
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
$this->title = $this->regex = $this->html = '';
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'title' => $this->title,
'regex' => $this->regex,
'html' => $this->html
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.bbcode.canManageBBCode');
+ public $neededPermissions = ['admin.content.bbcode.canManageBBCode'];
/**
* id of the edited media provider
AbstractForm::save();
// update media-provider
- $this->objectAction = new BBCodeMediaProviderAction(array($this->providerID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new BBCodeMediaProviderAction([$this->providerID], 'update', ['data' => array_merge($this->additionalFields, [
'title' => $this->title,
'regex' => $this->regex,
'html' => $this->html
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'mediaProvider' => $this->mediaProvider,
'action' => 'edit'
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.captcha.canManageCaptchaQuestion');
+ public $neededPermissions = ['admin.captcha.canManageCaptchaQuestion'];
/**
* @see \wcf\page\IPage::assignVariables()
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'isDisabled' => $this->isDisabled,
'invalidRegex' => $this->invalidRegex
- ));
+ ]);
}
/**
public function save() {
parent::save();
- $this->objectAction = new CaptchaQuestionAction(array(), 'create', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new CaptchaQuestionAction([], 'create', [
+ 'data' => array_merge($this->additionalFields, [
'answers' => I18nHandler::getInstance()->isPlainValue('answers') ? I18nHandler::getInstance()->getValue('answers') : '',
'isDisabled' => $this->isDisabled,
'question' => I18nHandler::getInstance()->isPlainValue('question') ? I18nHandler::getInstance()->getValue('question') : ''
- ))
- ));
+ ])
+ ]);
$returnValues = $this->objectAction->executeAction();
$questionID = $returnValues['returnValues']->questionID;
// set i18n values
- $questionUpdates = array();
+ $questionUpdates = [];
if (!I18nHandler::getInstance()->isPlainValue('question')) {
I18nHandler::getInstance()->save('question', 'wcf.captcha.question.question.question'.$questionID, 'wcf.captcha.question', 1);
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'captchaQuestion' => $this->captchaQuestion
- ));
+ ]);
}
/**
I18nHandler::getInstance()->save('answers', 'wcf.captcha.question.question.answers'.$this->captchaQuestion->questionID, 'wcf.captcha.question', 1);
}
- $this->objectAction = new CaptchaQuestionAction(array($this->captchaQuestion), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new CaptchaQuestionAction([$this->captchaQuestion], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'answers' => I18nHandler::getInstance()->isPlainValue('answers') ? I18nHandler::getInstance()->getValue('answers') : 'wcf.captcha.question.question.answers'.$this->captchaQuestion->questionID,
'isDisabled' => $this->isDisabled,
'question' => I18nHandler::getInstance()->isPlainValue('question') ? I18nHandler::getInstance()->getValue('question') : 'wcf.captcha.question.question.question'.$this->captchaQuestion->questionID
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
$this->saved();
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canManageCronjob');
+ public $neededPermissions = ['admin.management.canManageCronjob'];
/**
* cronjob class name
parent::save();
// save cronjob
- $data = array_merge($this->additionalFields, array(
+ $data = array_merge($this->additionalFields, [
'className' => $this->className,
'packageID' => $this->packageID,
'description' => $this->description,
'startDom' => $this->startDom,
'startMonth' => $this->startMonth,
'startDow' => $this->startDow
- ));
+ ]);
- $this->objectAction = new CronjobAction(array(), 'create', array('data' => $data));
+ $this->objectAction = new CronjobAction([], 'create', ['data' => $data]);
$this->objectAction->executeAction();
if (!I18nHandler::getInstance()->isPlainValue('description')) {
// update group name
$cronjobEditor = new CronjobEditor($returnValues['returnValues']);
- $cronjobEditor->update(array(
+ $cronjobEditor->update([
'description' => 'wcf.acp.cronjob.description.cronjob'.$cronjobID
- ));
+ ]);
}
$this->saved();
I18nHandler::getInstance()->reset();
// show success.
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'className' => $this->className,
'description' => $this->description,
'startMinute' => $this->startMinute,
'startMonth' => $this->startMonth,
'startDow' => $this->startDow,
'action' => 'add'
- ));
+ ]);
}
}
}
// update cronjob
- $data = array_merge($this->additionalFields, array(
+ $data = array_merge($this->additionalFields, [
'className' => $this->className,
'description' => $this->description,
'startMinute' => $this->startMinute,
'startDom' => $this->startDom,
'startMonth' => $this->startMonth,
'startDow' => $this->startDow
- ));
+ ]);
- $this->objectAction = new CronjobAction(array($this->cronjobID), 'update', array('data' => $data));
+ $this->objectAction = new CronjobAction([$this->cronjobID], 'update', ['data' => $data]);
$this->objectAction->executeAction();
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'cronjobID' => $this->cronjobID,
'action' => 'edit'
- ));
+ ]);
}
}
* additional data
* @var array
*/
- public $additionalData = array();
+ public $additionalData = [];
/**
* @see \wcf\page\AbstractPage::$activeMenuItem
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canImportData');
+ public $neededPermissions = ['admin.management.canImportData'];
/**
* list of available exporters
* @var array
*/
- public $exporters = array();
+ public $exporters = [];
/**
* exporter name
* list of available importers
* @var string[]
*/
- public $importers = array();
+ public $importers = [];
/**
* list of supported data types
* @var array
*/
- public $supportedData = array();
+ public $supportedData = [];
/**
* selected data types
* @var array
*/
- public $selectedData = array();
+ public $selectedData = [];
/**
* database host name
$queue = $this->exporter->getQueue();
// save import data
- WCF::getSession()->register('importData', array(
+ WCF::getSession()->register('importData', [
'exporterName' => $this->exporterName,
'dbHost' => $this->dbHost,
'dbUser' => $this->dbUser,
'fileSystemPath' => $this->fileSystemPath,
'userMergeMode' => $this->userMergeMode,
'additionalData' => $this->additionalData
- ));
+ ]);
WCF::getTPL()->assign('queue', $queue);
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'exporter' => $this->exporter,
'importers' => $this->importers,
'exporterName' => $this->exporterName,
'showInnoDBWarning' => $this->showInnoDBWarning,
'showMappingNotice' => $this->showMappingNotice,
'additionalData' => $this->additionalData
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.label.canManageLabel');
+ public $neededPermissions = ['admin.content.label.canManageLabel'];
/**
* label id
}
// update label
- $this->objectAction = new LabelAction(array($this->labelID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new LabelAction([$this->labelID], 'update', ['data' => array_merge($this->additionalFields, [
'label' => $this->label,
'cssClassName' => ($this->cssClassName == 'custom' ? $this->customCssClassName : $this->cssClassName),
'groupID' => $this->groupID,
'showOrder' => $this->showOrder
- ))));
+ ])]);
$this->objectAction->executeAction();
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.objectType');
if ($this->cssClassName != 'custom') $this->customCssClassName = '';
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'label' => $this->labelObj,
'action' => 'edit'
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.label.canManageLabel');
+ public $neededPermissions = ['admin.content.label.canManageLabel'];
/**
* force users to select a label
* list of label object type handlers
* @var ILabelObjectTypeHandler[]
*/
- public $labelObjectTypes = array();
+ public $labelObjectTypes = [];
/**
* list of label object type containers
* @var LabelObjectTypeContainer[]
*/
- public $labelObjectTypeContainers = array();
+ public $labelObjectTypeContainers = [];
/**
* list of label group to object type relations
* @var array<array>
*/
- public $objectTypes = array();
+ public $objectTypes = [];
/**
* object type id
parent::save();
// save label
- $this->objectAction = new LabelGroupAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new LabelGroupAction([], 'create', ['data' => array_merge($this->additionalFields, [
'forceSelection' => ($this->forceSelection ? 1 : 0),
'groupName' => $this->groupName,
'groupDescription' => $this->groupDescription,
'showOrder' => $this->showOrder
- ))));
+ ])]);
$returnValues = $this->objectAction->executeAction();
if (!I18nHandler::getInstance()->isPlainValue('groupName')) {
// update group name
$groupEditor = new LabelGroupEditor($returnValues['returnValues']);
- $groupEditor->update(array(
+ $groupEditor->update([
'groupName' => 'wcf.acp.label.group'.$returnValues['returnValues']->groupID
- ));
+ ]);
}
// save acl
// reset values
$this->forceSelection = false;
$this->groupName = $this->groupDescription = '';
- $this->objectTypes = array();
+ $this->objectTypes = [];
$this->showOrder = 0;
$this->setObjectTypeRelations();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
I18nHandler::getInstance()->reset();
}
ACLHandler::getInstance()->assignVariables($this->objectTypeID);
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'forceSelection' => $this->forceSelection,
'groupName' => $this->groupName,
'labelObjectTypeContainers' => $this->labelObjectTypeContainers,
'objectTypeID' => $this->objectTypeID,
'showOrder' => $this->showOrder
- ));
+ ]);
}
/**
$sql = "DELETE FROM wcf".WCF_N."_label_group_to_object
WHERE groupID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($groupID));
+ $statement->execute([$groupID]);
}
// insert new relations
// use "0" (stored as NULL) for simple true/false states
if (!$objectID) $objectID = null;
- $statement->execute(array(
+ $statement->execute([
$groupID,
$objectTypeID,
$objectID
- ));
+ ]);
}
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.label.canManageLabel');
+ public $neededPermissions = ['admin.content.label.canManageLabel'];
/**
* group id
}
// update label
- $this->objectAction = new LabelGroupAction(array($this->groupID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new LabelGroupAction([$this->groupID], 'update', ['data' => array_merge($this->additionalFields, [
'forceSelection' => ($this->forceSelection ? 1 : 0),
'groupName' => $this->groupName,
'groupDescription' => $this->groupDescription,
'showOrder' => $this->showOrder
- ))));
+ ])]);
$this->objectAction->executeAction();
// update acl
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'groupID' => $this->groupID,
'labelGroup' => $this->group
- ));
+ ]);
}
/**
FROM wcf".WCF_N."_label_group_to_object
WHERE groupID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupID));
+ $statement->execute([$this->groupID]);
- $data = array();
+ $data = [];
while ($row = $statement->fetchArray()) {
if (!isset($data[$row['objectTypeID']])) {
- $data[$row['objectTypeID']] = array();
+ $data[$row['objectTypeID']] = [];
}
// prevent NULL values which confuse isset()
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.language.canManageLanguage');
+ public $neededPermissions = ['admin.language.canManageLanguage'];
/**
* language object
* list of available languages
* @var Language[]
*/
- public $languages = array();
+ public $languages = [];
/**
* source language object
public function save() {
parent::save();
- $this->language = LanguageEditor::create(array(
+ $this->language = LanguageEditor::create([
'countryCode' => mb_strtolower($this->countryCode),
'languageName' => $this->languageName,
'languageCode' => mb_strtolower($this->languageCode)
- ));
+ ]);
$languageEditor = new LanguageEditor($this->sourceLanguage);
$languageEditor->copy($this->language);
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'countryCode' => $this->countryCode,
'languageName' => $this->languageName,
'languageCode' => $this->languageCode,
'sourceLanguageID' => $this->sourceLanguageID,
'languages' => $this->languages,
'action' => 'add'
- ));
+ ]);
}
}
AbstractForm::save();
$editor = new LanguageEditor($this->language);
- $editor->update(array(
+ $editor->update([
'countryCode' => mb_strtolower($this->countryCode),
'languageName' => $this->languageName,
- 'languageCode' => mb_strtolower($this->languageCode)
- ));
+ 'languageCode' => mb_strtolower($this->languageCode)
+ ]);
LanguageFactory::getInstance()->clearCache();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'languageID' => $this->languageID,
'language' => $this->language,
'action' => 'edit'
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.language.canManageLanguage');
+ public $neededPermissions = ['admin.language.canManageLanguage'];
/**
* language id
* selected packages
* @var string[]
*/
- public $selectedPackages = array();
+ public $selectedPackages = [];
/**
* available packages
* @var string[]
*/
- public $packages = array();
+ public $packages = [];
/**
* true to export custom variables
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'languageID' => $this->languageID,
'languages' => LanguageFactory::getInstance()->getLanguages(),
'selectedPackages' => $this->selectedPackages,
'packages' => $this->packages,
'selectAllPackages' => true,
'packageNameLength' => $this->packageNameLength
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.language.canManageLanguage');
+ public $neededPermissions = ['admin.language.canManageLanguage'];
/**
* file name
* list of available languages
* @var Language[]
*/
- public $languages = array();
+ public $languages = [];
/**
* @see \wcf\form\IForm::readFormParameters()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'languages' => $this->languages,
'languageFile' => $this->languageFile
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.language.canManageLanguage');
+ public $neededPermissions = ['admin.language.canManageLanguage'];
/**
* indicates if multilingualism is enabled
* ids of selected available languages
* @var integer[]
*/
- public $languageIDs = array();
+ public $languageIDs = [];
/**
* list of available content languages
* @var Language[]
*/
- public $languages = array();
+ public $languages = [];
/**
* @see \wcf\page\IPage::readParameters()
parent::save();
// save
- LanguageEditor::enableMultilingualism(($this->enable == 1 ? $this->languageIDs : array()));
+ LanguageEditor::enableMultilingualism(($this->enable == 1 ? $this->languageIDs : []));
// clear cache
LanguageCacheBuilder::getInstance()->reset();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'defaultLanguageID' => LanguageFactory::getInstance()->getDefaultLanguageID(),
'enable' => $this->enable,
'languageIDs' => $this->languageIDs,
'languages' => $this->languages
- ));
+ ]);
}
/**
// save authentication failure
if (ENABLE_USER_AUTHENTICATION_FAILURE) {
if ($this->errorField == 'username' || $this->errorField == 'password') {
- $action = new UserAuthenticationFailureAction(array(), 'create', array(
- 'data' => array(
+ $action = new UserAuthenticationFailureAction([], 'create', [
+ 'data' => [
'environment' => (RequestHandler::getInstance()->isACPRequest() ? 'admin' : 'user'),
'userID' => ($this->user !== null ? $this->user->userID : null),
'username' => $this->username,
'time' => TIME_NOW,
'ipAddress' => UserUtil::getIpAddress(),
'userAgent' => UserUtil::getUserAgent()
- )
- ));
+ ]
+ ]);
$action->executeAction();
if ($this->captchaObjectType) {
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'username' => $this->username,
'password' => $this->password,
'url' => $this->url
- ));
+ ]);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'masterPassword' => $this->masterPassword,
'relativeWcfDir' => RELATIVE_WCF_DIR,
'url' => $this->url
- ));
+ ]);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'confirmMasterPassword' => $this->confirmMasterPassword,
'exampleMasterPassword' => PasswordUtil::getRandomPassword(16),
'relativeWcfDir' => RELATIVE_WCF_DIR
- ));
+ ]);
}
}
parent::save();
// save label
- $this->objectAction = new MenuAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new MenuAction([], 'create', ['data' => array_merge($this->additionalFields, [
'title' => $this->title,
'packageID' => 1,
'identifier' => ''
- )), 'boxData' => array(
+ ]), 'boxData' => [
'name' => $this->title,
'boxType' => 'menu',
'position' => $this->position,
'showOrder' => $this->showOrder,
'cssClassName' => $this->cssClassName,
'packageID' => 1
- ), 'pageIDs' => $this->pageIDs));
+ ], 'pageIDs' => $this->pageIDs]);
$returnValues = $this->objectAction->executeAction();
// set generic identifier
$menuEditor = new MenuEditor($returnValues['returnValues']);
- $menuEditor->update(array(
+ $menuEditor->update([
'identifier' => 'com.woltlab.wcf.genericMenu'.$menuEditor->menuID
- ));
+ ]);
// save i18n
if (!I18nHandler::getInstance()->isPlainValue('title')) {
I18nHandler::getInstance()->save('title', 'wcf.menu.menu'.$menuEditor->menuID, 'wcf.menu', 1);
// update title
- $menuEditor->update(array(
+ $menuEditor->update([
'title' => 'wcf.menu.menu'.$menuEditor->menuID
- ));
+ ]);
}
$this->saved();
$this->title = '';
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
I18nHandler::getInstance()->reset();
}
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'title' => 'title',
'position' => $this->position,
'pageIDs' => $this->pageIDs,
'availablePositions' => Box::$availableMenuPositions,
'pageNodeList' => (new PageNodeTree())->getNodeList()
- ));
+ ]);
}
}
}
// update menu
- $this->objectAction = new MenuAction(array($this->menuID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new MenuAction([$this->menuID], 'update', ['data' => array_merge($this->additionalFields, [
'title' => $this->title
- ))));
+ ])]);
$this->objectAction->executeAction();
// update box
if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
- $boxAction = new BoxAction(array($this->menu->getBox()->boxID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $boxAction = new BoxAction([$this->menu->getBox()->boxID], 'update', ['data' => array_merge($this->additionalFields, [
'position' => $this->position,
'visibleEverywhere' => ($this->visibleEverywhere) ? 1 : 0,
'showHeader' => ($this->showHeader) ? 1 : 0,
'showOrder' => $this->showOrder,
'cssClassName' => $this->cssClassName
- )), 'pageIDs' => $this->pageIDs));
+ ]), 'pageIDs' => $this->pageIDs]);
$boxAction->executeAction();
}
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'menuID' => $this->menuID,
'menu' => $this->menu
- ));
+ ]);
}
}
}
// update menu
- $this->objectAction = new MenuItemAction(array($this->itemID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new MenuItemAction([$this->itemID], 'update', ['data' => array_merge($this->additionalFields, [
'isDisabled' => ($this->isDisabled) ? 1 : 0,
'title' => $this->title,
'pageID' => $this->pageID,
'externalURL' => $this->externalURL,
'parentItemID' => $this->parentItemID,
'showOrder' => $this->showOrder
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'itemID' => $this->itemID,
'menuItem' => $this->menuItem
- ));
+ ]);
}
}
* list pf pre-defined CSS class names
* @var string[]
*/
- public $availableCssClassNames = array(
+ public $availableCssClassNames = [
'info',
'success',
'warning',
'error',
'custom'
- );
+ ];
/**
* name of the chosen CSS class name
* grouped notice condition object types
* @var array
*/
- public $groupedConditionObjectTypes = array();
+ public $groupedConditionObjectTypes = [];
/**
* 1 if the notice is disabled
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.notice.canManageNotice');
+ public $neededPermissions = ['admin.notice.canManageNotice'];
/**
* name of the notice
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'availableCssClassNames' => $this->availableCssClassNames,
'cssClassName' => $this->cssClassName,
'noticeName' => $this->noticeName,
'noticeUseHtml' => $this->noticeUseHtml,
'showOrder' => $this->showOrder
- ));
+ ]);
}
/**
if (!$objectType->conditionobject) continue;
if (!isset($this->groupedConditionObjectTypes[$objectType->conditionobject])) {
- $this->groupedConditionObjectTypes[$objectType->conditionobject] = array();
+ $this->groupedConditionObjectTypes[$objectType->conditionobject] = [];
}
if ($objectType->conditiongroup) {
if (!isset($this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup])) {
- $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup] = array();
+ $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup] = [];
}
$this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
public function save() {
parent::save();
- $this->objectAction = new NoticeAction(array(), 'create', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new NoticeAction([], 'create', [
+ 'data' => array_merge($this->additionalFields, [
'cssClassName' => $this->cssClassName == 'custom' ? $this->customCssClassName : $this->cssClassName,
'isDisabled' => $this->isDisabled,
'isDismissible' => $this->isDismissible,
'noticeName' => $this->noticeName,
'noticeUseHtml' => $this->noticeUseHtml,
'showOrder' => $this->showOrder
- ))
- ));
+ ])
+ ]);
$returnValues = $this->objectAction->executeAction();
if (!I18nHandler::getInstance()->isPlainValue('notice')) {
// update notice name
$noticeEditor = new NoticeEditor($returnValues['returnValues']);
- $noticeEditor->update(array(
+ $noticeEditor->update([
'notice' => 'wcf.notice.notice.notice'.$returnValues['returnValues']->noticeID
- ));
+ ]);
}
// transform conditions array into one-dimensional array
- $conditions = array();
+ $conditions = [];
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
foreach ($groupedObjectTypes as $objectTypes) {
if (is_array($objectTypes)) {
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'notice' => $this->notice,
'resetIsDismissed' => $this->resetIsDismissed
- ));
+ ]);
}
/**
$this->showOrder = $this->notice->showOrder;
$conditions = $this->notice->getConditions();
- $conditionsByObjectTypeID = array();
+ $conditionsByObjectTypeID = [];
foreach ($conditions as $condition) {
$conditionsByObjectTypeID[$condition->objectTypeID] = $condition;
}
public function save() {
AbstractForm::save();
- $this->objectAction = new NoticeAction(array($this->notice), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new NoticeAction([$this->notice], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'cssClassName' => $this->cssClassName == 'custom' ? $this->customCssClassName : $this->cssClassName,
'isDisabled' => $this->isDisabled,
'isDismissible' => $this->isDismissible,
'noticeName' => $this->noticeName,
'noticeUseHtml' => $this->noticeUseHtml,
'showOrder' => $this->showOrder
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
if (I18nHandler::getInstance()->isPlainValue('notice')) {
}
// transform conditions array into one-dimensional array
- $conditions = array();
+ $conditions = [];
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
foreach ($groupedObjectTypes as $objectTypes) {
if (is_array($objectTypes)) {
$sql = "DELETE FROM wcf".WCF_N."_notice_dismissed
WHERE noticeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->notice->noticeID
- ));
+ ]);
$this->resetIsDismissed = 0;
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditUser');
+ public $neededPermissions = ['admin.user.canEditUser'];
/**
* list of notification events
* list of settings by event
* @var mixed[][]
*/
- public $settings = array();
+ public $settings = [];
/**
* true to apply change to existing users
* list of valid options for the mail notification type.
* @var string[]
*/
- protected static $validMailNotificationTypes = array('none', 'instant', 'daily');
+ protected static $validMailNotificationTypes = ['none', 'instant', 'daily'];
/**
* @see \wcf\page\IPage::readParameters()
parent::validate();
// valid event ids
- $validEventIDs = array();
+ $validEventIDs = [];
foreach ($this->events as $events) {
foreach ($events as $event) {
$validEventIDs[] = $event->eventID;
// default values
if (empty($_POST)) {
- $eventIDs = array();
+ $eventIDs = [];
foreach ($this->events as $events) {
foreach ($events as $event) {
$eventIDs[] = $event->eventID;
- $this->settings[$event->eventID] = array(
+ $this->settings[$event->eventID] = [
'enabled' => $event->preset,
'mailNotificationType' => $event->presetMailNotificationType
- );
+ ];
}
}
}
public function assignVariables() {
parent::assignVariables();
- $groupedEvents = array();
+ $groupedEvents = [];
foreach ($this->events as $objectType => $events) {
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.notification.objectType', $objectType);
$category = ($objectTypeObj->category ?: $objectType);
if (!isset($groupedEvents[$category])) {
- $groupedEvents[$category] = array();
+ $groupedEvents[$category] = [];
}
foreach ($events as $event) $groupedEvents[$category][] = $event;
ksort($groupedEvents);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'events' => $groupedEvents,
'settings' => $this->settings,
'applyChangesToExistingUsers' => $this->applyChangesToExistingUsers
- ));
+ ]);
}
/**
}
if ($event->preset != $preset || $event->presetMailNotificationType != $presetMailNotificationType) {
- $editor = new UserNotificationEventEditor(new UserNotificationEvent(null, array('eventID' => $event->eventID)));
- $editor->update(array(
+ $editor = new UserNotificationEventEditor(new UserNotificationEvent(null, ['eventID' => $event->eventID]));
+ $editor->update([
'preset' => $preset,
'presetMailNotificationType' => $presetMailNotificationType
- ));
+ ]);
if ($this->applyChangesToExistingUsers) {
if (!$preset) {
$sql = "DELETE FROM wcf".WCF_N."_user_notification_event_to_user
WHERE eventID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($event->eventID));
+ $statement->execute([$event->eventID]);
}
else {
$sql = "REPLACE INTO wcf".WCF_N."_user_notification_event_to_user
SELECT userID, ?, ?
FROM wcf".WCF_N."_user";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($event->eventID, $presetMailNotificationType));
+ $statement->execute([$event->eventID, $presetMailNotificationType]);
}
}
}
* the option tree
* @var array
*/
- public $optionTree = array();
+ public $optionTree = [];
/**
* @see \wcf\acp\form\AbstractOptionListForm::$languageItemPattern
// save options
$saveOptions = $this->optionHandler->save('wcf.acp.option', 'wcf.acp.option.option');
- $this->objectAction = new OptionAction(array(), 'updateAll', array('data' => $saveOptions));
+ $this->objectAction = new OptionAction([], 'updateAll', ['data' => $saveOptions]);
$this->objectAction->executeAction();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'category' => $this->category,
'optionName' => $this->optionName,
'optionTree' => $this->optionTree
- ));
+ ]);
}
/**
ACPMenu::getInstance()->setActiveMenuItem('wcf.acp.option.category.'.$this->category->categoryName);
// check permission
- WCF::getSession()->checkPermissions(array('admin.configuration.canEditOption'));
+ WCF::getSession()->checkPermissions(['admin.configuration.canEditOption']);
if ($this->category->categoryName == 'module') {
// check master password
// insert queue
$isApplication = PackageValidationManager::getInstance()->getPackageValidationArchive()->getArchive()->getPackageInfo('isApplication');
- $this->queue = PackageInstallationQueueEditor::create(array(
+ $this->queue = PackageInstallationQueueEditor::create([
'processNo' => $processNo,
'userID' => WCF::getUser()->userID,
'package' => PackageValidationManager::getInstance()->getPackageValidationArchive()->getArchive()->getPackageInfo('name'),
'archive' => $archive,
'action' => ($this->package != null ? 'update' : 'install'),
'isApplication' => (!$isApplication ? '0' : '1')
- ));
+ ]);
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'package' => $this->package,
'installingImportedStyle' => $this->stylePackageImportLocation != ''
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canEditServer');
+ public $neededPermissions = ['admin.configuration.package.canEditServer'];
/**
* server url
parent::save();
// save server
- $this->objectAction = new PackageUpdateServerAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new PackageUpdateServerAction([], 'create', ['data' => array_merge($this->additionalFields, [
'serverURL' => $this->serverURL,
'loginUsername' => $this->loginUsername,
'loginPassword' => $this->loginPassword
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'serverURL' => $this->serverURL,
'loginUsername' => $this->loginUsername,
'loginPassword' => $this->loginPassword,
'action' => 'add'
- ));
+ ]);
}
/**
AbstractForm::save();
// save server
- $this->objectAction = new PackageUpdateServerAction(array($this->packageUpdateServerID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new PackageUpdateServerAction([$this->packageUpdateServerID], 'update', ['data' => array_merge($this->additionalFields, [
'serverURL' => $this->serverURL,
'loginUsername' => $this->loginUsername,
'loginPassword' => $this->loginPassword
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'packageUpdateServerID' => $this->packageUpdateServerID,
'packageUpdateServer' => $this->updateServer,
'action' => 'edit'
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.paidSubscription.canManageSubscription');
+ public $neededPermissions = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\page\AbstractPage::$templateName
* list of group ids
* @var integer[]
*/
- public $groupIDs = array();
+ public $groupIDs = [];
/**
* list of excluded subscriptions
* @var integer[]
*/
- public $excludedSubscriptionIDs = array();
+ public $excludedSubscriptionIDs = [];
/**
* available user groups
* @var array
*/
- public $availableUserGroups = array();
+ public $availableUserGroups = [];
/**
* list of available currencies
* @var string[]
*/
- public $availableCurrencies = array();
+ public $availableCurrencies = [];
/**
* list of available subscriptions
* @var array
*/
- public $availableSubscriptions = array();
+ public $availableSubscriptions = [];
/**
* @see \wcf\page\IPage::readParameters()
I18nHandler::getInstance()->register('title');
// get available user groups
- $this->availableUserGroups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
+ $this->availableUserGroups = UserGroup::getAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
if (!count(PaymentMethodHandler::getInstance()->getPaymentMethods())) {
throw new NamedUserException(WCF::getLanguage()->get('wcf.acp.paidSubscription.error.noPaymentMethods'));
parent::save();
// save subscription
- $this->objectAction = new PaidSubscriptionAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new PaidSubscriptionAction([], 'create', ['data' => array_merge($this->additionalFields, [
'title' => $this->title,
'description' => $this->description,
'isDisabled' => $this->isDisabled,
'isRecurring' => $this->isRecurring,
'groupIDs' => implode(',', $this->groupIDs),
'excludedSubscriptionIDs' => implode(',', $this->excludedSubscriptionIDs)
- ))));
+ ])]);
$returnValues = $this->objectAction->executeAction();
// save i18n values
$this->title = $this->description = '';
$this->isDisabled = $this->showOrder = $this->cost = $this->subscriptionLength = $this->isRecurring = 0;
$this->currency = 'EUR';
- $this->groupIDs = array();
+ $this->groupIDs = [];
I18nHandler::getInstance()->reset();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
// update database
$editor = new PaidSubscriptionEditor($subscription);
- $editor->update(array(
+ $editor->update([
$columnName => 'wcf.paidSubscription.subscription'.$subscription->subscriptionID.($columnName == 'description' ? '.description' : '')
- ));
+ ]);
}
}
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'isDisabled' => $this->isDisabled,
'showOrder' => $this->showOrder,
'availableCurrencies' => $this->availableCurrencies,
'availableUserGroups' => $this->availableUserGroups,
'availableSubscriptions' => $this->availableSubscriptions
- ));
+ ]);
}
}
protected function getAvailableSubscriptions() {
$subscriptionList = new PaidSubscriptionList();
- $subscriptionList->getConditionBuilder()->add('subscriptionID <> ?', array($this->subscriptionID));
+ $subscriptionList->getConditionBuilder()->add('subscriptionID <> ?', [$this->subscriptionID]);
$subscriptionList->sqlOrderBy = 'title';
$subscriptionList->readObjects();
$this->availableSubscriptions = $subscriptionList->getObjects();
}
// save subscription
- $this->objectAction = new PaidSubscriptionAction(array($this->subscription), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new PaidSubscriptionAction([$this->subscription], 'update', ['data' => array_merge($this->additionalFields, [
'title' => $this->title,
'description' => $this->description,
'isDisabled' => $this->isDisabled,
'isRecurring' => $this->isRecurring,
'groupIDs' => implode(',', $this->groupIDs),
'excludedSubscriptionIDs' => implode(',', $this->excludedSubscriptionIDs)
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
$useRequestData = (empty($_POST)) ? false : true;
I18nHandler::getInstance()->assignVariables($useRequestData);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'subscriptionID' => $this->subscriptionID,
'subscription' => $this->subscription
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.paidSubscription.canManageSubscription');
+ public $neededPermissions = ['admin.paidSubscription.canManageSubscription'];
/**
* subscription id
parent::save();
$userSubscription = PaidSubscriptionUser::getSubscriptionUser($this->subscriptionID, $this->user->userID);
- $data = array();
+ $data = [];
if ($this->subscription->subscriptionLength) {
$data['endDate'] = $this->endDateTime->getTimestamp();
}
if ($userSubscription === null) {
// create new subscription
- $action = new PaidSubscriptionUserAction(array(), 'create', array(
+ $action = new PaidSubscriptionUserAction([], 'create', [
'user' => $this->user,
'subscription' => $this->subscription,
'data' => $data
- ));
+ ]);
$returnValues = $action->executeAction();
$userSubscription = $returnValues['returnValues'];
}
else {
// extend existing subscription
- $action = new PaidSubscriptionUserAction(array($userSubscription), 'extend', array('data' => $data));
+ $action = new PaidSubscriptionUserAction([$userSubscription], 'extend', ['data' => $data]);
$action->executeAction();
}
$this->saved();
$this->username = $this->endDate = '';
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'subscriptionID' => $this->subscriptionID,
'subscription' => $this->subscription,
'username' => $this->username,
'endDate' => $this->endDate
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.smiley.canManageSmiley');
+ public $neededPermissions = ['admin.content.smiley.canManageSmiley'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_SMILEY');
+ public $neededModules = ['MODULE_SMILEY'];
/**
* primary smiley code
* data of the uploaded smiley file
* @var array()
*/
- public $fileUpload = array();
+ public $fileUpload = [];
/**
* temporary name of the uploaded smiley file
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'smileyTitle' => $this->smileyTitle,
'showOrder' => $this->showOrder,
'smileyPath' => $this->smileyPath,
'categoryNodeList' => $this->categoryNodeTree->getIterator(),
'uploadedFilename' => $this->uploadedFilename
- ));
+ ]);
}
/**
public function save() {
parent::save();
- $this->objectAction = new SmileyAction(array(), 'create', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new SmileyAction([], 'create', [
+ 'data' => array_merge($this->additionalFields, [
'smileyTitle' => $this->smileyTitle,
'smileyCode' => $this->smileyCode,
'aliases' => $this->aliases,
'showOrder' => $this->showOrder,
'categoryID' => $this->categoryID ?: null,
'packageID' => 1
- )),
+ ]),
'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/'.$this->uploadedFilename : ''
- ));
+ ]);
$this->objectAction->executeAction();
$returnValues = $this->objectAction->getReturnValues();
$smileyEditor = new SmileyEditor($returnValues['returnValues']);
I18nHandler::getInstance()->save('smileyTitle', 'wcf.smiley.title'.$smileyID, 'wcf.smiley', 1);
// update title
- $smileyEditor->update(array(
+ $smileyEditor->update([
'smileyTitle' => 'wcf.smiley.title'.$smileyID
- ));
+ ]);
}
// reset values
// validate smiley code and aliases against existing smilies
$conditionBuilder = new PreparedStatementConditionBuilder();
if (isset($this->smiley)) {
- $conditionBuilder->add('smileyID <> ?', array($this->smiley->smileyID));
+ $conditionBuilder->add('smileyID <> ?', [$this->smiley->smileyID]);
}
$sql = "SELECT smileyCode, aliases
FROM wcf".WCF_N."_smiley
$aliases = explode("\n", $this->aliases);
while ($row = $statement->fetchArray()) {
- $known = array();
+ $known = [];
if (!empty($row['aliases'])) {
$known = explode("\n", $row['aliases']);
}
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_SMILEY');
+ public $neededModules = ['MODULE_SMILEY'];
}
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_SMILEY');
+ public $neededModules = ['MODULE_SMILEY'];
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.smiley.canManageSmiley');
+ public $neededPermissions = ['admin.content.smiley.canManageSmiley'];
/**
* smiley id
}
// update bbcode
- $this->objectAction = new SmileyAction(array($this->smileyID), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new SmileyAction([$this->smileyID], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'smileyTitle' => $this->smileyTitle,
'smileyCode' => $this->smileyCode,
'aliases' => $this->aliases,
'smileyPath' => $this->smileyPath,
'showOrder' => $this->showOrder,
'categoryID' => $this->categoryID ?: null
- )),
+ ]),
'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/'.$this->uploadedFilename : ''
- ));
+ ]);
$this->objectAction->executeAction();
$this->uploadedFilename = '';
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'smiley' => $this->smiley,
'action' => 'edit'
- ));
+ ]);
}
}
unset($this->variables['overrideScssCustom']);
}*/
- $this->objectAction = new StyleAction(array($this->style), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new StyleAction([$this->style], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'styleName' => $this->styleName,
'templateGroupID' => $this->templateGroupID,
'styleVersion' => $this->styleVersion,
'license' => $this->license,
'authorName' => $this->authorName,
'authorURL' => $this->authorURL
- )),
+ ]),
'tmpHash' => $this->tmpHash,
'variables' => $this->variables
- ));
+ ]);
$this->objectAction->executeAction();
// save description
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'style' => $this->style,
'styleID' => $this->styleID
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.style.canManageStyle');
+ public $neededPermissions = ['admin.style.canManageStyle'];
/**
* package identifier
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'canExportImages' => $this->canExportImages,
'canExportTemplates' => $this->canExportTemplates,
'exportAsPackage' => $this->exportAsPackage,
'packageName' => $this->packageName,
'style' => $this->style,
'styleID' => $this->styleID
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.style.canManageStyle');
+ public $neededPermissions = ['admin.style.canManageStyle'];
/**
* upload data
* @var string[]
*/
- public $source = array();
+ public $source = [];
/**
* style editor object
WCF::getSession()->register('stylePackageImportLocation', $filename);
- HeaderUtil::redirect(LinkHandler::getInstance()->getLink('PackageStartInstall', array(
+ HeaderUtil::redirect(LinkHandler::getInstance()->getLink('PackageStartInstall', [
'action' => 'install'
- )));
+ ]));
exit;
}
catch (SystemException $e) {
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.tag.canManageTag');
+ public $neededPermissions = ['admin.content.tag.canManageTag'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_TAGGING');
+ public $neededModules = ['MODULE_TAGGING'];
/**
* list of available languages
* @var array
*/
- public $availableLanguages = array();
+ public $availableLanguages = [];
/**
* name value
* synonyms
* @var string[]
*/
- public $synonyms = array();
+ public $synonyms = [];
/**
* @see \wcf\page\IPage::readParameters()
parent::save();
// save tag
- $this->objectAction = new TagAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new TagAction([], 'create', ['data' => array_merge($this->additionalFields, [
'name' => $this->name,
'languageID' => $this->languageID
- ))));
+ ])]);
$this->objectAction->executeAction();
$returnValues = $this->objectAction->getReturnValues();
$editor = new TagEditor($returnValues['returnValues']);
// find existing tag
$synonymObj = Tag::getTag($synonym, $this->languageID);
if ($synonymObj === null) {
- $synonymAction = new TagAction(array(), 'create', array('data' => array(
+ $synonymAction = new TagAction([], 'create', ['data' => [
'name' => $synonym,
'languageID' => $this->languageID,
'synonymFor' => $editor->tagID
- )));
+ ]]);
$synonymAction->executeAction();
}
else {
// reset values
$this->name = '';
- $this->synonyms = array();
+ $this->synonyms = [];
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'availableLanguages' => $this->availableLanguages,
'name' => $this->name,
'languageID' => $this->languageID,
'synonyms' => $this->synonyms
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.tag.canManageTag');
+ public $neededPermissions = ['admin.content.tag.canManageTag'];
/**
* tag id
AbstractForm::save();
// update tag
- $this->objectAction = new TagAction(array($this->tagID), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new TagAction([$this->tagID], 'update', ['data' => array_merge($this->additionalFields, [
'name' => $this->name
- ))));
+ ])]);
$this->objectAction->executeAction();
if ($this->tagObj->synonymFor === null) {
SET synonymFor = ?
WHERE synonymFor = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
null,
$this->tagID
- ));
+ ]);
$editor = new TagEditor($this->tagObj);
foreach ($this->synonyms as $synonym) {
// find existing tag
$synonymObj = Tag::getTag($synonym, $this->tagObj->languageID);
if ($synonymObj === null) {
- $synonymAction = new TagAction(array(), 'create', array('data' => array(
+ $synonymAction = new TagAction([], 'create', ['data' => [
'name' => $synonym,
'languageID' => $this->tagObj->languageID,
'synonymFor' => $this->tagID
- )));
+ ]]);
$synonymAction->executeAction();
}
else {
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
}
$synonymList = new TagList();
- $synonymList->getConditionBuilder()->add('synonymFor = ?', array($this->tagObj->tagID));
+ $synonymList->getConditionBuilder()->add('synonymFor = ?', [$this->tagObj->tagID]);
$synonymList->readObjects();
- $this->synonyms = array();
+ $this->synonyms = [];
foreach ($synonymList as $synonym) {
$this->synonyms[] = $synonym->name;
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'tagObj' => $this->tagObj,
'action' => 'edit',
'synonym' => (($this->tagObj !== null && $this->tagObj->synonymFor) ? new Tag($this->tagObj->synonymFor) : null)
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.template.canManageTemplate');
+ public $neededPermissions = ['admin.template.canManageTemplate'];
/**
* template name
* available template groups
* @var array
*/
- public $availableTemplateGroups = array();
+ public $availableTemplateGroups = [];
/**
* template's package id
WHERE templateName = ?
AND templateGroupID IS NULL";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->tplName));
+ $statement->execute([$this->tplName]);
$row = $statement->fetchArray();
if ($row !== false) {
$this->packageID = $row['packageID'];
}
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('templateName = ?', array($this->tplName));
- $conditionBuilder->add('templateGroupID = ?', array($this->templateGroupID));
+ $conditionBuilder->add('templateName = ?', [$this->tplName]);
+ $conditionBuilder->add('templateGroupID = ?', [$this->templateGroupID]);
if ($this->copiedTemplate !== null) {
- $conditionBuilder->add('(packageID = ? OR application = ?)', array($this->packageID, $this->copiedTemplate->application));
+ $conditionBuilder->add('(packageID = ? OR application = ?)', [$this->packageID, $this->copiedTemplate->application]);
}
else {
- $conditionBuilder->add('packageID = ?', array($this->packageID));
+ $conditionBuilder->add('packageID = ?', [$this->packageID]);
}
$sql = "SELECT COUNT(*)
$this->application = Package::getAbbreviation(PackageCache::getInstance()->getPackage($this->packageID)->package);
}
- $this->objectAction = new TemplateAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new TemplateAction([], 'create', ['data' => array_merge($this->additionalFields, [
'application' => $this->application,
'templateName' => $this->tplName,
'packageID' => $this->packageID,
'templateGroupID' => $this->templateGroupID
- )), 'source' => $this->templateSource));
+ ]), 'source' => $this->templateSource]);
$this->objectAction->executeAction();
$this->saved();
$this->templateGroupID = 0;
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'tplName' => $this->tplName,
'templateGroupID' => $this->templateGroupID,
'templateSource' => $this->templateSource,
'availableTemplateGroups' => $this->availableTemplateGroups,
'copy' => $this->copy
- ));
+ ]);
}
}
public function save() {
AbstractForm::save();
- $this->objectAction = new TemplateAction(array($this->template), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new TemplateAction([$this->template], 'update', ['data' => array_merge($this->additionalFields, [
'templateName' => $this->tplName,
'templateGroupID' => $this->templateGroupID,
'lastModificationTime' => TIME_NOW
- )), 'source' => $this->templateSource));
+ ]), 'source' => $this->templateSource]);
$this->objectAction->executeAction();
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'templateID' => $this->templateID,
'template' => $this->template
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.template.canManageTemplate');
+ public $neededPermissions = ['admin.template.canManageTemplate'];
/**
* template group name
* available template groups
* @var array
*/
- public $availableTemplateGroups = array();
+ public $availableTemplateGroups = [];
/**
* @see \wcf\form\IForm::readFormParameters()
FROM wcf".WCF_N."_template_group
WHERE templateGroupName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->templateGroupName));
+ $statement->execute([$this->templateGroupName]);
if ($statement->fetchSingleColumn()) {
throw new UserInputException('templateGroupName', 'notUnique');
FROM wcf".WCF_N."_template_group
WHERE templateGroupFolderName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->templateGroupFolderName));
+ $statement->execute([$this->templateGroupFolderName]);
if ($statement->fetchSingleColumn()) {
throw new UserInputException('templateGroupFolderName', 'notUnique');
public function save() {
parent::save();
- $this->objectAction = new TemplateGroupAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new TemplateGroupAction([], 'create', ['data' => array_merge($this->additionalFields, [
'templateGroupName' => $this->templateGroupName,
'templateGroupFolderName' => $this->templateGroupFolderName,
'parentTemplateGroupID' => ($this->parentTemplateGroupID ?: null)
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
$this->parentTemplateGroupID = 0;
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
* @see \wcf\page\IPage::readData()
*/
public function readData() {
- $this->availableTemplateGroups = TemplateGroup::getSelectList(array(), 1);
+ $this->availableTemplateGroups = TemplateGroup::getSelectList([], 1);
parent::readData();
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'templateGroupName' => $this->templateGroupName,
'templateGroupFolderName' => $this->templateGroupFolderName,
'parentTemplateGroupID' => $this->parentTemplateGroupID,
'availableTemplateGroups' => $this->availableTemplateGroups
- ));
+ ]);
}
}
public function save() {
AbstractForm::save();
- $this->objectAction = new TemplateGroupAction(array($this->templateGroup), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new TemplateGroupAction([$this->templateGroup], 'update', ['data' => array_merge($this->additionalFields, [
'templateGroupName' => $this->templateGroupName,
'templateGroupFolderName' => $this->templateGroupFolderName,
'parentTemplateGroupID' => ($this->parentTemplateGroupID ?: null)
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
* @see \wcf\page\IPage::readData()
*/
public function readData() {
- $this->availableTemplateGroups = TemplateGroup::getSelectList(array($this->templateGroupID), 1);
+ $this->availableTemplateGroups = TemplateGroup::getSelectList([$this->templateGroupID], 1);
AbstractForm::readData();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'templateGroupID' => $this->templateGroupID,
'templateGroup' => $this->templateGroup
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditActivityPoints');
+ public $neededPermissions = ['admin.user.canEditActivityPoints'];
/**
* points to objectType
* @var integer[]
*/
- public $points = array();
+ public $points = [];
/**
* valid object types
* @var ObjectType[]
*/
- public $objectTypes = array();
+ public $objectTypes = [];
/**
* @see \wcf\form\IForm::readFormParameters()
$editor = new ObjectTypeEditor($objectType);
$data = $objectType->additionalData;
$data['points'] = $this->points[$objectType->objectTypeID];
- $editor->update(array('additionalData' => serialize($data)));
+ $editor->update(['additionalData' => serialize($data)]);
}
ObjectTypeEditor::resetCache();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'objectTypes' => $this->objectTypes,
'points' => $this->points
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditUser');
+ public $neededPermissions = ['admin.user.canEditUser'];
/**
* @see \wcf\page\AbstractPage::$activeMenuItem
* ids of the relevant users
* @var integer[]
*/
- public $userIDs = array();
+ public $userIDs = [];
/**
* ids of the assigned user groups
* @var integer[]
*/
- public $groupIDs = array();
+ public $groupIDs = [];
/**
* relevant users
* @var User[]
*/
- public $users = array();
+ public $users = [];
/**
* assigned user groups
* @var UserGroup[]
*/
- public $groups = array();
+ public $groups = [];
/**
* id of the user clipboard item object type
parent::save();
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->userIDs));
+ $conditions->add("userID IN (?)", [$this->userIDs]);
$sql = "SELECT userID, groupID
FROM wcf".WCF_N."_user_to_group
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $groups = array();
+ $groups = [];
while ($row = $statement->fetchArray()) {
$groups[$row['userID']][] = $row['groupID'];
}
$groupsIDs = array_merge($groups[$user->userID], $this->groupIDs);
$groupsIDs = array_unique($groupsIDs);
- $action = new UserAction(array(new UserEditor($user)), 'addToGroups', array(
+ $action = new UserAction([new UserEditor($user)], 'addToGroups', [
'groups' => $groupsIDs,
'addDefaultGroups' => false
- ));
+ ]);
$action->executeAction();
}
$this->saved();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'groupIDs' => $this->groupIDs,
'message' => 'wcf.acp.user.assignToGroup.success',
'users' => $this->users
- ));
+ ]);
WCF::getTPL()->display('success');
exit;
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'users' => $this->users,
'userIDs' => $this->userIDs,
'groupIDs' => $this->groupIDs,
'groups' => $this->groups
- ));
+ ]);
}
/**
* Get a list of available groups.
*/
protected function readGroups() {
- $this->groups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
+ $this->groups = UserGroup::getAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_EDIT_HISTORY');
+ public $neededModules = ['MODULE_EDIT_HISTORY'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.canBulkRevertContentChanges');
+ public $neededPermissions = ['admin.content.canBulkRevertContentChanges'];
/**
* @see \wcf\page\AbstractPage::$activeMenuItem
* ids of the relevant users
* @var integer[]
*/
- public $userIDs = array();
+ public $userIDs = [];
/**
* relevant users
* @var User[]
*/
- public $users = array();
+ public $users = [];
/**
* timeframe to consider
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'users' => $this->users,
'userIDs' => $this->userIDs,
'timeframe' => $this->timeframe
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditUser');
+ public $neededPermissions = ['admin.user.canEditUser'];
/**
* user id
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'userID' => $this->user->userID,
'action' => 'edit',
'url' => '',
'disableAvatarExpires' => $this->disableAvatarExpires,
'userAvatar' => $this->userAvatar,
'banExpires' => $this->banExpires
- ));
+ ]);
}
/**
if ($this->avatarType != 'custom') {
// delete custom avatar
if ($this->user->avatarID) {
- $action = new UserAvatarAction(array($this->user->avatarID), 'delete');
+ $action = new UserAvatarAction([$this->user->avatarID], 'delete');
$action->executeAction();
}
}
switch ($this->avatarType) {
case 'none':
- $avatarData = array(
+ $avatarData = [
'avatarID' => null,
'enableGravatar' => 0
- );
+ ];
break;
case 'custom':
- $avatarData = array(
+ $avatarData = [
'enableGravatar' => 0
- );
+ ];
break;
case 'gravatar':
- $avatarData = array(
+ $avatarData = [
'avatarID' => null,
'enableGravatar' => 1
- );
+ ];
break;
}
$this->additionalFields = array_merge($this->additionalFields, $avatarData);
// add default groups
- $defaultGroups = UserGroup::getAccessibleGroups(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
+ $defaultGroups = UserGroup::getAccessibleGroups([UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
$oldGroupIDs = $this->user->getGroupIDs();
foreach ($oldGroupIDs as $oldGroupID) {
if (isset($defaultGroups[$oldGroupID])) {
// save user
$saveOptions = $this->optionHandler->save();
- $data = array(
- 'data' => array_merge($this->additionalFields, array(
+ $data = [
+ 'data' => array_merge($this->additionalFields, [
'username' => $this->username,
'email' => $this->email,
'password' => $this->password,
'signatureEnableBBCodes' => $this->signatureEnableBBCodes,
'signatureEnableSmilies' => $this->signatureEnableSmilies,
'signatureEnableHtml' => $this->signatureEnableHtml
- )),
+ ]),
'groups' => $this->groupIDs,
'languageIDs' => $this->visibleLanguages,
'options' => $saveOptions
- );
+ ];
// handle ban
if (WCF::getSession()->getPermission('admin.user.canBanUser')) {
$data['data']['disableAvatarExpires'] = $this->disableAvatarExpires;
}
- $this->objectAction = new UserAction(array($this->userID), 'update', $data);
+ $this->objectAction = new UserAction([$this->userID], 'update', $data);
$this->objectAction->executeAction();
// update user rank
$editor = new UserEditor(new User($this->userID));
if (MODULE_USER_RANK) {
- $action = new UserProfileAction(array($editor), 'updateUserRank');
+ $action = new UserProfileAction([$editor], 'updateUserRank');
$action->executeAction();
}
if (MODULE_USERS_ONLINE) {
- $action = new UserProfileAction(array($editor), 'updateUserOnlineMarking');
+ $action = new UserProfileAction([$editor], 'updateUserOnlineMarking');
$action->executeAction();
}
$sql = "DELETE FROM wcf".WCF_N."_moderation_queue_to_user
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->user->userID));
+ $statement->execute([$this->user->userID]);
// reset moderation count
ModerationQueueManager::getInstance()->resetModerationCount($this->user->userID);
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canMailUser');
+ public $neededPermissions = ['admin.user.canMailUser'];
/**
* type of the file containg the exported email addresses
* ids of the users whose email addresses are exported
* @var integer[]
*/
- public $userIDs = array();
+ public $userIDs = [];
/**
* string used to separate email adresses
* users whose email addresses are exported
* @var User[]
*/
- public $users = array();
+ public $users = [];
/**
* clipboard item type id
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->userIDs));
+ $conditions->add("userID IN (?)", [$this->userIDs]);
// count users
$sql = "SELECT COUNT(*)
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'users' => $this->users,
'separator' => $this->separator,
'textSeparator' => $this->textSeparator,
'fileType' => $this->fileType
- ));
+ ]);
}
}
* list of grouped user group assignment condition object types
* @var array
*/
- public $conditions = array();
+ public $conditions = [];
/**
* id of the selected user group
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canManageGroupAssignment');
+ public $neededPermissions = ['admin.user.canManageGroupAssignment'];
/**
* title of the user group assignment
* list of selectable user groups
* @var UserGroup[]
*/
- public $userGroups = array();
+ public $userGroups = [];
/**
* @see \wcf\page\IPage::assignVariables()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'groupedObjectTypes' => $this->conditions,
'groupID' => $this->groupID,
'isDisabled' => $this->isDisabled,
'title' => $this->title,
'userGroups' => $this->userGroups
- ));
+ ]);
}
/**
* @see \wcf\page\IPage::readData()
*/
public function readData() {
- $this->userGroups = UserGroup::getGroupsByType(array(), array(
+ $this->userGroups = UserGroup::getGroupsByType([], [
UserGroup::EVERYONE,
UserGroup::GUESTS,
UserGroup::USERS
- ));
+ ]);
foreach ($this->userGroups as $key => $userGroup) {
if (!$userGroup->isAccessible()) {
unset($this->userGroups[$key]);
public function save() {
parent::save();
- $this->objectAction = new UserGroupAssignmentAction(array(), 'create', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserGroupAssignmentAction([], 'create', [
+ 'data' => array_merge($this->additionalFields, [
'groupID' => $this->groupID,
'isDisabled' => $this->isDisabled,
'title' => $this->title
- ))
- ));
+ ])
+ ]);
$returnValues = $this->objectAction->executeAction();
// transform conditions array into one-dimensional array
- $conditions = array();
+ $conditions = [];
foreach ($this->conditions as $groupedObjectTypes) {
$conditions = array_merge($conditions, $groupedObjectTypes);
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'assignment' => $this->assignment
- ));
+ ]);
}
/**
public function save() {
AbstractForm::save();
- $this->objectAction = new UserGroupAssignmentAction(array($this->assignment), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserGroupAssignmentAction([$this->assignment], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'groupID' => $this->groupID,
'isDisabled' => $this->isDisabled,
'title' => $this->title
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
// transform conditions array into one-dimensional array
- $conditions = array();
+ $conditions = [];
foreach ($this->conditions as $groupedObjectTypes) {
$conditions = array_merge($conditions, $groupedObjectTypes);
}
* list of parsed form elements per group
* @var string[]
*/
- public $formElements = array();
+ public $formElements = [];
/**
* list of accessible groups
* @var UserGroup[]
*/
- public $groups = array();
+ public $groups = [];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditGroup');
+ public $neededPermissions = ['admin.user.canEditGroup'];
/**
* user group option type object
* list of parent categories
* @var UserGroupOptionCategory[]
*/
- public $parentCategories = array();
+ public $parentCategories = [];
/**
* list of values per user group
* @var array
*/
- public $values = array();
+ public $values = [];
/**
* user group option object
$categoryList = new UserGroupOptionCategoryList();
$categoryList->readObjects();
- $categories = array();
+ $categories = [];
foreach ($categoryList as $category) {
$categories[$category->categoryName] = $category;
}
if (empty($_POST)) {
// read values of accessible user groups
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("groupID IN (?)", array(array_keys($this->groups)));
- $conditions->add("optionID = ?", array($this->userGroupOption->optionID));
+ $conditions->add("groupID IN (?)", [array_keys($this->groups)]);
+ $conditions->add("optionID = ?", [$this->userGroupOption->optionID]);
$sql = "SELECT groupID, optionValue
FROM wcf".WCF_N."_user_group_option_value
public function save() {
parent::save();
- $this->objectAction = new UserGroupOptionAction(array($this->userGroupOption), 'updateValues', array('values' => $this->values));
+ $this->objectAction = new UserGroupOptionAction([$this->userGroupOption], 'updateValues', ['values' => $this->values]);
$this->objectAction->executeAction();
// fire saved event
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'formElements' => $this->formElements,
'groups' => $this->groups,
'parentCategories' => $this->parentCategories,
'userGroupOption' => $this->userGroupOption,
'values' => $this->values
- ));
+ ]);
}
/**
* list of group ids
* @var integer[]
*/
- public $groupIDs = array();
+ public $groupIDs = [];
/**
* list of groups
* @var UserGroup[]
*/
- public $groups = array();
+ public $groups = [];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canMailUser');
+ public $neededPermissions = ['admin.user.canMailUser'];
/**
* message subject
* list of user ids
* @var integer[]
*/
- public $userIDs = array();
+ public $userIDs = [];
/**
* list of users
// save config in session
$userMailData = WCF::getSession()->getVar('userMailData');
- if ($userMailData === null) $userMailData = array();
+ if ($userMailData === null) $userMailData = [];
$mailID = count($userMailData);
- $userMailData[$mailID] = array(
+ $userMailData[$mailID] = [
'action' => $this->action,
'userIDs' => $this->userIDs,
'groupIDs' => implode(',', $this->groupIDs),
'text' => $this->text,
'from' => $this->from,
'enableHTML' => $this->enableHTML
- );
+ ];
WCF::getSession()->register('userMailData', $userMailData);
$this->saved();
if (!empty($this->userIDs)) {
$this->userList = new UserList();
- $this->userList->getConditionBuilder()->add("user_table.userID IN (?)", array($this->userIDs));
+ $this->userList->getConditionBuilder()->add("user_table.userID IN (?)", [$this->userIDs]);
$this->userList->sqlOrderBy = "user_table.username ASC";
$this->userList->readObjects();
}
- $this->groups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE));
+ $this->groups = UserGroup::getAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'enableHTML' => $this->enableHTML,
'from' => $this->from,
'groupIDs' => $this->groupIDs,
'text' => $this->text,
'userIDs' => $this->userIDs,
'userList' => $this->userList
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditUser');
+ public $neededPermissions = ['admin.user.canEditUser'];
/**
* @see \wcf\page\AbstractPage::$activeMenuItem
* ids of the relevant users
* @var integer[]
*/
- public $userIDs = array();
+ public $userIDs = [];
/**
* relevant users
* @var User[]
*/
- public $users = array();
+ public $users = [];
/**
* destination user id
* ids of merge users (without destination user)
* @var integer[]
*/
- public $mergedUserIDs = array();
+ public $mergedUserIDs = [];
/**
* id of the user clipboard item object type
// poll_option_vote
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE IGNORE wcf".WCF_N."_poll_option_vote
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// comment
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_comment
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// comment_response
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_comment_response
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// profile comments
$objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.comment.commentableContent', 'com.woltlab.wcf.user.profileComment');
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectType->objectTypeID));
- $conditions->add("objectID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("objectTypeID = ?", [$objectType->objectTypeID]);
+ $conditions->add("objectID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_comment
SET objectID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// like (userID)
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE IGNORE wcf".WCF_N."_like
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// like (objectUserID)
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectUserID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("objectUserID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_like
SET objectUserID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// like_object
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectUserID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("objectUserID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_like_object
SET objectUserID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// user_follow (userID)
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
- $conditions->add("followUserID <> ?", array($this->destinationUserID));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
+ $conditions->add("followUserID <> ?", [$this->destinationUserID]);
$sql = "UPDATE IGNORE wcf".WCF_N."_user_follow
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// user_follow (followUserID)
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("followUserID IN (?)", array($this->mergedUserIDs));
- $conditions->add("userID <> ?", array($this->destinationUserID));
+ $conditions->add("followUserID IN (?)", [$this->mergedUserIDs]);
+ $conditions->add("userID <> ?", [$this->destinationUserID]);
$sql = "UPDATE IGNORE wcf".WCF_N."_user_follow
SET followUserID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// user_ignore (userID)
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
- $conditions->add("ignoreUserID <> ?", array($this->destinationUserID));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
+ $conditions->add("ignoreUserID <> ?", [$this->destinationUserID]);
$sql = "UPDATE IGNORE wcf".WCF_N."_user_ignore
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// user_ignore (ignoreUserID)
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("ignoreUserID IN (?)", array($this->mergedUserIDs));
- $conditions->add("userID <> ?", array($this->destinationUserID));
+ $conditions->add("ignoreUserID IN (?)", [$this->mergedUserIDs]);
+ $conditions->add("userID <> ?", [$this->destinationUserID]);
$sql = "UPDATE IGNORE wcf".WCF_N."_user_ignore
SET ignoreUserID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// user_object_watch
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE IGNORE wcf".WCF_N."_user_object_watch
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// user_activity_event
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_user_activity_event
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// attachments
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_attachment
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// modification_log
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->mergedUserIDs));
+ $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
$sql = "UPDATE wcf".WCF_N."_modification_log
SET userID = ?
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->destinationUserID), $conditions->getParameters()));
+ $statement->execute(array_merge([$this->destinationUserID], $conditions->getParameters()));
// delete merged users
$action = new UserAction($this->mergedUserIDs, 'delete');
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'users' => $this->users,
'userIDs' => $this->userIDs,
'destinationUserID' => $this->destinationUserID
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canManageUserOption');
+ public $neededPermissions = ['admin.user.canManageUserOption'];
/**
* category name
parent::save();
// save label
- $this->objectAction = new UserOptionCategoryAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserOptionCategoryAction([], 'create', ['data' => array_merge($this->additionalFields, [
'parentCategoryName' => 'profile',
'categoryName' => $this->categoryName,
'showOrder' => $this->showOrder
- ))));
+ ])]);
$this->objectAction->executeAction();
// update name
$categoryID = $returnValues['returnValues']->categoryID;
I18nHandler::getInstance()->save('categoryName', 'wcf.user.option.category.category'.$categoryID, 'wcf.user.option');
$categoryEditor = new UserOptionCategoryEditor($returnValues['returnValues']);
- $categoryEditor->update(array(
+ $categoryEditor->update([
'categoryName' => 'category'.$categoryID
- ));
+ ]);
$this->saved();
// reset values
I18nHandler::getInstance()->reset();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'categoryName' => $this->categoryName,
'showOrder' => $this->showOrder
- ));
+ ]);
}
}
I18nHandler::getInstance()->save('categoryName', 'wcf.user.option.category.'.$this->category->categoryName, 'wcf.user.option');
- $this->objectAction = new UserOptionCategoryAction(array($this->category), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserOptionCategoryAction([$this->category], 'update', ['data' => array_merge($this->additionalFields, [
'showOrder' => $this->showOrder
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'categoryID' => $this->categoryID,
'category' => $this->category
- ));
+ ]);
}
}
I18nHandler::getInstance()->save('optionName', 'wcf.user.option.'.$this->userOption->optionName, 'wcf.user.option');
I18nHandler::getInstance()->save('optionDescription', 'wcf.user.option.'.$this->userOption->optionName.'.description', 'wcf.user.option');
- $this->objectAction = new UserOptionAction(array($this->userOption), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserOptionAction([$this->userOption], 'update', ['data' => array_merge($this->additionalFields, [
'categoryName' => $this->categoryName,
'optionType' => $this->optionType,
'defaultValue' => $this->defaultValue,
'searchable' => $this->searchable,
'editable' => $this->editable,
'visible' => $this->visible
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'edit',
'optionID' => $this->optionID,
'userOption' => $this->userOption
- ));
+ ]);
}
}
* @return array
*/
protected function getAvailableGroups() {
- $userGroups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
+ $userGroups = UserGroup::getAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
// work-around for PHP 5.3.3 randomly failing in uasort()
foreach ($userGroups as $userGroup) {
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canManageUserOption');
+ public $neededPermissions = ['admin.user.canManageUserOption'];
/**
* user option handler
WHERE optionID IN (?".str_repeat(', ?', count($optionIDs) - 1).")";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($optionIDs);
- $optionIDs = $optionValues = array();
+ $optionIDs = $optionValues = [];
while ($row = $statement->fetchArray()) {
if ($row['defaultValue'] != $saveOptions[$row['optionID']]) {
$optionIDs[] = $row['optionID'];
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($saveOptions as $optionID => $value) {
- $statement->execute(array($value, $optionID));
+ $statement->execute([$value, $optionID]);
}
// reset cache
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'optionTree' => $this->optionHandler->getOptionTree(),
'applyChangesToExistingUsers' => $this->applyChangesToExistingUsers
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.rank.canManageRank');
+ public $neededPermissions = ['admin.user.rank.canManageRank'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_USER_RANK');
+ public $neededModules = ['MODULE_USER_RANK'];
/**
* rank group id
* list of pre-defined css class names
* @var string[]
*/
- public $availableCssClassNames = array(
+ public $availableCssClassNames = [
'yellow',
'orange',
'brown',
'none', /* not a real value */
'custom' /* not a real value */
- );
+ ];
/**
* @see \wcf\page\IPage::readParameters()
parent::save();
// save label
- $this->objectAction = new UserRankAction(array(), 'create', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserRankAction([], 'create', ['data' => array_merge($this->additionalFields, [
'rankTitle' => $this->rankTitle,
'cssClassName' => ($this->cssClassName == 'custom' ? $this->customCssClassName : $this->cssClassName),
'groupID' => $this->groupID,
'rankImage' => $this->rankImage,
'repeatImage' => $this->repeatImage,
'requiredGender' => $this->requiredGender
- ))));
+ ])]);
$this->objectAction->executeAction();
if (!I18nHandler::getInstance()->isPlainValue('rankTitle')) {
// update name
$rankEditor = new UserRankEditor($returnValues['returnValues']);
- $rankEditor->update(array(
+ $rankEditor->update([
'rankTitle' => 'wcf.user.rank.userRank'.$rankID
- ));
+ ]);
}
$this->saved();
I18nHandler::getInstance()->reset();
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => 'add',
'availableCssClassNames' => $this->availableCssClassNames,
'cssClassName' => $this->cssClassName,
'customCssClassName' => $this->customCssClassName,
'groupID' => $this->groupID,
'rankTitle' => $this->rankTitle,
- 'availableGroups' => UserGroup::getGroupsByType(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE)),
+ 'availableGroups' => UserGroup::getGroupsByType([], [UserGroup::GUESTS, UserGroup::EVERYONE]),
'requiredPoints' => $this->requiredPoints,
'rankImage' => $this->rankImage,
'repeatImage' => $this->repeatImage,
'requiredGender' => $this->requiredGender
- ));
+ ]);
}
}
}
// update label
- $this->objectAction = new UserRankAction(array($this->rank), 'update', array('data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserRankAction([$this->rank], 'update', ['data' => array_merge($this->additionalFields, [
'rankTitle' => $this->rankTitle,
'cssClassName' => ($this->cssClassName == 'custom' ? $this->customCssClassName : $this->cssClassName),
'groupID' => $this->groupID,
'rankImage' => $this->rankImage,
'repeatImage' => $this->repeatImage,
'requiredGender' => $this->requiredGender
- ))));
+ ])]);
$this->objectAction->executeAction();
$this->saved();
if ($this->cssClassName != 'custom') $this->customCssClassName = '';
// show success
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
}
/**
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'rankID' => $this->rankID,
'rank' => $this->rank,
'action' => 'edit'
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canSearchUser');
+ public $neededPermissions = ['admin.user.canSearchUser'];
/**
* list of grouped user group assignment condition object types
* @var array
*/
- public $conditions = array();
+ public $conditions = [];
/**
* list with searched users
* shown columns
* @var string[]
*/
- public $columns = array('registrationDate', 'lastActivityTime');
+ public $columns = ['registrationDate', 'lastActivityTime'];
/**
* number of results
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'groupedObjectTypes' => $this->conditions,
'sortField' => $this->sortField,
'sortOrder' => $this->sortOrder,
'itemsPerPage' => $this->itemsPerPage,
'columns' => $this->columns,
'columnOptions' => $this->optionHandler->getCategoryOptions('profile')
- ));
+ ]);
}
/**
'columns' => $this->columns
]);
- $search = SearchEditor::create(array(
+ $search = SearchEditor::create([
'userID' => WCF::getUser()->userID,
'searchData' => $data,
'searchTime' => TIME_NOW,
'searchType' => 'users'
- ));
+ ]);
// get new search id
$this->searchID = $search->searchID;
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canViewLog');
+ public $neededPermissions = ['admin.management.canViewLog'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('sessionLogID', 'username', 'ipAddress', 'userAgent', 'time', 'lastActivityTime', 'accesses');
+ public $validSortFields = ['sessionLogID', 'username', 'ipAddress', 'userAgent', 'time', 'lastActivityTime', 'accesses'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canViewLog');
+ public $neededPermissions = ['admin.management.canViewLog'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('sessionAccessLogID', 'ipAddress', 'time', 'requestURI', 'requestMethod', 'className');
+ public $validSortFields = ['sessionAccessLogID', 'ipAddress', 'time', 'requestURI', 'requestMethod', 'className'];
/**
* session log id
protected function initObjectList() {
parent::initObjectList();
- $this->objectList->getConditionBuilder()->add('sessionLogID = ?', array($this->sessionLogID));
+ $this->objectList->getConditionBuilder()->add('sessionLogID = ?', [$this->sessionLogID]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'sessionLogID' => $this->sessionLogID,
'sessionLog' => $this->sessionLog
- ));
+ ]);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'addController' => $this->addController,
'categoryNodeList' => $this->categoryNodeTree->getIterator(),
'collapsedCategoryIDs' => $this->collapsedCategoryIDs,
'collapsibleObjectTypeID' => $this->collapsibleObjectTypeID,
'editController' => $this->editController,
'objectType' => $this->objectType
- ));
+ ]);
if ($this->pageTitle) {
WCF::getTPL()->assign('pageTitle', $this->pageTitle);
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.ad.canManageAd');
+ public $neededPermissions = ['admin.ad.canManageAd'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_WCF_AD');
+ public $neededModules = ['MODULE_WCF_AD'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.canManageApplication');
+ public $neededPermissions = ['admin.configuration.canManageApplication'];
/**
* @see \wcf\page\IPage::readData()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'applicationList' => $this->applicationList
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.attachment.canManageAttachment');
+ public $neededPermissions = ['admin.attachment.canManageAttachment'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('attachmentID', 'filename', 'filesize', 'downloads', 'uploadTime', 'lastDownloadTime');
+ public $validSortFields = ['attachmentID', 'filename', 'filesize', 'downloads', 'uploadTime', 'lastDownloadTime'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
* available file types
* @var string[]
*/
- public $availableFileTypes = array();
+ public $availableFileTypes = [];
/**
* attachment stats
* @var array
*/
- public $stats = array();
+ public $stats = [];
/**
* @see \wcf\page\IPage::readParameters()
protected function initObjectList() {
parent::initObjectList();
- $objectTypeIDs = array();
+ $objectTypeIDs = [];
foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.attachment.objectType') as $objectType) {
if (!$objectType->private) {
$objectTypeIDs[] = $objectType->objectTypeID;
}
}
- if (!empty($objectTypeIDs)) $this->objectList->getConditionBuilder()->add('attachment.objectTypeID IN (?)', array($objectTypeIDs));
+ if (!empty($objectTypeIDs)) $this->objectList->getConditionBuilder()->add('attachment.objectTypeID IN (?)', [$objectTypeIDs]);
else $this->objectList->getConditionBuilder()->add('1 = 0');
$this->objectList->getConditionBuilder()->add("attachment.tmpHash = ''");
if (!empty($this->username)) {
$user = User::getUserByUsername($this->username);
if ($user->userID) {
- $this->objectList->getConditionBuilder()->add('attachment.userID = ?', array($user->userID));
+ $this->objectList->getConditionBuilder()->add('attachment.userID = ?', [$user->userID]);
}
}
if (!empty($this->filename)) {
- $this->objectList->getConditionBuilder()->add('attachment.filename LIKE ?', array($this->filename.'%'));
+ $this->objectList->getConditionBuilder()->add('attachment.filename LIKE ?', [$this->filename.'%']);
}
if (!empty($this->fileType)) {
- $this->objectList->getConditionBuilder()->add('attachment.fileType LIKE ?', array($this->fileType));
+ $this->objectList->getConditionBuilder()->add('attachment.fileType LIKE ?', [$this->fileType]);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'stats' => $this->stats,
'username' => $this->username,
'filename' => $this->filename,
'fileType' => $this->fileType,
'availableFileTypes' => $this->availableFileTypes
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.attachment.canManageAttachment');
+ public $neededPermissions = ['admin.attachment.canManageAttachment'];
/**
* @see \wcf\page\IPage::checkPermissions()
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.bbcode.canManageBBCode');
+ public $neededPermissions = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('bbcodeID', 'bbcodeTag', 'className');
+ public $validSortFields = ['bbcodeID', 'bbcodeTag', 'className'];
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.bbcode.canManageBBCode');
+ public $neededPermissions = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('providerID', 'title');
+ public $validSortFields = ['providerID', 'title'];
}
/**
* @inheritdoc
*/
- public $neededPermissions = array('admin.content.cms.canManageBox');
+ public $neededPermissions = ['admin.content.cms.canManageBox'];
/**
* @inheritdoc
/**
* @inheritdoc
*/
- public $validSortFields = array('boxID', 'name', 'boxType', 'position', 'showOrder');
+ public $validSortFields = ['boxID', 'name', 'boxType', 'position', 'showOrder'];
/**
* name
parent::initObjectList();
// hide menu boxes
- $this->objectList->getConditionBuilder()->add('box.boxType <> ?', array('menu'));
+ $this->objectList->getConditionBuilder()->add('box.boxType <> ?', ['menu']);
if (!empty($this->name)) {
- $this->objectList->getConditionBuilder()->add('box.name LIKE ?', array('%'.$this->name.'%'));
+ $this->objectList->getConditionBuilder()->add('box.name LIKE ?', ['%'.$this->name.'%']);
}
if (!empty($this->title)) {
- $this->objectList->getConditionBuilder()->add('box.boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_content WHERE title LIKE ?)', array('%'.$this->title.'%'));
+ $this->objectList->getConditionBuilder()->add('box.boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_content WHERE title LIKE ?)', ['%'.$this->title.'%']);
}
if (!empty($this->content)) {
- $this->objectList->getConditionBuilder()->add('box.boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_content WHERE content LIKE ?)', array('%'.$this->content.'%'));
+ $this->objectList->getConditionBuilder()->add('box.boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_content WHERE content LIKE ?)', ['%'.$this->content.'%']);
}
if (!empty($this->position)) {
- $this->objectList->getConditionBuilder()->add('box.position = ?', array($this->position));
+ $this->objectList->getConditionBuilder()->add('box.position = ?', [$this->position]);
}
if ($this->boxType == 'static') {
- $this->objectList->getConditionBuilder()->add('box.boxType IN (?, ?, ?)', array('text', 'html', 'tpl'));
+ $this->objectList->getConditionBuilder()->add('box.boxType IN (?, ?, ?)', ['text', 'html', 'tpl']);
}
else if ($this->boxType == 'system') {
- $this->objectList->getConditionBuilder()->add('box.boxType IN (?)', array('system'));
+ $this->objectList->getConditionBuilder()->add('box.boxType IN (?)', ['system']);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'name' => $this->name,
'title' => $this->title,
'content' => $this->content,
'boxType' => $this->boxType,
'position' => $this->position,
'availablePositions' => Box::$availablePositions
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.canManageApplication');
+ public $neededPermissions = ['admin.configuration.canManageApplication'];
/**
* indicates if cache was cleared
* contains a list of cache resources
* @var array
*/
- public $caches = array();
+ public $caches = [];
/**
* contains general cache information
* @var array
*/
- public $cacheData = array();
+ public $cacheData = [];
/**
* @see \wcf\page\IPage::readParameters()
parent::readData();
// init cache data
- $this->cacheData = array(
+ $this->cacheData = [
'source' => get_class(CacheHandler::getInstance()->getCacheSource()),
'version' => '',
'size' => 0,
'files' => 0
- );
+ ];
switch ($this->cacheData['source']) {
case 'wcf\system\cache\source\DiskCacheSource':
*/
protected function readCacheFiles($cacheType, $cacheDir, Regex $ignore = null, $extension = 'php') {
if (!isset($this->cacheData[$cacheType])) {
- $this->cacheData[$cacheType] = array();
+ $this->cacheData[$cacheType] = [];
}
// get files in cache directory
$files = $directoryUtil->getFileObjects(SORT_ASC, new Regex('\.'.$extension.'$'));
// get additional file information
- $data = array();
+ $data = [];
if (is_array($files)) {
/** @var \SplFileInfo $file */
foreach ($files as $file) {
continue;
}
- $data[] = array(
+ $data[] = [
'filename' => $file->getBasename(),
'filesize' => $file->getSize(),
'mtime' => $file->getMTime(),
'perm' => substr(sprintf('%o', $file->getPerms()), -3),
'writable' => $file->isWritable()
- );
+ ];
$this->cacheData['files']++;
$this->cacheData['size'] += $file->getSize();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'caches' => $this->caches,
'cacheData' => $this->cacheData,
'cleared' => $this->cleared
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.captcha.canManageCaptchaQuestion');
+ public $neededPermissions = ['admin.captcha.canManageCaptchaQuestion'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canManageCronjob');
+ public $neededPermissions = ['admin.management.canManageCronjob'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('cronjobID', 'nextExec', 'startMinute', 'startHour', 'startDom', 'startMonth', 'startDow');
+ public $validSortFields = ['cronjobID', 'nextExec', 'startMinute', 'startHour', 'startDom', 'startMonth', 'startDow'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canManageCronjob');
+ public $neededPermissions = ['admin.management.canManageCronjob'];
/**
* @see \wcf\page\MultipleLinkPage::$itemsPerPage
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('cronjobID', 'className', 'description', 'execTime', 'success');
+ public $validSortFields = ['cronjobID', 'className', 'description', 'execTime', 'success'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canViewLog');
+ public $neededPermissions = ['admin.management.canViewLog'];
/**
* @see \wcf\page\MultipleLinkPage::$itemsPerPage
* available logfiles
* @var string[]
*/
- public $logFiles = array();
+ public $logFiles = [];
/**
* exceptions shown
* @var array
*/
- public $exceptions = array();
+ public $exceptions = [];
/**
* @see \wcf\page\IPage::readParameters()
try {
$this->exceptions = call_user_func_array('array_merge', array_map(
function($v) {
- return array($v[0] => $v[1]);
+ return [$v[0] => $v[1]];
},
array_chunk($contents, 2)
));
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'exceptionID' => $this->exceptionID,
'logFiles' => array_flip(array_map('basename', $this->logFiles)),
'logFile' => $this->logFile,
'exceptions' => $this->exceptions
- ));
+ ]);
}
}
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('groupID', 'groupName', 'groupDescription', 'showOrder');
+ public $validSortFields = ['groupID', 'groupName', 'groupDescription', 'showOrder'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.label.canManageLabel');
+ public $neededPermissions = ['admin.content.label.canManageLabel'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.language.canManageLanguage');
+ public $neededPermissions = ['admin.language.canManageLanguage'];
/**
* language item list
* available languages
* @var array
*/
- public $availableLanguages = array();
+ public $availableLanguages = [];
/**
* available language categories
* @var array
*/
- public $availableLanguageCategories = array();
+ public $availableLanguageCategories = [];
/**
* current page no
// get items
$this->languageItemList = new LanguageItemList();
- $this->languageItemList->getConditionBuilder()->add('languageID = ?', array($this->languageID));
- if ($this->languageCategoryID) $this->languageItemList->getConditionBuilder()->add('languageCategoryID = ?', array($this->languageCategoryID));
- if ($this->languageItem) $this->languageItemList->getConditionBuilder()->add('languageItem LIKE ?', array('%'.$this->languageItem.'%'));
- if ($this->languageItemValue) $this->languageItemList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', array('%'.$this->languageItemValue.'%', '%'.$this->languageItemValue.'%'));
+ $this->languageItemList->getConditionBuilder()->add('languageID = ?', [$this->languageID]);
+ if ($this->languageCategoryID) $this->languageItemList->getConditionBuilder()->add('languageCategoryID = ?', [$this->languageCategoryID]);
+ if ($this->languageItem) $this->languageItemList->getConditionBuilder()->add('languageItem LIKE ?', ['%'.$this->languageItem.'%']);
+ if ($this->languageItemValue) $this->languageItemList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', ['%'.$this->languageItemValue.'%', '%'.$this->languageItemValue.'%']);
if ($this->hasCustomValue) $this->languageItemList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL");
$this->languageItemList->sqlLimit = 100;
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'objects' => $this->languageItemList,
'count' => $this->count,
'pageNo' => $this->pageNo,
'hasCustomValue' => $this->hasCustomValue,
'availableLanguages' => $this->availableLanguages,
'availableLanguageCategories' => $this->availableLanguageCategories
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.language.canManageLanguage');
+ public $neededPermissions = ['admin.language.canManageLanguage'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('languageID', 'languageCode', 'languageName', 'users', 'variables', 'customVariables');
+ public $validSortFields = ['languageID', 'languageCode', 'languageName', 'users', 'variables', 'customVariables'];
/**
* @see \wcf\page\MultipleLinkPage::initObjectList()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'languages' => $this->objectList->getObjects()
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.cms.canManageMenu');
+ public $neededPermissions = ['admin.content.cms.canManageMenu'];
/**
* menu item list
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'menuID' => $this->menuID,
'menu' => $this->menu,
'menuItemNodeList' => $this->menuItems->getNodeList()
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.notice.canManageNotice');
+ public $neededPermissions = ['admin.notice.canManageNotice'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\SortablePage::$objectListClassName
*/
- public $validSortFields = array('noticeID', 'noticeName', 'showOrder');
+ public $validSortFields = ['noticeID', 'noticeName', 'showOrder'];
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canInstallPackage', 'admin.configuration.package.canUpdatePackage');
+ public $neededPermissions = ['admin.configuration.package.canInstallPackage', 'admin.configuration.package.canUpdatePackage'];
/**
* @see \wcf\page\IPage::assignVariables()
return $ret;
}, $info);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'phpInfo' => $info
- ));
+ ]);
}
}
}
if ($this->queue->action == 'install') {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
}
else {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canUpdatePackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canUpdatePackage']);
}
$this->installingImportedStyle = WCF::getSession()->getVar('stylePackageImportLocation') !== null;
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'archive' => $this->packageInstallationDispatcher->getArchive(),
'packageValidationArchives' => PackageValidationManager::getInstance()->getPackageValidationArchiveList(),
'queue' => $this->queue,
'validationPassed' => $this->validationPassed,
'installingImportedStyle' => $this->installingImportedStyle
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canUninstallPackage');
+ public $neededPermissions = ['admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canUninstallPackage'];
/**
* @see \wcf\page\MultipleLinkPage::$itemsPerPage
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('packageID', 'package', 'packageDir', 'packageName', 'packageDescription', 'packageDate', 'packageURL', 'isApplication', 'author', 'authorURL', 'installDate', 'updateDate');
+ public $validSortFields = ['packageID', 'package', 'packageDir', 'packageName', 'packageDescription', 'packageDate', 'packageURL', 'isApplication', 'author', 'authorURL', 'installDate', 'updateDate'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'packageID' => $this->packageID
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canUninstallPackage');
+ public $neededPermissions = ['admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canUninstallPackage'];
/**
* id of the package
* list of available updates
* @var array
*/
- public $availableUpdates = array();
+ public $availableUpdates = [];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canUpdatePackage');
+ public $neededPermissions = ['admin.configuration.package.canUpdatePackage'];
/**
* @see \wcf\page\IPage::readData()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'availableUpdates' => $this->availableUpdates
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canEditServer');
+ public $neededPermissions = ['admin.configuration.package.canEditServer'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('packageUpdateServerID', 'serverURL', 'status', 'errorMessage', 'lastUpdateTime', 'packages');
+ public $validSortFields = ['packageUpdateServerID', 'serverURL', 'status', 'errorMessage', 'lastUpdateTime', 'packages'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.paidSubscription.canManageSubscription');
+ public $neededPermissions = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('subscriptionID', 'title', 'showOrder', 'cost', 'subscriptionLength');
+ public $validSortFields = ['subscriptionID', 'title', 'showOrder', 'cost', 'subscriptionLength'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.paidSubscription.canManageSubscription');
+ public $neededPermissions = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('logID', 'subscriptionUserID', 'userID', 'subscriptionID', 'paymentMethodObjectTypeID', 'logTime', 'transactionID', 'logMessage');
+ public $validSortFields = ['logID', 'subscriptionUserID', 'userID', 'subscriptionID', 'paymentMethodObjectTypeID', 'logTime', 'transactionID', 'logMessage'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
parent::initObjectList();
if ($this->transactionID) {
- $this->objectList->getConditionBuilder()->add('paid_subscription_transaction_log.transactionID LIKE ?', array('%' . $this->transactionID . '%'));
+ $this->objectList->getConditionBuilder()->add('paid_subscription_transaction_log.transactionID LIKE ?', ['%' . $this->transactionID . '%']);
}
if ($this->username) {
- $this->objectList->getConditionBuilder()->add('paid_subscription_transaction_log.userID IN (SELECT userID FROM wcf'.WCF_N.'_user WHERE username LIKE ?)', array('%' . $this->username . '%'));
+ $this->objectList->getConditionBuilder()->add('paid_subscription_transaction_log.userID IN (SELECT userID FROM wcf'.WCF_N.'_user WHERE username LIKE ?)', ['%' . $this->username . '%']);
}
if ($this->subscriptionID) {
- $this->objectList->getConditionBuilder()->add('paid_subscription_transaction_log.subscriptionID = ?', array($this->subscriptionID));
+ $this->objectList->getConditionBuilder()->add('paid_subscription_transaction_log.subscriptionID = ?', [$this->subscriptionID]);
}
$this->objectList->sqlSelects = 'user_table.username, paid_subscription.title';
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'transactionID' => $this->transactionID,
'username' => $this->username,
'subscriptionID' => $this->subscriptionID,
'availableSubscriptions' => PaidSubscriptionCacheBuilder::getInstance()->getData()
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.paidSubscription.canManageSubscription');
+ public $neededPermissions = ['admin.paidSubscription.canManageSubscription'];
/**
* log entry id
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'logID' => $this->logID,
'log' => $this->log
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.paidSubscription.canManageSubscription');
+ public $neededPermissions = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('subscriptionUserID', 'userID', 'subscriptionID', 'startDate', 'endDate');
+ public $validSortFields = ['subscriptionUserID', 'userID', 'subscriptionID', 'startDate', 'endDate'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
protected function initObjectList() {
parent::initObjectList();
- $this->objectList->getConditionBuilder()->add('isActive = ?', array(1));
+ $this->objectList->getConditionBuilder()->add('isActive = ?', [1]);
$this->objectList->sqlSelects = 'user_table.username, paid_subscription.title';
$this->objectList->sqlJoins = "LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = paid_subscription_user.userID)";
$this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_paid_subscription paid_subscription ON (paid_subscription.subscriptionID = paid_subscription_user.subscriptionID)";
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canUninstallPackage');
+ public $neededPermissions = ['admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canUninstallPackage'];
/**
* list of purchased products grouped by WCF major release
* @var array<array>
*/
- public $products = array();
+ public $products = [];
/**
* list of product data grouped by WCF major release
* @var array<array>
*/
- public $productData = array();
+ public $productData = [];
/**
* list of installed update servers (Plugin-Store only)
* @var PackageUpdateServer[]
*/
- public $updateServers = array();
+ public $updateServers = [];
/**
* list of supported WCF major releases (Plugin-Store)
* @var string[]
*/
- public $wcfMajorReleases = array();
+ public $wcfMajorReleases = [];
/**
* @see \wcf\page\IPage::readParameters()
foreach ($this->products as $packageUpdateID => $product) {
$wcfMajorRelease = $product['wcfMajorRelease'];
if (!isset($this->productData[$wcfMajorRelease])) {
- $this->productData[$wcfMajorRelease] = array();
+ $this->productData[$wcfMajorRelease] = [];
}
$languageCode = WCF::getLanguage()->languageCode;
$packageName = (isset($product['packageName'][$languageCode])) ? $product['packageName'][$languageCode] : $product['packageName']['en'];
- $this->productData[$wcfMajorRelease][$packageUpdateID] = array(
+ $this->productData[$wcfMajorRelease][$packageUpdateID] = [
'author' => $product['author'],
'authorURL' => $product['authorURL'],
'package' => $product['package'],
'packageName' => $packageName,
'pluginStoreURL' => $product['pluginStoreURL'],
- 'version' => array(
+ 'version' => [
'available' => $product['lastVersion'],
'installed' => ''
- ),
+ ],
'status' => (isset($this->updateServers[$wcfMajorRelease]) ? 'install' : 'unavailable')
- );
+ ];
$package = PackageCache::getInstance()->getPackageByIdentifier($product['package']);
if ($package !== null) {
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'productData' => $this->productData,
'updateServers' => $this->updateServers,
'wcfMajorReleases' => $this->wcfMajorReleases
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canRebuildData');
+ public $neededPermissions = ['admin.management.canRebuildData'];
/**
* object types
* @var array
*/
- public $objectTypes = array();
+ public $objectTypes = [];
/**
* display a warning if InnoDB uses a slow configuration
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'objectTypes' => $this->objectTypes,
'showInnoDBWarning' => $this->showInnoDBWarning
- ));
+ ]);
}
}
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_SMILEY');
+ public $neededModules = ['MODULE_SMILEY'];
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.smiley.canManageSmiley');
+ public $neededPermissions = ['admin.content.smiley.canManageSmiley'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_SMILEY');
+ public $neededModules = ['MODULE_SMILEY'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
* available categories
* @var SmileyCategory[]
*/
- public $categories = array();
+ public $categories = [];
/**
* @see \wcf\page\IPage::readParameters()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'category' => $this->category,
'categories' => $this->categories,
'smileyCount' => count(SmileyCache::getInstance()->getSmilies())
- ));
+ ]);
}
/**
parent::initObjectList();
if ($this->categoryID) {
- $this->objectList->getConditionBuilder()->add('categoryID = ?', array($this->categoryID));
+ $this->objectList->getConditionBuilder()->add('categoryID = ?', [$this->categoryID]);
}
else {
- $this->objectList->getConditionBuilder()->add('categoryID IS NULL', array());
+ $this->objectList->getConditionBuilder()->add('categoryID IS NULL', []);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canViewLog');
+ public $neededPermissions = ['admin.management.canViewLog'];
/**
* start date (yyyy-mm-dd)
* available object type
* @var array
*/
- public $availableObjectTypes = array();
+ public $availableObjectTypes = [];
/**
* @see \wcf\page\AbstractPage::readData()
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler');
foreach ($objectTypes as $objectType) {
if (!isset($this->availableObjectTypes[$objectType->categoryname])) {
- $this->availableObjectTypes[$objectType->categoryname] = array();
+ $this->availableObjectTypes[$objectType->categoryname] = [];
}
$this->availableObjectTypes[$objectType->categoryname][] = $objectType;
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'endDate' => $this->endDate,
'startDate' => $this->startDate,
'availableObjectTypes' => $this->availableObjectTypes
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.style.canManageStyle');
+ public $neededPermissions = ['admin.style.canManageStyle'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.content.tag.canManageTag');
+ public $neededPermissions = ['admin.content.tag.canManageTag'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_TAGGING');
+ public $neededModules = ['MODULE_TAGGING'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('tagID', 'languageID', 'name', 'usageCount');
+ public $validSortFields = ['tagID', 'languageID', 'name', 'usageCount'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'hasMarkedItems' => ClipboardHandler::getInstance()->hasMarkedItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.tag')),
'search' => $this->search
- ));
+ ]);
}
/**
$this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_tag synonym ON tag.synonymFor = synonym.tagID";
if ($this->search !== '') {
- $this->objectList->getConditionBuilder()->add('tag.name LIKE ?', array($this->search.'%'));
+ $this->objectList->getConditionBuilder()->add('tag.name LIKE ?', [$this->search.'%']);
}
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.template.canManageTemplate');
+ public $neededPermissions = ['admin.template.canManageTemplate'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$defaultSortField
*/
- public $validSortFields = array('templateGroupID', 'templateGroupName', 'templateGroupFolderName', 'templates');
+ public $validSortFields = ['templateGroupID', 'templateGroupName', 'templateGroupFolderName', 'templates'];
/**
* @see \wcf\page\MultipleLinkPage::initObjectList()
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.template.canManageTemplate');
+ public $neededPermissions = ['admin.template.canManageTemplate'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('templateID', 'templateName', 'lastModificationTime');
+ public $validSortFields = ['templateID', 'templateName', 'lastModificationTime'];
/**
* template group id
* available template groups
* @var array
*/
- public $availableTemplateGroups = array();
+ public $availableTemplateGroups = [];
/**
* available applications
* @var array
*/
- public $availableApplications = array();
+ public $availableApplications = [];
/**
* @see \wcf\page\IPage::readParameters()
protected function initObjectList() {
parent::initObjectList();
- if ($this->templateGroupID) $this->objectList->getConditionBuilder()->add('template.templateGroupID = ?', array($this->templateGroupID));
+ if ($this->templateGroupID) $this->objectList->getConditionBuilder()->add('template.templateGroupID = ?', [$this->templateGroupID]);
else $this->objectList->getConditionBuilder()->add('template.templateGroupID IS NULL');
- if ($this->searchTemplateName) $this->objectList->getConditionBuilder()->add('templateName LIKE ?', array('%'.$this->searchTemplateName.'%'));
- if ($this->application) $this->objectList->getConditionBuilder()->add('application = ?', array($this->application));
+ if ($this->searchTemplateName) $this->objectList->getConditionBuilder()->add('templateName LIKE ?', ['%'.$this->searchTemplateName.'%']);
+ if ($this->application) $this->objectList->getConditionBuilder()->add('application = ?', [$this->application]);
}
/**
parent::readData();
// get template groups
- $this->availableTemplateGroups = TemplateGroup::getSelectList(array(), 1);
+ $this->availableTemplateGroups = TemplateGroup::getSelectList([], 1);
// get applications
$applications = ApplicationHandler::getInstance()->getApplications();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'templateGroupID' => $this->templateGroupID,
'searchTemplateName' => $this->searchTemplateName,
'application' => $this->application,
'availableTemplateGroups' => $this->availableTemplateGroups,
'availableApplications' => $this->availableApplications
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.management.canViewLog');
+ public $neededPermissions = ['admin.management.canViewLog'];
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('ENABLE_USER_AUTHENTICATION_FAILURE');
+ public $neededModules = ['ENABLE_USER_AUTHENTICATION_FAILURE'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('failureID', 'environment', 'userID', 'username', 'time', 'ipAddress', 'userAgent');
+ public $validSortFields = ['failureID', 'environment', 'userID', 'username', 'time', 'ipAddress', 'userAgent'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canManageGroupAssignment');
+ public $neededPermissions = ['admin.user.canManageGroupAssignment'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canEditGroup', 'admin.user.canDeleteGroup');
+ public $neededPermissions = ['admin.user.canEditGroup', 'admin.user.canDeleteGroup'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('groupID', 'groupName', 'groupType', 'members', 'priority');
+ public $validSortFields = ['groupID', 'groupName', 'groupType', 'members', 'priority'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'deletedGroups' => $this->deletedGroups
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canManageUserOption');
+ public $neededPermissions = ['admin.user.canManageUserOption'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$defaultSortField
*/
- public $validSortFields = array('categoryID', 'categoryName', 'showOrder', 'userOptions');
+ public $validSortFields = ['categoryID', 'categoryName', 'showOrder', 'userOptions'];
/**
* @see \wcf\page\MultipleLinkPage::initObjectList
parent::initObjectList();
$this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf".WCF_N."_user_option WHERE categoryName = user_option_category.categoryName) AS userOptions";
- $this->objectList->getConditionBuilder()->add('user_option_category.parentCategoryName = ?', array('profile'));
+ $this->objectList->getConditionBuilder()->add('user_option_category.parentCategoryName = ?', ['profile']);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canManageUserOption');
+ public $neededPermissions = ['admin.user.canManageUserOption'];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\SortablePage::$defaultSortField
*/
- public $validSortFields = array('optionID', 'optionName', 'categoryName', 'optionType', 'showOrder');
+ public $validSortFields = ['optionID', 'optionName', 'categoryName', 'optionType', 'showOrder'];
/**
* @see \wcf\page\MultipleLinkPage::initObjectList
protected function initObjectList() {
parent::initObjectList();
- $this->objectList->getConditionBuilder()->add("option_table.categoryName IN (SELECT categoryName FROM wcf".WCF_N."_user_option_category WHERE parentCategoryName = ?)", array('profile'));
+ $this->objectList->getConditionBuilder()->add("option_table.categoryName IN (SELECT categoryName FROM wcf".WCF_N."_user_option_category WHERE parentCategoryName = ?)", ['profile']);
}
}
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.rank.canManageRank');
+ public $neededPermissions = ['admin.user.rank.canManageRank'];
/**
* @see wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_USER_RANK');
+ public $neededModules = ['MODULE_USER_RANK'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\MultipleLinkPage::$validSortFields
*/
- public $validSortFields = array('rankID', 'groupID', 'requiredPoints', 'rankTitle', 'rankImage', 'requiredGender');
+ public $validSortFields = ['rankID', 'groupID', 'requiredPoints', 'rankTitle', 'rankImage', 'requiredGender'];
/**
* @see \wcf\page\MultipleLinkPage::show()
* list of object ids
* @var integer[]
*/
- protected $objectIDs = array();
+ protected $objectIDs = [];
/**
* additional parameters
* @var mixed[]
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* @see \wcf\action\IAction::readParameters()
protected function sendResponse() {
// add benchmark and debug data
if (ENABLE_BENCHMARK) {
- $this->response['benchmark'] = array(
+ $this->response['benchmark'] = [
'executionTime' => WCF::getBenchmark()->getExecutionTime().'s',
'memoryUsage' => WCF::getBenchmark()->getMemoryUsage(),
'phpExecution' => StringUtil::formatNumeric((WCF::getBenchmark()->getExecutionTime() - WCF::getBenchmark()->getQueryExecutionTime()) / WCF::getBenchmark()->getExecutionTime() * 100).'%',
'sqlExecution' => StringUtil::formatNumeric(WCF::getBenchmark()->getQueryExecutionTime() / WCF::getBenchmark()->getExecutionTime() * 100).'%',
'sqlQueries' => WCF::getBenchmark()->getQueryCount()
- );
+ ];
if (ENABLE_DEBUG_MODE) {
$this->response['benchmark']['items'] = WCF::getBenchmark()->getItems();
* needed modules to execute this action
* @var string[]
*/
- public $neededModules = array();
+ public $neededModules = [];
/**
* needed permissions to execute this action
* @var string[]
*/
- public $neededPermissions = array();
+ public $neededPermissions = [];
/**
* @see \wcf\form\IAction::__run()
* response data
* @var array
*/
- public $data = array();
+ public $data = [];
/**
* @see \wcf\action\IAction::readParameters()
/**
* @see \wcf\action\AbstractAction::$neededModules
*/
- public $neededModules = array('FACEBOOK_PUBLIC_KEY', 'FACEBOOK_PRIVATE_KEY');
+ public $neededModules = ['FACEBOOK_PUBLIC_KEY', 'FACEBOOK_PRIVATE_KEY'];
/**
* @see \wcf\action\IAction::execute()
if (UserAuthenticationFactory::getInstance()->getUserAuthentication()->supportsPersistentLogins()) {
$password = StringUtil::getRandomID();
$userEditor = new UserEditor($user);
- $userEditor->update(array('password' => $password));
+ $userEditor->update(['password' => $password]);
// reload user to retrieve salt
$user = new User($user->userID);
/**
* @see \wcf\action\AbstractAction::$neededModules
*/
- public $neededModules = array('GITHUB_PUBLIC_KEY', 'GITHUB_PRIVATE_KEY');
+ public $neededModules = ['GITHUB_PUBLIC_KEY', 'GITHUB_PRIVATE_KEY'];
/**
* @see \wcf\action\IAction::execute()
if (isset($_GET['code'])) {
try {
// fetch access_token
- $request = new HTTPRequest('https://github.com/login/oauth/access_token', array(), array(
+ $request = new HTTPRequest('https://github.com/login/oauth/access_token', [], [
'client_id' => StringUtil::trim(GITHUB_PUBLIC_KEY),
'client_secret' => StringUtil::trim(GITHUB_PRIVATE_KEY),
'code' => $_GET['code']
- ));
+ ]);
$request->execute();
$reply = $request->getReply();
if (!$user->userID) {
$user = $this->getUser($data['access_token']);
$userEditor = new UserEditor($user);
- $userEditor->update(array('authData' => 'github:'.$userData['id']));
+ $userEditor->update(['authData' => 'github:'.$userData['id']]);
}
if ($user->userID) {
if (UserAuthenticationFactory::getInstance()->getUserAuthentication()->supportsPersistentLogins()) {
$password = StringUtil::getRandomID();
$userEditor = new UserEditor($user);
- $userEditor->update(array('password' => $password));
+ $userEditor->update(['password' => $password]);
// reload user to retrieve salt
$user = new User($user->userID);
/**
* @see \wcf\action\AbstractAction::$neededModules
*/
- public $neededModules = array('GOOGLE_PUBLIC_KEY', 'GOOGLE_PRIVATE_KEY');
+ public $neededModules = ['GOOGLE_PUBLIC_KEY', 'GOOGLE_PRIVATE_KEY'];
/**
* @see \wcf\action\IAction::execute()
public function execute() {
parent::execute();
- $callbackURL = LinkHandler::getInstance()->getLink('GoogleAuth', array(
+ $callbackURL = LinkHandler::getInstance()->getLink('GoogleAuth', [
'appendSession' => false
- ));
+ ]);
// user accepted the connection
if (isset($_GET['code'])) {
try {
// fetch access_token
- $request = new HTTPRequest('https://accounts.google.com/o/oauth2/token', array(), array(
+ $request = new HTTPRequest('https://accounts.google.com/o/oauth2/token', [], [
'code' => $_GET['code'],
'client_id' => StringUtil::trim(GOOGLE_PUBLIC_KEY),
'client_secret' => StringUtil::trim(GOOGLE_PRIVATE_KEY),
'redirect_uri' => $callbackURL,
'grant_type' => 'authorization_code'
- ));
+ ]);
$request->execute();
$reply = $request->getReply();
if (UserAuthenticationFactory::getInstance()->getUserAuthentication()->supportsPersistentLogins()) {
$password = StringUtil::getRandomID();
$userEditor = new UserEditor($user);
- $userEditor->update(array('password' => $password));
+ $userEditor->update(['password' => $password]);
// reload user to retrieve salt
$user = new User($user->userID);
// update file extension
if ($fileExtension != $this->user->gravatarFileExtension) {
$editor = new UserEditor($this->user);
- $editor->update(array(
+ $editor->update([
'gravatarFileExtension' => $fileExtension
- ));
+ ]);
}
@header('Content-Type: '.$mimeType);
catch (SystemException $e) {
// disable gravatar
$editor = new UserEditor($this->user);
- $editor->update(array(
+ $editor->update([
'enableGravatar' => 0
- ));
+ ]);
}
}
* list of quote ids
* @var string[]
*/
- public $quoteIDs = array();
+ public $quoteIDs = [];
/**
* list of object types
* @var string[]
*/
- public $objectTypes = array();
+ public $objectTypes = [];
/**
* @see \wcf\action\IAction::readParameters()
$returnValues = null;
switch ($this->actionName) {
case 'count':
- $returnValues = array(
+ $returnValues = [
'count' => $this->count()
- );
+ ];
break;
case 'getQuotes':
- $returnValues = array(
+ $returnValues = [
'template' => $this->getQuotes()
- );
+ ];
break;
case 'markForRemoval':
break;
case 'remove':
- $returnValues = array(
+ $returnValues = [
'count' => $this->remove()
- );
+ ];
break;
case 'removeMarkedQuotes':
- $returnValues = array(
+ $returnValues = [
'count' => $this->removeMarkedQuotes()
- );
+ ];
break;
default:
$event = new UserNotificationEvent($this->notification->eventID);
$objectType = ObjectTypeCache::getInstance()->getObjectType($event->objectTypeID);
- $objects = $objectType->getProcessor()->getObjectsByIDs(array($this->notification->objectID));
+ $objects = $objectType->getProcessor()->getObjectsByIDs([$this->notification->objectID]);
$userProfile = null;
if ($this->notification->authorID) {
$userProfile = new UserProfile(new User($this->notification->authorID));
}
else {
- $userProfile = new UserProfile(new User(null, array('userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest'))));
+ $userProfile = new UserProfile(new User(null, ['userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest')]));
}
$className = $event->className;
WHERE userID = ?
AND eventID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
'none',
$this->userID,
$this->eventID
- ));
+ ]);
}
else {
$sql = "UPDATE wcf".WCF_N."_user_notification_event_to_user
SET mailNotificationType = ?
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
'none',
$this->userID
- ));
+ ]);
}
$this->executed();
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
}
- $request = new HTTPRequest($url, array(), array_merge(array('cmd' => '_notify-validate'), $_POST));
+ $request = new HTTPRequest($url, [], array_merge(['cmd' => '_notify-validate'], $_POST));
$request->execute();
$reply = $request->getReply();
$content = $reply['body'];
* list of option ids
* @var integer[]
*/
- public $optionIDs = array();
+ public $optionIDs = [];
/**
* poll object
if (isset($_POST['actionName'])) $this->actionName = StringUtil::trim($_POST['actionName']);
if (isset($_POST['pollID'])) $this->pollID = intval($_POST['pollID']);
- $polls = PollManager::getInstance()->getPolls(array($this->pollID));
+ $polls = PollManager::getInstance()->getPolls([$this->pollID]);
if (!isset($polls[$this->pollID])) {
throw new UserInputException('pollID');
}
throw new PermissionDeniedException();
}
- $optionIDs = array();
+ $optionIDs = [];
foreach ($this->poll->getOptions() as $option) {
$optionIDs[] = $option->optionID;
}
public function execute() {
AbstractAction::execute();
- $returnValues = array(
+ $returnValues = [
'actionName' => $this->actionName,
'pollID' => $this->pollID
- );
+ ];
switch ($this->actionName) {
case 'getResult':
* @param array $returnValues
*/
public function getResult(array &$returnValues) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'poll' => $this->poll
- ));
+ ]);
$returnValues['resultTemplate'] = WCF::getTPL()->fetch('pollResult');
}
* @param array $returnValues
*/
public function getVote(array &$returnValues) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'poll' => $this->poll
- ));
+ ]);
$returnValues['voteTemplate'] = WCF::getTPL()->fetch('pollVote');
}
* @param mixed[] $returnValues
*/
protected function vote(array &$returnValues) {
- $pollAction = new \wcf\data\poll\PollAction(array($this->poll), 'vote', array('optionIDs' => $this->optionIDs));
+ $pollAction = new \wcf\data\poll\PollAction([$this->poll], 'vote', ['optionIDs' => $this->optionIDs]);
$pollAction->executeAction();
// update poll object
- $polls = PollManager::getInstance()->getPolls(array($this->pollID));
+ $polls = PollManager::getInstance()->getPolls([$this->pollID]);
$this->poll = $polls[$this->pollID];
if ($this->relatedObject !== null) {
$this->poll->setRelatedObject($this->relatedObject);
/**
* @see \wcf\action\AbstractAction::$neededModules
*/
- public $neededModules = array('TWITTER_PUBLIC_KEY', 'TWITTER_PRIVATE_KEY');
+ public $neededModules = ['TWITTER_PUBLIC_KEY', 'TWITTER_PRIVATE_KEY'];
/**
* @see \wcf\action\IAction::execute()
try {
// fetch access_token
- $oauthHeader = array(
+ $oauthHeader = [
'oauth_consumer_key' => StringUtil::trim(TWITTER_PUBLIC_KEY),
'oauth_nonce' => StringUtil::getRandomID(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => TIME_NOW,
'oauth_version' => '1.0',
'oauth_token' => $initData['oauth_token']
- );
- $postData = array(
+ ];
+ $postData = [
'oauth_verifier' => $_GET['oauth_verifier']
- );
+ ];
$signature = $this->createSignature('https://api.twitter.com/oauth/access_token', array_merge($oauthHeader, $postData));
$oauthHeader['oauth_signature'] = $signature;
- $request = new HTTPRequest('https://api.twitter.com/oauth/access_token', array(), $postData);
+ $request = new HTTPRequest('https://api.twitter.com/oauth/access_token', [], $postData);
$request->addHeader('Authorization', 'OAuth '.$this->buildOAuthHeader($oauthHeader));
$request->execute();
$reply = $request->getReply();
if (UserAuthenticationFactory::getInstance()->getUserAuthentication()->supportsPersistentLogins()) {
$password = StringUtil::getRandomID();
$userEditor = new UserEditor($user);
- $userEditor->update(array('password' => $password));
+ $userEditor->update(['password' => $password]);
// reload user to retrieve salt
$user = new User($user->userID);
// start auth by fetching request_token
try {
- $callbackURL = LinkHandler::getInstance()->getLink('TwitterAuth', array(
+ $callbackURL = LinkHandler::getInstance()->getLink('TwitterAuth', [
'appendSession' => false
- ));
- $oauthHeader = array(
+ ]);
+ $oauthHeader = [
'oauth_callback' => $callbackURL,
'oauth_consumer_key' => StringUtil::trim(TWITTER_PUBLIC_KEY),
'oauth_nonce' => StringUtil::getRandomID(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => TIME_NOW,
'oauth_version' => '1.0'
- );
+ ];
$signature = $this->createSignature('https://api.twitter.com/oauth/request_token', $oauthHeader);
$oauthHeader['oauth_signature'] = $signature;
// call api
- $request = new HTTPRequest('https://api.twitter.com/oauth/request_token', array('method' => 'POST'));
+ $request = new HTTPRequest('https://api.twitter.com/oauth/request_token', ['method' => 'POST']);
$request->addHeader('Authorization', 'OAuth '.$this->buildOAuthHeader($oauthHeader));
$request->execute();
$reply = $request->getReply();
* @return string
*/
public function createSignature($url, array $parameters, $tokenSecret = '') {
- $tmp = array();
+ $tmp = [];
foreach ($parameters as $key => $val) {
$tmp[rawurlencode($key)] = rawurlencode($val);
}
* list of object ids
* @var integer[]
*/
- protected $objectIDs = array();
+ protected $objectIDs = [];
/**
* list of object editors
* @var DatabaseObjectEditor[]
*/
- protected $objects = array();
+ protected $objects = [];
/**
* multi-dimensional array of parameters required by an action
* @var mixed[][]
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* list of permissions required to create objects
* @var string[]
*/
- protected $permissionsCreate = array();
+ protected $permissionsCreate = [];
/**
* list of permissions required to delete objects
* @var string[]
*/
- protected $permissionsDelete = array();
+ protected $permissionsDelete = [];
/**
* list of permissions required to update objects
* @var string[]
*/
- protected $permissionsUpdate = array();
+ protected $permissionsUpdate = [];
/**
* disallow requests for specified methods if the origin is not the ACP
* @var string[]
*/
- protected $requireACP = array();
+ protected $requireACP = [];
/**
* Resets cache if any of the listed actions is invoked
* @var string[]
*/
- protected $resetCache = array('create', 'delete', 'toggle', 'update', 'updatePosition');
+ protected $resetCache = ['create', 'delete', 'toggle', 'update', 'updatePosition'];
/**
* values returned by executed action
* is completely disabled
* @var string[]
*/
- protected $allowGuestAccess = array();
+ protected $allowGuestAccess = [];
const TYPE_INTEGER = 1;
const TYPE_STRING = 2;
* @param array $parameters
* @throws SystemException
*/
- public function __construct(array $objects, $action, array $parameters = array()) {
+ public function __construct(array $objects, $action, array $parameters = []) {
// set class name
if (empty($this->className)) {
$className = get_called_class();
}
}
- $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
- $baseClass = call_user_func(array($this->className, 'getBaseClass'));
+ $indexName = call_user_func([$this->className, 'getDatabaseTableIndexName']);
+ $baseClass = call_user_func([$this->className, 'getBaseClass']);
foreach ($objects as $object) {
if (is_object($object)) {
}
// execute action
- call_user_func_array(array($this, $actionName), $this->getParameters());
+ call_user_func_array([$this, $actionName], $this->getParameters());
// fire event action
EventHandler::getInstance()->fireAction($this, 'validateAction');
throw new SystemException("call to undefined function '".$this->getActionName()."'");
}
- $this->returnValues = call_user_func(array($this, $this->getActionName()));
+ $this->returnValues = call_user_func([$this, $this->getActionName()]);
// reset cache
if (in_array($this->getActionName(), $this->resetCache)) {
*/
protected function resetCache() {
if (is_subclass_of($this->className, 'wcf\data\IEditableCachedObject')) {
- call_user_func(array($this->className, 'resetCache'));
+ call_user_func([$this->className, 'resetCache']);
}
}
$this->objects = $objects;
// update object IDs
- $this->objectIDs = array();
+ $this->objectIDs = [];
foreach ($this->objects as $object) {
$this->objectIDs[] = $object->getObjectID();
}
* @see \wcf\data\IDatabaseObjectAction::getReturnValues()
*/
public function getReturnValues() {
- return array(
+ return [
'actionName' => $this->action,
'objectIDs' => $this->getObjectIDs(),
'returnValues' => $this->returnValues
- );
+ ];
}
/**
* @return \wcf\data\DatabaseObject
*/
public function create() {
- return call_user_func(array($this->className, 'create'), $this->parameters['data']);
+ return call_user_func([$this->className, 'create'], $this->parameters['data']);
}
/**
}
// get ids
- $objectIDs = array();
+ $objectIDs = [];
foreach ($this->objects as $object) {
$objectIDs[] = $object->getObjectID();
}
// execute action
- return call_user_func(array($this->className, 'deleteAll'), $objectIDs);
+ return call_user_func([$this->className, 'deleteAll'], $objectIDs);
}
/**
}
// get base class
- $baseClass = call_user_func(array($this->className, 'getBaseClass'));
+ $baseClass = call_user_func([$this->className, 'getBaseClass']);
// get db information
- $tableName = call_user_func(array($this->className, 'getDatabaseTableName'));
- $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
+ $tableName = call_user_func([$this->className, 'getDatabaseTableName']);
+ $indexName = call_user_func([$this->className, 'getDatabaseTableIndexName']);
// get objects
$sql = "SELECT *
case self::TYPE_INTEGER:
if (!isset($target[$variableName])) {
if ($allowEmpty) {
- $target[$variableName] = ($structure === self::STRUCT_FLAT) ? 0 : array();
+ $target[$variableName] = ($structure === self::STRUCT_FLAT) ? 0 : [];
}
else {
throw new UserInputException($variableName);
case self::TYPE_STRING:
if (!isset($target[$variableName])) {
if ($allowEmpty) {
- $target[$variableName] = ($structure === self::STRUCT_FLAT) ? '' : array();
+ $target[$variableName] = ($structure === self::STRUCT_FLAT) ? '' : [];
}
else {
throw new UserInputException($variableName);
case self::TYPE_JSON:
if (!isset($target[$variableName])) {
if ($allowEmpty) {
- $target[$variableName] = array();
+ $target[$variableName] = [];
}
else {
throw new UserInputException($variableName);
throw new SystemException("unknown method '".$name."'");
}
- return call_user_func_array(array($this->object, $name), $arguments);
+ return call_user_func_array([$this->object, $name], $arguments);
}
/**
* @see \wcf\data\IStorableObject::getDatabaseTableAlias()
*/
public static function getDatabaseTableAlias() {
- return call_user_func(array(static::$baseClass, 'getDatabaseTableAlias'));
+ return call_user_func([static::$baseClass, 'getDatabaseTableAlias']);
}
/**
* @see \wcf\data\IStorableObject::getDatabaseTableName()
*/
public static function getDatabaseTableName() {
- return call_user_func(array(static::$baseClass, 'getDatabaseTableName'));
+ return call_user_func([static::$baseClass, 'getDatabaseTableName']);
}
/**
* @see \wcf\data\IStorableObject::getDatabaseTableIndexIsIdentity()
*/
public static function getDatabaseTableIndexIsIdentity() {
- return call_user_func(array(static::$baseClass, 'getDatabaseTableIndexIsIdentity'));
+ return call_user_func([static::$baseClass, 'getDatabaseTableIndexIsIdentity']);
}
/**
* @see \wcf\data\IStorableObject::getDatabaseTableIndexName()
*/
public static function getDatabaseTableIndexName() {
- return call_user_func(array(static::$baseClass, 'getDatabaseTableIndexName'));
+ return call_user_func([static::$baseClass, 'getDatabaseTableIndexName']);
}
/**
/**
* @see \wcf\data\IEditableObject::create()
*/
- public static function create(array $parameters = array()) {
+ public static function create(array $parameters = []) {
$keys = $values = '';
- $statementParameters = array();
+ $statementParameters = [];
foreach ($parameters as $key => $value) {
if (!empty($keys)) {
$keys .= ',';
/**
* @see \wcf\data\IEditableObject::update()
*/
- public function update(array $parameters = array()) {
+ public function update(array $parameters = []) {
if (empty($parameters)) return;
$updateSQL = '';
- $statementParameters = array();
+ $statementParameters = [];
foreach ($parameters as $key => $value) {
if (!empty($updateSQL)) $updateSQL .= ', ';
$updateSQL .= $key . ' = ?';
/**
* @see \wcf\data\IEditableObject::updateCounters()
*/
- public function updateCounters(array $counters = array()) {
+ public function updateCounters(array $counters = []) {
if (empty($counters)) return;
$updateSQL = '';
- $statementParameters = array();
+ $statementParameters = [];
foreach ($counters as $key => $value) {
if (!empty($updateSQL)) $updateSQL .= ', ';
$updateSQL .= $key . ' = ' . $key . ' + ?';
* @see \wcf\data\IEditableObject::delete()
*/
public function delete() {
- static::deleteAll(array($this->getObjectID()));
+ static::deleteAll([$this->getObjectID()]);
}
/**
* @see \wcf\data\IEditableObject::deleteAll()
*/
- public static function deleteAll(array $objectIDs = array()) {
+ public static function deleteAll(array $objectIDs = []) {
$sql = "DELETE FROM ".static::getDatabaseTableName()."
WHERE ".static::getDatabaseTableIndexName()." = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$affectedCount = 0;
WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) {
- $statement->execute(array($objectID));
+ $statement->execute([$objectID]);
$affectedCount += $statement->getAffectedRows();
}
WCF::getDB()->commitTransaction();
* result objects
* @var DatabaseObject[]
*/
- public $objects = array();
+ public $objects = [];
/**
* ids of result objects
}
$objectClassName = $this->objectClassName ?: $this->className;
- $baseClassName = call_user_func(array($this->decoratorClassName, 'getBaseClass'));
+ $baseClassName = call_user_func([$this->decoratorClassName, 'getBaseClass']);
if ($objectClassName != $baseClassName && !is_subclass_of($baseClassName, $objectClassName)) {
throw new SystemException("'".$this->decoratorClassName."' can't decorate objects of class '".$objectClassName."'");
}
* Reads the object ids from database.
*/
public function readObjectIDs() {
- $this->objectIDs = array();
+ $this->objectIDs = [];
$sql = "SELECT ".$this->getDatabaseTableAlias().".".$this->getDatabaseTableIndexName()." AS objectID
FROM ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()."
".$this->sqlConditionJoins."
}
// use table index as array index
- $objects = array();
+ $objects = [];
foreach ($this->objects as $object) {
$objectID = $object->getObjectID();
$objects[$objectID] = $object;
* @return string
*/
public function getDatabaseTableName() {
- return call_user_func(array($this->className, 'getDatabaseTableName'));
+ return call_user_func([$this->className, 'getDatabaseTableName']);
}
/**
* @return string
*/
public function getDatabaseTableIndexName() {
- return call_user_func(array($this->className, 'getDatabaseTableIndexName'));
+ return call_user_func([$this->className, 'getDatabaseTableIndexName']);
}
/**
* @return string
*/
public function getDatabaseTableAlias() {
- return call_user_func(array($this->className, 'getDatabaseTableAlias'));
+ return call_user_func([$this->className, 'getDatabaseTableAlias']);
}
/**
* @param array $parameters
* @return \wcf\data\IStorableObject
*/
- public static function create(array $parameters = array());
+ public static function create(array $parameters = []);
/**
* Updates this object.
*
* @param array $parameters
*/
- public function update(array $parameters = array());
+ public function update(array $parameters = []);
/**
* Updates the counters of this object.
*
* @param array $counters
*/
- public function updateCounters(array $counters = array());
+ public function updateCounters(array $counters = []);
/**
* Deletes this object.
* @param array $objectIDs
* @return integer
*/
- public static function deleteAll(array $objectIDs = array());
+ public static function deleteAll(array $objectIDs = []);
}
}
if (is_subclass_of($this->className, 'wcf\system\SingletonFactory')) {
- $this->processor = call_user_func(array($this->className, 'getInstance'));
+ $this->processor = call_user_func([$this->className, 'getInstance']);
}
else {
if (!is_subclass_of($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
* ids of the object's categories
* @var integer[]
*/
- protected $categoryIDs = array();
+ protected $categoryIDs = [];
/**
* list of the object's leaf categories
*/
public function getCategories() {
if ($this->categories === null) {
- $this->categories = array();
+ $this->categories = [];
$className = static::getCategoryClassName();
if (!is_subclass_of($className, AbstractDecoratedCategory::class)) {
)
ORDER BY parentCategoryID, showOrder";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectID()));
+ $statement->execute([$this->getObjectID()]);
while ($categoryID = $statement->fetchColumn()) {
$this->categories[$categoryID] = $className::getCategory($categoryID);
}
*/
public static function getOptions($objectTypeID) {
$optionList = new ACLOptionList();
- $optionList->getConditionBuilder()->add("acl_option.objectTypeID = ?", array($objectTypeID));
+ $optionList->getConditionBuilder()->add("acl_option.objectTypeID = ?", [$objectTypeID]);
$optionList->readObjects();
return $optionList;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('loadAll');
+ protected $requireACP = ['loadAll'];
/**
* Validates parameters for ACL options.
* @return array
*/
public function loadAll() {
- $objectIDs = ($this->parameters['objectID']) ? array($this->parameters['objectID']) : array();
+ $objectIDs = ($this->parameters['objectID']) ? [$this->parameters['objectID']] : [];
$permissions = ACLHandler::getInstance()->getPermissions($this->parameters['objectTypeID'], $objectIDs, $this->parameters['categoryName'], true);
return $permissions;
$this->parseController();
- $linkParameters = array(
+ $linkParameters = [
'application' => $this->application
- );
+ ];
// links of top option category menu items need the id of the option
// category
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('getSearchResultList');
+ protected $requireACP = ['getSearchResultList'];
/**
* @see \wcf\data\ISearchAction::validateGetSearchResultList()
* @see \wcf\data\ISearchAction::getSearchResultList()
*/
public function getSearchResultList() {
- $data = array();
+ $data = [];
$results = ACPSearchHandler::getInstance()->search($this->parameters['data']['searchString']);
foreach ($results as $resultList) {
- $items = array();
+ $items = [];
foreach ($resultList as $item) {
- $items[] = array(
+ $items[] = [
'link' => $item->getLink(),
'subtitle' => $item->getSubtitle(),
'title' => $item->getTitle()
- );
+ ];
}
foreach ($items as $key => &$item) {
}
unset($item);
- $data[] = array(
+ $data[] = [
'items' => $items,
'title' => $resultList->getTitle()
- );
+ ];
}
return $data;
AND ipAddress = ?
AND userAgent = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$sessionID,
UserUtil::getIpAddress(),
UserUtil::getUserAgent()
- ));
+ ]);
return $statement->fetchObject(static::class);
}
FROM ".static::getDatabaseTableName()."
WHERE sessionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($sessionID));
+ $statement->execute([$sessionID]);
return $statement->fetchColumn();
}
*/
public function create() {
// try to find an existing virtual session
- $baseClass = call_user_func(array($this->className, 'getBaseClass'));
- $virtualSession = call_user_func(array($baseClass, 'getExistingSession'), $this->parameters['data']['sessionID']);
+ $baseClass = call_user_func([$this->className, 'getBaseClass']);
+ $virtualSession = call_user_func([$baseClass, 'getExistingSession'], $this->parameters['data']['sessionID']);
if ($virtualSession !== null) {
return $virtualSession;
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.template.canAddTemplate');
+ protected $permissionsCreate = ['admin.template.canAddTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.template.canDeleteTemplate');
+ protected $permissionsDelete = ['admin.template.canDeleteTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.template.canUpdateTemplate');
+ protected $permissionsUpdate = ['admin.template.canUpdateTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.ad.canManageAd');
+ protected $permissionsDelete = ['admin.ad.canManageAd'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.ad.canManageAd');
+ protected $permissionsUpdate = ['admin.ad.canManageAd'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update', 'updatePosition');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update', 'updatePosition'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
*/
public function toggle() {
foreach ($this->objects as $ad) {
- $ad->update(array(
+ $ad->update([
'isDisabled' => $ad->isDisabled ? 0 : 1
- ));
+ ]);
}
}
$showOrder = $this->parameters['data']['offset'];
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'][0] as $adID) {
- $statement->execute(array(
+ $statement->execute([
$showOrder++,
$adID
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
SET showOrder = showOrder + 1
WHERE showOrder >= ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$showOrder
- ));
+ ]);
$newShowOrder = $showOrder;
}
- $this->update(array(
+ $this->update([
'showOrder' => $newShowOrder
- ));
+ ]);
}
/**
*/
public static function resetCache() {
AdCacheBuilder::getInstance()->reset();
- ConditionCacheBuilder::getInstance()->reset(array(
+ ConditionCacheBuilder::getInstance()->reset([
'definitionID' => ObjectTypeCache::getInstance()->getDefinitionByName('com.woltlab.wcf.condition.ad')->definitionID
- ));
+ ]);
}
}
*/
public static function getDirectory($abbreviation) {
if (static::$directories === null) {
- static::$directories = array();
+ static::$directories = [];
// read application directories
$packageList = new PackageList();
- $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
+ $packageList->getConditionBuilder()->add('package.isApplication = ?', [1]);
$packageList->readObjects();
foreach ($packageList as $package) {
$abbr = Package::getAbbreviation($package->package);
* grouped objects
* @var array
*/
- public $groupedObjects = array();
+ public $groupedObjects = [];
/**
* object type
parent::__construct();
$this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType);
- $this->getConditionBuilder()->add('attachment.objectTypeID = ?', array($this->objectType->objectTypeID));
+ $this->getConditionBuilder()->add('attachment.objectTypeID = ?', [$this->objectType->objectTypeID]);
- $this->getConditionBuilder()->add('(SELECT embeddedObjectID FROM wcf'.WCF_N.'_message_embedded_object WHERE messageObjectTypeID = ? AND messageID = attachment.objectID AND embeddedObjectTypeID = ? AND embeddedObjectID = attachment.attachmentID) IS NULL', array(
+ $this->getConditionBuilder()->add('(SELECT embeddedObjectID FROM wcf'.WCF_N.'_message_embedded_object WHERE messageObjectTypeID = ? AND messageID = attachment.objectID AND embeddedObjectTypeID = ? AND embeddedObjectID = attachment.attachmentID) IS NULL', [
ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $objectType),
ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message.embeddedObject', 'com.woltlab.wcf.attachment')
- ));
+ ]);
}
/**
// group by object id
foreach ($this->objects as $attachmentID => $attachment) {
if (!isset($this->groupedObjects[$attachment->objectID])) {
- $this->groupedObjects[$attachment->objectID] = array();
+ $this->groupedObjects[$attachment->objectID] = [];
}
$this->groupedObjects[$attachment->objectID][$attachmentID] = $attachment;
return $this->groupedObjects[$objectID];
}
- return array();
+ return [];
}
}
FROM wcf".WCF_N."_bbcode
WHERE bbcodeTag = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($tag));
+ $statement->execute([$tag]);
$row = $statement->fetchArray();
- if (!$row) $row = array();
+ if (!$row) $row = [];
return new self(null, $row);
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.content.bbcode.canManageBBCode');
+ protected $permissionsDelete = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.content.bbcode.canManageBBCode');
+ protected $permissionsUpdate = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('delete', 'toggle', 'update');
+ protected $requireACP = ['delete', 'toggle', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
FROM wcf".WCF_N."_user_group_option
WHERE optionType = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('BBCodeSelect'));
+ $statement->execute(['BBCodeSelect']);
$optionIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (!empty($optionIDs)) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("optionID IN (?)", array($optionIDs));
- $conditionBuilder->add("groupID IN (?)", array(UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE))));
- $conditionBuilder->add("optionValue <> ?", array('all'));
+ $conditionBuilder->add("optionID IN (?)", [$optionIDs]);
+ $conditionBuilder->add("groupID IN (?)", [UserGroup::getGroupIDsByType([UserGroup::EVERYONE])]);
+ $conditionBuilder->add("optionValue <> ?", ['all']);
$sql = "SELECT *
FROM wcf".WCF_N."_user_group_option_value
$row['optionValue'] = $bbCode->bbcodeTag;
}
- $updateStatement->execute(array(
+ $updateStatement->execute([
$row['optionValue'],
$row['optionID'],
$row['groupID']
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
*/
public function toggle() {
foreach ($this->objects as $bbcode) {
- $bbcode->update(array(
+ $bbcode->update([
'isDisabled' => $bbcode->isDisabled ? 0 : 1
- ));
+ ]);
}
}
}
* cached bbcodes
* @var BBCode[]
*/
- protected $cachedBBCodes = array();
+ protected $cachedBBCodes = [];
/**
* list of known highlighters
* @var string[]
*/
- protected $highlighters = array();
+ protected $highlighters = [];
/**
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
// get bbcode cache
- $this->cachedBBCodes = BBCodeCacheBuilder::getInstance()->getData(array(), 'bbcodes');
+ $this->cachedBBCodes = BBCodeCacheBuilder::getInstance()->getData([], 'bbcodes');
}
/**
*/
public function getHighlighters() {
if (empty($this->highlighters)) {
- $this->highlighters = BBCodeCacheBuilder::getInstance()->getData(array(), 'highlighters');
+ $this->highlighters = BBCodeCacheBuilder::getInstance()->getData([], 'highlighters');
}
return $this->highlighters;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getMessagePreview');
+ protected $allowGuestAccess = ['getMessagePreview'];
/**
* Validates parameters for message preview.
if ($enableBBCodes && $allowedBBCodesPermission) {
$disallowedBBCodes = MessageParser::getInstance()->validateBBCodes($this->parameters['data']['message'], ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
if (!empty($disallowedBBCodes)) {
- throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array(
+ throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', [
'disallowedBBCodes' => $disallowedBBCodes
- )));
+ ]));
}
}
// parse message
$preview = MessageParser::getInstance()->parse($message, $enableSmilies, $enableHtml, $enableBBCodes, false);
- return array(
+ return [
'message' => $preview
- );
+ ];
}
}
public static function getAttributesByBBCode(BBCode $bbcode) {
$attributeList = new BBCodeAttributeList();
$attributeList->sqlOrderBy = "bbcode_attribute.attributeNo ASC";
- $attributeList->getConditionBuilder()->add('bbcode_attribute.bbcodeID = ?', array($bbcode->bbcodeID));
+ $attributeList->getConditionBuilder()->add('bbcode_attribute.bbcodeID = ?', [$bbcode->bbcodeID]);
$attributeList->readObjects();
return $attributeList->getObjects();
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.content.bbcode.canManageBBCode');
+ protected $permissionsDelete = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.content.bbcode.canManageBBCode');
+ protected $permissionsUpdate = ['admin.content.bbcode.canManageBBCode'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('delete', 'update');
+ protected $requireACP = ['delete', 'update'];
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.captcha.canManageCaptchaQuestion');
+ protected $permissionsDelete = ['admin.captcha.canManageCaptchaQuestion'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.captcha.canManageCaptchaQuestion');
+ protected $permissionsUpdate = ['admin.captcha.canManageCaptchaQuestion'];
/**
* @see \wcf\data\IToggleAction::toggle()
*/
public function toggle() {
foreach ($this->objects as $question) {
- $question->update(array(
+ $question->update([
'isDisabled' => $question->isDisabled ? 0 : 1
- ));
+ ]);
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update', 'updatePosition');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update', 'updatePosition'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::delete()
*/
public function toggle() {
foreach ($this->objects as $categoryEditor) {
- $categoryEditor->update(array(
+ $categoryEditor->update([
'isDisabled' => 1 - $categoryEditor->isDisabled
- ));
+ ]);
}
}
if (isset($this->parameters['data']['parentCategoryID'])) {
$objectType = null;
- $parentUpdates = array();
+ $parentUpdates = [];
foreach ($this->objects as $category) {
if ($objectType === null) {
}
if ($category->parentCategoryID != $this->parameters['data']['parentCategoryID']) {
- $parentUpdates[$category->categoryID] = array(
+ $parentUpdates[$category->categoryID] = [
'oldParentCategoryID' => $category->parentCategoryID,
'newParentCategoryID' => $this->parameters['data']['parentCategoryID']
- );
+ ];
}
}
*/
public function updatePosition() {
$objectType = null;
- $parentUpdates = array();
+ $parentUpdates = [];
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'] as $parentCategoryID => $categoryIDs) {
}
if ($category->parentCategoryID != $parentCategoryID) {
- $parentUpdates[$categoryID] = array(
+ $parentUpdates[$categoryID] = [
'oldParentCategoryID' => $category->parentCategoryID,
'newParentCategoryID' => $parentCategoryID
- );
+ ];
}
- $this->objects[$categoryID]->update(array(
+ $this->objects[$categoryID]->update([
'parentCategoryID' => $parentCategoryID ? $this->objects[$parentCategoryID]->categoryID : 0,
'showOrder' => $showOrder++
- ));
+ ]);
}
}
WCF::getDB()->commitTransaction();
* child category nodes
* @var CategoryNode[]
*/
- protected $children = array();
+ protected $children = [];
/**
* current iterator key
* locally cached categories
* @var Category[]
*/
- protected $categoryCache = array();
+ protected $categoryCache = [];
/**
* locally cached category ids grouped by the id of their parent category
* @var array
*/
- protected $categoryStructureCache = array();
+ protected $categoryStructureCache = [];
/**
* @see \wcf\data\category\CategoryNodeTree::buildTree()
*/
protected function buildTree() {
$categoryList = new CategoryList();
- $categoryList->getConditionBuilder()->add('category.objectTypeID = ?', array(CategoryHandler::getInstance()->getObjectTypeByName($this->objectType)->objectTypeID));
+ $categoryList->getConditionBuilder()->add('category.objectTypeID = ?', [CategoryHandler::getInstance()->getObjectTypeByName($this->objectType)->objectTypeID]);
$categoryList->sqlOrderBy = "category.showOrder ASC";
$categoryList->readObjects();
foreach ($categoryList as $category) {
if (!isset($this->categoryStructureCache[$category->parentCategoryID])) {
- $this->categoryStructureCache[$category->parentCategoryID] = array();
+ $this->categoryStructureCache[$category->parentCategoryID] = [];
}
$this->categoryStructureCache[$category->parentCategoryID][] = $category->categoryID;
* @see \wcf\data\category\CategoryNodeTree::getChildCategories()
*/
protected function getChildCategories(CategoryNode $parentNode) {
- $categories = array();
+ $categories = [];
if (isset($this->categoryStructureCache[$parentNode->categoryID])) {
foreach ($this->categoryStructureCache[$parentNode->categoryID] as $categoryID) {
$categories[$categoryID] = $this->getCategory($categoryID);
*
* @see \wcf\data\AbstractDatabaseObjectAction
*/
- public function __construct(array $objects, $action, array $parameters = array()) {
+ public function __construct(array $objects, $action, array $parameters = []) {
$this->action = $action;
$this->parameters = $parameters;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('loadResponses');
+ protected $allowGuestAccess = ['loadResponses'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
$ignoreCounters = !empty($this->parameters['ignoreCounters']);
// read object type ids for comments
- $commentIDs = array();
+ $commentIDs = [];
foreach ($this->objects as $response) {
$commentIDs[] = $response->commentID;
}
$comments = $commentList->getObjects();
// update counters
- $processors = $responseIDs = $updateComments = array();
+ $processors = $responseIDs = $updateComments = [];
foreach ($this->objects as $response) {
$objectTypeID = $comments[$response->commentID]->objectTypeID;
if (!isset($processors[$objectTypeID])) {
$objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
$processors[$objectTypeID] = $objectType->getProcessor();
- $responseIDs[$objectTypeID] = array();
+ $responseIDs[$objectTypeID] = [];
}
$responseIDs[$objectTypeID][] = $response->responseID;
foreach ($comments as $comment) {
$commentEditor = new CommentEditor($comment);
$commentEditor->updateResponseIDs();
- $commentEditor->updateCounters(array(
+ $commentEditor->updateCounters([
'responses' => -1 * $updateComments[$comment->commentID]
- ));
+ ]);
}
}
- $likeObjectIDs = array();
- $notificationObjectTypes = array();
+ $likeObjectIDs = [];
+ $notificationObjectTypes = [];
foreach ($responseIDs as $objectTypeID => $objectIDs) {
// remove activity events
$objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
public function loadResponses() {
// get response list
$responseList = new StructuredCommentResponseList($this->commentManager, $this->comment);
- $responseList->getConditionBuilder()->add("comment_response.time > ?", array($this->parameters['data']['lastResponseTime']));
+ $responseList->getConditionBuilder()->add("comment_response.time > ?", [$this->parameters['data']['lastResponseTime']]);
if (!$this->parameters['data']['loadAllResponses']) $responseList->sqlLimit = 50;
$responseList->readObjects();
$lastResponseTime = max($lastResponseTime, $response->time);
}
- WCF::getTPL()->assign(array(
- 'likeData' => (MODULE_LIKE ? $responseList->getLikeData() : array()),
+ WCF::getTPL()->assign([
+ 'likeData' => (MODULE_LIKE ? $responseList->getLikeData() : []),
'responseList' => $responseList,
'commentManager' => $this->commentManager
- ));
+ ]);
- return array(
+ return [
'commentID' => $this->comment->commentID,
'lastResponseTime' => $lastResponseTime,
'template' => WCF::getTPL()->fetch('commentResponseList')
- );
+ ];
}
}
// handle condition data
$this->data['conditionData'] = @unserialize($data['conditionData']);
if (!is_array($this->data['conditionData'])) {
- $this->data['conditionData'] = array();
+ $this->data['conditionData'] = [];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.management.canManageCronjob');
+ protected $permissionsCreate = ['admin.management.canManageCronjob'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.management.canManageCronjob');
+ protected $permissionsDelete = ['admin.management.canManageCronjob'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.management.canManageCronjob');
+ protected $permissionsUpdate = ['admin.management.canManageCronjob'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('executeCronjobs');
+ protected $allowGuestAccess = ['executeCronjobs'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update', 'toggle', 'execute');
+ protected $requireACP = ['create', 'delete', 'update', 'toggle', 'execute'];
/**
* @see \wcf\data\IDeleteAction::validateDelete()
*/
public function toggle() {
foreach ($this->objects as $cronjob) {
- $cronjob->update(array(
+ $cronjob->update([
'isDisabled' => $cronjob->isDisabled ? 0 : 1
- ));
+ ]);
}
}
* Executes cronjobs.
*/
public function execute() {
- $return = array();
+ $return = [];
foreach ($this->objects as $key => $cronjob) {
// mark them as pending
- $cronjob->update(array('state' => Cronjob::PENDING));
+ $cronjob->update(['state' => Cronjob::PENDING]);
}
foreach ($this->objects as $cronjob) {
// it now time for executing
- $cronjob->update(array('state' => Cronjob::EXECUTING));
+ $cronjob->update(['state' => Cronjob::EXECUTING]);
$className = $cronjob->className;
$executable = new $className();
catch (\Exception $exception) { }
}
- CronjobLogEditor::create(array(
+ CronjobLogEditor::create([
'cronjobID' => $cronjob->cronjobID,
'execTime' => TIME_NOW,
'success' => ($exception ? 0 : 1),
'error' => ($exception ? $exception->getMessage() : '')
- ));
+ ]);
// calculate next exec-time
$nextExec = $cronjob->getNextExec();
- $data = array(
+ $data = [
'lastExec' => TIME_NOW,
'nextExec' => $nextExec,
'afterNextExec' => $cronjob->getNextExec(($nextExec + 120))
- );
+ ];
// cronjob failed
if ($exception) {
// build the return value
if ($exception === null && !$cronjob->isDisabled) {
$dateTime = DateUtil::getDateTimeByTimestamp($nextExec);
- $return[$cronjob->cronjobID] = array(
+ $return[$cronjob->cronjobID] = [
'time' => $nextExec,
'formatted' => str_replace(
'%time%',
WCF::getLanguage()->get('wcf.date.dateTimeFormat')
)
)
- );
+ ];
}
// we are finished
- $cronjob->update(array('state' => Cronjob::READY));
+ $cronjob->update(['state' => Cronjob::READY]);
// throw exception again to show error message
if ($exception) {
*/
public function executeCronjobs() {
// switch session owner to 'system' during execution of cronjobs
- WCF::getSession()->changeUser(new User(null, array('userID' => 0, 'username' => 'System')), true);
+ WCF::getSession()->changeUser(new User(null, ['userID' => 0, 'username' => 'System']), true);
WCF::getSession()->disableUpdate();
CronjobScheduler::getInstance()->executeCronjobs();
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('clearAll');
+ protected $requireACP = ['clearAll'];
/**
* Validates the clear all action.
*/
public function validateClearAll() {
- WCF::getSession()->checkPermissions(array('admin.management.canManageCronjob'));
+ WCF::getSession()->checkPermissions(['admin.management.canManageCronjob']);
}
/**
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'] as $labelIDs) {
foreach ($labelIDs as $labelID) {
- $statement->execute(array(
+ $statement->execute([
$showOrder++,
$labelID
- ));
+ ]);
}
}
WCF::getDB()->commitTransaction();
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.content.label.canManageLabel');
+ protected $permissionsCreate = ['admin.content.label.canManageLabel'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.content.label.canManageLabel');
+ protected $permissionsDelete = ['admin.content.label.canManageLabel'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.content.label.canManageLabel');
+ protected $permissionsUpdate = ['admin.content.label.canManageLabel'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::delete()
* list of labels
* @var Label[]
*/
- protected $labels = array();
+ protected $labels = [];
/**
* list of permissions by type
* @var integer[][]
*/
- protected $permissions = array(
- 'group' => array(),
- 'user' => array()
- );
+ protected $permissions = [
+ 'group' => [],
+ 'user' => []
+ ];
/**
* current iterator index
* list of language items
* @var string[]
*/
- protected $items = array();
+ protected $items = [];
/**
* list of dynamic language items
* @var string[]
*/
- protected $dynamicItems = array();
+ protected $dynamicItems = [];
/**
* instance of LanguageEditor
* @param boolean $optional
* @return string result
*/
- public function getDynamicVariable($item, array $variables = array(), $optional = false) {
+ public function getDynamicVariable($item, array $variables = [], $optional = false) {
$staticItem = $this->get($item, $optional);
if (!$staticItem) return '';
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.language.canManageLanguage');
+ protected $permissionsCreate = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.language.canManageLanguage');
+ protected $permissionsDelete = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.language.canManageLanguage');
+ protected $permissionsUpdate = ['admin.language.canManageLanguage'];
/**
* language editor object
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'setAsDefault', 'update');
+ protected $requireACP = ['create', 'delete', 'setAsDefault', 'update'];
/**
* Validates permission to set a language as default.
$xml->load(TMP_DIR.'setup/lang/setup_'.$this->languageCode.'.xml');
// get language items
- $categoriesToCache = array();
+ $categoriesToCache = [];
$items = $xml->xpath()->query('/ns:language/ns:category/ns:item');
foreach ($items as $item) {
- $categoriesToCache[] = array(
+ $categoriesToCache[] = [
'name' => $item->getAttribute('name'),
'cdata' => $item->nodeValue
- );
+ ];
}
// update language files here
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.language.canManageLanguage');
+ protected $permissionsCreate = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.language.canManageLanguage');
+ protected $permissionsDelete = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.language.canManageLanguage');
+ protected $permissionsUpdate = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.language.canManageLanguage');
+ protected $permissionsCreate = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.language.canManageLanguage');
+ protected $permissionsDelete = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.language.canManageLanguage');
+ protected $permissionsUpdate = ['admin.language.canManageLanguage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'edit', 'prepareEdit', 'update');
+ protected $requireACP = ['create', 'delete', 'edit', 'prepareEdit', 'update'];
/**
* Validates parameters to prepare edit.
*/
public function prepareEdit() {
$item = reset($this->objects);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'item' => $item
- ));
+ ]);
- return array(
+ return [
'languageItem' => $item->languageItem,
'template' => WCF::getTPL()->fetch('languageItemEditDialog')
- );
+ ];
}
/**
// save item
$editor = reset($this->objects);
if ($editor->languageItemOriginIsSystem) {
- $updateData = array(
+ $updateData = [
'languageCustomItemValue' => !$this->parameters['languageUseCustomValue'] && empty($this->parameters['languageCustomItemValue']) ? null : $this->parameters['languageCustomItemValue'],
'languageUseCustomValue' => ($this->parameters['languageUseCustomValue'] ? 1 : 0)
- );
+ ];
}
else {
- $updateData = array(
+ $updateData = [
'languageItemValue' => $this->parameters['languageItemValue']
- );
+ ];
}
$editor->update($updateData);
AND objectID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
$userID
- ));
+ ]);
$row = $statement->fetchArray();
if (!$row) {
- $row = array();
+ $row = [];
}
return new Like(null, $row);
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getGroupedUserList', 'getLikeDetails', 'load');
+ protected $allowGuestAccess = ['getGroupedUserList', 'getLikeDetails', 'load'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
AND objectTypeID = ?
ORDER BY time DESC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->parameters['data']['objectID'],
$this->objectType->objectTypeID
- ));
- $data = array(
- Like::LIKE => array(),
- Like::DISLIKE => array()
- );
+ ]);
+ $data = [
+ Like::LIKE => [],
+ Like::DISLIKE => []
+ ];
while ($row = $statement->fetchArray()) {
$data[$row['likeValue']][] = $row['userID'];
}
- $values = array();
+ $values = [];
if (!empty($data[Like::LIKE])) {
$values[Like::LIKE] = new GroupedUserList(WCF::getLanguage()->get('wcf.like.details.like'));
$values[Like::LIKE]->addUserIDs($data[Like::LIKE]);
// load user profiles
GroupedUserList::loadUsers();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'groupedUsers' => $values
- ));
+ ]);
- return array(
+ return [
'containerID' => $this->parameters['data']['containerID'],
'template' => WCF::getTPL()->fetch('groupedUserList')
- );
+ ];
}
/**
UserActivityEventHandler::getInstance()->fireEvent($this->objectType->objectType.'.recentActivityEvent', $this->parameters['data']['objectID'], $this->likeableObject->getLanguageID());
}
else {
- UserActivityEventHandler::getInstance()->removeEvents($this->objectType->objectType.'.recentActivityEvent', array($this->parameters['data']['objectID']));
+ UserActivityEventHandler::getInstance()->removeEvents($this->objectType->objectType.'.recentActivityEvent', [$this->parameters['data']['objectID']]);
}
}
// get stats
- return array(
+ return [
'likes' => ($likeData['data']['likes'] === null) ? 0 : $likeData['data']['likes'],
'dislikes' => ($likeData['data']['dislikes'] === null) ? 0 : $likeData['data']['dislikes'],
'cumulativeLikes' => ($likeData['data']['cumulativeLikes'] === null) ? 0 : $likeData['data']['cumulativeLikes'],
'newValue' => $likeData['newValue'],
'oldValue' => $likeData['oldValue'],
'users' => $likeData['users']
- );
+ ];
}
/**
WHERE objectID = ?
AND objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->parameters['data']['objectID'],
$this->objectType->objectTypeID
- ));
+ ]);
$pageCount = ceil($statement->fetchColumn() / 20);
$sql = "SELECT userID, likeValue
AND objectTypeID = ?
ORDER BY likeValue DESC, time DESC";
$statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
- $statement->execute(array(
+ $statement->execute([
$this->parameters['data']['objectID'],
$this->objectType->objectTypeID
- ));
- $data = array(
- Like::LIKE => array(),
- Like::DISLIKE => array()
- );
+ ]);
+ $data = [
+ Like::LIKE => [],
+ Like::DISLIKE => []
+ ];
while ($row = $statement->fetchArray()) {
$data[$row['likeValue']][] = $row['userID'];
}
- $values = array();
+ $values = [];
if (!empty($data[Like::LIKE])) {
$values[Like::LIKE] = new GroupedUserList(WCF::getLanguage()->get('wcf.like.details.like'));
$values[Like::LIKE]->addUserIDs($data[Like::LIKE]);
// load user profiles
GroupedUserList::loadUsers();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'groupedUsers' => $values
- ));
+ ]);
- return array(
+ return [
'containerID' => $this->parameters['data']['containerID'],
'pageCount' => $pageCount,
'template' => WCF::getTPL()->fetch('groupedUserList')
- );
+ ];
}
/**
public function load() {
$likeList = new ViewableLikeList();
if ($this->parameters['lastLikeTime']) {
- $likeList->getConditionBuilder()->add("like_table.time < ?", array($this->parameters['lastLikeTime']));
+ $likeList->getConditionBuilder()->add("like_table.time < ?", [$this->parameters['lastLikeTime']]);
}
if ($this->parameters['likeType'] == 'received') {
- $likeList->getConditionBuilder()->add("like_table.objectUserID = ?", array($this->parameters['userID']));
+ $likeList->getConditionBuilder()->add("like_table.objectUserID = ?", [$this->parameters['userID']]);
}
else {
- $likeList->getConditionBuilder()->add("like_table.userID = ?", array($this->parameters['userID']));
+ $likeList->getConditionBuilder()->add("like_table.userID = ?", [$this->parameters['userID']]);
}
- $likeList->getConditionBuilder()->add("like_table.likeValue = ?", array($this->parameters['likeValue']));
+ $likeList->getConditionBuilder()->add("like_table.likeValue = ?", [$this->parameters['likeValue']]);
$likeList->readObjects();
if (!count($likeList)) {
- return array();
+ return [];
}
// parse template
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'likeList' => $likeList
- ));
+ ]);
- return array(
+ return [
'lastLikeTime' => $likeList->getLastLikeTime(),
'template' => WCF::getTPL()->fetch('userProfileLikeItem')
- );
+ ];
}
/**
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$sourceObjectType->objectTypeID,
$this->parameters['sourceObjectID']
- ));
+ ]);
$row = $statement->fetchArray();
// no (dis-)likes at all
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$sourceObjectType->objectTypeID,
$this->parameters['sourceObjectID']
- ));
+ ]);
//
// step 3) update owner
AND objectID = ?
AND likeValue = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$targetObjectType->objectTypeID,
$this->parameters['targetObjectID'],
Like::LIKE
- ));
+ ]);
$count = $statement->fetchSingleColumn();
if ($count) {
// update received likes
$userEditor = new UserEditor(new User($newLikeObject->objectUserID));
- $userEditor->updateCounters(array(
+ $userEditor->updateCounters([
'likesReceived' => $count
- ));
+ ]);
// add activity points
- UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($newLikeObject->objectUserID => $count));
+ UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$newLikeObject->objectUserID => $count]);
}
}
}
public function readObjects() {
parent::readObjects();
- $userIDs = array();
- $likeGroups = array();
+ $userIDs = [];
+ $likeGroups = [];
foreach ($this->objects as &$like) {
$userIDs[] = $like->userID;
if (!isset($likeGroups[$like->objectTypeID])) {
$objectType = ObjectTypeCache::getInstance()->getObjectType($like->objectTypeID);
- $likeGroups[$like->objectTypeID] = array(
+ $likeGroups[$like->objectTypeID] = [
'provider' => $objectType->getProcessor(),
- 'objects' => array()
- );
+ 'objects' => []
+ ];
}
$likeGroups[$like->objectTypeID]['objects'][] = $like;
* list of users who liked this object
* @var User[]
*/
- protected $users = array();
+ protected $users = [];
/**
* @inheritDoc
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID
- ));
+ ]);
$row = $statement->fetchArray();
if (!$row) {
- $row = array();
+ $row = [];
}
return new LikeObject(null, $row);
*/
public function toggle() {
foreach ($this->objects as $object) {
- $object->update(array('isDisabled' => ($object->isDisabled) ? 0 : 1));
+ $object->update(['isDisabled' => ($object->isDisabled) ? 0 : 1]);
}
}
* @return MenuItemNode[] nested menu item tree
*/
protected function generateNodeTree($parentID = null, MenuItemNode $parentNode = null) {
- $nodes = array();
+ $nodes = [];
$itemIDs = (isset($this->menuItemStructure[$parentID]) ? $this->menuItemStructure[$parentID] : []);
foreach ($itemIDs as $itemID) {
$this->readObjects();
}
- $queueIDs = array();
+ $queueIDs = [];
foreach ($this->objects as $queue) {
$queueIDs[] = $queue->queueID;
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("queueID IN (?)", array($queueIDs));
+ $conditions->add("queueID IN (?)", [$queueIDs]);
$sql = "UPDATE wcf".WCF_N."_moderation_queue
SET status = ".ModerationQueue::STATUS_DONE."
* Validates parameters to fetch a list of outstanding queues.
*/
public function validateGetOutstandingQueues() {
- WCF::getSession()->checkPermissions(array('mod.general.canUseModeration'));
+ WCF::getSession()->checkPermissions(['mod.general.canUseModeration']);
}
/**
*/
public function getOutstandingQueues() {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("moderation_queue_to_user.userID = ?", array(WCF::getUser()->userID));
- $conditions->add("moderation_queue_to_user.isAffected = ?", array(1));
- $conditions->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
- $conditions->add("moderation_queue.time > ?", array(VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.moderation.queue')));
+ $conditions->add("moderation_queue_to_user.userID = ?", [WCF::getUser()->userID]);
+ $conditions->add("moderation_queue_to_user.isAffected = ?", [1]);
+ $conditions->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING]]);
+ $conditions->add("moderation_queue.time > ?", [VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.moderation.queue')]);
$conditions->add("(moderation_queue.time > tracked_visit.visitTime OR tracked_visit.visitTime IS NULL)");
$sql = "SELECT moderation_queue.queueID
$statement->execute($conditions->getParameters());
$queueIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
- $queues = array();
+ $queues = [];
if (!empty($queueIDs)) {
$queueList = new ViewableModerationQueueList();
- $queueList->getConditionBuilder()->add("moderation_queue.queueID IN (?)", array($queueIDs));
+ $queueList->getConditionBuilder()->add("moderation_queue.queueID IN (?)", [$queueIDs]);
$queueList->sqlOrderBy = "moderation_queue.lastChangeTime DESC";
$queueList->loadUserProfiles = true;
$queueList->readObjects();
if ($count < 5) {
// load more entries to fill up list
$queueList = new ViewableModerationQueueList();
- $queueList->getConditionBuilder()->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
- if (!empty($queueIDs)) $queueList->getConditionBuilder()->add("moderation_queue.queueID NOT IN (?)", array($queueIDs));
+ $queueList->getConditionBuilder()->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING]]);
+ if (!empty($queueIDs)) $queueList->getConditionBuilder()->add("moderation_queue.queueID NOT IN (?)", [$queueIDs]);
$queueList->sqlOrderBy = "moderation_queue.lastChangeTime DESC";
$queueList->sqlLimit = 5 - $count;
$queueList->loadUserProfiles = true;
// check if stored count is out of sync
if ($count < $totalCount) {
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'outstandingModerationCount');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'outstandingModerationCount');
// check for orphaned queues
$queueCount = ModerationQueueManager::getInstance()->getUnreadModerationCount();
}
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'queues' => $queues
- ));
+ ]);
- return array(
+ return [
'template' => WCF::getTPL()->fetch('moderationQueueList'),
'totalCount' => $totalCount
- );
+ ];
}
/**
public function getAssignUserForm() {
$assignedUser = ($this->moderationQueueEditor->assignedUserID) ? new User($this->moderationQueueEditor->assignedUserID) : null;
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'assignedUser' => $assignedUser,
'queue' => $this->moderationQueueEditor
- ));
+ ]);
- return array(
+ return [
'template' => WCF::getTPL()->fetch('moderationQueueAssignUser')
- );
+ ];
}
/**
* @return string[]
*/
public function assignUser() {
- $data = array('assignedUserID' => ($this->parameters['assignedUserID'] ?: null));
+ $data = ['assignedUserID' => ($this->parameters['assignedUserID'] ?: null)];
if ($this->user->userID) {
if ($this->moderationQueueEditor->status == ModerationQueue::STATUS_OUTSTANDING) {
$data['status'] = ModerationQueue::STATUS_PROCESSING;
$username = ($this->user->userID) ? $this->user->username : WCF::getLanguage()->get('wcf.moderation.assignedUser.nobody');
$link = '';
if ($this->user->userID) {
- $link = LinkHandler::getInstance()->getLink('User', array('object' => $this->user));
+ $link = LinkHandler::getInstance()->getLink('User', ['object' => $this->user]);
}
$newStatus = '';
$newStatus = ($data['status'] == ModerationQueue::STATUS_OUTSTANDING) ? 'outstanding' : 'processing';
}
- return array(
+ return [
'link' => $link,
'newStatus' => $newStatus,
'userID' => $this->user->userID,
'username' => $username
- );
+ ];
}
/**
}
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadModerationCount');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'unreadModerationCount');
if (count($this->objects) == 1) {
$queue = reset($this->objects);
- return array(
+ return [
'markAsRead' => $queue->queueID,
'totalCount' => ModerationQueueManager::getInstance()->getUnreadModerationCount(true)
- );
+ ];
}
}
VisitTracker::getInstance()->trackTypeVisit('com.woltlab.wcf.moderation.queue');
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadModerationCount');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'unreadModerationCount');
- return array(
+ return [
'markAllAsRead' => true
- );
+ ];
}
/**
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('enableContent', 'removeContent');
+ protected $allowGuestAccess = ['enableContent', 'removeContent'];
/**
* moderation queue editor object
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('prepareReport', 'removeContent', 'removeReport', 'report');
+ protected $allowGuestAccess = ['prepareReport', 'removeContent', 'removeReport', 'report'];
/**
* moderation queue editor object
* Validates parameters to prepare a report.
*/
public function validatePrepareReport() {
- WCF::getSession()->checkPermissions(array('user.profile.canReportContent'));
+ WCF::getSession()->checkPermissions(['user.profile.canReportContent']);
$this->readInteger('objectID');
$this->readString('objectType');
// content was already reported
$alreadyReported = (ModerationQueueReportManager::getInstance()->hasPendingReport($this->parameters['objectType'], $this->parameters['objectID'])) ? 1 : 0;
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'alreadyReported' => $alreadyReported,
'object' => ModerationQueueReportManager::getInstance()->getReportedObject($this->parameters['objectType'], $this->parameters['objectID'])
- ));
+ ]);
- return array(
+ return [
'alreadyReported' => $alreadyReported,
'template' => WCF::getTPL()->fetch('moderationReportDialog')
- );
+ ];
}
/**
* Validates parameters for reporting.
*/
public function validateReport() {
- WCF::getSession()->checkPermissions(array('user.profile.canReportContent'));
+ WCF::getSession()->checkPermissions(['user.profile.canReportContent']);
$this->readString('message');
if (mb_strlen($this->parameters['message']) > 64000) {
);
}
- return array(
+ return [
'reported' => 1
- );
+ ];
}
}
$this->data['additionalData'] = @unserialize($this->data['additionalData']);
if (!is_array($this->data['additionalData'])) {
- $this->data['additionalData'] = array();
+ $this->data['additionalData'] = [];
}
}
}
FROM wcf".WCF_N."_notice_dismissed
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
WCF::getUser()->userID
- ));
+ ]);
- $noticeIDs = array();
+ $noticeIDs = [];
while ($noticeID = $statement->fetchColumn()) {
$noticeIDs[] = $noticeID;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('dismiss');
+ protected $allowGuestAccess = ['dismiss'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.notice.canManageNotice');
+ protected $permissionsDelete = ['admin.notice.canManageNotice'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.notice.canManageNotice');
+ protected $permissionsUpdate = ['admin.notice.canManageNotice'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update', 'updatePosition');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update', 'updatePosition'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
(noticeID, userID)
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
reset($this->objectIDs),
WCF::getUser()->userID
- ));
+ ]);
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'dismissedNotices');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'dismissedNotices');
}
else {
$dismissedNotices = WCF::getSession()->getVar('dismissedNotices');
$dismissedNotices[] = reset($this->objectIDs);
}
else {
- $dismissedNotices = array(
+ $dismissedNotices = [
reset($this->objectIDs)
- );
+ ];
}
WCF::getSession()->register('dismissedNotices', serialize($dismissedNotices));
}
- return array(
+ return [
'noticeID' => reset($this->objectIDs)
- );
+ ];
}
/**
*/
public function toggle() {
foreach ($this->objects as $notice) {
- $notice->update(array(
+ $notice->update([
'isDisabled' => $notice->isDisabled ? 0 : 1
- ));
+ ]);
}
}
$showOrder = $this->parameters['data']['offset'];
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'][0] as $noticeID) {
- $statement->execute(array(
+ $statement->execute([
$showOrder++,
$noticeID
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
* @see \wcf\data\object\type\IObjectTypeProvider::getObjectsByIDs()
*/
public function getObjectsByIDs(array $objectIDs) {
- $tableAlias = call_user_func(array($this->className, 'getDatabaseTableAlias'));
- $tableIndex = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
+ $tableAlias = call_user_func([$this->className, 'getDatabaseTableAlias']);
+ $tableIndex = call_user_func([$this->className, 'getDatabaseTableIndexName']);
$objectList = new $this->listClassName();
if ($this->decoratorClassName) {
$objectList->decoratorClassName = $this->decoratorClassName;
}
- $objectList->getConditionBuilder()->add($tableAlias.".".$tableIndex." IN (?)", array($objectIDs));
+ $objectList->getConditionBuilder()->add($tableAlias.".".$tableIndex." IN (?)", [$objectIDs]);
$objectList->readObjects();
return $objectList->getObjects();
* object type definitions
* @var ObjectTypeDefinition[]
*/
- protected $definitions = array();
+ protected $definitions = [];
/**
* object type definition ids grouped by category name
* @var integer[][]
*/
- protected $definitionsByCategory = array();
+ protected $definitionsByCategory = [];
/**
* object type definitions sorted by name
* @var ObjectTypeDefinition[]
*/
- protected $definitionsByName = array();
+ protected $definitionsByName = [];
/**
* object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* object types grouped by definition
* @var array
*/
- protected $groupedObjectTypes = array();
+ protected $groupedObjectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
// get definition cache
- $this->definitionsByCategory = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'categories');
- $this->definitions = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'definitions');
+ $this->definitionsByCategory = ObjectTypeCacheBuilder::getInstance()->getData([], 'categories');
+ $this->definitions = ObjectTypeCacheBuilder::getInstance()->getData([], 'definitions');
foreach ($this->definitions as $definition) {
$this->definitionsByName[$definition->definitionName] = $definition;
}
// get object type cache
- $this->objectTypes = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'objectTypes');
- $this->groupedObjectTypes = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'groupedObjectTypes');
+ $this->objectTypes = ObjectTypeCacheBuilder::getInstance()->getData([], 'objectTypes');
+ $this->groupedObjectTypes = ObjectTypeCacheBuilder::getInstance()->getData([], 'groupedObjectTypes');
}
/**
*/
public function getDefinitionsByCategory($categoryName) {
if (isset($this->definitionsByCategory[$categoryName])) {
- $definitions = array();
+ $definitions = [];
foreach ($this->definitionsByCategory[$categoryName] as $definitionID) {
$definitions[$definitionID] = $this->getDefinition($definitionID);
}
return $this->groupedObjectTypes[$definitionName];
}
- return array();
+ return [];
}
/**
parent::handleData($data);
// unserialize additional data
- $this->data['additionalData'] = (empty($data['additionalData']) ? array() : @unserialize($data['additionalData']));
+ $this->data['additionalData'] = (empty($data['additionalData']) ? [] : @unserialize($data['additionalData']));
}
/**
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $options = array();
+ $options = [];
while ($row = $statement->fetchArray()) {
$option = new Option(null, $row);
$options[$option->getConstantName()] = $option;
}
}
- return array(
+ return [
'disableOptions' => $disableOptions,
'enableOptions' => $enableOptions
- );
+ ];
}
/**
* @return array
*/
public function parseSelectOptions() {
- $result = array();
+ $result = [];
$options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($this->selectOptions)));
foreach ($options as $option) {
$key = $value = $option;
* @return array
*/
public function parseMultipleEnableOptions() {
- $result = array();
+ $result = [];
if (!empty($this->enableOptions)) {
$options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($this->enableOptions)));
$key = -1;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.configuration.canEditOption');
+ protected $permissionsCreate = ['admin.configuration.canEditOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.configuration.canEditOption');
+ protected $permissionsDelete = ['admin.configuration.canEditOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.configuration.canEditOption');
+ protected $permissionsUpdate = ['admin.configuration.canEditOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'import', 'update', 'updateAll');
+ protected $requireACP = ['create', 'delete', 'import', 'update', 'updateAll'];
/**
* Validates permissions and parameters.
*/
public function import() {
// create data
- call_user_func(array($this->className, 'import'), $this->parameters['data']);
+ call_user_func([$this->className, 'import'], $this->parameters['data']);
}
/**
*/
public function updateAll() {
// create data
- call_user_func(array($this->className, 'updateAll'), $this->parameters['data']);
+ call_user_func([$this->className, 'updateAll'], $this->parameters['data']);
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.configuration.canEditOption');
+ protected $permissionsCreate = ['admin.configuration.canEditOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.configuration.canEditOption');
+ protected $permissionsDelete = ['admin.configuration.canEditOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.configuration.canEditOption');
+ protected $permissionsUpdate = ['admin.configuration.canEditOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
}
if ($this->requiredPackages === null) {
self::loadRequirements();
- $this->requiredPackages = array();
+ $this->requiredPackages = [];
if (isset(self::$requirements[$this->packageID])) {
foreach (self::$requirements[$this->packageID] as $packageID) {
$this->requiredPackages[$packageID] = PackageCache::getInstance()->getPackage($packageID);
if ($this->dependentPackages === null) {
self::loadRequirements();
- $this->dependentPackages = array();
+ $this->dependentPackages = [];
foreach (self::$requirements as $packageID => $requiredPackageIDs) {
if (in_array($this->packageID, $requiredPackageIDs)) {
$this->dependentPackages[$packageID] = PackageCache::getInstance()->getPackage($packageID);
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- self::$requiredPackageIDs = array();
- self::$requirements = array();
+ self::$requiredPackageIDs = [];
+ self::$requirements = [];
while ($row = $statement->fetchArray()) {
if (!isset(self::$requirements[$row['packageID']])) {
- self::$requirements[$row['packageID']] = array();
+ self::$requirements[$row['packageID']] = [];
}
self::$requirements[$row['packageID']][] = $row['requirement'];
FROM wcf".WCF_N."_package
WHERE package = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($package));
+ $statement->execute([$package]);
return $statement->fetchSingleColumn() > 0;
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.configuration.package.canInstallPackage');
+ protected $permissionsCreate = ['admin.configuration.package.canInstallPackage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.configuration.package.canUninstallPackage');
+ protected $permissionsDelete = ['admin.configuration.package.canUninstallPackage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.configuration.package.canUpdatePackage');
+ protected $permissionsUpdate = ['admin.configuration.package.canUpdatePackage'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('searchForPurchasedItems');
+ protected $requireACP = ['searchForPurchasedItems'];
/**
* Validates parameters to search for purchased items in the WoltLab Plugin-Store.
*/
public function validateSearchForPurchasedItems() {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage', 'admin.configuration.package.canUpdatePackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage', 'admin.configuration.package.canUpdatePackage']);
$this->readString('password', true);
$this->readString('username', true);
if (empty($this->parameters['username'])) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("serverURL IN (?)", array(array('http://store.woltlab.com/maelstrom/', 'http://store.woltlab.com/typhoon/')));
+ $conditions->add("serverURL IN (?)", [['http://store.woltlab.com/maelstrom/', 'http://store.woltlab.com/typhoon/']]);
$conditions->add("loginUsername <> ''");
$conditions->add("loginPassword <> ''");
*/
public function searchForPurchasedItems() {
if (!RemoteFile::supportsSSL()) {
- return array(
+ return [
'noSSL' => WCF::getLanguage()->get('wcf.acp.pluginStore.api.noSSL')
- );
+ ];
}
if (empty($this->parameters['username']) || empty($this->parameters['password'])) {
- return array(
+ return [
'template' => $this->renderAuthorizationDialog(false)
- );
+ ];
}
- $request = new HTTPRequest('https://api.woltlab.com/1.0/customer/purchases/list.json', array(
+ $request = new HTTPRequest('https://api.woltlab.com/1.0/customer/purchases/list.json', [
'method' => 'POST'
- ), array(
+ ], [
'username' => $this->parameters['username'],
'password' => $this->parameters['password'],
'wcfVersion' => WCF_VERSION
- ));
+ ]);
$request->execute();
$reply = $request->getReply();
switch ($code) {
case 200:
if (empty($response['products'])) {
- return array(
+ return [
'noResults' => WCF::getLanguage()->get('wcf.acp.pluginStore.purchasedItems.noResults')
- );
+ ];
}
else {
WCF::getSession()->register('__pluginStoreProducts', $response['products']);
WCF::getSession()->register('__pluginStoreWcfMajorReleases', $response['wcfMajorReleases']);
- return array(
+ return [
'redirectURL' => LinkHandler::getInstance()->getLink('PluginStorePurchasedItems')
- );
+ ];
}
break;
// authentication error
case 401:
- return array(
+ return [
'template' => $this->renderAuthorizationDialog(true)
- );
+ ];
break;
// any other kind of errors
default:
- throw new SystemException(WCF::getLanguage()->getDynamicVariable('wcf.acp.pluginStore.api.error', array('status' => $code)));
+ throw new SystemException(WCF::getLanguage()->getDynamicVariable('wcf.acp.pluginStore.api.error', ['status' => $code]));
break;
}
}
* @return string
*/
protected function renderAuthorizationDialog($rejected) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'rejected' => $rejected
- ));
+ ]);
return WCF::getTPL()->fetch('pluginStoreAuthorization');
}
* list of cached packages
* @var mixed[][]
*/
- protected $packages = array();
+ protected $packages = [];
/**
* @see \wcf\system\SingletonFactory::init()
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('cancelInstallation', 'prepareQueue');
+ protected $requireACP = ['cancelInstallation', 'prepareQueue'];
/**
* Validates the 'prepareQueue' action:
throw new UserInputException('packageID');
}
- if (!isset($this->parameters['action']) || !in_array($this->parameters['action'], array('install', 'update', 'uninstall', 'rollback'))) {
+ if (!isset($this->parameters['action']) || !in_array($this->parameters['action'], ['install', 'update', 'uninstall', 'rollback'])) {
throw new UserInputException('action');
}
}
public function prepareQueue() {
$processNo = PackageInstallationQueue::getNewProcessNo();
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'processNo' => $processNo,
'userID' => WCF::getUser()->userID,
'package' => $this->package->package,
'packageID' => $this->package->packageID,
'action' => $this->parameters['action'],
'installationType' => 'other'
- ));
+ ]);
- return array(
+ return [
'queueID' => $queue->queueID
- );
+ ];
}
/**
*/
public function validateCancelInstallation() {
// check permissions
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
// validate queue
$this->queue = $this->getSingleObject();
$this->queue->delete();
- return array(
+ return [
'url' => LinkHandler::getInstance()->getLink('PackageList')
- );
+ ];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('getResultList', 'prepareInstallation', 'prepareUpdate', 'search', 'searchForUpdates');
+ protected $requireACP = ['getResultList', 'prepareInstallation', 'prepareUpdate', 'search', 'searchForUpdates'];
/**
* search object
* Validates parameters to search for installable packages.
*/
public function validateSearch() {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
$this->readString('package', true);
$this->readString('packageDescription', true);
// there are no available package update servers
if (empty($availableUpdateServers)) {
- WCF::getTPL()->assign(array(
- 'packageUpdates' => array()
- ));
+ WCF::getTPL()->assign([
+ 'packageUpdates' => []
+ ]);
- return array(
+ return [
'count' => 0,
'pageCount' => 0,
'searchID' => 0,
'template' => WCF::getTPL()->fetch('packageSearchResultList')
- );
+ ];
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package_update.packageUpdateServerID IN (?)", array(array_keys($availableUpdateServers)));
+ $conditions->add("package_update.packageUpdateServerID IN (?)", [array_keys($availableUpdateServers)]);
if (!empty($this->parameters['package'])) {
- $conditions->add("package_update.package LIKE ?", array('%'.$this->parameters['package'].'%'));
+ $conditions->add("package_update.package LIKE ?", ['%'.$this->parameters['package'].'%']);
}
if (!empty($this->parameters['packageDescription'])) {
- $conditions->add("package_update.packageDescription LIKE ?", array('%'.$this->parameters['packageDescription'].'%'));
+ $conditions->add("package_update.packageDescription LIKE ?", ['%'.$this->parameters['packageDescription'].'%']);
}
if (!empty($this->parameters['packageName'])) {
- $conditions->add("package_update.packageName LIKE ?", array('%'.$this->parameters['packageName'].'%'));
+ $conditions->add("package_update.packageName LIKE ?", ['%'.$this->parameters['packageName'].'%']);
}
$conditions->add("package.packageID IS NULL");
ORDER BY package_update.packageName ASC";
$statement = WCF::getDB()->prepareStatement($sql, 1000);
$statement->execute($conditions->getParameters());
- $packageUpdateIDs = array();
+ $packageUpdateIDs = [];
while ($row = $statement->fetchArray()) {
$packageUpdateIDs[] = $row['packageUpdateID'];
}
// no matches found
if (empty($packageUpdateIDs)) {
- WCF::getTPL()->assign(array(
- 'packageUpdates' => array()
- ));
+ WCF::getTPL()->assign([
+ 'packageUpdates' => []
+ ]);
- return array(
+ return [
'count' => 0,
'pageCount' => 0,
'searchID' => 0,
'template' => WCF::getTPL()->fetch('packageSearchResultList')
- );
+ ];
}
// get excluded packages
FROM wcf".WCF_N."_package_update_exclusion";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $excludedPackages = array();
+ $excludedPackages = [];
while ($row = $statement->fetchArray()) {
$package = $row['excludedPackage'];
$packageVersion = $row['excludedPackageVersion'];
FROM wcf".WCF_N."_package";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $installedPackages = array();
+ $installedPackages = [];
while ($row = $statement->fetchArray()) {
$installedPackages[$row['package']] = $row['packageVersion'];
}
// filter by version
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("puv.packageUpdateID IN (?)", array($packageUpdateIDs));
+ $conditions->add("puv.packageUpdateID IN (?)", [$packageUpdateIDs]);
$sql = "SELECT pu.package, puv.packageUpdateVersionID, puv.packageUpdateID, puv.packageVersion, puv.isAccessible
FROM wcf".WCF_N."_package_update_version puv
LEFT JOIN wcf".WCF_N."_package_update pu
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $packageVersions = array();
+ $packageVersions = [];
while ($row = $statement->fetchArray()) {
$package = $row['package'];
$packageVersion = $row['packageVersion'];
}
if (!isset($packageVersions[$package])) {
- $packageVersions[$package] = array();
+ $packageVersions[$package] = [];
}
$packageUpdateID = $row['packageUpdateID'];
if (!isset($packageVersions[$package][$packageUpdateID])) {
- $packageVersions[$package][$packageUpdateID] = array(
- 'accessible' => array(),
- 'existing' => array()
- );
+ $packageVersions[$package][$packageUpdateID] = [
+ 'accessible' => [],
+ 'existing' => []
+ ];
}
if ($row['isAccessible']) {
// all found versions are excluded
if (empty($packageVersions)) {
- WCF::getTPL()->assign(array(
- 'packageUpdates' => array()
- ));
+ WCF::getTPL()->assign([
+ 'packageUpdates' => []
+ ]);
- return array(
+ return [
'count' => 0,
'pageCount' => 0,
'searchID' => 0,
'template' => WCF::getTPL()->fetch('packageSearchResultList')
- );
+ ];
}
// determine highest versions
- $packageUpdates = array();
+ $packageUpdates = [];
foreach ($packageVersions as $package => $versionData) {
- $accessible = $existing = $versions = array();
+ $accessible = $existing = $versions = [];
foreach ($versionData as $packageUpdateID => $versionTypes) {
// ignore unaccessible packages
continue;
}
- uasort($versionTypes['accessible'], array('wcf\data\package\Package', 'compareVersion'));
- uasort($versionTypes['existing'], array('wcf\data\package\Package', 'compareVersion'));
+ uasort($versionTypes['accessible'], ['wcf\data\package\Package', 'compareVersion']);
+ uasort($versionTypes['existing'], ['wcf\data\package\Package', 'compareVersion']);
$accessibleVersion = array_slice($versionTypes['accessible'], -1, 1, true);
$existingVersion = array_slice($versionTypes['existing'], -1, 1, true);
continue;
}
- uksort($accessible, array('wcf\data\package\Package', 'compareVersion'));
- uksort($existing, array('wcf\data\package\Package', 'compareVersion'));
+ uksort($accessible, ['wcf\data\package\Package', 'compareVersion']);
+ uksort($existing, ['wcf\data\package\Package', 'compareVersion']);
$accessible = array_pop($accessible);
$existing = array_pop($existing);
- $packageUpdates[$versions[$accessible]] = array(
+ $packageUpdates[$versions[$accessible]] = [
'accessible' => $accessible,
'existing' => $existing
- );
+ ];
}
// no found packages is accessible
if (empty($packageUpdates)) {
- WCF::getTPL()->assign(array(
- 'packageUpdates' => array()
- ));
+ WCF::getTPL()->assign([
+ 'packageUpdates' => []
+ ]);
- return array(
+ return [
'count' => 0,
'pageCount' => 0,
'searchID' => 0,
'template' => WCF::getTPL()->fetch('packageSearchResultList')
- );
+ ];
}
- $search = SearchEditor::create(array(
+ $search = SearchEditor::create([
'userID' => WCF::getUser()->userID,
'searchData' => serialize($packageUpdates),
'searchTime' => TIME_NOW,
'searchType' => 'acpPackageSearch'
- ));
+ ]);
// forward call to build the actual result list
- $updateAction = new PackageUpdateAction(array(), 'getResultList', array(
+ $updateAction = new PackageUpdateAction([], 'getResultList', [
'pageNo' => 1,
'search' => $search
- ));
+ ]);
$returnValues = $updateAction->executeAction();
return $returnValues['returnValues'];
* Validates parameters to return a result list for a previous search.
*/
public function validateGetResultList() {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
$this->readInteger('pageNo');
$this->readInteger('searchID');
// get package updates
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("packageUpdateID IN (?)", array(array_keys($updateData)));
+ $conditions->add("packageUpdateID IN (?)", [array_keys($updateData)]);
$sql = "SELECT *
FROM wcf".WCF_N."_package_update
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
$statement->execute($conditions->getParameters());
- $packageUpdates = $packageVersionIDs = array();
+ $packageUpdates = $packageVersionIDs = [];
while ($packageUpdate = $statement->fetchObject('wcf\data\package\update\PackageUpdate')) {
$packageUpdates[$packageUpdate->packageUpdateID] = new ViewablePackageUpdate($packageUpdate);
// read update versions
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("packageUpdateVersionID IN (?)", array($packageVersionIDs));
+ $conditions->add("packageUpdateVersionID IN (?)", [$packageVersionIDs]);
$sql = "SELECT packageUpdateVersionID, packageVersion, packageDate, license, licenseURL
FROM wcf".WCF_N."_package_update_version
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $updateVersions = array();
+ $updateVersions = [];
while ($updateVersion = $statement->fetchObject('wcf\data\package\update\version\PackageUpdateVersion')) {
$updateVersions[$updateVersion->packageUpdateVersionID] = $updateVersion;
}
$packageUpdate->setLatestVersion($updateVersions[$versionIDs['existing']]);
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'packageUpdates' => $packageUpdates
- ));
+ ]);
$count = count($updateData);
- return array(
+ return [
'count' => $count,
'pageCount' => ceil($count / 20),
'searchID' => $this->search->searchID,
'template' => WCF::getTPL()->fetch('packageSearchResultList')
- );
+ ];
}
/**
* Validates permissions to search for updates.
*/
public function validateSearchForUpdates() {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canUpdatePackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canUpdatePackage']);
$this->readBoolean('ignoreCache', true);
}
* @return array
*/
public function searchForUpdates() {
- PackageUpdateDispatcher::getInstance()->refreshPackageDatabase(array(), $this->parameters['ignoreCache']);
+ PackageUpdateDispatcher::getInstance()->refreshPackageDatabase([], $this->parameters['ignoreCache']);
$updates = PackageUpdateDispatcher::getInstance()->getAvailableUpdates();
$url = '';
$url = LinkHandler::getInstance()->getLink('PackageUpdate');
}
- return array(
+ return [
'url' => $url
- );
+ ];
}
/**
* Validates parameters to perform a system update.
*/
public function validatePrepareUpdate() {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canUpdatePackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canUpdatePackage']);
if (!isset($this->parameters['packages']) || !is_array($this->parameters['packages'])) {
throw new UserInputException('packages');
* Validates parameters to prepare a package installation.
*/
public function validatePrepareInstallation() {
- WCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage'));
+ WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
if (!isset($this->parameters['packages']) || !is_array($this->parameters['packages']) || count($this->parameters['packages']) != 1) {
throw new UserInputException('packages');
$scheduler->buildPackageInstallationStack(($queueType == 'install'));
}
catch (PackageUpdateUnauthorizedException $e) {
- return array(
+ return [
'template' => $e->getRenderedTemplate()
- );
+ ];
}
// validate exclusions
$excludedPackages = $scheduler->getExcludedPackages();
if (!empty($excludedPackages)) {
- return array(
+ return [
'excludedPackages' => true,
- 'template' => WCF::getTPL()->fetch('packageUpdateExcludedPackages', 'wcf', array('excludedPackages' => $excludedPackages))
- );
+ 'template' => WCF::getTPL()->fetch('packageUpdateExcludedPackages', 'wcf', ['excludedPackages' => $excludedPackages])
+ ];
}
}
$parentQueueID = 0;
$processNo = PackageInstallationQueue::getNewProcessNo();
foreach ($stack as $package) {
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'parentQueueID' => $parentQueueID,
'processNo' => $processNo,
'userID' => WCF::getUser()->userID,
'packageID' => ($package['packageID'] ?: null),
'archive' => $package['archive'],
'action' => $package['action']
- ));
+ ]);
$parentQueueID = $queue->queueID;
if ($queueID === null) {
}
}
- return array(
+ return [
'queueID' => $queueID
- );
+ ];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.configuration.package.canEditServer');
+ protected $permissionsCreate = ['admin.configuration.package.canEditServer'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.configuration.package.canEditServer');
+ protected $permissionsDelete = ['admin.configuration.package.canEditServer'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.configuration.package.canEditServer');
+ protected $permissionsUpdate = ['admin.configuration.package.canEditServer'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update'];
/**
* @see \wcf\data\IToggleAction::validateToggle()
*/
public function toggle() {
foreach ($this->objects as $server) {
- $server->update(array('isDisabled' => ($server->isDisabled) ? 0 : 1));
+ $server->update(['isDisabled' => ($server->isDisabled) ? 0 : 1]);
}
}
}
*/
public function getPurchaseButtons() {
$objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.payment.type', 'com.woltlab.wcf.payment.type.paidSubscription');
- $buttons = array();
+ $buttons = [];
foreach (PaymentMethodHandler::getInstance()->getPaymentMethods() as $paymentMethod) {
// check if payment method supports recurring payments
if ($this->isRecurring && !$paymentMethod->supportsRecurringPayments()) continue;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.paidSubscription.canManageSubscription');
+ protected $permissionsDelete = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.paidSubscription.canManageSubscription');
+ protected $permissionsUpdate = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
*/
public function toggle() {
foreach ($this->objects as $object) {
- $object->update(array(
+ $object->update([
'isDisabled' => $object->isDisabled ? 0 : 1
- ));
+ ]);
}
}
WHERE paymentMethodObjectTypeID = ?
AND transactionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($paymentMethodObjectTypeID, $transactionID));
+ $statement->execute([$paymentMethodObjectTypeID, $transactionID]);
$row = $statement->fetchArray();
if ($row !== false) {
return new PaidSubscriptionTransactionLog(null, $row);
WHERE subscriptionID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($subscriptionID, $userID));
+ $statement->execute([$subscriptionID, $userID]);
$row = $statement->fetchArray();
if ($row !== false) {
return new PaidSubscriptionUser(null, $row);
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.paidSubscription.canManageSubscription');
+ protected $permissionsDelete = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.paidSubscription.canManageSubscription');
+ protected $permissionsUpdate = ['admin.paidSubscription.canManageSubscription'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
$subscriptionUser = parent::create();
// update group memberships
- $action = new PaidSubscriptionUserAction(array($subscriptionUser), 'addGroupMemberships');
+ $action = new PaidSubscriptionUserAction([$subscriptionUser], 'addGroupMemberships');
$action->executeAction();
return $subscriptionUser;
$endDate = $this->parameters['data']['endDate'];
}
- $subscriptionUser->update(array(
+ $subscriptionUser->update([
'endDate' => $endDate,
'isActive' => 1
- ));
+ ]);
if (!$subscriptionUser->isActive) {
// update group memberships
- $action = new PaidSubscriptionUserAction(array($subscriptionUser), 'addGroupMemberships');
+ $action = new PaidSubscriptionUserAction([$subscriptionUser], 'addGroupMemberships');
$action->executeAction();
}
}
}
foreach ($this->objects as $subscriptionUser) {
- $subscriptionUser->update(array('isActive' => 0));
+ $subscriptionUser->update(['isActive' => 0]);
// update group memberships
- $action = new PaidSubscriptionUserAction(array($subscriptionUser), 'removeGroupMemberships');
+ $action = new PaidSubscriptionUserAction([$subscriptionUser], 'removeGroupMemberships');
$action->executeAction();
}
}
}
foreach ($this->objects as $subscriptionUser) {
- $subscriptionUser->update(array('isActive' => 1));
+ $subscriptionUser->update(['isActive' => 1]);
// update group memberships
- $action = new PaidSubscriptionUserAction(array($subscriptionUser), 'addGroupMemberships');
+ $action = new PaidSubscriptionUserAction([$subscriptionUser], 'addGroupMemberships');
$action->executeAction();
}
}
}
foreach ($this->objects as $subscriptionUser) {
- $groupIDs = array();
+ $groupIDs = [];
foreach (explode(',', $subscriptionUser->getSubscription()->groupIDs) as $groupID) {
if (UserGroup::getGroupByID($groupID) !== null) {
$groupIDs[] = $groupID;
}
}
if (!empty($groupIDs)) {
- $action = new UserAction(array($subscriptionUser->userID), 'addToGroups', array(
+ $action = new UserAction([$subscriptionUser->userID], 'addToGroups', [
'groups' => $groupIDs,
'deleteOldGroups' => false,
'addDefaultGroups' => false
- ));
+ ]);
$action->executeAction();
}
}
}
foreach ($this->objects as $subscriptionUser) {
- $groupIDs = array();
+ $groupIDs = [];
foreach (explode(',', $subscriptionUser->getSubscription()->groupIDs) as $groupID) {
if (UserGroup::getGroupByID($groupID) !== null) {
$groupIDs[] = $groupID;
}
}
if (!empty($groupIDs)) {
- $action = new UserAction(array($subscriptionUser->userID), 'removeFromGroups', array(
+ $action = new UserAction([$subscriptionUser->userID], 'removeFromGroups', [
'groups' => $groupIDs,
- ));
+ ]);
$action->executeAction();
}
}
* list of poll options
* @var PollOption[]
*/
- protected $options = array();
+ protected $options = [];
/**
* related object
return;
}
- $optionList = PollManager::getInstance()->getPollOptions(array($this->pollID));
+ $optionList = PollManager::getInstance()->getPollOptions([$this->pollID]);
foreach ($optionList as $option) {
$this->options[$option->optionID] = $option;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getGroupedUserList');
+ protected $allowGuestAccess = ['getGroupedUserList'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
WCF::getDB()->beginTransaction();
foreach ($this->parameters['options'] as $showOrder => $option) {
- $statement->execute(array(
+ $statement->execute([
$poll->pollID,
$option['optionValue'],
$showOrder
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
// get current options
$optionList = new PollOptionList();
- $optionList->getConditionBuilder()->add("poll_option.pollID = ?", array($pollEditor->pollID));
+ $optionList->getConditionBuilder()->add("poll_option.pollID = ?", [$pollEditor->pollID]);
$optionList->sqlOrderBy = "poll_option.showOrder ASC";
$optionList->readObjects();
$options = $optionList->getObjects();
- $newOptions = $updateOptions = array();
+ $newOptions = $updateOptions = [];
foreach ($this->parameters['options'] as $showOrder => $option) {
// check if editing an existing option
if ($option['optionID']) {
// check if an update is required
if ($options[$option['optionID']]->showOrder != $showOrder || $options[$option['optionID']]->optionValue != $option['optionValue']) {
- $updateOptions[$option['optionID']] = array(
+ $updateOptions[$option['optionID']] = [
'optionValue' => $option['optionValue'],
'showOrder' => $showOrder
- );
+ ];
}
// remove option
unset($options[$option['optionID']]);
}
else {
- $newOptions[] = array(
+ $newOptions[] = [
'optionValue' => $option['optionValue'],
'showOrder' => $showOrder
- );
+ ];
}
}
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($newOptions as $option) {
- $statement->execute(array(
+ $statement->execute([
$pollEditor->pollID,
$option['optionValue'],
$option['showOrder']
- ));
+ ]);
}
}
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($updateOptions as $optionID => $option) {
- $statement->execute(array(
+ $statement->execute([
$option['optionValue'],
$option['showOrder'],
$optionID
- ));
+ ]);
}
}
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($options as $option) {
- $statement->execute(array($option->optionID));
+ $statement->execute([$option->optionID]);
}
}
WHERE pollID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$poll->pollID,
WCF::getUser()->userID
- ));
+ ]);
$alreadyVoted = false;
- $optionIDs = array();
+ $optionIDs = [];
while ($row = $statement->fetchArray()) {
$alreadyVoted = true;
$optionIDs[] = $row['optionID'];
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($this->parameters['optionIDs'] as $optionID) {
- $statement->execute(array(
+ $statement->execute([
$poll->pollID,
$optionID,
WCF::getUser()->userID
- ));
+ ]);
}
// increase votes per option
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($this->parameters['optionIDs'] as $optionID) {
- $statement->execute(array($optionID));
+ $statement->execute([$optionID]);
}
}
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($optionIDs as $optionID) {
- $statement->execute(array(
+ $statement->execute([
$optionID,
WCF::getUser()->userID
- ));
+ ]);
}
// decrease votes per option
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($optionIDs as $optionID) {
- $statement->execute(array($optionID));
+ $statement->execute([$optionID]);
}
}
WHERE pollID = ?
ORDER BY ".($this->poll->sortByVotes ? "votes DESC" : "showOrder ASC");
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->poll->pollID));
- $options = array();
+ $statement->execute([$this->poll->pollID]);
+ $options = [];
while ($row = $statement->fetchArray()) {
$options[$row['optionID']] = new GroupedUserList($row['optionValue'], 'wcf.poll.noVotes');
}
FROM wcf".WCF_N."_poll_option_vote
WHERE pollID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->poll->pollID));
- $voteData = array();
+ $statement->execute([$this->poll->pollID]);
+ $voteData = [];
while ($row = $statement->fetchArray()) {
if (!isset($voteData[$row['optionID']])) {
- $voteData[$row['optionID']] = array();
+ $voteData[$row['optionID']] = [];
}
$voteData[$row['optionID']][] = $row['userID'];
// load user profiles
GroupedUserList::loadUsers();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'groupedUsers' => $options
- ));
+ ]);
- return array(
+ return [
'pageCount' => 1,
'template' => WCF::getTPL()->fetch('groupedUserList')
- );
+ ];
}
/**
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$sourceObjectType->objectTypeID,
$this->parameters['sourceObjectID']
- ));
+ ]);
$row = $statement->fetchArray();
if ($row === false) {
- return array(
+ return [
'pollID' => null
- );
+ ];
}
// get options
$pollOptionList = new PollOptionList();
- $pollOptionList->getConditionBuilder()->add("poll_option.pollID = ?", array($row['pollID']));
+ $pollOptionList->getConditionBuilder()->add("poll_option.pollID = ?", [$row['pollID']]);
$pollOptionList->readObjects();
//
$newPoll = PollEditor::create($pollData);
// create options
- $newOptionIDs = array();
+ $newOptionIDs = [];
foreach ($pollOptionList as $pollOption) {
- $newOption = PollOptionEditor::create(array(
+ $newOption = PollOptionEditor::create([
'pollID' => $newPoll->pollID,
'optionValue' => $pollOption->optionValue,
'votes' => $pollOption->votes,
'showOrder' => $pollOption->showOrder
- ));
+ ]);
$newOptionIDs[$pollOption->optionID] = $newOption->optionID;
}
FROM wcf".WCF_N."_poll_option_vote
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($oldOptionID));
+ $statement->execute([$oldOptionID]);
}
WCF::getDB()->commitTransaction();
- return array(
+ return [
'pollID' => $newPoll->pollID
- );
+ ];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getSearchResultList');
+ protected $allowGuestAccess = ['getSearchResultList'];
/**
* @see \wcf\data\ISearchAction::validateGetSearchResultList()
* @see \wcf\data\ISearchAction::getSearchResultList()
*/
public function getSearchResultList() {
- $list = array();
+ $list = [];
// find users
$sql = "SELECT *
WHERE keyword LIKE ?
ORDER BY searches DESC";
$statement = WCF::getDB()->prepareStatement($sql, 10);
- $statement->execute(array($this->parameters['data']['searchString'].'%'));
+ $statement->execute([$this->parameters['data']['searchString'].'%']);
while ($row = $statement->fetchArray()) {
- $list[] = array(
+ $list[] = [
'label' => $row['keyword'],
'objectID' => $row['keywordID']
- );
+ ];
}
return $list;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('keepAlive');
+ protected $allowGuestAccess = ['keepAlive'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
* list of data values returned upon a keep alive request
* @var mixed[]
*/
- public $keepAliveData = array();
+ public $keepAliveData = [];
/**
* Validates the 'keepAlive' action.
SessionHandler::getInstance()->keepAlive();
// update notification counts
- $this->keepAliveData = array(
+ $this->keepAliveData = [
'userNotificationCount' => UserNotificationHandler::getInstance()->getNotificationCount(true)
- );
+ ];
// notify 3rd party components
EventHandler::getInstance()->fireAction($this, 'keepAlive');
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getSitemap');
+ protected $allowGuestAccess = ['getSitemap'];
/**
* Validates the 'getSitemap' action.
*/
public function getSitemap() {
if (isset($this->parameters['sitemapName'])) {
- return array(
+ return [
'sitemapName' => $this->parameters['sitemapName'],
'template' => SitemapHandler::getInstance()->getSitemap($this->parameters['sitemapName'])
- );
+ ];
}
else {
$sitemapName = SitemapHandler::getInstance()->getDefaultSitemapName();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'defaultSitemapName' => $sitemapName,
'sitemap' => SitemapHandler::getInstance()->getSitemap($sitemapName),
'tree' => SitemapHandler::getInstance()->getTree()
- ));
+ ]);
- return array(
+ return [
'sitemapName' => $sitemapName,
'template' => WCF::getTPL()->fetch('sitemap')
- );
+ ];
}
}
}
* @return string[]
*/
public function getAliases() {
- if (!$this->aliases) return array();
+ if (!$this->aliases) return [];
return explode("\n", StringUtil::unifyNewlines($this->aliases));
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.content.smiley.canManageSmiley');
+ protected $permissionsDelete = ['admin.content.smiley.canManageSmiley'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.content.smiley.canManageSmiley');
+ protected $permissionsUpdate = ['admin.content.smiley.canManageSmiley'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('delete', 'update', 'updatePosition');
+ protected $requireACP = ['delete', 'update', 'updatePosition'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
@rename($this->parameters['fileLocation'], WCF_DIR.'images/smilies/'.$smileyFilename);
$smileyEditor = new SmileyEditor($smiley);
- $smileyEditor->update(array(
+ $smileyEditor->update([
'smileyPath' => 'images/smilies/'.$smileyFilename
- ));
+ ]);
$smiley = new Smiley($smiley->smileyID);
}
if ($smiley === null) continue;
$editor = new SmileyEditor($smiley);
- $editor->update(array('showOrder' => $i++));
+ $editor->update(['showOrder' => $i++]);
}
WCF::getDB()->commitTransaction();
}
* cached smilies
* @var array
*/
- protected $cachedSmilies = array();
+ protected $cachedSmilies = [];
/**
* cached smiley categories
* @var SmileyCategory[]
*/
- protected $cachedCategories = array();
+ protected $cachedCategories = [];
/**
* enabled smiley categories with at least one smiley
*/
protected function init() {
// get smiley cache
- $this->cachedSmilies = SmileyCacheBuilder::getInstance()->getData(array(), 'smilies');
+ $this->cachedSmilies = SmileyCacheBuilder::getInstance()->getData([], 'smilies');
$smileyCategories = CategoryHandler::getInstance()->getCategories('com.woltlab.wcf.bbcode.smiley');
- $this->cachedCategories[null] = new SmileyCategory(new Category(null, array(
+ $this->cachedCategories[null] = new SmileyCategory(new Category(null, [
'categoryID' => null,
'parentCategoryID' => 0,
'title' => 'wcf.acp.smiley.categoryID.default',
'description' => '',
'showOrder' => -1,
'isDisabled' => 0
- )));
+ ]));
foreach ($smileyCategories as $key => $smileyCategory) {
$this->cachedCategories[$key] = new SmileyCategory($smileyCategory);
*/
public function getVisibleCategories() {
if ($this->visibleCategories === null) {
- $this->visibleCategories = array();
+ $this->visibleCategories = [];
foreach ($this->cachedCategories as $key => $category) {
if (!$category->isDisabled) {
public function getCategorySmilies($categoryID = null) {
if (isset($this->cachedSmilies[$categoryID])) return $this->cachedSmilies[$categoryID];
- return array();
+ return [];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getSmilies');
+ protected $allowGuestAccess = ['getSmilies'];
/**
* active smiley category
public function getSmilies() {
$this->smileyCategory->loadSmilies();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'smilies' => $this->smileyCategory
- ));
+ ]);
- return array(
+ return [
'smileyCategoryID' => $this->smileyCategory->categoryID,
'template' => WCF::getTPL()->fetch('__messageFormSmilies')
- );
+ ];
}
}
* Validates the getData action.
*/
public function validateGetData() {
- WCF::getSession()->checkPermissions(array('admin.management.canViewLog'));
+ WCF::getSession()->checkPermissions(['admin.management.canViewLog']);
// validate start date
if (empty($this->parameters['startDate']) || !preg_match('/^\d{4}\-\d{2}\-\d{2}$/', $this->parameters['startDate'])) {
* Returns the stat data.
*/
public function getData() {
- $data = array();
+ $data = [];
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('objectTypeID IN (?)', array($this->parameters['objectTypeIDs']));
- $conditionBuilder->add('date BETWEEN ? AND ?', array($this->parameters['startDate'], $this->parameters['endDate']));
+ $conditionBuilder->add('objectTypeID IN (?)', [$this->parameters['objectTypeIDs']]);
+ $conditionBuilder->add('date BETWEEN ? AND ?', [$this->parameters['startDate'], $this->parameters['endDate']]);
$limit = 0;
if ($this->parameters['dateGrouping'] == 'yearly') {
$objectType = ObjectTypeCache::getInstance()->getObjectType($row['objectTypeID']);
if (!isset($data[$row['objectTypeID']])) {
- $data[$row['objectTypeID']] = array(
+ $data[$row['objectTypeID']] = [
'label' => WCF::getLanguage()->get('wcf.acp.stat.'.$objectType->objectType),
- 'data' => array()
- );
+ 'data' => []
+ ];
}
- $data[$row['objectTypeID']]['data'][] = array(strtotime($row['date'] . ' UTC'), $objectType->getProcessor()->getFormattedCounter($value));
+ $data[$row['objectTypeID']]['data'][] = [strtotime($row['date'] . ' UTC'), $objectType->getProcessor()->getFormattedCounter($value)];
}
return $data;
* list of style variables
* @var string[]
*/
- protected $variables = array();
+ protected $variables = [];
const PREVIEW_IMAGE_MAX_HEIGHT = 64;
const PREVIEW_IMAGE_MAX_WIDTH = 102;
ON (value.variableID = variable.variableID AND value.styleID = ?)
ORDER BY variable.variableID ASC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->styleID));
+ $statement->execute([$this->styleID]);
while ($row = $statement->fetchArray()) {
$variableName = $row['variableName'];
$variableValue = (isset($row['variableValue'])) ? $row['variableValue'] : $row['defaultValue'];
WHERE languageID = ?
AND name = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($languageID, $name));
+ $statement->execute([$languageID, $name]);
$row = $statement->fetchArray();
if ($row !== false) return new Tag(null, $row);
/**
* @see \wcf\data\AbstractDatabaseObjectAction
*/
- protected $allowGuestAccess = array('getSearchResultList');
+ protected $allowGuestAccess = ['getSearchResultList'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.content.tag.canManageTag');
+ protected $permissionsDelete = ['admin.content.tag.canManageTag'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.content.tag.canManageTag');
+ protected $permissionsUpdate = ['admin.content.tag.canManageTag'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('delete', 'update');
+ protected $requireACP = ['delete', 'update'];
/**
* tag for which other tags will be used as synonyms
* @see \wcf\data\ISearchAction::getSearchResultList()
*/
public function getSearchResultList() {
- $excludedSearchValues = array();
+ $excludedSearchValues = [];
if (isset($this->parameters['data']['excludedSearchValues'])) {
$excludedSearchValues = $this->parameters['data']['excludedSearchValues'];
}
- $list = array();
+ $list = [];
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("name LIKE ?", array($this->parameters['data']['searchString'].'%'));
+ $conditionBuilder->add("name LIKE ?", [$this->parameters['data']['searchString'].'%']);
if (!empty($excludedSearchValues)) {
- $conditionBuilder->add("name NOT IN (?)", array($excludedSearchValues));
+ $conditionBuilder->add("name NOT IN (?)", [$excludedSearchValues]);
}
// find tags
$statement = WCF::getDB()->prepareStatement($sql, 5);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
- $list[] = array(
+ $list[] = [
'label' => $row['name'],
'objectID' => $row['tagID']
- );
+ ];
}
return $list;
* @param integer[] $tagIDs
* @since 2.2
*/
- protected function unmarkItems(array $tagIDs = array()) {
+ protected function unmarkItems(array $tagIDs = []) {
if (empty($tagIDs)) {
$tagIDs = $this->objectIDs;
}
ON (package.packageID = template.packageID)
WHERE template.templateID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($id));
+ $statement->execute([$id]);
$row = $statement->fetchArray();
if ($row !== false) {
$row['packageDir'] = PackageCache::getInstance()->getPackage($application->packageID)->packageDir;
}
else {
- $row = array();
+ $row = [];
}
}
else if ($object !== null) {
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.template.canManageTemplate');
+ protected $permissionsCreate = ['admin.template.canManageTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.template.canManageTemplate');
+ protected $permissionsDelete = ['admin.template.canManageTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.template.canManageTemplate');
+ protected $permissionsUpdate = ['admin.template.canManageTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
* @param integer $initialDepth Specifies the initial indentation depth of the list
* @return array
*/
- public static function getSelectList($ignore = array(), $initialDepth = 0) {
+ public static function getSelectList($ignore = [], $initialDepth = 0) {
if (self::$templateGroupStructure === null) {
- self::$templateGroupStructure = array();
+ self::$templateGroupStructure = [];
$sql = "SELECT templateGroupID, templateGroupName, parentTemplateGroupID
FROM wcf".WCF_N."_template_group
}
}
- self::$selectList = array();
+ self::$selectList = [];
self::makeSelectList(0, $initialDepth, $ignore);
return self::$selectList;
* @param integer $depth current list depth
* @param array $ignore list of template group ids to ignore in result
*/
- protected static function makeSelectList($parentID = 0, $depth = 0, $ignore = array()) {
+ protected static function makeSelectList($parentID = 0, $depth = 0, $ignore = []) {
if (!isset(self::$templateGroupStructure[$parentID ?: 0])) return;
foreach (self::$templateGroupStructure[$parentID ?: 0] as $templateGroup) {
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.template.canManageTemplate');
+ protected $permissionsCreate = ['admin.template.canManageTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.template.canManageTemplate');
+ protected $permissionsDelete = ['admin.template.canManageTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.template.canManageTemplate');
+ protected $permissionsUpdate = ['admin.template.canManageTemplate'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
}
* teams included in the list
* @var Team[]
*/
- protected $teams = array();
+ protected $teams = [];
/**
* @see \wcf\data\DatabaseObjectList::countObjects()
* @see \wcf\data\DatabaseObjectList::readObjectIDs()
*/
public function readObjectIDs() {
- $this->objectIDs = array();
+ $this->objectIDs = [];
$sql = "SELECT user_to_group.userID AS objectID
FROM wcf".WCF_N."_user_group user_group,
wcf".WCF_N."_user_to_group user_to_group
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getGroupedUserList');
+ protected $allowGuestAccess = ['getGroupedUserList'];
/**
* @see \wcf\data\IGroupedUserListAction::validateGetGroupedUserList()
if (isset($value[2])) $day = intval($value[2]);
// get users
- $users = array();
- $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
+ $users = [];
+ $userOptions = UserOptionCacheBuilder::getInstance()->getData([], 'options');
if (isset($userOptions['birthday'])) {
$birthdayUserOption = $userOptions['birthday'];
}
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'users' => $users,
'year' => $year
- ));
- return array(
+ ]);
+ return [
'pageCount' => 1,
'template' => WCF::getTPL()->fetch('userBirthdayList')
- );
+ ];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getUserProfile', 'getDetailedActivityPointList');
+ protected $allowGuestAccess = ['getUserProfile', 'getDetailedActivityPointList'];
/**
* user profile object
if (isset($this->parameters['options']['enableBBCodes']) && WCF::getSession()->getPermission('user.signature.canUseBBCodes')) {
$disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($this->parameters['data']['message'], explode(',', WCF::getSession()->getPermission('user.signature.allowedBBCodes')));
if (!empty($disallowedBBCodes)) {
- throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array(
+ throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', [
'disallowedBBCodes' => $disallowedBBCodes
- )));
+ ]));
}
}
}
$message = StringUtil::trim($this->parameters['data']['message']);
$preview = MessageParser::getInstance()->parse($message, $enableSmilies, $enableHtml, $enableBBCodes, false);
- return array(
+ return [
'message' => $preview
- );
+ ];
}
/**
if ($userID) {
$userProfileList = new UserProfileList();
- $userProfileList->getConditionBuilder()->add("user_table.userID = ?", array($userID));
+ $userProfileList->getConditionBuilder()->add("user_table.userID = ?", [$userID]);
$userProfileList->readObjects();
$userProfiles = $userProfileList->getObjects();
WCF::getTPL()->assign('unknownUser', true);
}
- return array(
+ return [
'template' => WCF::getTPL()->fetch('userProfilePreview'),
'userID' => $userID
- );
+ ];
}
/**
* @return array
*/
public function getDetailedActivityPointList() {
- $activityPointObjectTypes = array();
+ $activityPointObjectTypes = [];
foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.activityPointEvent') as $objectType) {
$activityPointObjectTypes[$objectType->objectTypeID] = $objectType;
}
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('userID = ?', array($this->userProfile->userID));
- $conditionBuilder->add('objectTypeID IN (?)', array(array_keys($activityPointObjectTypes)));
+ $conditionBuilder->add('userID = ?', [$this->userProfile->userID]);
+ $conditionBuilder->add('objectTypeID IN (?)', [array_keys($activityPointObjectTypes)]);
$sql = "SELECT objectTypeID, activityPoints
FROM wcf".WCF_N."_user_activity_point
$activityPointObjectTypes[$row['objectTypeID']]->activityPoints = $row['activityPoints'];
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'activityPointObjectTypes' => $activityPointObjectTypes,
'user' => $this->userProfile
- ));
+ ]);
- return array(
+ return [
'template' => WCF::getTPL()->fetch('detailedActivityPointList'),
'userID' => $this->userProfile->userID
- );
+ ];
}
/**
*/
public function beginEdit() {
$optionTree = $this->getOptionHandler($this->userProfile->getDecoratedObject())->getOptionTree();
- WCF::getTPL()->assign(array(
- 'errorType' => array(),
+ WCF::getTPL()->assign([
+ 'errorType' => [],
'optionTree' => $optionTree,
'__userTitle' => $this->userProfile->userTitle
- ));
+ ]);
- return array(
+ return [
'template' => WCF::getTPL()->fetch('userProfileAboutEditable')
- );
+ ];
}
/**
$this->validateBeginEdit();
if (!isset($this->parameters['values']) || !is_array($this->parameters['values'])) {
- $this->parameters['values'] = array();
+ $this->parameters['values'] = [];
}
if (isset($this->parameters['values']['__userTitle']) && !WCF::getSession()->getPermission('user.profile.canEditUserTitle')) {
// validation was successful
if (empty($errors)) {
$saveOptions = $optionHandler->save();
- $data = array(
+ $data = [
'options' => $saveOptions
- );
+ ];
// save user title
if ($userTitle !== null) {
- $data['data'] = array(
+ $data['data'] = [
'userTitle' => $userTitle
- );
+ ];
}
- $userAction = new UserAction(array($this->userProfile->userID), 'update', $data);
+ $userAction = new UserAction([$this->userProfile->userID], 'update', $data);
$userAction->executeAction();
// check if the user will be automatically added to new
// user groups because of the changed user options
- UserGroupAssignmentHandler::getInstance()->checkUsers(array($this->userProfile->userID));
+ UserGroupAssignmentHandler::getInstance()->checkUsers([$this->userProfile->userID]);
// return parsed template
$user = new User($this->userProfile->userID);
$optionHandler = $this->getOptionHandler($user, false);
$options = $optionHandler->getOptionTree();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'options' => $options,
'userID' => $this->userProfile->userID
- ));
+ ]);
- return array(
+ return [
'success' => true,
'template' => WCF::getTPL()->fetch('userProfileAbout')
- );
+ ];
}
else {
// validation failed
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'errorType' => $errors,
'optionTree' => $optionHandler->getOptionTree(),
'__userTitle' => ($userTitle !== null ? $userTitle : $this->userProfile->userTitle)
- ));
+ ]);
- return array(
+ return [
'success' => false,
'template' => WCF::getTPL()->fetch('userProfileAboutEditable')
- );
+ ];
}
}
$this->readObjects();
}
- $resetUserIDs = array();
+ $resetUserIDs = [];
foreach ($this->objects as $user) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('user_rank.groupID IN (?)', array($user->getGroupIDs()));
- $conditionBuilder->add('user_rank.requiredPoints <= ?', array($user->activityPoints));
- if ($user->gender) $conditionBuilder->add('user_rank.requiredGender IN (?)', array(array(0, $user->gender)));
- else $conditionBuilder->add('user_rank.requiredGender = ?', array(0));
+ $conditionBuilder->add('user_rank.groupID IN (?)', [$user->getGroupIDs()]);
+ $conditionBuilder->add('user_rank.requiredPoints <= ?', [$user->activityPoints]);
+ if ($user->gender) $conditionBuilder->add('user_rank.requiredGender IN (?)', [[0, $user->gender]]);
+ else $conditionBuilder->add('user_rank.requiredGender = ?', [0]);
$sql = "SELECT user_rank.rankID
FROM wcf".WCF_N."_user_rank user_rank
$row = $statement->fetchArray();
if ($row === false) {
if ($user->rankID) {
- $user->update(array('rankID' => null));
+ $user->update(['rankID' => null]);
$resetUserIDs[] = $user->userID;
}
}
else {
if ($row['rankID'] != $user->rankID) {
- $user->update(array('rankID' => $row['rankID']));
+ $user->update(['rankID' => $row['rankID']]);
$resetUserIDs[] = $user->userID;
}
}
$this->readObjects();
}
- $userToGroup = array();
+ $userToGroup = [];
foreach ($this->objects as $user) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('groupID IN (?)', array($user->getGroupIDs()));
+ $conditionBuilder->add('groupID IN (?)', [$user->getGroupIDs()]);
$sql = "SELECT groupID
FROM wcf".WCF_N."_user_group
WCF::getDB()->beginTransaction();
foreach ($userToGroup as $userID => $groupID) {
- $statement->execute(array(
+ $statement->execute([
$groupID,
$userID
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('validateEmailAddress', 'validatePassword', 'validateUsername');
+ protected $allowGuestAccess = ['validateEmailAddress', 'validatePassword', 'validateUsername'];
/**
* Validates the validate username function.
*/
public function validateUsername() {
if (!UserRegistrationUtil::isValidUsername($this->parameters['username'])) {
- return array(
+ return [
'isValid' => false,
'error' => 'notValid'
- );
+ ];
}
if (!UserUtil::isAvailableUsername($this->parameters['username'])) {
- return array(
+ return [
'isValid' => false,
'error' => 'notUnique'
- );
+ ];
}
- return array(
+ return [
'isValid' => true
- );
+ ];
}
/**
*/
public function validateEmailAddress() {
if (!UserRegistrationUtil::isValidEmail($this->parameters['email'])) {
- return array(
+ return [
'isValid' => false,
'error' => 'notValid'
- );
+ ];
}
if (!UserUtil::isAvailableEmail($this->parameters['email'])) {
- return array(
+ return [
'isValid' => false,
'error' => 'notUnique'
- );
+ ];
}
- return array(
+ return [
'isValid' => true
- );
+ ];
}
/**
*/
public function validatePassword() {
if (!UserRegistrationUtil::isSecurePassword($this->parameters['password'])) {
- return array(
+ return [
'isValid' => false,
'error' => 'notSecure'
- );
+ ];
}
- return array(
+ return [
'isValid' => true
- );
+ ];
}
}
$this->data['additionalData'] = @unserialize($this->data['additionalData']);
if (!is_array($this->data['additionalData'])) {
- $this->data['additionalData'] = array();
+ $this->data['additionalData'] = [];
}
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- public $allowGuestAccess = array('load');
+ public $allowGuestAccess = ['load'];
/**
* Validates parameters to load recent activity entries.
public function load() {
$eventList = new ViewableUserActivityEventList();
if ($this->parameters['lastEventID']) {
- $eventList->getConditionBuilder()->add("user_activity_event.time <= ?", array($this->parameters['lastEventTime']));
- $eventList->getConditionBuilder()->add("user_activity_event.eventID < ?", array($this->parameters['lastEventID']));
+ $eventList->getConditionBuilder()->add("user_activity_event.time <= ?", [$this->parameters['lastEventTime']]);
+ $eventList->getConditionBuilder()->add("user_activity_event.eventID < ?", [$this->parameters['lastEventID']]);
}
else {
- $eventList->getConditionBuilder()->add("user_activity_event.time < ?", array($this->parameters['lastEventTime']));
+ $eventList->getConditionBuilder()->add("user_activity_event.time < ?", [$this->parameters['lastEventTime']]);
}
// profile view
if ($this->parameters['userID']) {
- $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", array($this->parameters['userID']));
+ $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", [$this->parameters['userID']]);
}
else if ($this->parameters['filteredByFollowedUsers'] && count(WCF::getUserProfileHandler()->getFollowingUsers())) {
- $eventList->getConditionBuilder()->add('user_activity_event.userID IN (?)', array(WCF::getUserProfileHandler()->getFollowingUsers()));
+ $eventList->getConditionBuilder()->add('user_activity_event.userID IN (?)', [WCF::getUserProfileHandler()->getFollowingUsers()]);
}
$eventList->readObjects();
$lastEventTime = $eventList->getLastEventTime();
if (!$lastEventTime) {
- return array();
+ return [];
}
// removes orphaned and non-accessable events
UserActivityEventHandler::validateEvents($eventList);
if (!count($eventList)) {
- return array();
+ return [];
}
// parse template
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'eventList' => $eventList
- ));
+ ]);
$events = $eventList->getObjects();
- return array(
+ return [
'lastEventID' => end($events)->eventID,
'lastEventTime' => $lastEventTime,
'template' => WCF::getTPL()->fetch('recentActivityListItem')
- );
+ ];
}
/**
public function validateSwitchContext() { }
public function switchContext() {
- $userAction = new UserAction(array(WCF::getUser()), 'update', array(
- 'options' => array(
+ $userAction = new UserAction([WCF::getUser()], 'update', [
+ 'options' => [
User::getUserOptionID('recentActivitiesFilterByFollowing') => (WCF::getUser()->recentActivitiesFilterByFollowing ? 0 : 1)
- )
- ));
+ ]
+ ]);
$userAction->executeAction();
}
}
WHERE ipAddress = ?
AND time > ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($ipAddress, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT));
+ $statement->execute([$ipAddress, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT]);
return $statement->fetchColumn();
}
WHERE userID = ?
AND time > ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($userID, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT));
+ $statement->execute([$userID, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT]);
return $statement->fetchColumn();
}
* urls of this gravatar
* @var string[]
*/
- protected $url = array();
+ protected $url = [];
/**
* Creates a new Gravatar object.
$this->url[$size] = WCF::getPath().$cachedFilename;
}
else {
- $this->url[$size] = LinkHandler::getInstance()->getLink('GravatarDownload', array(
+ $this->url[$size] = LinkHandler::getInstance()->getLink('GravatarDownload', [
'forceFrontend' => true
- ), 'userID='.$this->userID.'&size='.$size);
+ ], 'userID='.$this->userID.'&size='.$size);
}
}
* needed avatar thumbnail sizes
* @var integer[]
*/
- public static $avatarThumbnailSizes = array(32, 96, 128);
+ public static $avatarThumbnailSizes = [32, 96, 128];
/**
* @see \wcf\data\DatabaseObject::$databaseTableName
$fileLocation = $this->enforceDimensions($file->getLocation());
$imageData = getimagesize($fileLocation);
- $data = array(
+ $data = [
'avatarName' => $file->getFilename(),
'avatarExtension' => $file->getFileExtension(),
'width' => $imageData[0],
'height' => $imageData[1],
'userID' => $userID,
'fileHash' => sha1_file($fileLocation)
- );
+ ];
// create avatar
$avatar = UserAvatarEditor::create($data);
@unlink($fileLocation);
// create thumbnails
- $action = new UserAvatarAction(array($avatar), 'generateThumbnails');
+ $action = new UserAvatarAction([$avatar], 'generateThumbnails');
$action->executeAction();
// delete old avatar
if ($user->avatarID) {
- $action = new UserAvatarAction(array($user->avatarID), 'delete');
+ $action = new UserAvatarAction([$user->avatarID], 'delete');
$action->executeAction();
}
// update user
$userEditor = new UserEditor($user);
- $userEditor->update(array(
+ $userEditor->update([
'avatarID' => $avatar->avatarID,
'enableGravatar' => 0
- ));
+ ]);
// reset user storage
- UserStorageHandler::getInstance()->reset(array($userID), 'avatar');
+ UserStorageHandler::getInstance()->reset([$userID], 'avatar');
// return result
- return array(
+ return [
'avatarID' => $avatar->avatarID,
'canCrop' => $avatar->canCrop(),
'url' => $avatar->getURL(96)
- );
+ ];
}
else {
// moving failed; delete avatar
$file->setValidationErrorType($e->getType());
}
- return array('errorType' => $file->getValidationErrorType());
+ return ['errorType' => $file->getValidationErrorType()];
}
/**
return;
}
- $data = array(
+ $data = [
'avatarName' => $tmp['basename'],
'avatarExtension' => $tmp['extension'],
'width' => $imageData[0],
'height' => $imageData[1],
'userID' => $this->parameters['userEditor']->userID,
'fileHash' => sha1_file($filename)
- );
+ ];
// create avatar
$avatar = UserAvatarEditor::create($data);
@unlink($filename);
// create thumbnails
- $action = new UserAvatarAction(array($avatar), 'generateThumbnails');
+ $action = new UserAvatarAction([$avatar], 'generateThumbnails');
$action->executeAction();
$avatarID = $avatar->avatarID;
// update user
if ($avatarID) {
- $this->parameters['userEditor']->update(array(
+ $this->parameters['userEditor']->update([
'avatarID' => $avatarID,
'enableGravatar' => 0
- ));
+ ]);
// delete old avatar
if ($this->parameters['userEditor']->avatarID) {
- $action = new UserAvatarAction(array($this->parameters['userEditor']->avatarID), 'delete');
+ $action = new UserAvatarAction([$this->parameters['userEditor']->avatarID], 'delete');
$action->executeAction();
}
}
// reset user storage
- UserStorageHandler::getInstance()->reset(array($this->parameters['userEditor']->userID), 'avatar');
+ UserStorageHandler::getInstance()->reset([$this->parameters['userEditor']->userID], 'avatar');
}
/**
* @return array
*/
public function getCropDialog() {
- return array(
+ return [
'cropX' => $this->avatar->cropX,
'cropY' => $this->avatar->cropY,
- 'template' => WCF::getTPL()->fetch('avatarCropDialog', 'wcf', array(
+ 'template' => WCF::getTPL()->fetch('avatarCropDialog', 'wcf', [
'avatar' => $this->avatar
- ))
- );
+ ])
+ ];
}
/**
}
// update database entry
- $this->avatar->update(array(
+ $this->avatar->update([
'cropX' => $this->parameters['cropX'],
'cropY' => $this->parameters['cropY']
- ));
+ ]);
- return array(
+ return [
'url' => $this->avatar->getURL(96)
- );
+ ];
}
}
$sql = "DELETE FROM wcf".WCF_N."_user_avatar
WHERE avatarID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->avatarID));
+ $statement->execute([$this->avatarID]);
$this->deleteFiles();
}
/**
* @inheritDoc
*/
- public static function deleteAll(array $objectIDs = array()) {
+ public static function deleteAll(array $objectIDs = []) {
$sql = "SELECT *
FROM wcf".WCF_N."_user_avatar
WHERE avatarID IN (".str_repeat('?,', count($objectIDs) - 1)."?)";
WHERE userID = ?
AND followUserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$userID,
$followUserID
- ));
+ ]);
$row = $statement->fetchArray();
- if (!$row) $row = array();
+ if (!$row) $row = [];
return new UserFollow(null, $row);
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getGroupedUserList');
+ protected $allowGuestAccess = ['getGroupedUserList'];
/**
* user profile object
// not following right now
if (!$follow->followID) {
- $follow = UserFollowEditor::create(array(
+ $follow = UserFollowEditor::create([
'userID' => WCF::getUser()->userID,
'followUserID' => $this->parameters['data']['userID'],
'time' => TIME_NOW
- ));
+ ]);
// send notification
- UserNotificationHandler::getInstance()->fireEvent('following', 'com.woltlab.wcf.user.follow', new UserFollowUserNotificationObject($follow), array($follow->followUserID));
+ UserNotificationHandler::getInstance()->fireEvent('following', 'com.woltlab.wcf.user.follow', new UserFollowUserNotificationObject($follow), [$follow->followUserID]);
// fire activity event
UserActivityEventHandler::getInstance()->fireEvent('com.woltlab.wcf.user.recentActivityEvent.follow', $this->parameters['data']['userID']);
// reset storage
- UserStorageHandler::getInstance()->reset(array($this->parameters['data']['userID']), 'followerUserIDs');
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'followingUserIDs');
+ UserStorageHandler::getInstance()->reset([$this->parameters['data']['userID']], 'followerUserIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'followingUserIDs');
}
- return array(
+ return [
'following' => 1
- );
+ ];
}
/**
$followEditor->delete();
// remove activity event
- UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.user.recentActivityEvent.follow', array($this->parameters['data']['userID']));
+ UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.user.recentActivityEvent.follow', [$this->parameters['data']['userID']]);
}
// reset storage
- UserStorageHandler::getInstance()->reset(array($this->parameters['data']['userID']), 'followerUserIDs');
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'followingUserIDs');
+ UserStorageHandler::getInstance()->reset([$this->parameters['data']['userID']], 'followerUserIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'followingUserIDs');
- return array(
+ return [
'following' => 0
- );
+ ];
}
/**
public function delete() {
$returnValues = parent::delete();
- $followUserIDs = array();
+ $followUserIDs = [];
foreach ($this->objects as $follow) {
$followUserIDs[] = $follow->followUserID;
// remove activity event
- UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.user.recentActivityEvent.follow', array($follow->followUserID));
+ UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.user.recentActivityEvent.follow', [$follow->followUserID]);
}
// reset storage
UserStorageHandler::getInstance()->reset($followUserIDs, 'followerUserIDs');
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'followingUserIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'followingUserIDs');
return $returnValues;
}
FROM wcf".WCF_N."_user_follow
WHERE followUserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->parameters['userID']));
+ $statement->execute([$this->parameters['userID']]);
$pageCount = ceil($statement->fetchSingleColumn() / 20);
// get user ids
FROM wcf".WCF_N."_user_follow
WHERE followUserID = ?";
$statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
- $statement->execute(array($this->parameters['userID']));
+ $statement->execute([$this->parameters['userID']]);
$userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
// create group
// load user profiles
GroupedUserList::loadUsers();
- WCF::getTPL()->assign(array(
- 'groupedUsers' => array($group)
- ));
+ WCF::getTPL()->assign([
+ 'groupedUsers' => [$group]
+ ]);
- return array(
+ return [
'pageCount' => $pageCount,
'template' => WCF::getTPL()->fetch('groupedUserList')
- );
+ ];
}
}
FROM wcf".WCF_N."_user_follow
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->parameters['userID']));
+ $statement->execute([$this->parameters['userID']]);
$pageCount = ceil($statement->fetchSingleColumn() / 20);
// get user ids
FROM wcf".WCF_N."_user_follow
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
- $statement->execute(array($this->parameters['userID']));
+ $statement->execute([$this->parameters['userID']]);
$userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
// create group
// load user profiles
GroupedUserList::loadUsers();
- WCF::getTPL()->assign(array(
- 'groupedUsers' => array($group)
- ));
+ WCF::getTPL()->assign([
+ 'groupedUsers' => [$group]
+ ]);
- return array(
+ return [
'pageCount' => $pageCount,
'template' => WCF::getTPL()->fetch('groupedUserList')
- );
+ ];
}
}
public static function getGroupIDsByType(array $types) {
self::getCache();
- $groupIDs = array();
+ $groupIDs = [];
foreach ($types as $type) {
if (isset(self::$cache['types'][$type])) {
$groupIDs = array_merge($groupIDs, self::$cache['types'][$type]);
* @param integer[] $invalidGroupTypes
* @return UserGroup[]
*/
- public static function getGroupsByType(array $types = array(), array $invalidGroupTypes = array()) {
+ public static function getGroupsByType(array $types = [], array $invalidGroupTypes = []) {
self::getCache();
- $groups = array();
+ $groups = [];
foreach (self::$cache['groups'] as $group) {
if ((empty($types) || in_array($group->groupType, $types)) && !in_array($group->groupType, $invalidGroupTypes)) {
$groups[$group->groupID] = $group;
throw new SystemException('invalid value for type argument');
}
- $groups = self::getGroupsByType(array($type));
+ $groups = self::getGroupsByType([$type]);
return array_shift($groups);
}
* @param array $groupIDs
* @return boolean
*/
- public static function isAccessibleGroup(array $groupIDs = array()) {
+ public static function isAccessibleGroup(array $groupIDs = []) {
if (self::$accessibleGroups === null) {
self::$accessibleGroups = explode(',', WCF::getSession()->getPermission('admin.user.accessibleGroups'));
}
* @param integer[] $invalidGroupTypes
* @return UserGroup[]
*/
- public static function getAccessibleGroups(array $groupTypes = array(), array $invalidGroupTypes = array()) {
+ public static function getAccessibleGroups(array $groupTypes = [], array $invalidGroupTypes = []) {
$groups = self::getGroupsByType($groupTypes, $invalidGroupTypes);
foreach ($groups as $key => $value) {
- if (!self::isAccessibleGroup(array($key))) {
+ if (!self::isAccessibleGroup([$key])) {
unset($groups[$key]);
}
}
* @return boolean
*/
public function isAccessible() {
- return self::isAccessibleGroup(array($this->groupID));
+ return self::isAccessibleGroup([$this->groupID]);
}
/**
public function getGroupOption($name) {
if ($this->groupOptions === null) {
// get all options and filter options with low priority
- $this->groupOptions = $groupOptionIDs = array();
+ $this->groupOptions = $groupOptionIDs = [];
$sql = "SELECT optionName, optionID
FROM wcf".WCF_N."_user_group_option";
if (!empty($groupOptionIDs)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("option_value.groupID = ?", array($this->groupID));
- $conditions->add("option_value.optionID IN (?)", array($groupOptionIDs));
+ $conditions->add("option_value.groupID = ?", [$this->groupID]);
+ $conditions->add("option_value.optionID IN (?)", [$groupOptionIDs]);
$sql = "SELECT group_option.optionName, option_value.optionValue
FROM wcf".WCF_N."_user_group_option_value option_value
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.user.canAddGroup');
+ protected $permissionsCreate = ['admin.user.canAddGroup'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.user.canDeleteGroup');
+ protected $permissionsDelete = ['admin.user.canDeleteGroup'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.user.canEditGroup');
+ protected $permissionsUpdate = ['admin.user.canEditGroup'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('copy', 'create', 'delete', 'update');
+ protected $requireACP = ['copy', 'create', 'delete', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::create()
* Validates the 'copy' action.
*/
public function validateCopy() {
- WCF::getSession()->checkPermissions(array(
+ WCF::getSession()->checkPermissions([
'admin.user.canAddGroup',
'admin.user.canEditGroup'
- ));
+ ]);
$this->readBoolean('copyACLOptions');
$this->readBoolean('copyMembers');
FROM wcf".WCF_N."_user_group_option_value
WHERE groupID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupEditor->groupID));
+ $statement->execute([$this->groupEditor->groupID]);
}
else {
$sql = "SELECT optionID, defaultValue AS optionValue
$statement->execute();
}
- $optionValues = array();
+ $optionValues = [];
while ($row = $statement->fetchArray()) {
$optionValues[$row['optionID']] = $row['optionValue'];
}
- $groupAction = new UserGroupAction(array(), 'create', array(
- 'data' => array(
+ $groupAction = new UserGroupAction([], 'create', [
+ 'data' => [
'groupName' => $this->groupEditor->groupName,
'groupDescription' => $this->groupEditor->groupDescription,
'priority' => $this->groupEditor->priority,
'userOnlineMarking' => $this->groupEditor->userOnlineMarking,
'showOnTeamPage' => $this->groupEditor->showOnTeamPage
- ),
+ ],
'options' => $optionValues
- ));
+ ]);
$returnValues = $groupAction->executeAction();
$group = $returnValues['returnValues'];
$groupEditor = new UserGroupEditor($group);
FROM wcf".WCF_N."_language_item
WHERE languageItem = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupEditor->groupName));
+ $statement->execute([$this->groupEditor->groupName]);
}
else {
$groupName .= ' (2)';
FROM wcf".WCF_N."_language_item
WHERE languageItem = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupEditor->groupDescription));
+ $statement->execute([$this->groupEditor->groupDescription]);
}
- $groupEditor->update(array(
+ $groupEditor->update([
'groupDescription' => $groupDescription,
'groupName' => $groupName
- ));
+ ]);
// copy members
if ($this->parameters['copyMembers']) {
FROM wcf".WCF_N."_user_to_group
WHERE groupID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupEditor->groupID));
+ $statement->execute([$this->groupEditor->groupID]);
}
// copy acl options
FROM wcf".WCF_N."_acl_option_to_group
WHERE groupID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupEditor->groupID));
+ $statement->execute([$this->groupEditor->groupID]);
// it is likely that applications or plugins use caches
// for acl option values like for the labels which have
UserGroupEditor::resetCache();
- return array(
- 'redirectURL' => LinkHandler::getInstance()->getLink('UserGroupEdit', array(
+ return [
+ 'redirectURL' => LinkHandler::getInstance()->getLink('UserGroupEdit', [
'id' => $group->groupID
- ))
- );
+ ])
+ ];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.user.canManageGroupAssignment');
+ protected $permissionsDelete = ['admin.user.canManageGroupAssignment'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.user.canManageGroupAssignment');
+ protected $permissionsUpdate = ['admin.user.canManageGroupAssignment'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update'];
/**
* @see \wcf\data\IDeleteAction::delete()
*/
public function toggle() {
foreach ($this->objects as $assignment) {
- $assignment->update(array(
+ $assignment->update([
'isDisabled' => $assignment->isDisabled ? 0 : 1
- ));
+ ]);
}
}
$sql = "DELETE FROM wcf".WCF_N."_user_group_option_value
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$option->optionID
- ));
+ ]);
if (!empty($this->parameters['values'])) {
$sql = "INSERT INTO wcf".WCF_N."_user_group_option_value
WCF::getDB()->beginTransaction();
foreach ($this->parameters['values'] as $groupID => $optionValue) {
- $statement->execute(array(
+ $statement->execute([
$option->optionID,
$groupID,
$optionValue
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
WHERE userID = ?
AND ignoreUserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
WCF::getUser()->userID,
$ignoreUserID
- ));
+ ]);
$row = $statement->fetchArray();
- if (!$row) $row = array();
+ if (!$row) $row = [];
return new UserIgnore(null, $row);
}
}
$this->parseController();
- return LinkHandler::getInstance()->getLink($this->controller, array('application' => $this->application), $this->menuItemLink);
+ return LinkHandler::getInstance()->getLink($this->controller, ['application' => $this->application], $this->menuItemLink);
}
/**
$this->data['additionalData'] = @unserialize($this->data['additionalData']);
if (!is_array($this->data['additionalData'])) {
- $this->data['additionalData'] = array();
+ $this->data['additionalData'] = [];
}
}
AND eventID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($packageID, $eventID, $objectID));
+ $statement->execute([$packageID, $eventID, $objectID]);
$row = $statement->fetchArray();
if ($row !== false) return new UserNotification(null, $row);
AND userID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($objectTypeID, $userID, $objectID));
+ $statement->execute([$objectTypeID, $userID, $objectID]);
$row = $statement->fetch();
if (!$row) return null;
return new UserObjectWatch(null, $row);
* @return array
*/
public function manageSubscription() {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'objectType' => $this->objectType,
'userObjectWatch' => $this->userObjectWatch
- ));
+ ]);
- return array(
+ return [
'objectID' => $this->parameters['objectID'],
'template' => WCF::getTPL()->fetch('manageSubscription')
- );
+ ];
}
/**
if ($this->parameters['subscribe']) {
// newly subscribed
if ($this->userObjectWatch === null) {
- UserObjectWatchEditor::create(array(
+ UserObjectWatchEditor::create([
'notification' => ($this->parameters['enableNotification'] ? 1 : 0),
'objectID' => $this->parameters['objectID'],
'objectTypeID' => $this->objectType->objectTypeID,
'userID' => WCF::getUser()->userID
- ));
+ ]);
}
else if ($this->userObjectWatch->notification != $this->parameters['enableNotification']) {
// update notification type
$editor = new UserObjectWatchEditor($this->userObjectWatch);
- $editor->update(array(
+ $editor->update([
'notification' => ($this->parameters['enableNotification'] ? 1 : 0)
- ));
+ ]);
}
// reset user storage
- $this->objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID));
+ $this->objectType->getProcessor()->resetUserStorage([WCF::getUser()->userID]);
}
else if ($this->userObjectWatch !== null) {
// unsubscribe
$editor->delete();
// reset user storage
- $this->objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID));
+ $this->objectType->getProcessor()->resetUserStorage([WCF::getUser()->userID]);
}
- return array(
+ return [
'objectID' => $this->parameters['objectID'],
'subscribe' => $this->parameters['subscribe']
- );
+ ];
}
/**
public function subscribe() {
$objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', $this->parameters['data']['objectType']);
- UserObjectWatchEditor::create(array(
+ UserObjectWatchEditor::create([
'userID' => WCF::getUser()->userID,
'objectID' => intval($this->parameters['data']['objectID']),
'objectTypeID' => $objectType->objectTypeID,
'notification' => (!empty($this->parameters['enableNotification']) ? 1 : 0)
- ));
+ ]);
// reset user storage
- $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID));
+ $objectType->getProcessor()->resetUserStorage([WCF::getUser()->userID]);
}
/**
$editor->delete();
// reset user storage
- $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID));
+ $objectType->getProcessor()->resetUserStorage([WCF::getUser()->userID]);
}
/**
* users online stats
* @var array
*/
- public $stats = array(
+ public $stats = [
'total' => 0,
'invisible' => 0,
'members' => 0,
'guests' => 0
- );
+ ];
/**
* users online markings
$this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
$this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user_group user_group ON (user_group.groupID = user_table.userOnlineGroupID)";
- $this->getConditionBuilder()->add('session.lastActivityTime > ?', array(TIME_NOW - USER_ONLINE_TIMEOUT));
+ $this->getConditionBuilder()->add('session.lastActivityTime > ?', [TIME_NOW - USER_ONLINE_TIMEOUT]);
}
/**
parent::readObjects();
$objects = $this->objects;
- $this->indexToObject = $this->objects = array();
+ $this->indexToObject = $this->objects = [];
foreach ($objects as $object) {
$object = new UserOnline(new User(null, null, $object));
*/
public function getUsersOnlineMarkings() {
if ($this->usersOnlineMarkings === null) {
- $this->usersOnlineMarkings = $priorities = array();
+ $this->usersOnlineMarkings = $priorities = [];
// get groups
foreach (UserGroup::getGroupsByType() as $group) {
$usersOnlineTotal = (USERS_ONLINE_RECORD_NO_GUESTS ? $this->stats['members'] : $this->stats['total']);
if ($usersOnlineTotal > USERS_ONLINE_RECORD) {
// save new record
- $optionAction = new OptionAction(array(), 'import', array('data' => array(
+ $optionAction = new OptionAction([], 'import', ['data' => [
'users_online_record' => $usersOnlineTotal,
'users_online_record_time' => TIME_NOW
- )));
+ ]]);
$optionAction->executeAction();
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.user.canManageUserOption');
+ protected $permissionsCreate = ['admin.user.canManageUserOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.user.canManageUserOption');
+ protected $permissionsDelete = ['admin.user.canManageUserOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.user.canManageUserOption');
+ protected $permissionsUpdate = ['admin.user.canManageUserOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'toggle', 'update');
+ protected $requireACP = ['create', 'delete', 'toggle', 'update'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::validateDelete()
*/
public function toggle() {
foreach ($this->objects as $optionEditor) {
- $optionEditor->update(array(
+ $optionEditor->update([
'isDisabled' => 1 - $optionEditor->isDisabled
- ));
+ ]);
}
}
* list of output objects
* @var IUserOptionOutput[]
*/
- public static $outputObjects = array();
+ public static $outputObjects = [];
/**
* cached user options
* @var ViewableUserOption[]
*/
- public static $userOptions = array();
+ public static $userOptions = [];
/**
* user option value
*/
public static function getUserOption($name) {
if (!isset(self::$userOptions[$name])) {
- $options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
+ $options = UserOptionCacheBuilder::getInstance()->getData([], 'options');
self::$userOptions[$name] = new ViewableUserOption($options[$name]);
}
FROM wcf".WCF_N."_user_option_category option_category
WHERE option_category.categoryID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($categoryID));
+ $statement->execute([$categoryID]);
$row = $statement->fetchArray();
}
FROM wcf".WCF_N."_user_option_category
WHERE categoryName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($categoryName));
+ $statement->execute([$categoryName]);
$row = $statement->fetchArray();
if ($row === false) return null;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
*/
- protected $permissionsCreate = array('admin.user.canManageUserOption');
+ protected $permissionsCreate = ['admin.user.canManageUserOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.user.canManageUserOption');
+ protected $permissionsDelete = ['admin.user.canManageUserOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/
- protected $permissionsUpdate = array('admin.user.canManageUserOption');
+ protected $permissionsUpdate = ['admin.user.canManageUserOption'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('create', 'delete', 'update');
+ protected $requireACP = ['create', 'delete', 'update'];
}
throw new SystemException("'".$this->className."' does not implement 'wcf\system\menu\user\profile\content\IUserProfileMenuContent'");
}
- $this->contentManager = call_user_func(array($this->className, 'getInstance'));
+ $this->contentManager = call_user_func([$this->className, 'getInstance']);
}
return $this->contentManager;
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getContent');
+ protected $allowGuestAccess = ['getContent'];
/**
* menu item
public function getContent() {
$contentManager = $this->menuItem->getContentManager();
- return array(
+ return [
'containerID' => $this->parameters['data']['containerID'],
'template' => $contentManager->getContent($this->parameters['data']['userID'])
- );
+ ];
}
}
WHERE ownerID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($ownerID, $userID));
+ $statement->execute([$ownerID, $userID]);
if ($row = $statement->fetchArray()) {
return new UserProfileVisitor(null, $row);
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
*/
- protected $allowGuestAccess = array('getGroupedUserList');
+ protected $allowGuestAccess = ['getGroupedUserList'];
/**
* user profile object
FROM wcf".WCF_N."_user_profile_visitor
WHERE ownerID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->parameters['userID']));
+ $statement->execute([$this->parameters['userID']]);
$pageCount = ceil($statement->fetchSingleColumn() / 20);
// get user ids
WHERE ownerID = ?
ORDER BY time DESC";
$statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
- $statement->execute(array($this->parameters['userID']));
+ $statement->execute([$this->parameters['userID']]);
$userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
// create group
// load user profiles
GroupedUserList::loadUsers();
- WCF::getTPL()->assign(array(
- 'groupedUsers' => array($group)
- ));
+ WCF::getTPL()->assign([
+ 'groupedUsers' => [$group]
+ ]);
- return array(
+ return [
'pageCount' => $pageCount,
'template' => WCF::getTPL()->fetch('groupedUserList')
- );
+ ];
}
}
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
- protected $permissionsDelete = array('admin.user.rank.canManageRank');
+ protected $permissionsDelete = ['admin.user.rank.canManageRank'];
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
*/
- protected $requireACP = array('delete');
+ protected $requireACP = ['delete'];
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'captchaObjectType' => $this->captchaObjectType,
'useCaptcha' => $this->useCaptcha
- ));
+ ]);
}
/**
* additional fields
* @var mixed[]
*/
- public $additionalFields = array();
+ public $additionalFields = [];
/**
* @see \wcf\form\IForm::submit()
parent::assignVariables();
// assign default variables
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'activeTabMenuItem' => $this->activeTabMenuItem,
'errorField' => $this->errorField,
'errorType' => $this->errorType
- ));
+ ]);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'password' => $this->password,
'email' => $this->email,
'confirmEmail' => $this->confirmEmail,
'facebookDisconnect' => $this->facebookDisconnect,
'googleConnect' => $this->googleConnect,
'googleDisconnect' => $this->googleDisconnect
- ));
+ ]);
}
/**
public function save() {
parent::save();
- $success = array();
- $updateParameters = array();
+ $success = [];
+ $updateParameters = [];
// quit
if (WCF::getSession()->getPermission('user.profile.canQuit')) {
$updateParameters['reactivationCode'] = $activationCode;
$updateParameters['newEmail'] = $this->email;
- $messageData = array(
+ $messageData = [
'username' => WCF::getUser()->username,
'userID' => WCF::getUser()->userID,
'activationCode' => $activationCode
- );
+ ];
- $mail = new Mail(array(WCF::getUser()->username => $this->email), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData));
+ $mail = new Mail([WCF::getUser()->username => $this->email], WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData));
$mail->send();
$success[] = 'wcf.user.changeEmail.needReactivation';
}
$success[] = 'wcf.user.3rdparty.google.disconnect.success';
}
- $data = array();
+ $data = [];
if (!empty($updateParameters) || !empty($this->additionalFields)) {
$data['data'] = array_merge($this->additionalFields, $updateParameters);
}
- $this->objectAction = new UserAction(array(WCF::getUser()), 'update', $data);
+ $this->objectAction = new UserAction([WCF::getUser()], 'update', $data);
$this->objectAction->executeAction();
// update cookie
$this->saved();
- $success = array_merge($success, WCF::getTPL()->get('success') ?: array());
+ $success = array_merge($success, WCF::getTPL()->get('success') ?: []);
// show success message
WCF::getTPL()->assign('success', $success);
if ($this->avatarType != 'custom') {
// delete custom avatar
if (WCF::getUser()->avatarID) {
- $action = new UserAvatarAction(array(WCF::getUser()->avatarID), 'delete');
+ $action = new UserAvatarAction([WCF::getUser()->avatarID], 'delete');
$action->executeAction();
}
}
// update user
switch ($this->avatarType) {
case 'none':
- $data = array(
+ $data = [
'avatarID' => null,
'enableGravatar' => 0
- );
+ ];
break;
case 'custom':
- $data = array(
+ $data = [
'enableGravatar' => 0
- );
+ ];
break;
case 'gravatar':
- $data = array(
+ $data = [
'avatarID' => null,
'enableGravatar' => 1
- );
+ ];
break;
}
- $this->objectAction = new UserAction(array(WCF::getUser()), 'update', array(
+ $this->objectAction = new UserAction([WCF::getUser()], 'update', [
'data' => array_merge($this->additionalFields, $data)
- ));
+ ]);
$this->objectAction->executeAction();
// check if the user will be automatically added to new user groups
// because of the changed avatar
- UserGroupAssignmentHandler::getInstance()->checkUsers(array(WCF::getUser()->userID));
+ UserGroupAssignmentHandler::getInstance()->checkUsers([WCF::getUser()->userID]);
// reset gravatar cache
if ($this->avatarType == 'gravatar') {
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'avatarType' => $this->avatarType
- ));
+ ]);
}
/**
parent::save();
// enable new email
- $this->objectAction = new UserAction(array($this->user), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserAction([$this->user], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'email' => $this->user->newEmail,
'newEmail' => '',
'reactivationCode' => 0
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'u' => $this->userID,
'a' => $this->activationCode
- ));
+ ]);
}
/**
$activationCode = UserRegistrationUtil::getActivationCode();
// save user
- $this->objectAction = new UserAction(array($this->user), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserAction([$this->user], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'reactivationCode' => $activationCode
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
// send activation mail
- $messageData = array(
+ $messageData = [
'username' => $this->user->username,
'userID' => $this->user->userID,
'activationCode' => $activationCode
- );
- $mail = new Mail(array($this->user->username => $this->user->newEmail), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData));
+ ];
+ $mail = new Mail([$this->user->username => $this->user->newEmail], WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData));
$mail->send();
$this->saved();
// check whether a lost password request was sent in the last 24 hours
if ($this->user->lastLostPasswordRequestTime && TIME_NOW - 86400 < $this->user->lastLostPasswordRequestTime) {
- throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.error.tooManyRequests', array('hours' => ceil(($this->user->lastLostPasswordRequestTime - (TIME_NOW - 86400)) / 3600))));
+ throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.error.tooManyRequests', ['hours' => ceil(($this->user->lastLostPasswordRequestTime - (TIME_NOW - 86400)) / 3600)]));
}
}
$lostPasswordKey = StringUtil::getRandomID();
// save key and request time in database
- $this->objectAction = new UserAction(array($this->user), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserAction([$this->user], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'lostPasswordKey' => $lostPasswordKey,
'lastLostPasswordRequestTime' => TIME_NOW
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
// send mail
- $mail = new Mail(array($this->user->username => $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.mail', array(
+ $mail = new Mail([$this->user->username => $this->user->email], WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.mail', [
'username' => $this->user->username,
'userID' => $this->user->userID,
'key' => $lostPasswordKey
- )));
+ ]));
$mail->send();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'username' => $this->username,
'email' => $this->email
- ));
+ ]);
}
}
* list of available content languages
* @var Language[]
*/
- public $availableContentLanguages = array();
+ public $availableContentLanguages = [];
/**
* list of default smilies
* @var Smiley[]
*/
- public $defaultSmilies = array();
+ public $defaultSmilies = [];
/**
* enables bbcodes
* list of smiley categories
* @var SmileyCategory[]
*/
- public $smileyCategories = array();
+ public $smileyCategories = [];
/**
* message subject
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'attachmentHandler' => $this->attachmentHandler,
'attachmentObjectID' => $this->attachmentObjectID,
'attachmentObjectType' => $this->attachmentObjectType,
'subject' => $this->subject,
'text' => $this->text,
'tmpHash' => $this->tmpHash
- ));
+ ]);
if ($this->allowedBBCodesPermission) {
WCF::getTPL()->assign('allowedBBCodes', explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($this->allowedBBCodesPermission))));
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'disabledContent' => ModerationQueueActivationManager::getInstance()->getDisabledContent($this->queue),
'queueManager' => ModerationQueueActivationManager::getInstance()
- ));
+ ]);
}
}
parent::assignVariables();
$reportUser = UserProfile::getUserProfile($this->queue->userID);
- if ($reportUser === null) $reportUser = new UserProfile(new User(null, array()));
- WCF::getTPL()->assign(array(
+ if ($reportUser === null) $reportUser = new UserProfile(new User(null, []));
+ WCF::getTPL()->assign([
'reportedContent' => ModerationQueueReportManager::getInstance()->getReportedContent($this->queue),
'queueManager' => ModerationQueueReportManager::getInstance(),
'reportUser' => $reportUser
- ));
+ ]);
}
}
$this->newPassword = PasswordUtil::getRandomPassword((REGISTER_PASSWORD_MIN_LENGTH > 12 ? REGISTER_PASSWORD_MIN_LENGTH : 12));
// update user
- $this->objectAction = new UserAction(array($this->user), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserAction([$this->user], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'password' => $this->newPassword,
'lastLostPasswordRequestTime' => 0,
'lostPasswordKey' => ''
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
// send mail
- $mail = new Mail(array($this->user->username => $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail', array(
+ $mail = new Mail([$this->user->username => $this->user->email], WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail', [
'username' => $this->user->username,
'userID' => $this->user->userID,
'newPassword' => $this->newPassword
- )));
+ ]));
$mail->send();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'userID' => $this->userID,
'lostPasswordKey' => $this->lostPasswordKey
- ));
+ ]);
}
/**
* list of settings by event
* @var mixed[][]
*/
- public $settings = array();
+ public $settings = [];
/**
* list of valid options for the mail notification type.
* @var string[]
*/
- protected static $validMailNotificationTypes = array('none', 'instant', 'daily');
+ protected static $validMailNotificationTypes = ['none', 'instant', 'daily'];
/**
* @see \wcf\page\IPage::readParameters()
parent::validate();
// valid event ids
- $validEventIDs = array();
+ $validEventIDs = [];
foreach ($this->events as $events) {
foreach ($events as $event) {
$validEventIDs[] = $event->eventID;
// default values
if (empty($_POST)) {
// get user settings
- $eventIDs = array();
+ $eventIDs = [];
foreach ($this->events as $events) {
foreach ($events as $event) {
$eventIDs[] = $event->eventID;
- $this->settings[$event->eventID] = array(
+ $this->settings[$event->eventID] = [
'enabled' => false,
'mailNotificationType' => 'none'
- );
+ ];
}
}
FROM wcf".WCF_N."_user_notification_event_to_user
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(WCF::getUser()->userID));
+ $statement->execute([WCF::getUser()->userID]);
while ($row = $statement->fetchArray()) {
$this->settings[$row['eventID']]['enabled'] = true;
$this->settings[$row['eventID']]['mailNotificationType'] = $row['mailNotificationType'];
public function assignVariables() {
parent::assignVariables();
- $groupedEvents = array();
+ $groupedEvents = [];
foreach ($this->events as $objectType => $events) {
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.notification.objectType', $objectType);
$category = ($objectTypeObj->category ?: $objectType);
if (!isset($groupedEvents[$category])) {
- $groupedEvents[$category] = array();
+ $groupedEvents[$category] = [];
}
foreach ($events as $event) $groupedEvents[$category][] = $event;
ksort($groupedEvents);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'events' => $groupedEvents,
'settings' => $this->settings
- ));
+ ]);
}
/**
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
- $newSettings = array();
+ $newSettings = [];
foreach ($this->settings as $eventID => $setting) {
- $statement->execute(array(
+ $statement->execute([
$eventID,
WCF::getUser()->userID
- ));
+ ]);
if ($setting['enabled']) {
- $newSettings[] = array(
+ $newSettings[] = [
'eventID' => $eventID,
'mailNotificationType' => $setting['mailNotificationType']
- );
+ ];
}
}
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($newSettings as $newSetting) {
- $statement->execute(array(
+ $statement->execute([
$newSetting['eventID'],
WCF::getUser()->userID,
$newSetting['mailNotificationType']
- ));
+ ]);
}
}
WCF::getDB()->commitTransaction();
}
else {
// V2
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'recaptchaLegacyMode' => true
- ));
+ ]);
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'useCaptcha' => $this->useCaptcha
- ));
+ ]);
}
}
parent::save();
// enable user
- $this->objectAction = new UserAction(array($this->user), 'enable', array('skipNotification' => true));
+ $this->objectAction = new UserAction([$this->user], 'enable', ['skipNotification' => true]);
$this->objectAction->executeAction();
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'username' => $this->username,
'activationCode' => $this->activationCode
- ));
+ ]);
}
/**
$activationCode = UserRegistrationUtil::getActivationCode();
// save user
- $parameters = array('activationCode' => $activationCode);
+ $parameters = ['activationCode' => $activationCode];
if (!empty($this->email)) $parameters['email'] = $this->email;
- $this->objectAction = new UserAction(array($this->user), 'update', array(
+ $this->objectAction = new UserAction([$this->user], 'update', [
'data' => array_merge($this->additionalFields, $parameters)
- ));
+ ]);
$this->objectAction->executeAction();
// reload user to reflect changes
$this->user = new User($this->user->userID);
// send activation mail
- $mail = new Mail(array($this->user->username => (!empty($this->email) ? $this->email : $this->user->email)), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', array('user' => $this->user)));
+ $mail = new Mail([$this->user->username => (!empty($this->email) ? $this->email : $this->user->email)], WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', ['user' => $this->user]));
$mail->send();
$this->saved();
// forward to index page
- HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.newActivationCode.success', array('email' => (!empty($this->email) ? $this->email : $this->user->email))), 10);
+ HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.newActivationCode.success', ['email' => (!empty($this->email) ? $this->email : $this->user->email)]), 10);
exit;
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'username' => $this->username,
'password' => $this->password,
'email' => $this->email
- ));
+ ]);
}
/**
* list of additional conditions
* @var string[]
*/
- public $additionalConditions = array();
+ public $additionalConditions = [];
/**
* end date
* list of search results
* @var array
*/
- public $results = array();
+ public $results = [];
/**
* @see \wcf\page\SortablePage::$sortField
* parameters used for previous search
* @var array
*/
- public $searchData = array();
+ public $searchData = [];
/**
* search id
* selected object types
* @var string[]
*/
- public $selectedObjectTypes = array();
+ public $selectedObjectTypes = [];
/**
* start date
}
// build search hash
- $this->searchHash = StringUtil::getHash(serialize(array($this->query, $this->selectedObjectTypes, !$this->subjectOnly, $this->searchIndexCondition, $this->additionalConditions, $this->sortField.' '.$this->sortOrder, PACKAGE_ID)));
+ $this->searchHash = StringUtil::getHash(serialize([$this->query, $this->selectedObjectTypes, !$this->subjectOnly, $this->searchIndexCondition, $this->additionalConditions, $this->sortField.' '.$this->sortOrder, PACKAGE_ID]));
// check search hash
if (!empty($this->query)) {
- $parameters = array($this->searchHash, 'messages', TIME_NOW - 1800);
+ $parameters = [$this->searchHash, 'messages', TIME_NOW - 1800];
if (WCF::getUser()->userID) $parameters[] = WCF::getUser()->userID;
$sql = "SELECT searchID
$statement->execute($parameters);
$row = $statement->fetchArray();
if ($row !== false) {
- HeaderUtil::redirect(LinkHandler::getInstance()->getLink('SearchResult', array('id' => $row['searchID']), 'highlight='.urlencode($this->query)));
+ HeaderUtil::redirect(LinkHandler::getInstance()->getLink('SearchResult', ['id' => $row['searchID']], 'highlight='.urlencode($this->query)));
exit;
}
}
throw new NamedUserException(WCF::getLanguage()->get('wcf.search.error.user.noMatches'));
}
else {
- throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.search.error.noMatches', array('query' => $this->query)));
+ throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.search.error.noMatches', ['query' => $this->query]));
}
}
parent::save();
// get additional data
- $additionalData = array();
+ $additionalData = [];
foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $objectTypeName => $objectType) {
if (($data = $objectType->getAdditionalData()) !== null) {
$additionalData[$objectTypeName] = $data;
}
// save result in database
- $this->searchData = array(
+ $this->searchData = [
'packageID' => PACKAGE_ID,
'query' => $this->query,
'results' => $this->results,
'userID' => $this->userID,
'selectedObjectTypes' => $this->selectedObjectTypes,
'alterable' => (!$this->userID ? 1 : 0)
- );
+ ];
if ($this->modifySearchID) {
- $this->objectAction = new SearchAction(array($this->modifySearchID), 'update', array('data' => array(
+ $this->objectAction = new SearchAction([$this->modifySearchID], 'update', ['data' => [
'searchData' => serialize($this->searchData),
'searchTime' => TIME_NOW,
'searchType' => 'messages',
'searchHash' => $this->searchHash
- )));
+ ]]);
$this->objectAction->executeAction();
}
else {
- $this->objectAction = new SearchAction(array(), 'create', array('data' => array(
+ $this->objectAction = new SearchAction([], 'create', ['data' => [
'userID' => (WCF::getUser()->userID ?: null),
'searchData' => serialize($this->searchData),
'searchTime' => TIME_NOW,
'searchType' => 'messages',
'searchHash' => $this->searchHash
- )));
+ ]]);
$resultValues = $this->objectAction->executeAction();
$this->searchID = $resultValues['returnValues']->searchID;
}
}
// forward to result page
- HeaderUtil::redirect(LinkHandler::getInstance()->getLink('SearchResult', array(
+ HeaderUtil::redirect(LinkHandler::getInstance()->getLink('SearchResult', [
'id' => $this->searchID,
'application' => $application
- ), 'highlight='.urlencode($this->query)));
+ ], 'highlight='.urlencode($this->query)));
exit;
}
// init form
foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $objectType) $objectType->show($this);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'query' => $this->query,
'subjectOnly' => $this->subjectOnly,
'username' => $this->username,
'sortOrder' => $this->sortOrder,
'selectedObjectTypes' => $this->selectedObjectTypes,
'objectTypes' => SearchEngine::getInstance()->getAvailableObjectTypes()
- ));
+ ]);
}
/**
// user ids
if (!empty($userIDs)) {
- $this->searchIndexCondition->add('userID IN (?)', array($userIDs));
+ $this->searchIndexCondition->add('userID IN (?)', [$userIDs]);
}
// dates
$startDate = @strtotime($this->startDate);
$endDate = @strtotime($this->endDate);
if ($startDate && $endDate) {
- $this->searchIndexCondition->add('time BETWEEN ? AND ?', array($startDate, $endDate));
+ $this->searchIndexCondition->add('time BETWEEN ? AND ?', [$startDate, $endDate]);
}
else if ($startDate) {
- $this->searchIndexCondition->add('time > ?', array($startDate));
+ $this->searchIndexCondition->add('time > ?', [$startDate]);
}
else if ($endDate) {
- $this->searchIndexCondition->add('time < ?', array($endDate));
+ $this->searchIndexCondition->add('time < ?', [$endDate]);
}
// language
if (!empty($this->query) && LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
- $this->searchIndexCondition->add('(languageID IN (?) OR languageID = 0)', array(WCF::getUser()->getLanguageIDs()));
+ $this->searchIndexCondition->add('(languageID IN (?) OR languageID = 0)', [WCF::getUser()->getLanguageIDs()]);
}
foreach ($this->selectedObjectTypes as $key => $objectTypeName) {
* @return integer[]
*/
public function getUserIDs() {
- $userIDs = array();
+ $userIDs = [];
// username
if (!empty($this->username)) {
FROM wcf".WCF_N."_user
WHERE username ".($this->nameExactly ? "= ?" : "LIKE ?");
$statement = WCF::getDB()->prepareStatement($sql, 100);
- $statement->execute(array($this->username.(!$this->nameExactly ? '%' : '')));
+ $statement->execute([$this->username.(!$this->nameExactly ? '%' : '')]);
$userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (empty($userIDs)) {
/**
* @see \wcf\form\AbstractForm::$errorType
*/
- public $errorType = array();
+ public $errorType = [];
/**
* option category
* list of available content languages
* @var Language[]
*/
- public $availableContentLanguages = array();
+ public $availableContentLanguages = [];
/**
* list of available languages
* @var Language[]
*/
- public $availableLanguages = array();
+ public $availableLanguages = [];
/**
* list of available styles
* @var Style[]
*/
- public $availableStyles = array();
+ public $availableStyles = [];
/**
* list of content language ids
* @var integer[]
*/
- public $contentLanguageIDs = array();
+ public $contentLanguageIDs = [];
/**
* language id
parent::save();
$saveOptions = $this->optionHandler->save();
- $parameters = array('options' => $saveOptions);
+ $parameters = ['options' => $saveOptions];
// static options
if ($this->category == 'general') {
- $parameters['data'] = array_merge($this->additionalFields, array(
+ $parameters['data'] = array_merge($this->additionalFields, [
'languageID' => $this->languageID,
'styleID' => $this->styleID
- ));
+ ]);
$parameters['languageIDs'] = $this->contentLanguageIDs;
}
- $this->objectAction = new UserAction(array(WCF::getUser()), 'update', $parameters);
+ $this->objectAction = new UserAction([WCF::getUser()], 'update', $parameters);
$this->objectAction->executeAction();
// static options
if ($this->category == 'general') {
// reset user language ids cache
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'languageIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'languageIDs');
}
$this->saved();
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'optionTree' => $this->optionHandler->getOptionTree(),
'category' => $this->category
- ));
+ ]);
// static options
if ($this->category == 'general') {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'availableContentLanguages' => $this->availableContentLanguages,
'availableLanguages' => $this->availableLanguages,
'availableStyles' => $this->availableStyles,
'contentLanguageIDs' => $this->contentLanguageIDs,
'languageID' => $this->languageID,
'styleID' => $this->styleID
- ));
+ ]);
}
}
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_USER_SIGNATURE');
+ public $neededModules = ['MODULE_USER_SIGNATURE'];
/**
* @see \wcf\page\AbstractPage::$templateName
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'signatureCache' => $this->signatureCache
- ));
+ ]);
}
/**
public function save() {
parent::save();
- $this->objectAction = new UserAction(array(WCF::getUser()), 'update', array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserAction([WCF::getUser()], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'signature' => $this->text,
'signatureEnableBBCodes' => $this->enableBBCodes,
'signatureEnableHtml' => $this->enableHtml,
'signatureEnableSmilies' => $this->enableSmilies
- ))
- ));
+ ])
+ ]);
$this->objectAction->executeAction();
SignatureCache::getInstance()->getSignature(new User(WCF::getUser()->userID));
$this->saved();
* parsed contents of $_REQUEST['id']
* @var integer[]
*/
- public $objectIDs = array();
+ public $objectIDs = [];
/**
* list of feed-entries for the current page
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'items' => $this->items,
'title' => $this->title
- ));
+ ]);
}
/**
* needed modules to view this page
* @var string[]
*/
- public $neededModules = array();
+ public $neededModules = [];
/**
* needed permissions to view this page
* @var string[]
*/
- public $neededPermissions = array();
+ public $neededPermissions = [];
/**
* name of the template for the called page
EventHandler::getInstance()->fireAction($this, 'assignVariables');
// assign parameters
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'action' => $this->action,
'templateName' => $this->templateName
- ));
+ ]);
}
/**
* list of mime types which belong to files that are displayed inline
* @var string[]
*/
- public static $inlineMimeTypes = array('image/gif', 'image/jpeg', 'image/png', 'image/x-png', 'application/pdf', 'image/pjpeg');
+ public static $inlineMimeTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/x-png', 'application/pdf', 'image/pjpeg'];
/**
* etag for this attachment
throw new IllegalLinkException();
}
- $parameters = array('object' => $this->attachment);
+ $parameters = ['object' => $this->attachment];
if (isset($_REQUEST['tiny']) && $this->attachment->tinyThumbnailType) {
$this->tiny = intval($_REQUEST['tiny']);
$parameters['tiny'] = $this->tiny;
}
// init file reader
- $this->fileReader = new FileReader($location, array(
+ $this->fileReader = new FileReader($location, [
'filename' => $this->attachment->filename,
'mimeType' => $mimeType,
'filesize' => $filesize,
'lastModificationTime' => $this->attachment->uploadTime,
'expirationDate' => TIME_NOW + 31536000,
'maxAge' => 31536000
- ));
+ ]);
if ($this->eTag !== null) {
$this->fileReader->addHeader('ETag', '"'.$this->eTag.'"');
if (!$this->tiny && !$this->thumbnail) {
// update download count
$editor = new AttachmentEditor($this->attachment);
- $editor->update(array(
+ $editor->update([
'downloads' => $this->attachment->downloads + 1,
'lastDownloadTime' => TIME_NOW
- ));
+ ]);
}
// send file to client
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('mod.general.canUseModeration');
+ public $neededPermissions = ['mod.general.canUseModeration'];
/**
* object type object
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'availableObjectTypes' => ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.deletedContent'),
'objectType' => $this->objectType->objectType,
'resultListTemplateName' => $this->objectType->getProcessor()->getTemplateName(),
'resultListApplication' => $this->objectType->getProcessor()->getApplication()
- ));
+ ]);
}
}
protected function initObjectList() {
parent::initObjectList();
- $this->objectList->getConditionBuilder()->add("user_follow.userID = ?", array(WCF::getUser()->userID));
+ $this->objectList->getConditionBuilder()->add("user_follow.userID = ?", [WCF::getUser()->userID]);
}
/**
protected function initObjectList() {
parent::initObjectList();
- $this->objectList->getConditionBuilder()->add("user_ignore.userID = ?", array(WCF::getUser()->userID));
+ $this->objectList->getConditionBuilder()->add("user_ignore.userID = ?", [WCF::getUser()->userID]);
}
/**
* list of available definitions
* @var string[]
*/
- public $availableDefinitions = array();
+ public $availableDefinitions = [];
/**
* @see \wcf\page\SortablePage::$defaultSortField
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('mod.general.canUseModeration');
+ public $neededPermissions = ['mod.general.canUseModeration'];
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('assignedUsername', 'lastChangeTime', 'queueID', 'time', 'username', 'comments');
+ public $validSortFields = ['assignedUsername', 'lastChangeTime', 'queueID', 'time', 'username', 'comments'];
/**
* @see \wcf\page\IPage::readParameters()
parent::initObjectList();
// filter by object type id
- $objectTypeIDs = ModerationQueueManager::getInstance()->getObjectTypeIDs( ($this->definitionID ? array($this->definitionID) : array_keys($this->availableDefinitions)) );
+ $objectTypeIDs = ModerationQueueManager::getInstance()->getObjectTypeIDs( ($this->definitionID ? [$this->definitionID] : array_keys($this->availableDefinitions)) );
if (empty($objectTypeIDs)) {
// no object type ids given? screw that, display nothing
$this->objectList->getConditionBuilder()->add("0 = 1");
return;
}
- $this->objectList->getConditionBuilder()->add("moderation_queue.objectTypeID IN (?)", array($objectTypeIDs));
+ $this->objectList->getConditionBuilder()->add("moderation_queue.objectTypeID IN (?)", [$objectTypeIDs]);
// filter by assigned user id
if ($this->assignedUserID == 0) $this->objectList->getConditionBuilder()->add("moderation_queue.assignedUserID IS NULL");
- else if ($this->assignedUserID > 0) $this->objectList->getConditionBuilder()->add("moderation_queue.assignedUserID = ?", array($this->assignedUserID));
+ else if ($this->assignedUserID > 0) $this->objectList->getConditionBuilder()->add("moderation_queue.assignedUserID = ?", [$this->assignedUserID]);
// filter by status
if ($this->status == ModerationQueue::STATUS_DONE) {
- $this->objectList->getConditionBuilder()->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_DONE, ModerationQueue::STATUS_CONFIRMED, ModerationQueue::STATUS_REJECTED)));
+ $this->objectList->getConditionBuilder()->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_DONE, ModerationQueue::STATUS_CONFIRMED, ModerationQueue::STATUS_REJECTED]]);
}
else {
- $this->objectList->getConditionBuilder()->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
+ $this->objectList->getConditionBuilder()->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING]]);
}
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'assignedUserID' => $this->assignedUserID,
'availableDefinitions' => $this->availableDefinitions,
'definitionID' => $this->definitionID,
'definitionNames' => ModerationQueueManager::getInstance()->getDefinitionNamesByObjectTypeIDs(),
'status' => $this->status
- ));
+ ]);
}
}
parent::assignVariables();
// assign page parameters
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'pageNo' => $this->pageNo,
'pages' => $this->pages,
'items' => $this->items,
'startIndex' => $this->startIndex,
'endIndex' => $this->endIndex,
'objects' => $this->objectList
- ));
+ ]);
}
}
* list of outstanding notifications
* @var mixed[][]
*/
- public $notifications = array();
+ public $notifications = [];
/**
* @see \wcf\page\MultipleLinkPage::countItems()
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'notifications' => $this->notifications
- ));
+ ]);
}
/**
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_PAID_SUBSCRIPTION');
+ public $neededModules = ['MODULE_PAID_SUBSCRIPTION'];
/**
* list of available paid subscriptions
* @var array
*/
- public $subscriptions = array();
+ public $subscriptions = [];
/**
* list of user subscriptions
* @var \wcf\data\paid\subscription\user\PaidSubscriptionUserList
*/
- public $userSubscriptionList = array();
+ public $userSubscriptionList = [];
/**
* @see \wcf\page\AbstractPage::readData()
// get user subscriptions
$this->userSubscriptionList = new PaidSubscriptionUserList();
- $this->userSubscriptionList->getConditionBuilder()->add('userID = ?', array(WCF::getUser()->userID));
- $this->userSubscriptionList->getConditionBuilder()->add('isActive = ?', array(1));
+ $this->userSubscriptionList->getConditionBuilder()->add('userID = ?', [WCF::getUser()->userID]);
+ $this->userSubscriptionList->getConditionBuilder()->add('isActive = ?', [1]);
$this->userSubscriptionList->readObjects();
foreach ($this->userSubscriptionList as $userSubscription) {
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'subscriptions' => $this->subscriptions,
'userSubscriptions' => $this->userSubscriptionList
- ));
+ ]);
}
/**
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'message' => WCF::getLanguage()->get('wcf.paidSubscription.returnMessage'),
'wait' => 60,
'url' => LinkHandler::getInstance()->getLink()
- ));
+ ]);
}
}
* messages
* @var array
*/
- public $messages = array();
+ public $messages = [];
/**
* search data
* Caches the message data.
*/
protected function cacheMessageData() {
- $types = array();
+ $types = [];
// group object id by object type
for ($i = $this->startIndex - 1; $i < $this->endIndex; $i++) {
$type = $this->searchData['results'][$i]['objectType'];
$objectID = $this->searchData['results'][$i]['objectID'];
- if (!isset($types[$type])) $types[$type] = array();
+ if (!isset($types[$type])) $types[$type] = [];
$types[$type][] = $objectID;
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'query' => $this->searchData['query'],
'objects' => $this->messages,
'searchData' => $this->searchData,
'resultListTemplateName' => $this->resultListTemplateName,
'resultListApplication' => $this->resultListApplication,
'application' => ApplicationHandler::getInstance()->getAbbreviation(ApplicationHandler::getInstance()->getActiveApplication()->packageID)
- ));
+ ]);
}
/**
* list of valid sort fields
* @var string[]
*/
- public $validSortFields = array();
+ public $validSortFields = [];
/**
* @see \wcf\page\IPage::readParameters()
parent::assignVariables();
// assign sorting parameters
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'sortField' => $this->sortField,
'sortOrder' => $this->sortOrder
- ));
+ ]);
}
}
* list of available taggable object types
* @var ObjectType[]
*/
- public $availableObjectTypes = array();
+ public $availableObjectTypes = [];
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
- public $neededModules = array('MODULE_TAGGING');
+ public $neededModules = ['MODULE_TAGGING'];
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('user.tag.canViewTag');
+ public $neededPermissions = ['user.tag.canViewTag'];
/**
* tag id
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'tag' => $this->tag,
'tags' => $this->tagCloud->getTags(100),
'availableObjectTypes' => $this->availableObjectTypes,
'objectType' => $this->objectType->objectType,
'resultListTemplateName' => $this->objectType->getProcessor()->getTemplateName(),
'resultListApplication' => $this->objectType->getProcessor()->getApplication()
- ));
+ ]);
if (count($this->objectList) === 0) {
@header('HTTP/1.0 404 Not Found');
use Zend\Loader\StandardAutoloader as ZendLoader;
// set exception handler
-set_exception_handler(array('wcf\system\CLIWCF', 'handleCLIException'));
+set_exception_handler(['wcf\system\CLIWCF', 'handleCLIException']);
/**
* Extends WCF class with functions for CLI.
// register additional autoloaders
require_once(WCF_DIR.'lib/system/api/phpline/phpline.phar');
require_once(WCF_DIR.'lib/system/api/zend/Loader/StandardAutoloader.php');
- $zendLoader = new ZendLoader(array(ZendLoader::AUTOREGISTER_ZF => true));
+ $zendLoader = new ZendLoader([ZendLoader::AUTOREGISTER_ZF => true]);
$zendLoader->register();
- $argv = new ArgvParser(array(
+ $argv = new ArgvParser([
'packageID=i' => ''
- ));
+ ]);
$argv->setOption(ArgvParser::CONFIG_FREEFORM_FLAGS, true);
$argv->parse();
define('PACKAGE_ID', $argv->packageID ?: 1);
$this->initApplications();
// the destructor registered in core.functions.php will only call the destructor of the parent class
- register_shutdown_function(array('wcf\system\CLIWCF', 'destruct'));
+ register_shutdown_function(['wcf\system\CLIWCF', 'destruct']);
$this->initArgv();
$this->initPHPLine();
*/
protected function initArgv() {
// initialise ArgvParser
- self::$argvParser = new ArgvParser(array(
+ self::$argvParser = new ArgvParser([
'language=s' => WCF::getLanguage()->get('wcf.cli.help.language'),
'v' => WCF::getLanguage()->get('wcf.cli.help.v'),
'q' => WCF::getLanguage()->get('wcf.cli.help.q'),
'disableUpdateCheck' => WCF::getLanguage()->get('wcf.cli.help.disableUpdateCheck'),
'exitOnFail' => WCF::getLanguage()->get('wcf.cli.help.exitOnFail'),
'packageID=i' => WCF::getLanguage()->get('wcf.cli.help.packageID')
- ));
- self::getArgvParser()->setOptions(array(
+ ]);
+ self::getArgvParser()->setOptions([
ArgvParser::CONFIG_CUMULATIVE_FLAGS => true,
ArgvParser::CONFIG_DASHDASH => false
- ));
+ ]);
// parse arguments
EventHandler::getInstance()->fireAction($this, 'beforeArgumentParsing');
$help = WCF::getLanguage()->get('wcf.cli.help.'.self::getArgvParser()->help.'.description', true);
if ($help) echo $help.PHP_EOL;
else {
- echo WCF::getLanguage()->getDynamicVariable('wcf.cli.help.noLongHelp', array('topic' => self::getArgvParser()->help)).PHP_EOL;
+ echo WCF::getLanguage()->getDynamicVariable('wcf.cli.help.noLongHelp', ['topic' => self::getArgvParser()->help]).PHP_EOL;
}
exit;
}
// set language
$language = LanguageFactory::getInstance()->getLanguageByCode(self::getArgvParser()->language);
if ($language === null) {
- echo WCF::getLanguage()->getDynamicVariable('wcf.cli.error.language.notFound', array('languageCode' => self::getArgvParser()->language)).PHP_EOL;
+ echo WCF::getLanguage()->getDynamicVariable('wcf.cli.error.language.notFound', ['languageCode' => self::getArgvParser()->language]).PHP_EOL;
exit;
}
self::setLanguage($language->languageID);
WCF::getSession()->changeUser($user);
}
catch (UserInputException $e) {
- $message = WCF::getLanguage()->getDynamicVariable('wcf.user.'.$e->getField().'.error.'.$e->getType(), array('username' => $username));
+ $message = WCF::getLanguage()->getDynamicVariable('wcf.user.'.$e->getField().'.error.'.$e->getType(), ['username' => $username]);
self::getReader()->println($message);
exit(1);
}
$command->execute(CLICommandHandler::getParameters($line));
}
catch (IllegalLinkException $e) {
- Log::error('notFound:'.JSON::encode(array('command' => $line)));
- self::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.cli.error.command.notFound', array('command' => $line)));
+ Log::error('notFound:'.JSON::encode(['command' => $line]));
+ self::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.cli.error.command.notFound', ['command' => $line]));
if (self::getArgvParser()->exitOnFail) {
exit(1);
self::getReader()->println(count($updates) . ' update' . (count($updates) > 1 ? 's are' : ' is') . ' available');
if (VERBOSITY >= 1) {
- $table = array(
- array(
+ $table = [
+ [
WCF::getLanguage()->get('wcf.acp.package.name'),
WCF::getLanguage()->get('wcf.acp.package.version'),
WCF::getLanguage()->get('wcf.acp.package.newVersion')
- )
- );
+ ]
+ ];
foreach ($updates as $update) {
- $row = array(
+ $row = [
WCF::getLanguage()->get($update['packageName']),
$update['packageVersion'],
$update['version']['packageVersion']
- );
+ ];
$table[] = $row;
}
* list of meta tags
* @var array
*/
- protected $objects = array();
+ protected $objects = [];
/**
* @see \wcf\system\SingletonFactory::init()
$this->indexToObject[] = $identifier;
}
- $this->objects[$identifier] = array(
+ $this->objects[$identifier] = [
'isProperty' => $isProperty,
'name' => $name,
'value' => $value
- );
+ ];
// replace description if Open Graph Protocol tag was given
if ($name == 'og:description') {
* last matches
* @var array
*/
- private $matches = array();
+ private $matches = [];
/**
* Creates a regex.
* list of singletons
* @var SingletonFactory[]
*/
- protected static $__singletonObjects = array();
+ protected static $__singletonObjects = [];
/**
* Singletons do not support a public constructor. Override init() if
* list of currently loaded applications
* @var Application[]
*/
- protected static $applications = array();
+ protected static $applications = [];
/**
* list of currently loaded application objects
* @var IApplication[]
*/
- protected static $applicationObjects = array();
+ protected static $applicationObjects = [];
/**
* list of autoload directories
* @var array
*/
- protected static $autoloadDirectories = array();
+ protected static $autoloadDirectories = [];
/**
* list of unique instances of each core object
* @var SingletonFactory[]
*/
- protected static $coreObject = array();
+ protected static $coreObject = [];
/**
* list of cached core objects
* @var string[]
*/
- protected static $coreObjectCache = array();
+ protected static $coreObjectCache = [];
/**
* database object
*/
protected function initApplications() {
// step 1) load all applications
- $loadedApplications = array();
+ $loadedApplications = [];
// register WCF as application
self::$applications['wcf'] = ApplicationHandler::getInstance()->getApplicationByID(1);
}
// init application and assign it as template variable
- self::$applicationObjects[$application->packageID] = call_user_func(array($className, 'getInstance'));
+ self::$applicationObjects[$application->packageID] = call_user_func([$className, 'getInstance']);
$this->getTPL()->assign('__'.$abbreviation, self::$applicationObjects[$application->packageID]);
}
else {
* Assigns some default variables to the template engine.
*/
protected function assignDefaultTemplateVariables() {
- self::getTPL()->registerPrefilter(array('event', 'hascontent', 'lang'));
- self::getTPL()->assign(array(
+ self::getTPL()->registerPrefilter(['event', 'hascontent', 'lang']);
+ self::getTPL()->assign([
'__wcf' => $this,
'__wcfVersion' => LAST_UPDATE_TIME // @deprecated since 2.1, use LAST_UPDATE_TIME directly
- ));
+ ]);
}
/**
throw new SystemException("class '".$objectName."' does not implement the interface 'SingletonFactory'");
}
- self::$coreObject[$className] = call_user_func(array($objectName, 'getInstance'));
+ self::$coreObject[$className] = call_user_func([$objectName, 'getInstance']);
return self::$coreObject[$className];
}
}
// work-around for AJAX-requests within ACP
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
try {
- WCF::getSession()->checkPermissions(array('admin.general.canUseAcp'));
+ WCF::getSession()->checkPermissions(['admin.general.canUseAcp']);
}
catch (PermissionDeniedException $e) {
throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS, $e->getTraceAsString());
}
}
else {
- WCF::getSession()->checkPermissions(array('admin.general.canUseAcp'));
+ WCF::getSession()->checkPermissions(['admin.general.canUseAcp']);
}
// force debug mode if in ACP and authenticated
$host = RouteHandler::getHost();
$path = RouteHandler::getPath();
- self::getTPL()->assign(array(
+ self::getTPL()->assign([
'baseHref' => $host . $path
- ));
+ ]);
}
/**
* list of available object types
* @var array
*/
- protected $availableObjectTypes = array();
+ protected $availableObjectTypes = [];
/**
* list of acl option categories sorted by their object type id and name
* @var ACLOptionCategory[][]
*/
- protected $categories = array();
+ protected $categories = [];
/**
* Assignes the acl values to the template.
*/
public function assignVariables($objectTypeID) {
if (WCF::getTPL()->get('aclValues') === null) {
- WCF::getTPL()->assign('aclValues', array());
+ WCF::getTPL()->assign('aclValues', []);
}
if (!$this->assignVariablesDisabled && isset($_POST['aclValues'])) {
$values = $_POST['aclValues'];
- $data = $this->getPermissions($objectTypeID, array(), null, true);
+ $data = $this->getPermissions($objectTypeID, [], null, true);
foreach ($values as $type => $optionData) {
if ($type === 'user') {
$users = User::getUsers(array_keys($optionData));
}
- $values[$type] = array(
- 'label' => array(),
- 'option' => array()
- );
+ $values[$type] = [
+ 'label' => [],
+ 'option' => []
+ ];
foreach ($optionData as $typeID => $optionValues) {
foreach ($optionValues as $optionID => $optionValue) {
$values['options'] = $data['options'];
$values['categories'] = $data['categories'];
- WCF::getTPL()->append('aclValues', array(
+ WCF::getTPL()->append('aclValues', [
$objectTypeID => $values
- ));
+ ]);
}
}
// remove previous values
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("optionID IN (?)", array(array_keys($options)));
- $conditions->add("objectID = ?", array($objectID));
+ $conditions->add("optionID IN (?)", [array_keys($options)]);
+ $conditions->add("objectID = ?", [$objectID]);
$sql = "DELETE FROM wcf".WCF_N."_acl_option_to_".$type."
".$conditions;
continue;
}
- $statement->execute(array(
+ $statement->execute([
$optionID,
$objectID,
$typeID,
$optionValue
- ));
+ ]);
}
}
WCF::getDB()->commitTransaction();
public function getPermissions($objectTypeID, array $objectIDs, $categoryName = '', $settingsView = false) {
$optionList = $this->getOptions($objectTypeID, $categoryName);
- $data = array(
+ $data = [
'options' => $optionList,
- 'group' => array(),
- 'user' => array()
- );
+ 'group' => [],
+ 'user' => []
+ ];
if (!empty($objectIDs)) {
$this->getValues($optionList, 'group', $objectIDs, $data, $settingsView);
if ($settingsView) {
$objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
- $data['options'] = array();
- $data['categories'] = array();
+ $data['options'] = [];
+ $data['categories'] = [];
if (count($optionList)) {
- $categoryNames = array();
+ $categoryNames = [];
foreach ($optionList as $option) {
- $data['options'][$option->optionID] = array(
+ $data['options'][$option->optionID] = [
'categoryName' => $option->categoryName,
'label' => WCF::getLanguage()->get('wcf.acl.option.'.$objectType->objectType.'.'.$option->optionName),
'optionName' => $option->optionName
- );
+ ];
if (!in_array($option->categoryName, $categoryNames)) {
$categoryNames[] = $option->categoryName;
// load categories
$categoryList = new ACLOptionCategoryList();
- $categoryList->getConditionBuilder()->add("acl_option_category.categoryName IN (?)", array($categoryNames));
- $categoryList->getConditionBuilder()->add("acl_option_category.objectTypeID = ?", array($objectTypeID));
+ $categoryList->getConditionBuilder()->add("acl_option_category.categoryName IN (?)", [$categoryNames]);
+ $categoryList->getConditionBuilder()->add("acl_option_category.objectTypeID = ?", [$objectTypeID]);
$categoryList->readObjects();
foreach ($categoryList as $category) {
* @param boolean $settingsView
*/
protected function getValues(ACLOptionList $optionList, $type, array $objectIDs, array &$data, $settingsView) {
- $data[$type] = array();
- $optionsIDs = array();
+ $data[$type] = [];
+ $optionsIDs = [];
foreach ($optionList as $option) {
$optionsIDs[] = $option->optionID;
}
$columnID = $type.'ID';
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("optionID IN (?)", array($optionsIDs));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("optionID IN (?)", [$optionsIDs]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "SELECT *
FROM wcf".WCF_N."_acl_option_to_".$type."
".$conditions;
$statement->execute($conditions->getParameters());
while ($row = $statement->fetchArray()) {
if (!isset($data[$type][$row['objectID']])) {
- $data[$type][$row['objectID']] = array();
+ $data[$type][$row['objectID']] = [];
}
if (!isset($data[$type][$row['objectID']][$row[$columnID]])) {
- $data[$type][$row['objectID']][$row[$columnID]] = array();
+ $data[$type][$row['objectID']][$row[$columnID]] = [];
}
$data[$type][$row['objectID']][$row[$columnID]][$row['optionID']] = $row['optionValue'];
if ($settingsView) {
$objectID = current($objectIDs);
if (!isset($data[$type][$objectID])) {
- $data[$type][$objectID] = array();
+ $data[$type][$objectID] = [];
}
// build JS-compilant structure
- $data[$type] = array(
- 'label' => array(),
+ $data[$type] = [
+ 'label' => [],
'option' => $data[$type][$objectID]
- );
+ ];
// load labels
if (!empty($data[$type]['option'])) {
$conditions = new PreparedStatementConditionBuilder();
if ($type == 'group') {
- $conditions->add("groupID IN (?)", array(array_keys($data[$type]['option'])));
+ $conditions->add("groupID IN (?)", [array_keys($data[$type]['option'])]);
$sql = "SELECT groupID, groupName
FROM wcf".WCF_N."_user_group
".$conditions;
}
}
else {
- $conditions->add("userID IN (?)", array(array_keys($data[$type]['option'])));
+ $conditions->add("userID IN (?)", [array_keys($data[$type]['option'])]);
$sql = "SELECT userID, username
FROM wcf".WCF_N."_user
".$conditions;
if (!empty($categoryName)) {
if (StringUtil::endsWith($categoryName, '.*')) {
$categoryName = mb_substr($categoryName, 0, -1) . '%';
- $optionList->getConditionBuilder()->add("acl_option.categoryName LIKE ?", array($categoryName));
+ $optionList->getConditionBuilder()->add("acl_option.categoryName LIKE ?", [$categoryName]);
}
else {
- $optionList->getConditionBuilder()->add("acl_option.categoryName = ?", array($categoryName));
+ $optionList->getConditionBuilder()->add("acl_option.categoryName = ?", [$categoryName]);
}
}
- $optionList->getConditionBuilder()->add("acl_option.objectTypeID = ?", array($objectTypeID));
+ $optionList->getConditionBuilder()->add("acl_option.objectTypeID = ?", [$objectTypeID]);
$optionList->readObjects();
return $optionList;
$options = $optionList->getObjects();
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("optionID IN (?)", array(array_keys($options)));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("optionID IN (?)", [array_keys($options)]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
WCF::getDB()->beginTransaction();
- foreach (array('group', 'user') as $type) {
+ foreach (['group', 'user'] as $type) {
$sql = "DELETE FROM wcf".WCF_N."_acl_option_to_".$type."
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
* list of ad objects grouped by ad location
* @var array
*/
- protected $ads = array();
+ protected $ads = [];
/**
* list of ad location object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* Returns the ad output for the given ad location.
return $this->objectTypes;
}
- $objectTypes = array();
+ $objectTypes = [];
foreach ($this->objectTypes as $key => $objectType) {
if ($objectType->categoryname == $categoryName) {
$objectTypes[$key] = $objectType;
}
}
- $selection = array();
+ $selection = [];
foreach ($objectTypes as $objectType) {
$categoryName = WCF::getLanguage()->get('wcf.acp.ad.location.category.'.$objectType->categoryname);
if (!isset($selection[$categoryName])) {
- $selection[$categoryName] = array();
+ $selection[$categoryName] = [];
}
$selection[$categoryName][$objectType->objectTypeID] = WCF::getLanguage()->get('wcf.acp.ad.location.'.$objectType->objectType);
ksort($selection);
- $selection = array_merge(array(
+ $selection = array_merge([
$globalCategory => $globalLocations
- ), $selection);
+ ], $selection);
return $selection;
}
* @see \wcf\system\application\IApplication::__callStatic()
*/
public static function __callStatic($method, array $arguments) {
- return call_user_func_array(array('wcf\system\WCF', $method), $arguments);
+ return call_user_func_array(['wcf\system\WCF', $method], $arguments);
}
}
* cached objects
* @var DatabaseObject[]
*/
- protected $cachedObjects = array();
+ protected $cachedObjects = [];
/**
* @see \wcf\system\attachment\IAttachmentObjectType::getMaxSize()
*/
public function setPermissions(array $attachments) {
foreach ($attachments as $attachment) {
- $attachment->setPermissions(array(
+ $attachment->setPermissions([
'canDownload' => $this->canDownload($attachment->objectID),
'canViewPreview' => $this->canViewPreview($attachment->objectID)
- ));
+ ]);
}
}
}
if ($this->attachmentList === null) {
$this->attachmentList = new AttachmentList();
$this->attachmentList->sqlOrderBy = 'attachment.showOrder';
- $this->attachmentList->getConditionBuilder()->add('objectTypeID = ?', array($this->objectType->objectTypeID));
+ $this->attachmentList->getConditionBuilder()->add('objectTypeID = ?', [$this->objectType->objectTypeID]);
if ($this->objectID) {
- $this->attachmentList->getConditionBuilder()->add('objectID = ?', array($this->objectID));
+ $this->attachmentList->getConditionBuilder()->add('objectID = ?', [$this->objectID]);
}
else {
- $this->attachmentList->getConditionBuilder()->add('tmpHash = ?', array($this->tmpHash));
+ $this->attachmentList->getConditionBuilder()->add('tmpHash = ?', [$this->tmpHash]);
}
$this->attachmentList->readObjects();
}
WHERE objectTypeID = ?
AND tmpHash = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($objectID, $this->objectType->objectTypeID, $this->tmpHash));
+ $statement->execute([$objectID, $this->objectType->objectTypeID, $this->tmpHash]);
}
/**
*/
public static function transferAttachments($objectType, $newObjectID, array $oldObjectIDs) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array(ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType)->objectTypeID));
- $conditions->add("objectID IN (?)", array($oldObjectIDs));
+ $conditions->add("objectTypeID = ?", [ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType)->objectTypeID]);
+ $conditions->add("objectID IN (?)", [$oldObjectIDs]);
$parameters = $conditions->getParameters();
array_unshift($parameters, $newObjectID);
*/
public static function removeAttachments($objectType, array $objectIDs) {
$attachmentList = new AttachmentList();
- $attachmentList->getConditionBuilder()->add("objectTypeID = ?", array(ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType)->objectTypeID));
- $attachmentList->getConditionBuilder()->add("objectID IN (?)", array($objectIDs));
+ $attachmentList->getConditionBuilder()->add("objectTypeID = ?", [ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType)->objectTypeID]);
+ $attachmentList->getConditionBuilder()->add("objectID IN (?)", [$objectIDs]);
$attachmentList->readObjects();
if (count($attachmentList)) {
$class = 'messageFloatObject'.ucfirst($alignment);
}
- $source = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment)));
+ $source = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', ['object' => $attachment]));
$title = StringUtil::encodeHTML($attachment->filename);
$result = '<a href="' . $source . '" title="' . $title . '" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' '.$class : '') . '"><img src="' . $source . '" style="width: '.$width.'px" alt="" /></a>';
}
else {
- $linkParameters = array(
+ $linkParameters = [
'object' => $attachment
- );
+ ];
if ($attachment->hasThumbnail()) $linkParameters['thumbnail'] = 1;
$class = '';
$result = '<img src="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)).'"'.($imageClasses ? ' class="'.$imageClasses.'"' : '').' style="width: '.($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width).'px; height: '.($attachment->hasThumbnail() ? $attachment->thumbnailHeight : $attachment->height).'px;" alt="" />';
if ($attachment->hasThumbnail() && $attachment->canDownload()) {
- $result = '<a href="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))).'" title="'.StringUtil::encodeHTML($attachment->filename).'" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' '.$class : '') . '">'.$result.'</a>';
+ $result = '<a href="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', ['object' => $attachment])).'" title="'.StringUtil::encodeHTML($attachment->filename).'" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' '.$class : '') . '">'.$result.'</a>';
}
}
}
else {
// file
- return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', array(
+ return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', [
'object' => $attachment
- )), ((!empty($content) && $content != $attachmentID) ? $content : $attachment->filename));
+ ]), ((!empty($content) && $content != $attachmentID) ? $content : $attachment->filename));
}
}
// fallback
- return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', array(
+ return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', [
'id' => $attachmentID
- )));
+ ]));
}
/**
* list of BBCodes allowed for usage
* @var BBCode[]
*/
- protected $allowedBBCodes = array();
+ protected $allowedBBCodes = [];
/**
* list of BBCodes displayed as buttons
* @var BBCode[]
*/
- protected $buttonBBCodes = array();
+ protected $buttonBBCodes = [];
/**
* list of BBCodes which contain raw code (disabled BBCode parsing)
* @return BBCode[]
*/
public function getButtonBBCodes() {
- $buttons = array();
+ $buttons = [];
foreach ($this->buttonBBCodes as $bbcode) {
if ($this->isAvailableBBCode($bbcode->bbcodeTag)) {
$buttons[] = $bbcode;
*/
public function getSourceBBCodes() {
if (empty($this->allowedBBCodes)) {
- return array();
+ return [];
}
if ($this->sourceBBCodes === null) {
- $this->sourceBBCodes = array();
+ $this->sourceBBCodes = [];
foreach (BBCodeCache::getInstance()->getBBCodes() as $bbcode) {
if (!$bbcode->isSourceCode) {
* list of bbcodes
* @var BBCode[]
*/
- protected $bbcodes = array();
+ protected $bbcodes = [];
/**
* output type
* tag array
* @var array
*/
- protected $tagArray = array();
+ protected $tagArray = [];
/**
* text array
* @var array
*/
- protected $textArray = array();
+ protected $textArray = [];
/**
* regular expression for source code tags
$this->bbcodes = BBCodeCache::getInstance()->getBBCodes();
// handle source codes
- $sourceCodeTags = array();
+ $sourceCodeTags = [];
foreach ($this->bbcodes as $bbcode) {
if ($bbcode->isSourceCode) $sourceCodeTags[] = $bbcode->bbcodeTag;
}
*/
public function buildXMLStructure() {
// stack for open tags
- $openTagStack = $openTagDataStack = array();
- $newTagArray = array();
- $newTextArray = array();
+ $openTagStack = $openTagDataStack = [];
+ $newTagArray = [];
+ $newTextArray = [];
$i = -1;
foreach ($this->tagArray as $i => $tag) {
// closing tag
if (in_array($tag['name'], $openTagStack) && $this->isAllowed($openTagStack, $tag['name'], true)) {
// close unclosed tags
- $tmpOpenTags = array();
+ $tmpOpenTags = [];
while (($previousTag = end($openTagStack)) != $tag['name']) {
$nextIndex = count($newTagArray);
$newTagArray[$nextIndex] = $this->buildTag('[/'.$previousTag.']');
}
foreach ($this->bbcodes[$tag['name']]->getAttributes() as $attribute) {
- if (!$this->isValidTagAttribute((isset($tag['attributes']) ? $tag['attributes'] : array()), $attribute)) {
+ if (!$this->isValidTagAttribute((isset($tag['attributes']) ? $tag['attributes'] : []), $attribute)) {
return false;
}
}
$arguments = explode('^', $this->bbcodes[$openTag]->allowedChildren);
if (!empty($arguments[1])) $tags = explode(',', $arguments[1]);
- else $tags = array();
+ else $tags = [];
if ($arguments[0] == 'none' && !in_array($tag, $tags)) return false;
if ($arguments[0] == 'all' && in_array($tag, $tags)) return false;
$buffer =& $this->parsedText;
// stack of buffered tags
- $bufferedTagStack = array();
+ $bufferedTagStack = [];
// loop through the tags
$i = -1;
* @return array bbcode tag data
*/
protected function buildTag($string) {
- $tag = array('name' => '', 'closing' => false, 'source' => $string);
+ $tag = ['name' => '', 'closing' => false, 'source' => $string];
if (mb_substr($string, 1, 1) == '/') {
// closing tag
public function validateBBCodes($text, array $allowedBBCodes) {
// if all BBCodes are allowed, return directly
if (in_array('all', $allowedBBCodes)) {
- return array();
+ return [];
}
$this->setText($text);
$this->buildTagArray(false);
$this->buildXMLStructure();
- $usedDisallowedBBCodes = array();
+ $usedDisallowedBBCodes = [];
foreach ($this->tagArray as $tag) {
if (!in_array($tag['name'], $allowedBBCodes) && !isset($usedDisallowedBBCodes[$tag['name']])) {
$usedDisallowedBBCodes[$tag['name']] = $tag['name'];
* already used ids for line numbers to prevent duplicate ids in the output
* @var string[]
*/
- private static $codeIDs = array();
+ private static $codeIDs = [];
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
$highlightedContent = self::fixMarkup(explode("\n", $className::getInstance()->highlight($content)));
// show template
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'lineNumbers' => self::makeLineNumbers($content, $this->startLineNumber),
'startLineNumber' => $this->startLineNumber,
'content' => $highlightedContent,
'highlighter' => $className::getInstance(),
'filename' => $this->filename,
'lines' => substr_count($content, "\n") + 1
- ));
+ ]);
return WCF::getTPL()->fetch('codeBBCodeTag');
}
else if ($parser->getOutputType() == 'text/simplified-html') {
- return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.code.text', array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.code.text', [
'highlighterTitle' => $className::getInstance()->getTitle(),
'lines' => substr_count($content, "\n") + 1
- ));
+ ]);
}
}
protected static function makeLineNumbers($code, $start, $split = "\n") {
$lines = explode($split, $code);
- $lineNumbers = array();
+ $lineNumbers = [];
$i = -1;
// find an unused codeID
do {
$emptyTagRegex = new Regex('<span(?: class="(?:[^"])*")?></span>');
}
- $openTags = array();
+ $openTags = [];
foreach ($lines as &$line) {
$spanRegex->match($line, true);
// open all tags again
$buffer =& $this->parsedText;
// stack of buffered tags
- $bufferedTagStack = array();
+ $bufferedTagStack = [];
// loop through the tags
$i = -1;
* search keywords
* @var string[]
*/
- protected $keywords = array();
+ protected $keywords = [];
/**
* search query parameters
* @var string[]
*/
- protected static $searchQueryKeys = array(
+ protected static $searchQueryKeys = [
'q', // google, msn, altavista
'p', // yahoo
'query', // lycos, fireball
//'k',
//'t',
'va'
- );
+ ];
/**
* @see \wcf\system\SingletonFactory::init()
$keywordString = StringUtil::trim(mb_substr($keywordString, 1, -1));
if (!empty($keywordString)) {
- $this->keywords = array_merge($this->keywords, array(StringUtil::encodeHTML($keywordString)));
+ $this->keywords = array_merge($this->keywords, [StringUtil::encodeHTML($keywordString)]);
}
}
else {
// replace word delimiters by space
- $keywordString = str_replace(array('.', ','), ' ', $keywordString);
+ $keywordString = str_replace(['.', ','], ' ', $keywordString);
$keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
if (!empty($keywords)) {
* list of smilies
* @var Smiley[]
*/
- protected $smilies = array();
+ protected $smilies = [];
/**
* cached bbcodes
* @var array
*/
- protected $cachedCodes = array();
+ protected $cachedCodes = [];
/**
* currently parsed message
* @return string parsed message
*/
public function parse($message, $enableSmilies = true, $enableHtml = false, $enableBBCodes = true, $doKeywordHighlighting = true) {
- $this->cachedCodes = array();
+ $this->cachedCodes = [];
$this->message = $message;
// call event
}
// replace bad html tags (script etc.)
- $badSearch = array('/(javascript):/i', '/(about):/i', '/(vbscript):/i');
- $badReplace = array('$1<b></b>:', '$1<b></b>:', '$1<b></b>:');
+ $badSearch = ['/(javascript):/i', '/(about):/i', '/(vbscript):/i'];
+ $badReplace = ['$1<b></b>:', '$1<b></b>:', '$1<b></b>:'];
$this->message = preg_replace($badSearch, $badReplace, $this->message);
// call event
(?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*))*
)?\])
(.*?)
- (?:\[/\\2\])~six", array($this, 'cacheCodesCallback'), $text);
+ (?:\[/\\2\])~six", [$this, 'cacheCodesCallback'], $text);
}
return $text;
}
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
- $sourceCodeTags = array();
+ $sourceCodeTags = [];
foreach (BBCodeCache::getInstance()->getBBCodes() as $bbcode) {
if ($bbcode->isSourceCode) $sourceCodeTags[] = $bbcode->bbcodeTag;
}
$matches = $userRegex->getMatches();
if (!empty($matches)) {
- $usernames = array();
+ $usernames = [];
foreach ($matches as $match) {
// we don't care about the full match
array_shift($match);
if (!empty($usernames)) {
// fetch users
$userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.username IN (?)', array($usernames));
+ $userList->getConditionBuilder()->add('user_table.username IN (?)', [$usernames]);
$userList->readObjects();
- $users = array();
+ $users = [];
foreach ($userList as $user) {
$users[mb_strtolower($user->username)] = $user;
}
$text = $userRegex->replace($text, new Callback(function ($matches) use ($users) {
// containing the full match
- $usernames = array($matches[1]);
+ $usernames = [$matches[1]];
// containing only the part before the first space
if (isset($matches[2])) $usernames[] = $matches[2];
- $usernames = array_map(array(PreParser::class, 'getUsername'), $usernames);
+ $usernames = array_map([PreParser::class, 'getUsername'], $usernames);
foreach ($usernames as $username) {
if (!isset($users[$username])) continue;
- $link = LinkHandler::getInstance()->getLink('User', array(
+ $link = LinkHandler::getInstance()->getLink('User', [
'appendSession' => false,
'object' => $users[$username]
- ));
+ ]);
$mention = "[url='".$link."']@".$users[$username]->username.'[/url]';
}
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'content' => $content,
'quoteLink' => $quoteLink,
'quoteAuthor' => $quoteAuthor,
'quoteAuthorObject' => $quoteAuthorObject,
'isExternalQuoteLink' => $externalQuoteLink
- ));
+ ]);
return WCF::getTPL()->fetch('quoteBBCodeTag');
}
else if ($parser->getOutputType() == 'text/simplified-html') {
- return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.text', array('content' => $content, 'cite' => (!empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')))."\n";
+ return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.text', ['content' => $content, 'cite' => (!empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')])."\n";
}
}
}
* list of smilies
* @var Smiley[]
*/
- protected $smilies = array();
+ protected $smilies = [];
/**
* cached URLs
* @var string[]
*/
- protected $cachedURLs = array();
+ protected $cachedURLs = [];
/**
* cached e-mails
* @var string[]
*/
- protected $cachedEmails = array();
+ protected $cachedEmails = [];
/**
* currently parsed message
*/
public function parse($message, $parseURLs = true, $parseSmilies = true) {
$this->message = $message;
- $this->cachedURLs = $this->cachedEmails = array();
+ $this->cachedURLs = $this->cachedEmails = [];
// call event
EventHandler::getInstance()->fireAction($this, 'beforeParsing');
}
// replace bad html tags (script etc.)
- $badSearch = array('/(javascript):/i', '/(about):/i', '/(vbscript):/i');
- $badReplace = array('$1<b></b>:', '$1<b></b>:', '$1<b></b>:');
+ $badSearch = ['/(javascript):/i', '/(about):/i', '/(vbscript):/i'];
+ $badReplace = ['$1<b></b>:', '$1<b></b>:', '$1<b></b>:'];
$this->message = preg_replace($badSearch, $badReplace, $this->message);
// call event
~ix';
// parse urls
- $text = preg_replace_callback($urlPattern, array($this, 'cacheURLsCallback'), $text);
+ $text = preg_replace_callback($urlPattern, [$this, 'cacheURLsCallback'], $text);
// parse emails
if (mb_strpos($text, '@') !== false) {
- $text = preg_replace_callback($emailPattern, array($this, 'cacheEmailsCallback'), $text);
+ $text = preg_replace_callback($emailPattern, [$this, 'cacheEmailsCallback'], $text);
}
return $text;
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) {
if ($parser->getOutputType() == 'text/html') {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'content' => $content,
'buttonTitle' => (!empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')
- ));
+ ]);
return WCF::getTPL()->fetch('spoilerBBCodeTag');
}
if ($parser->getOutputType() == 'text/simplified-html') {
if ($regex->match($parsedContent, true)) {
$matches = $regex->getMatches();
- $openTags = array();
+ $openTags = [];
$openTDs = 0;
$firstRowTDs = 0;
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array(';', '=');
+ protected $separators = [';', '='];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$quotes
*/
- protected $quotes = array('"', "'", '`');
+ protected $quotes = ['"', "'", '`'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array('#');
+ protected $singleLineComment = ['#'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentStart
*/
- protected $commentStart = array();
+ protected $commentStart = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentEnd
*/
- protected $commentEnd = array();
+ protected $commentEnd = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array('||', '&&', '&', '|', '<<=', '>>=', '<<', '+=', '-=', '*=', '/=', '%=',
+ protected $operators = ['||', '&&', '&', '|', '<<=', '>>=', '<<', '+=', '-=', '*=', '/=', '%=',
'-gt', '-lt', '-n', '-a', '-o',
- '+', '-', '*', '/', '%', '<', '?', ':', '==', '!=', '=', '!', '>', '2>', '>>');
+ '+', '-', '*', '/', '%', '<', '?', ':', '==', '!=', '=', '!', '>', '2>', '>>'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
'true',
'false'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'if',
'then',
'else',
'case',
'in',
'esac'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords3
*/
- protected $keywords3 = array(
+ protected $keywords3 = [
'echo',
'exit',
'unset',
'sed',
'grep',
'awk'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords4
*/
- protected $keywords4 = array(
+ protected $keywords4 = [
'$?'
- );
+ ];
}
$string = preg_replace('/[\\.,]+/', '<span class="hlKeywords2">\\0</span>', $string);
$string = preg_replace('/[\\[\\]]+/', '<span class="hlKeywords3">\\0</span>', $string);
- $string = str_replace(array('||span class="hlComments"||', '||/span||'), array('<span class="hlComments">', '</span>'), $string);
+ $string = str_replace(['||span class="hlComments"||', '||/span||'], ['<span class="hlComments">', '</span>'], $string);
return $string;
}
}
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array('(', ')', '{', '}', '[', ']', ';', '.', ',');
+ protected $separators = ['(', ')', '{', '}', '[', ']', ';', '.', ','];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array('=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=',
+ protected $operators = ['=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=',
'&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', '<<', '>>', '>>>', '+=', '-=', '*=',
- '/=', '&=', '|=', '^=', '%=', '<<=', '>>=', '>>>=');
+ '/=', '&=', '|=', '^=', '%=', '<<=', '>>=', '>>>='];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
'and',
'and_eq',
'asm',
'while',
'xor',
'xor_eq'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'auto',
'bool',
'char',
'void',
'volatile',
'wchar_t'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords3
*/
- protected $keywords3 = array(
+ protected $keywords3 = [
'#include',
'#define',
'#if',
'#else',
'#ifdef',
'#endif'
- );
+ ];
}
* temporary string replacement map for properties that can also be tags
* @var string[]
*/
- public static $duplicates = array(
+ public static $duplicates = [
'table:' => 't@@able:',
'caption:' => 'c@@aption:',
'menu:' => 'm@@enu:',
'sub:' => 's@@ub:',
'pre:' => 'p@@re:',
'small:' => 's@@mall:'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::highlightNumbers()
public function highlight($string) {
$string = str_replace('span', '053a0024219422ca9215c0a3ed0578ee76cff477', $string); // fix to not highlight the spans of the highlighter
$string = str_replace(':link', ':li@@nk', $string); // fix to highlight pseudo-class different than tag
- $string = str_replace(array('right:', 'left:'), array('r@@ight:', 'l@@eft:'), $string); // fix to highlight properties different than values
+ $string = str_replace(['right:', 'left:'], ['r@@ight:', 'l@@eft:'], $string); // fix to highlight properties different than values
$string = strtr($string, self::$duplicates); // fix to highlight properties different than tags
$string = parent::highlight($string);
$string = strtr($string, array_flip(self::$duplicates)); // fix to highlight properties different than tags
- $string = str_replace(array('r@@ight', 'l@@eft'), array('right', 'left'), $string); // fix to highlight properties different than values
+ $string = str_replace(['r@@ight', 'l@@eft'], ['right', 'left'], $string); // fix to highlight properties different than values
$string = str_replace('li@@nk', 'link', $string); // fix to highlight pseudo-class different than tag
return str_replace('053a0024219422ca9215c0a3ed0578ee76cff477', 'span', $string); // fix to not highlight the spans of the highlighter
}
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array('//');
+ protected $singleLineComment = ['//'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array('(', ')', '{', '}', ';', '[', ']', ':', ',', '.');
+ protected $separators = ['(', ')', '{', '}', ';', '[', ']', ':', ',', '.'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
'azimuth',
'background',
'background-attachment',
'!important',
'@import',
'@media'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'left-side',
'far-left',
'left',
'hsla',
'rgb',
'rgba'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords3
*/
- protected $keywords3 = array(
+ protected $keywords3 = [
'active',
'after',
'before',
'root',
'target',
'visited'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords4
*/
- protected $keywords4 = array(
+ protected $keywords4 = [
'abbr',
'acronym',
'address',
'var',
'video',
'wbr'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords5
*/
- public $keywords5 = array(
+ public $keywords5 = [
// modifying
'darken',
'lighten',
'true',
// others
'&'
- );
+ ];
}
* normal diffs
* @var string[]
*/
- protected $add = array("+", ">");
+ protected $add = ["+", ">"];
/**
* keywords for an deleted line, the - is used in unified diff, the < in
* normal diffs
* @var string[]
*/
- protected $delete = array("-", "<");
+ protected $delete = ["-", "<"];
/**
* splitter in changes for normal diff
* @var string[]
*/
- protected $splitter = array("---");
+ protected $splitter = ["---"];
/**
* keywords for the line info, the @ is used in unified diffs, the numbers
* in normal diffs
* @var string[]
*/
- protected $info = array("@", '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
+ protected $info = ["@", '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::highlight()
* comment end delimiter
* @var string[]
*/
- protected $commentEnd = array("*/");
+ protected $commentEnd = ["*/"];
/**
* comment start delimiter
* @var string[]
*/
- protected $commentStart = array("/*");
+ protected $commentStart = ["/*"];
/**
* escape sequence
* @var string[]
*/
- protected $escapeSequence = array("\\");
+ protected $escapeSequence = ["\\"];
/**
* categorized keywords
* @var string[]
*/
- protected $keywords1 = array();
+ protected $keywords1 = [];
/**
* categorized keywords
* @var string[]
*/
- protected $keywords2 = array();
+ protected $keywords2 = [];
/**
* categorized keywords
* @var string[]
*/
- protected $keywords3 = array();
+ protected $keywords3 = [];
/**
* categorized keywords
* @var string[]
*/
- protected $keywords4 = array();
+ protected $keywords4 = [];
/**
* categorized keywords
* @var string[]
*/
- protected $keywords5 = array();
+ protected $keywords5 = [];
/**
* list of arithmetic operators
* @var string[]
*/
- protected $operators = array();
+ protected $operators = [];
/**
* list of quote marks
* @var string[]
*/
- protected $quotes = array("'", '"');
+ protected $quotes = ["'", '"'];
/**
* list of separator sequences
* @var string[]
*/
- protected $separators = array();
+ protected $separators = [];
/**
* inline comment sequence
* @var string[]
*/
- protected $singleLineComment = array("//");
+ protected $singleLineComment = ["//"];
/**
* regular expression to extract comments
$quotesRegEx = '';
foreach ($this->quotes as $quote) {
if ($quotesRegEx !== '') $quotesRegEx .= '|';
- if (!is_array($quote)) $quote = array($quote, $quote);
+ if (!is_array($quote)) $quote = [$quote, $quote];
list($opening, $closing) = $quote;
$opening = preg_quote($opening);
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array("(", ")", "{", "}", "[", "]", ";", ".", ",", "<", ">");
+ protected $separators = ["(", ")", "{", "}", "[", "]", ";", ".", ",", "<", ">"];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'package',
'abstract',
'break',
'static',
'void',
'import'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords3
*/
- protected $keywords3 = array(
+ protected $keywords3 = [
'Boolean',
'Float',
'Character',
'HashMap',
'List',
'ArrayList'
- );
+ ];
}
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array("(", ")", "{", "}", "[", "]", ";", ".", ",");
+ protected $separators = ["(", ")", "{", "}", "[", "]", ";", ".", ","];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array("=", ">", "<", "!", "~", "?", ":", "==", "<=", ">=", "!=",
+ protected $operators = ["=", ">", "<", "!", "~", "?", ":", "==", "<=", ">=", "!=",
"&&", "||", "++", "--", "+", "-", "*", "/", "&", "|", "^", "%", "<<", ">>", ">>>", "+=", "-=", "*=",
- "/=", "&=", "|=", "^=", "%=", "<<=", ">>=", ">>>=");
+ "/=", "&=", "|=", "^=", "%=", "<<=", ">>=", ">>>="];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
"String",
"Array",
"RegExp",
"onSelect",
"onSubmit",
"onUnload"
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
"break",
"continue",
"do",
"true",
"try",
"volatile"
- );
+ ];
}
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array('(', ')', '{', '}', '[', ']', ';', '.', ',');
+ protected $separators = ['(', ')', '{', '}', '[', ']', ';', '.', ','];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array('#');
+ protected $singleLineComment = ['#'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentStart
*/
- protected $commentStart = array();
+ protected $commentStart = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentEnd
*/
- protected $commentEnd = array();
+ protected $commentEnd = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array('.=', '=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=',
+ protected $operators = ['.=', '=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=',
'&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', '<<', '>>', '>>>', '+=', '-=', '*=',
- '/=', '&=', '|=', '^=', '%=', '<<=', '>>=', '>>>=', '->', '::');
+ '/=', '&=', '|=', '^=', '%=', '<<=', '>>=', '>>>=', '->', '::'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
'print',
'sprintf',
'length',
'crypt',
'pack',
'unpack'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'case',
'do',
'while',
'until',
'break',
'exit'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords3
*/
- protected $keywords3 = array(
+ protected $keywords3 = [
'use',
'import',
'require',
'sub'
- );
+ ];
}
* @category Community Framework
*/
class PhpHighlighter extends Highlighter {
- public static $colorToClass = array();
+ public static $colorToClass = [];
/**
* @see \wcf\system\SingletonFactory::init()
protected function init() {
parent::init();
- $types = array('default' => 'hlKeywords1', 'keyword' => 'hlKeywords2', 'comment' => 'hlComments', 'string' => 'hlQuotes');
+ $types = ['default' => 'hlKeywords1', 'keyword' => 'hlKeywords2', 'comment' => 'hlComments', 'string' => 'hlQuotes'];
self::$colorToClass['<span style="color: '.ini_get('highlight.html').'">'] = '<span>';
foreach ($types as $type => $class) {
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array('(', ')',/* from __future__ import braces '{', '}', */'[', ']', ';', '.', ',', ':');
+ protected $separators = ['(', ')',/* from __future__ import braces '{', '}', */'[', ']', ';', '.', ',', ':'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array('#');
+ protected $singleLineComment = ['#'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentStart
*/
- protected $commentStart = array();
+ protected $commentStart = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentEnd
*/
- protected $commentEnd = array();
+ protected $commentEnd = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array('+=', '-=', '**=', '*=', '//=', '/=', '%=', '~=', '+', '-', '**', '*', '//', '/', '%',
- '&=', '<<=', '>>=', '^=', '~', '&', '^', '|', '<<', '>>', '=', '!=', '<', '>', '<=', '>=');
+ protected $operators = ['+=', '-=', '**=', '*=', '//=', '/=', '%=', '~=', '+', '-', '**', '*', '//', '/', '%',
+ '&=', '<<=', '>>=', '^=', '~', '&', '^', '|', '<<', '>>', '=', '!=', '<', '>', '<=', '>='];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$quotes
*/
- protected $quotes = array(array("r'", "'"), array("u'", "'"), array('r"', '"'), array('u"', '"'), "'", '"');
+ protected $quotes = [["r'", "'"], ["u'", "'"], ['r"', '"'], ['u"', '"'], "'", '"'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
'print',
'del',
'str',
'continue',
'break',
'return'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'if',
'elif',
'else',
'for',
'in',
'while'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords3
*/
- protected $keywords3 = array(
+ protected $keywords3 = [
'from',
'import',
'as',
'class',
'def'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords4
*/
- protected $keywords4 = array(
+ protected $keywords4 = [
'__name__',
'__init__',
'__str__',
'or',
'not',
'is'
- );
+ ];
}
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$quotes
*/
- protected $quotes = array("'", '"');
+ protected $quotes = ["'", '"'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array('#', '--');
+ protected $singleLineComment = ['#', '--'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array('(', ')', ',', ';');
+ protected $separators = ['(', ')', ',', ';'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array('<>', '~=', '!=', '^=', '=', '<', '<=', '>', '>=', '*', '/', '+', '-', '||', '@', '%', '&', '?', '\$');
+ protected $operators = ['<>', '~=', '!=', '^=', '=', '<', '<=', '>', '>=', '*', '/', '+', '-', '||', '@', '%', '&', '?', '\$'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::cacheComments()
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords1
*/
- protected $keywords1 = array(
+ protected $keywords1 = [
'action',
'add',
'aggregate',
'year',
'year_month',
'zerofill'
- );
+ ];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$keywords2
*/
- protected $keywords2 = array(
+ protected $keywords2 = [
'ABS',
'ACOS',
'ADDDATE',
'WEEK',
'WEEKDAY',
'YEAR'
- );
+ ];
}
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$quotes
*/
- protected $quotes = array();
+ protected $quotes = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array('%');
+ protected $singleLineComment = ['%'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::highlightKeywords()
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$quotes
*/
- protected $quotes = array('"');
+ protected $quotes = ['"'];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$singleLineComment
*/
- protected $singleLineComment = array();
+ protected $singleLineComment = [];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentStart
*/
- protected $commentStart = array("<!--");
+ protected $commentStart = ["<!--"];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$commentEnd
*/
- protected $commentEnd = array("-->");
+ protected $commentEnd = ["-->"];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$separators
*/
- protected $separators = array("<", ">");
+ protected $separators = ["<", ">"];
/**
* @see \wcf\system\bbcode\highlighter\Highlighter::$operators
*/
- protected $operators = array();
+ protected $operators = [];
const XML_ATTRIBUTE_NAME = '[a-z0-9](?:(?:(?<!-)-)?[a-z0-9])*';
* benchmark items
* @var array
*/
- protected $items = array();
+ protected $items = [];
/**
* number of executed sql queries
// load box layout for active page
$boxList = new BoxList();
- if ($pageID) $boxList->getConditionBuilder()->add('(box.visibleEverywhere = ? AND boxID NOT IN (SELECT boxID FROM wcf'.WCF_N.'_box_to_page WHERE pageID = ? AND visible = ?)) OR boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_to_page WHERE pageID = ? AND visible = ?)', array(1, $pageID, 0, $pageID, 1));
- else $boxList->getConditionBuilder()->add('box.visibleEverywhere = ?', array(1));
+ if ($pageID) $boxList->getConditionBuilder()->add('(box.visibleEverywhere = ? AND boxID NOT IN (SELECT boxID FROM wcf'.WCF_N.'_box_to_page WHERE pageID = ? AND visible = ?)) OR boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_to_page WHERE pageID = ? AND visible = ?)', [1, $pageID, 0, $pageID, 1]);
+ else $boxList->getConditionBuilder()->add('box.visibleEverywhere = ?', [1]);
$boxList->sqlOrderBy = 'showOrder';
$boxList->readObjects();
foreach ($boxList as $box) {
* @inheritDoc
*/
protected function loadContent() {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'statistics' => UserStatsCacheBuilder::getInstance()->getData()
- ));
+ ]);
$this->content = WCF::getTPL()->fetch('boxStatistics');
}
$userList = parent::getObjectList();
// deny self deletion
- $userList->getConditionBuilder()->add('user_table.userID <> ?', array(WCF::getUser()->userID));
+ $userList->getConditionBuilder()->add('user_table.userID <> ?', [WCF::getUser()->userID]);
return $userList;
}
// the active user may not remove themselves from any user group
// to avoid potential permission issues
- $userList->getConditionBuilder()->add('user_table.userID <> ?', array(WCF::getUser()->userID));
+ $userList->getConditionBuilder()->add('user_table.userID <> ?', [WCF::getUser()->userID]);
return $userList;
}
if (count($objectList)) {
// save config in session
$userMailData = WCF::getSession()->getVar('userMailData');
- if ($userMailData === null) $userMailData = array();
+ if ($userMailData === null) $userMailData = [];
$this->mailID = count($userMailData);
- $userMailData[$this->mailID] = array(
+ $userMailData[$this->mailID] = [
'action' => '',
'enableHTML' => $this->enableHTML,
'from' => $this->from,
'subject' => $this->subject,
'text' => $this->text,
'userIDs' => $objectList->getObjectIDs()
- );
+ ];
WCF::getSession()->register('userMailData', $userMailData);
}
}
* @param array $parameters
* @return string
*/
- protected function getCacheName(ICacheBuilder $cacheBuilder, array $parameters = array()) {
+ protected function getCacheName(ICacheBuilder $cacheBuilder, array $parameters = []) {
$className = explode('\\', get_class($cacheBuilder));
$application = array_shift($className);
$cacheName = str_replace('CacheBuilder', '', array_pop($className));
$list = new ACLOptionCategoryList();
$list->readObjects();
- $data = array();
+ $data = [];
foreach ($list as $aclOptionCategory) {
if (!isset($data[$aclOptionCategory->objectTypeID])) {
- $data[$aclOptionCategory->objectTypeID] = array();
+ $data[$aclOptionCategory->objectTypeID] = [];
}
$data[$aclOptionCategory->objectTypeID][$aclOptionCategory->categoryName] = $aclOptionCategory;
* list of option categories which directly contain options
* @var string[]
*/
- protected $categoriesWithOptions = array();
+ protected $categoriesWithOptions = [];
/**
* list of option categories grouped by the name of their parent category
* @var OptionCategory[]
*/
- protected $categoryStructure = array();
+ protected $categoryStructure = [];
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array();
+ $data = [];
// get "real" menu items
$menuItemList = new ACPMenuItemList();
}
// get menu items for top option categories
- $data['wcf.acp.menu.link.option.category'] = array();
+ $data['wcf.acp.menu.link.option.category'] = [];
foreach ($this->getTopOptionCategories() as $optionCategory) {
- $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array(
+ $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, [
'menuItem' => 'wcf.acp.option.category.'.$optionCategory->categoryName,
'parentMenuItem' => 'wcf.acp.menu.link.option.category',
'menuItemController' => 'wcf\acp\form\OptionForm',
'permissions' => $optionCategory->permissions,
'optionCategoryID' => $optionCategory->categoryID,
'options' => $optionCategory->options
- ));
+ ]);
}
return $data;
$optionCategories = $optionCategoryList->getObjects();
// build category structure
- $this->categoryStructure = array();
+ $this->categoryStructure = [];
foreach ($optionCategories as $optionCategory) {
if (!isset($this->categoryStructure[$optionCategory->parentCategoryName])) {
- $this->categoryStructure[$optionCategory->parentCategoryName] = array();
+ $this->categoryStructure[$optionCategory->parentCategoryName] = [];
}
$this->categoryStructure[$optionCategory->parentCategoryName][] = $optionCategory;
}
// collect top categories which contain options
- $topCategories = array();
+ $topCategories = [];
foreach ($this->categoryStructure[""] as $topCategory) {
if ($this->containsOptions($topCategory)) {
$topCategories[$topCategory->categoryID] = $topCategory;
* list of cache resources by index
* @var mixed[][]
*/
- protected $cache = array();
+ protected $cache = [];
/**
* maximum cache lifetime in seconds, '0' equals infinite
/**
* @inheritDoc
*/
- public function getData(array $parameters = array(), $arrayIndex = '') {
+ public function getData(array $parameters = [], $arrayIndex = '') {
$index = CacheHandler::getInstance()->getCacheIndex($parameters);
if (!isset($this->cache[$index])) {
/**
* @inheritDoc
*/
- public function reset(array $parameters = array()) {
+ public function reset(array $parameters = []) {
CacheHandler::getInstance()->flush($this, $parameters);
}
*/
public function rebuild(array $parameters) {
$adList = new AdList();
- $adList->getConditionBuilder()->add('isDisabled = ?', array(0));
+ $adList->getConditionBuilder()->add('isDisabled = ?', [0]);
$adList->sqlOrderBy = 'showOrder ASC';
$adList->readObjects();
- $data = array();
+ $data = [];
foreach ($adList as $ad) {
if (!isset($data[$ad->objectTypeID])) {
- $data[$ad->objectTypeID] = array();
+ $data[$ad->objectTypeID] = [];
}
$data[$ad->objectTypeID][$ad->adID] = $ad;
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters) {
- $attributes = array();
- $data = array('bbcodes' => array(), 'highlighters' => array());
+ $attributes = [];
+ $data = ['bbcodes' => [], 'highlighters' => []];
// get attributes
$sql = "SELECT attribute.*, bbcode.bbcodeTag
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
while ($row = $statement->fetchArray()) {
- if (!isset($attributes[$row['bbcodeTag']])) $attributes[$row['bbcodeTag']] = array();
+ if (!isset($attributes[$row['bbcodeTag']])) $attributes[$row['bbcodeTag']] = [];
$attributes[$row['bbcodeTag']][$row['attributeNo']] = new BBCodeAttribute(null, $row);
}
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
while ($row = $statement->fetchArray()) {
- $row['attributes'] = (isset($attributes[$row['bbcodeTag']]) ? $attributes[$row['bbcodeTag']] : array());
+ $row['attributes'] = (isset($attributes[$row['bbcodeTag']]) ? $attributes[$row['bbcodeTag']] : []);
$data['bbcodes'][$row['bbcodeTag']] = new BBCode(null, $row);
}
*/
public function rebuild(array $parameters) {
$questionList = new CaptchaQuestionList();
- $questionList->getConditionBuilder()->add('isDisabled = ?', array(0));
+ $questionList->getConditionBuilder()->add('isDisabled = ?', [0]);
$questionList->readObjects();
return $questionList->getObjects();
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array();
+ $data = [];
foreach (CategoryHandler::getInstance()->getCategories() as $objectTypeName => $categories) {
$objectType = CategoryHandler::getInstance()->getObjectTypeByName($objectTypeName);
$aclObjectType = $objectType->getProcessor()->getObjectTypeName('com.woltlab.wcf.acl');
$aclOptions = ACLHandler::getInstance()->getPermissions(ACLHandler::getInstance()->getObjectTypeID($aclObjectType), array_keys($categories));
$options = $aclOptions['options']->getObjects();
- foreach (array('group', 'user') as $type) {
+ foreach (['group', 'user'] as $type) {
foreach ($aclOptions[$type] as $categoryID => $optionData) {
if (!isset($data[$categoryID])) {
- $data[$categoryID] = array(
- 'group' => array(),
- 'user' => array()
- );
+ $data[$categoryID] = [
+ 'group' => [],
+ 'user' => []
+ ];
}
foreach ($optionData as $typeID => $optionValues) {
- $data[$categoryID][$type][$typeID] = array();
+ $data[$categoryID][$type][$typeID] = [];
foreach ($optionValues as $optionID => $optionValue) {
$data[$categoryID][$type][$typeID][$options[$optionID]->optionName] = $optionValue;
$list->sqlOrderBy = "category.showOrder ASC";
$list->readObjects();
- $data = array(
+ $data = [
'categories' => $list->getObjects(),
- 'objectTypeCategoryIDs' => array()
- );
+ 'objectTypeCategoryIDs' => []
+ ];
foreach ($list as $category) {
if (!isset($data['objectTypeCategoryIDs'][$category->objectType])) {
- $data['objectTypeCategoryIDs'][$category->objectType] = array();
+ $data['objectTypeCategoryIDs'][$category->objectType] = [];
}
$data['objectTypeCategoryIDs'][$category->objectType][] = $category->categoryID;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $data = array();
+ $data = [];
while ($row = $statement->fetchArray()) {
if (!isset($data[$row['pageClassName']])) {
- $data[$row['pageClassName']] = array();
+ $data[$row['pageClassName']] = [];
}
$data[$row['pageClassName']][] = $row['actionID'];
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes($definition->definitionName);
if (empty($objectTypes)) {
- return array();
+ return [];
}
- $objectTypeIDs = array();
+ $objectTypeIDs = [];
foreach ($objectTypes as $objectType) {
$objectTypeIDs[] = $objectType->objectTypeID;
}
$conditionList = new ConditionList();
- $conditionList->getConditionBuilder()->add('condition_table.objectTypeID IN (?)', array($objectTypeIDs));
+ $conditionList->getConditionBuilder()->add('condition_table.objectTypeID IN (?)', [$objectTypeIDs]);
$conditionList->readObjects();
- $groupedConditions = array();
+ $groupedConditions = [];
foreach ($conditionList as $condition) {
if (!isset($groupedConditions[$condition->objectID])) {
- $groupedConditions[$condition->objectID] = array();
+ $groupedConditions[$condition->objectID] = [];
}
$groupedConditions[$condition->objectID][$condition->conditionID] = $condition;
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array();
+ $data = [];
$coreObjectList = new CoreObjectList();
$coreObjectList->readObjects();
FROM wcf".WCF_N."_cronjob
WHERE isDisabled = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(0));
+ $statement->execute([0]);
$row = $statement->fetchArray();
- return array(
+ return [
'afterNextExec' => $row['afterNextExec'],
'nextExec' => $row['nextExec']
- );
+ ];
}
}
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $actions = array(
- 'admin' => array(),
- 'user' => array()
- );
+ $actions = [
+ 'admin' => [],
+ 'user' => []
+ ];
- $inheritedActions = array(
- 'admin' => array(),
- 'user' => array()
- );
+ $inheritedActions = [
+ 'admin' => [],
+ 'user' => []
+ ];
$sql = "SELECT *
FROM wcf".WCF_N."_event_listener
if (!$eventListener->inherit) {
if (!isset($actions[$eventListener->environment])) {
- $actions[$eventListener->environment] = array();
+ $actions[$eventListener->environment] = [];
}
foreach ($eventNames as $eventName) {
$key = EventHandler::generateKey($eventListener->eventClassName, $eventName);
if (!isset($actions[$eventListener->environment][$key])) {
- $actions[$eventListener->environment][$key] = array();
+ $actions[$eventListener->environment][$key] = [];
}
$actions[$eventListener->environment][$key][] = $eventListener;
}
else {
if (!isset($inheritedActions[$eventListener->environment])) {
- $inheritedActions[$eventListener->environment] = array();
+ $inheritedActions[$eventListener->environment] = [];
}
foreach ($eventNames as $eventName) {
if (!isset($inheritedActions[$eventListener->environment][$eventListener->eventClassName])) {
- $inheritedActions[$eventListener->environment][$eventListener->eventClassName] = array();
+ $inheritedActions[$eventListener->environment][$eventListener->eventClassName] = [];
}
$inheritedActions[$eventListener->environment][$eventListener->eventClassName][$eventName][] = $eventListener;
}
}
- return array(
+ return [
'actions' => $actions,
'inheritedActions' => $inheritedActions
- );
+ ];
}
}
* @param string $arrayIndex
* @return mixed
*/
- public function getData(array $parameters = array(), $arrayIndex = '');
+ public function getData(array $parameters = [], $arrayIndex = '');
/**
* Returns maximum lifetime for cache resource.
*
* @param array $parameters
*/
- public function reset(array $parameters = array());
+ public function reset(array $parameters = []);
}
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array(
- 'codes' => array(),
- 'countryCodes' => array(),
- 'languages' => array(),
+ $data = [
+ 'codes' => [],
+ 'countryCodes' => [],
+ 'languages' => [],
'default' => 0,
- 'categories' => array(),
- 'categoryIDs' => array(),
+ 'categories' => [],
+ 'categoryIDs' => [],
'multilingualismEnabled' => false
- );
+ ];
// get languages
$languageList = new LanguageList();
*/
protected function rebuild(array $parameters) {
$noticeList = new NoticeList();
- $noticeList->getConditionBuilder()->add('isDisabled = ?', array(0));
+ $noticeList->getConditionBuilder()->add('isDisabled = ?', [0]);
$noticeList->sqlOrderBy = 'showOrder ASC';
$noticeList->readObjects();
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array(
- 'categories' => array(),
- 'definitions' => array(),
- 'objectTypes' => array(),
- 'groupedObjectTypes' => array()
- );
+ $data = [
+ 'categories' => [],
+ 'definitions' => [],
+ 'objectTypes' => [],
+ 'groupedObjectTypes' => []
+ ];
// get definitions
$sql = "SELECT *
if ($row['categoryName']) {
if (!isset($data['categories'][$row['categoryName']])) {
- $data['categories'][$row['categoryName']] = array();
+ $data['categories'][$row['categoryName']] = [];
}
$data['categories'][$row['categoryName']][] = $row['definitionID'];
$data['objectTypes'][$row['objectTypeID']] = $objectType = new ObjectType(null, $row);
$definition = $data['definitions'][$objectType->definitionID];
- if (!isset($data['groupedObjectTypes'][$definition->definitionName])) $data['groupedObjectTypes'][$definition->definitionName] = array();
+ if (!isset($data['groupedObjectTypes'][$definition->definitionName])) $data['groupedObjectTypes'][$definition->definitionName] = [];
$data['groupedObjectTypes'][$definition->definitionName][$objectType->objectType] = $objectType;
}
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array(
- 'packages' => array(),
- 'packageIDs' => array()
- );
+ $data = [
+ 'packages' => [],
+ 'packageIDs' => []
+ ];
$packageList = new PackageList();
$packageList->readObjects();
public function rebuild(array $parameters) {
$updates = PackageUpdateDispatcher::getInstance()->getAvailableUpdates();
- return array('updates' => count($updates));
+ return ['updates' => count($updates)];
}
}
*/
protected function rebuild(array $parameters) {
$subscriptionList = new PaidSubscriptionList();
- $subscriptionList->getConditionBuilder()->add('isDisabled = ?', array(0));
+ $subscriptionList->getConditionBuilder()->add('isDisabled = ?', [0]);
$subscriptionList->sqlOrderBy = 'showOrder';
$subscriptionList->readObjects();
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters) {
- $data = array('smilies' => array());
+ $data = ['smilies' => []];
// get smilies
$sql = "SELECT *
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array(
+ $data = [
'default' => 0,
- 'styles' => array()
- );
+ 'styles' => []
+ ];
// get all styles
$sql = "SELECT *
* list of tags
* @var TagCloudTag[]
*/
- protected $tags = array();
+ protected $tags = [];
/**
* language ids
* @var integer
*/
- protected $languageIDs = array();
+ protected $languageIDs = [];
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::$maxLifetime
* object type ids
* @var integer
*/
- protected $objectTypeIDs = array();
+ protected $objectTypeIDs = [];
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
// handle special '0' value
if (in_array(0, $parameters)) {
// discard all language ids
- $parameters = array();
+ $parameters = [];
}
return $parameters;
* Reads associated tags.
*/
protected function getTags() {
- $this->tags = array();
+ $this->tags = [];
if (!empty($this->objectTypeIDs)) {
// get tag ids
- $tagIDs = array();
+ $tagIDs = [];
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('object.objectTypeID IN (?)', array($this->objectTypeIDs));
- $conditionBuilder->add('object.languageID IN (?)', array($this->languageIDs));
+ $conditionBuilder->add('object.objectTypeID IN (?)', [$this->objectTypeIDs]);
+ $conditionBuilder->add('object.languageID IN (?)', [$this->languageIDs]);
$sql = "SELECT COUNT(*) AS counter, object.tagID
FROM wcf".WCF_N."_tag_to_object object
".$conditionBuilder."
}
// sort by counter
- uasort($this->tags, array('self', 'compareTags'));
+ uasort($this->tags, ['self', 'compareTags']);
}
}
}
public function rebuild(array $parameters) {
// get templates for current package id
$templateListenerList = new TemplateListenerList();
- $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($parameters['environment']));
+ $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", [$parameters['environment']]);
$templateListenerList->sqlOrderBy = "template_listener.listenerID ASC";
$templateListenerList->readObjects();
- $data = array();
+ $data = [];
foreach ($templateListenerList->getObjects() as $templateListener) {
- $data[$templateListener->templateName] = array();
+ $data[$templateListener->templateName] = [];
}
return $data;
public function rebuild(array $parameters) {
// get template codes for specified template
$templateListenerList = new TemplateListenerList();
- $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($parameters['environment']));
+ $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", [$parameters['environment']]);
$templateListenerList->sqlOrderBy = 'template_listener.niceValue ASC, template_listener.listenerID ASC';
$templateListenerList->readObjects();
- $data = array();
+ $data = [];
foreach ($templateListenerList->getObjects() as $templateListener) {
if (!isset($data[$templateListener->templateName])) {
- $data[$templateListener->templateName] = array();
+ $data[$templateListener->templateName] = [];
}
$templateCode = $templateListener->templateCode;
$userOptionID = User::getUserOptionID('birthday');
if ($userOptionID === null) {
// birthday profile field missing; skip
- return array();
+ return [];
}
- $data = array();
+ $data = [];
$birthday = 'userOption'.$userOptionID;
$sql = "SELECT userID, ".$birthday."
FROM wcf".WCF_N."_user_option_value
WHERE ".$birthday." LIKE ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('%-' . ($parameters['month'] < 10 ? '0' : '') . $parameters['month'] . '-%'));
+ $statement->execute(['%-' . ($parameters['month'] < 10 ? '0' : '') . $parameters['month'] . '-%']);
while ($row = $statement->fetchArray()) {
list($year, $month, $day) = explode('-', $row[$birthday]);
- if (!isset($data[$month . '-' . $day])) $data[$month . '-' . $day] = array();
+ if (!isset($data[$month . '-' . $day])) $data[$month . '-' . $day] = [];
$data[$month . '-' . $day][] = $row['userID'];
}
*/
protected function rebuild(array $parameters) {
$assignmentList = new UserGroupAssignmentList();
- $assignmentList->getConditionBuilder()->add('isDisabled = ?', array(0));
+ $assignmentList->getConditionBuilder()->add('isDisabled = ?', [0]);
$assignmentList->readObjects();
return $assignmentList->getObjects();
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
public function rebuild(array $parameters) {
- $data = array(
- 'types' => array(),
- 'groups' => array()
- );
+ $data = [
+ 'types' => [],
+ 'groups' => []
+ ];
// get all user groups
$groupList = new UserGroupList();
foreach ($groups as $group) {
if (!isset($data['types'][$group->groupType])) {
- $data['types'][$group->groupType] = array();
+ $data['types'][$group->groupType] = [];
}
$data['types'][$group->groupType][] = $group->groupID;
public function rebuild(array $parameters) {
$data = parent::rebuild($parameters);
- $usersOnlyPermissions = array();
+ $usersOnlyPermissions = [];
foreach ($data['options'] as $option) {
if ($option->usersOnly) {
$usersOnlyPermissions[] = $option->optionName;
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters) {
- $data = array();
+ $data = [];
// get all option categories
$sql = "SELECT *
WHERE parentCategoryName = ?
ORDER BY showOrder ASC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('settings'));
+ $statement->execute(['settings']);
while ($row = $statement->fetchArray()) {
if (!isset($data['wcf.user.menu.settings'])) {
- $data['wcf.user.menu.settings'] = array();
+ $data['wcf.user.menu.settings'] = [];
}
$categoryShortName = str_replace('settings.', '', $row['categoryName']);
- $data['wcf.user.menu.settings'][] = new UserMenuItem(null, array(
+ $data['wcf.user.menu.settings'][] = new UserMenuItem(null, [
'packageID' => $row['packageID'],
'menuItem' => 'wcf.user.option.category.'.$row['categoryName'],
'parentMenuItem' => 'wcf.user.menu.settings',
'menuItemLink' => ($categoryShortName != 'general' ? 'category='.$categoryShortName : ''),
'permissions' => $row['permissions'],
'options' => $row['options']
- ));
+ ]);
}
// get all menu items
$statement->execute();
while ($row = $statement->fetchArray()) {
if (!isset($data[$row['parentMenuItem']])) {
- $data[$row['parentMenuItem']] = array();
+ $data[$row['parentMenuItem']] = [];
}
$data[$row['parentMenuItem']][] = new UserMenuItem(null, $row);
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters) {
- $data = array();
+ $data = [];
// get events
$sql = "SELECT event.*, object_type.objectType
$statement->execute();
while ($row = $statement->fetchArray()) {
if (!isset($data[$row['objectType']])) {
- $data[$row['objectType']] = array();
+ $data[$row['objectType']] = [];
}
if (!isset($data[$row['objectType']][$row['eventName']])) {
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters) {
- $data = array();
+ $data = [];
// number of members
$sql = "SELECT COUNT(*) AS amount
// add servers
$tmp = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHED_HOST));
- $servers = array();
+ $servers = [];
$defaultWeight = floor(100 / count($tmp));
$regex = new Regex('^\[([a-z0-9\:\.]+)\](?::([0-9]{1,5}))?(?::([0-9]{1,3}))?$', Regex::CASE_INSENSITIVE);
}
}
- $servers[] = array($host, $port, $weight);
+ $servers[] = [$host, $port, $weight];
}
}
$this->memcached->addServers($servers);
* @return string[]
*/
public function getCaptchaSelection() {
- $selection = array();
+ $selection = [];
foreach ($this->objectTypes as $objectType) {
if ($objectType->getProcessor()->isAvailable()) {
$selection[$objectType->objectType] = WCF::getLanguage()->get('wcf.captcha.'.$objectType->objectType);
}
else {
// V2
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'recaptchaLegacyMode' => true
- ));
+ ]);
}
return WCF::getTPL()->fetch('recaptcha');
* key is the definition name and value the object type name)
* @var string[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* @see \wcf\system\category\ICategoryType::afterDeletion()
if (!empty($categoryIDs)) {
// move child categories to parent category
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("categoryID IN (?)", array($categoryIDs));
+ $conditionBuilder->add("categoryID IN (?)", [$categoryIDs]);
$sql = "UPDATE wcf".WCF_N."_category
SET parentCategoryID = ?
".$conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($categoryEditor->parentCategoryID), $conditionBuilder->getParameters()));
+ $statement->execute(array_merge([$categoryEditor->parentCategoryID], $conditionBuilder->getParameters()));
}
}
* cached categories
* @var Category[]
*/
- protected $categories = array();
+ protected $categories = [];
/**
* category ids grouped by the object type they belong to
* @var integer[][]
*/
- protected $objectTypeCategoryIDs = array();
+ protected $objectTypeCategoryIDs = [];
/**
* mapes the names of the category object types to the object type ids
* @var integer[]
*/
- protected $objectTypeIDs = array();
+ protected $objectTypeIDs = [];
/**
* list of category object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* Returns all category objects with the given object type. If no object
* @return mixed[]
*/
public function getCategories($objectType = null) {
- $categories = array();
+ $categories = [];
if ($objectType === null) {
foreach ($this->objectTypes as $objectType) {
$categories[$objectType->objectType] = $this->getCategories($objectType->objectType);
throw new SystemException("Missing object type id");
}
- $categories = array();
+ $categories = [];
foreach ($this->categories as $category) {
if ($category->parentCategoryID == $categoryID && ($categoryID || $category->objectTypeID == $objectTypeID)) {
$categories[$category->categoryID] = $category;
$this->objectTypeIDs[$objectType->objectTypeID] = $objectType->objectType;
}
- $this->categories = CategoryCacheBuilder::getInstance()->getData(array(), 'categories');
- $this->objectTypeCategoryIDs = CategoryCacheBuilder::getInstance()->getData(array(), 'objectTypeCategoryIDs');
+ $this->categories = CategoryCacheBuilder::getInstance()->getData([], 'categories');
+ $this->objectTypeCategoryIDs = CategoryCacheBuilder::getInstance()->getData([], 'objectTypeCategoryIDs');
}
/**
$sql = "DELETE FROM wcf".WCF_N."_cli_history
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(WCF::getUser()->userID));
+ $statement->execute([WCF::getUser()->userID]);
}
$sql = "INSERT INTO wcf".WCF_N."_cli_history (userID, command)
WCF::getDB()->beginTransaction();
foreach ($this as $item) {
- $statement->execute(array(WCF::getUser()->userID, $item));
+ $statement->execute([WCF::getUser()->userID, $item]);
}
WCF::getDB()->commitTransaction();
}
FROM wcf".WCF_N."_cli_history
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(WCF::getUser()->userID));
+ $statement->execute([WCF::getUser()->userID]);
while ($row = $statement->fetchArray()) {
$this->add($row['command']);
* list of all available commands
* @var ICLICommand[]
*/
- private static $commands = array();
+ private static $commands = [];
/**
* Returns all available commands.
$tmp = '';
$escaped = false;
$quoted = false;
- $return = array();
+ $return = [];
// handle quotes
foreach ($chars as $char) {
// escaped chars are simply added
* names of all available commands
* @var string[]
*/
- private $commands = array();
+ private $commands = [];
/**
* Creates a new instance of CLICommandNameCompleter.
* Initializes the argument parser.
*/
public function __construct() {
- $this->argv = new ArgvParser(array());
+ $this->argv = new ArgvParser([]);
}
/**
* Initializes the argument parser.
*/
public function __construct() {
- $this->argv = new ArgvParser(array());
- $this->argv->setOptions(array(
+ $this->argv = new ArgvParser([]);
+ $this->argv->setOptions([
ArgvParser::CONFIG_FREEFORM_FLAGS => true,
ArgvParser::CONFIG_PARSEALL => false,
ArgvParser::CONFIG_CUMULATIVE_PARAMETERS => true
- ));
+ ]);
}
/**
$commands = CLICommandHandler::getCommands();
if (!isset($commands[$args[0]])) {
- throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.cli.error.command.notFound', array('command' => $args[0])), $this->getUsage());
+ throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.cli.error.command.notFound', ['command' => $args[0]]), $this->getUsage());
}
$command = $commands[$args[0]];
if (!($command instanceof IArgumentedCLICommand)) {
- throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.cli.error.help.noArguments', array('command' => $args[0])), $this->getUsage());
+ throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.cli.error.help.noArguments', ['command' => $args[0]]), $this->getUsage());
}
CLIWCF::getReader()->println($command->getUsage());
* list of available exporters
* @var ObjectType[]
*/
- protected $exporters = array();
+ protected $exporters = [];
/**
* file system path
* list of available importers
* @var string[]
*/
- public $importers = array();
+ public $importers = [];
/**
* indicates if the imported will be quit
* selected data types
* @var string[]
*/
- public $selectedData = array();
+ public $selectedData = [];
/**
* list of supported data types
* @var array
*/
- protected $supportedData = array();
+ protected $supportedData = [];
/**
* user merge mode
// step 7) save import data
$queue = $this->exporter->getQueue();
- WCF::getSession()->register('importData', array(
- 'additionalData' => array(),
+ WCF::getSession()->register('importData', [
+ 'additionalData' => [],
'dbHost' => $this->dbHost,
'dbName' => $this->dbName,
'dbPassword' => $this->dbPassword,
'exporterName' => $this->exporterName,
'fileSystemPath' => $this->fileSystemPath,
'userMergeMode' => $this->userMergeMode
- ));
+ ]);
// step 8) import data
CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.started'));
foreach ($queue as $objectType) {
CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.data.'.$objectType));
$workerCommand = CLICommandHandler::getCommand('worker');
- $workerCommand->execute(array(
+ $workerCommand->execute([
'--objectType='.$objectType,
'ImportWorker'
- ));
+ ]);
}
CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.completed'));
$this->dbPrefix = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database.prefix').'> ');
if ($this->dbPrefix === null) exit;
- $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, '', array());
+ $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, '', []);
try {
$this->exporter->validateDatabaseAccess();
}
catch (DatabaseException $e) {
- $errorMessage = WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.configure.database.error', array(
+ $errorMessage = WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.configure.database.error', [
'exception' => $e
- ));
+ ]);
$errorMessageLines = explode('<br />', $errorMessage);
foreach ($errorMessageLines as &$line) {
$line = StringUtil::stripHTML($line);
*/
protected function readExporter() {
CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.selectExporter'));
- $exporterSelection = array();
+ $exporterSelection = [];
$exporterIndex = 1;
foreach ($this->exporters as $objectType) {
CLIWCF::getReader()->println($exporterIndex.') '.WCF::getLanguage()->get('wcf.acp.dataImport.exporter.'.$objectType->objectType));
$exporterSelection[$exporterIndex++] = $objectType->objectType;
}
- CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array(
+ CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', [
'minSelection' => 1,
'maxSelection' => $exporterIndex - 1
- )));
+ ]));
while (true) {
$exporterIndex = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.exporter').'> ');
while (true) {
$this->fileSystemPath = CLIWCF::getReader()->readLine('> ');
if ($this->fileSystemPath === null) exit;
- $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, $this->fileSystemPath, array());
+ $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, $this->fileSystemPath, []);
if (!$this->exporter->validateFileAccess()) {
CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.configure.fileSystem.path.error'));
*/
protected function readSelectedData() {
$printPrimaryTypes = true;
- $selectedData = array();
- $supportedDataSelection = array(
- '' => array()
- );
+ $selectedData = [];
+ $supportedDataSelection = [
+ '' => []
+ ];
$i = 1;
- $availablePrimaryDataTypes = array();
+ $availablePrimaryDataTypes = [];
foreach ($this->supportedData as $objectType => $subData) {
$availablePrimaryDataTypes[$i++] = $objectType;
}
$supportedDataIndex++;
}
}
- CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array(
+ CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', [
'minSelection' => $minSupportedDataIndex,
'maxSelection' => $supportedDataIndex - 1
- )));
+ ]));
$printPrimaryTypes = false;
}
// validate selected primary import data type
if (isset($supportedDataSelection[''][$selectedObjectTypeIndex])) {
$selectedObjectType = $supportedDataSelection[''][$selectedObjectTypeIndex];
- $selectedData[$selectedObjectType] = array();
+ $selectedData[$selectedObjectType] = [];
unset($supportedDataSelection[''][$selectedObjectTypeIndex]);
}
else if (isset($availablePrimaryDataTypes[$selectedObjectTypeIndex])) {
CLIWCF::getReader()->println(' '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.data.description'));
CLIWCF::getReader()->println(' 0) '.WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.selectAll'));
- $supportedDataSelection[$selectedObjectType] = array();
+ $supportedDataSelection[$selectedObjectType] = [];
$supportedDataIndex = 1;
foreach ($this->supportedData[$selectedObjectType] as $objectType) {
CLIWCF::getReader()->println(' '.$supportedDataIndex.') '.WCF::getLanguage()->get('wcf.acp.dataImport.data.'.$objectType));
$supportedDataSelection[$selectedObjectType][$supportedDataIndex++] = $objectType;
}
- CLIWCF::getReader()->println(' '.WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array(
+ CLIWCF::getReader()->println(' '.WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', [
'minSelection' => 0,
'maxSelection' => $supportedDataIndex - 1
- )));
+ ]));
while (true) {
// read index of selected secondary import data type
CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode'));
CLIWCF::getReader()->println('1) '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode.4').' (*)');
CLIWCF::getReader()->println('2) '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode.5'));
- CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array(
+ CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', [
'minSelection' => 1,
'maxSelection' => 2
- )));
+ ]));
while (true) {
$this->userMergeMode = CLIWCF::getReader()->readLine('> ');
* Initializes the argument parser.
*/
public function __construct() {
- $this->argv = new ArgvParser(array(
+ $this->argv = new ArgvParser([
'l|list' => CLIWCF::getLanguage()->get('wcf.cli.worker.list'),
'setParameter=s' => CLIWCF::getLanguage()->get('wcf.cli.worker.setParameter')
- ));
- $this->argv->setOptions(array(
+ ]);
+ $this->argv->setOptions([
ArgvParser::CONFIG_FREEFORM_FLAGS => true,
ArgvParser::CONFIG_PARSEALL => false,
ArgvParser::CONFIG_CUMULATIVE_PARAMETERS => true
- ));
+ ]);
}
/**
// parse parameters
$options = $this->argv->getOptions();
- $parameters = array();
+ $parameters = [];
foreach ($options as $option) {
$value = $this->argv->getOption($option);
if ($option === 'setParameter') {
if (!is_array($value)) {
- $value = array($value);
+ $value = [$value];
}
foreach ($value as $parameter) {
$worker->getProgress(); // make sure objects are counted
// initialize progressbar
- $progressbar = new ProgressBar(new ConsoleProgressBar(array(
+ $progressbar = new ProgressBar(new ConsoleProgressBar([
'width' => CLIWCF::getTerminal()->getWidth()
- )));
+ ]));
$progress = 0;
for ($i = 0; $progress < 100; $i++) {
$worker->setLoopCount($i);
$directory = DirectoryUtil::getInstance(WCF_DIR.'lib/system/worker/');
$workerList = $directory->getFiles(SORT_ASC, new Regex('Worker\.class\.php$'));
- $table = array(
- array(
+ $table = [
+ [
'Class',
'Description'
- )
- );
+ ]
+ ];
foreach ($workerList as $worker) {
$class = 'wcf\system\worker\\'.basename($worker, '.class.php');
if (!class_exists($class) && !interface_exists($class)) {
}
}
- $table[] = array(
+ $table[] = [
basename($worker, '.class.php'),
$comment
- );
+ ];
}
return $table;
* internal data
* @var array
*/
- protected $internalData = array();
+ protected $internalData = [];
/**
* item name
* list of parameters passed to ClipboardProxyAction
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* redirect url
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
- $this->cache = array(
- 'objectTypes' => array(),
- 'objectTypeNames' => array()
- );
+ $this->cache = [
+ 'objectTypes' => [],
+ 'objectTypeNames' => []
+ ];
$cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.clipboardItem');
foreach ($cache as $objectType) {
$this->cache['objectTypes'][$objectType->objectTypeID] = $objectType;
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($objectIDs as $objectID) {
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
WCF::getUser()->userID,
$objectID
- ));
+ ]);
}
}
*/
public function unmark(array $objectIDs, $objectTypeID) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectTypeID));
- $conditions->add("objectID IN (?)", array($objectIDs));
- $conditions->add("userID = ?", array(WCF::getUser()->userID));
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
+ $conditions->add("userID = ?", [WCF::getUser()->userID]);
$sql = "DELETE FROM wcf".WCF_N."_clipboard_item
".$conditions;
WHERE objectTypeID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
WCF::getUser()->userID
- ));
+ ]);
}
/**
*/
protected function loadMarkedItems($objectTypeID = null) {
if ($this->markedItems === null) {
- $this->markedItems = array();
+ $this->markedItems = [];
}
if ($objectTypeID !== null) {
}
if (!isset($this->markedItems[$objectType->objectType])) {
- $this->markedItems[$objectType->objectType] = array();
+ $this->markedItems[$objectType->objectType] = [];
}
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID = ?", array(WCF::getUser()->userID));
+ $conditions->add("userID = ?", [WCF::getUser()->userID]);
if ($objectTypeID !== null) {
- $conditions->add("objectTypeID = ?", array($objectTypeID));
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
}
// fetch object ids
$statement->execute($conditions->getParameters());
// group object ids by type name
- $data = array();
+ $data = [];
while ($row = $statement->fetchArray()) {
$objectType = $this->getObjectType($row['objectTypeID']);
if ($objectType === null) {
throw new SystemException("Missing list class for object type '".$objectType->objectType."'");
}
- $data[$objectType->objectType] = array(
+ $data[$objectType->objectType] = [
'className' => $objectType->listclassname,
- 'objectIDs' => array()
- );
+ 'objectIDs' => []
+ ];
}
$data[$objectType->objectType]['objectIDs'][] = $row['objectID'];
// read objects
foreach ($data as $objectType => $objectData) {
$objectList = new $objectData['className']();
- $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias() . "." . $objectList->getDatabaseTableIndexName() . " IN (?)", array($objectData['objectIDs']));
+ $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias() . "." . $objectList->getDatabaseTableIndexName() . " IN (?)", [$objectData['objectIDs']]);
$objectList->readObjects();
$this->markedItems[$objectType] = $objectList->getObjects();
if (!empty($objectData['objectIDs'])) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($this->getObjectTypeByName($objectType)));
- $conditions->add("userID = ?", array(WCF::getUser()->userID));
- $conditions->add("objectID IN (?)", array($objectData['objectIDs']));
+ $conditions->add("objectTypeID = ?", [$this->getObjectTypeByName($objectType)]);
+ $conditions->add("userID = ?", [WCF::getUser()->userID]);
+ $conditions->add("objectID IN (?)", [$objectData['objectIDs']]);
$sql = "DELETE FROM wcf".WCF_N."_clipboard_item
".$conditions;
// fetch action ids
$this->loadActionCache();
- $actionIDs = array();
+ $actionIDs = [];
foreach ($this->pageCache[$page] as $actionID) {
if (isset($this->actionCache[$actionID])) {
$actionIDs[] = $actionID;
$actionIDs = array_unique($actionIDs);
// load actions
- $actions = array();
+ $actions = [];
foreach ($actionIDs as $actionID) {
$actionObject = $this->actionCache[$actionID];
$actionClassName = $actionObject->actionClassName;
throw new SystemException("'".$actionClassName."' does not implement 'wcf\system\clipboard\action\IClipboardAction'");
}
- $actions[$actionClassName] = array(
- 'actions' => array(),
+ $actions[$actionClassName] = [
+ 'actions' => [],
'object' => new $actionClassName()
- );
+ ];
}
$actions[$actionClassName]['actions'][] = $actionObject;
}
// execute actions
- $editorData = array();
+ $editorData = [];
foreach ($actions as $actionData) {
// get accepted objects
$typeName = $actionData['object']->getTypeName();
if (!isset($this->markedItems[$typeName]) || empty($this->markedItems[$typeName])) continue;
if (!isset($editorData[$typeName])) {
- $editorData[$typeName] = array(
+ $editorData[$typeName] = [
'label' => $actionData['object']->getEditorLabel($this->markedItems[$typeName]),
- 'items' => array()
- );
+ 'items' => []
+ ];
}
foreach ($actionData['actions'] as $actionObject) {
*/
public function removeItems($typeID = null) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID = ?", array(WCF::getUser()->userID));
- if ($typeID !== null) $conditions->add("objectTypeID = ?", array($typeID));
+ $conditions->add("userID = ?", [WCF::getUser()->userID]);
+ if ($typeID !== null) $conditions->add("objectTypeID = ?", [$typeID]);
$sql = "DELETE FROM wcf".WCF_N."_clipboard_item
".$conditions;
if (!WCF::getUser()->userID) return 0;
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("userID = ?", array(WCF::getUser()->userID));
+ $conditionBuilder->add("userID = ?", [WCF::getUser()->userID]);
if ($objectTypeID !== null) {
- $conditionBuilder->add("objectTypeID = ?", array($objectTypeID));
+ $conditionBuilder->add("objectTypeID = ?", [$objectTypeID]);
}
$sql = "SELECT COUNT(*)
* list of the clipboard actions which are executed by the action class
* @var string[]
*/
- protected $actionClassActions = array();
+ protected $actionClassActions = [];
/**
* relevant database objects
* @var DatabaseObject[]
*/
- protected $objects = array();
+ protected $objects = [];
/**
* list of the supported clipboard actions
* @var string[]
*/
- protected $supportedActions = array();
+ protected $supportedActions = [];
/**
* @see \wcf\system\clipboard\action\IClipboardAction::execute()
* @see \wcf\system\clipboard\action\IClipboardAction::getEditorLabel()
*/
public function getEditorLabel(array $objects) {
- return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.label.'.$this->getTypeName().'.marked', array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.label.'.$this->getTypeName().'.marked', [
'count' => count($objects)
- ));
+ ]);
}
}
/**
* @see \wcf\system\clipboard\action\AbstractClipboardAction::$actionClassActions
*/
- protected $actionClassActions = array('delete');
+ protected $actionClassActions = ['delete'];
/**
* @see \wcf\system\clipboard\action\AbstractClipboardAction::$supportedActions
*/
- protected $supportedActions = array('delete', 'setAsSynonyms');
+ protected $supportedActions = ['delete', 'setAsSynonyms'];
/**
* @see \wcf\system\clipboard\action\IClipboardAction::execute()
/**
* @see \wcf\system\clipboard\action\AbstractClipboardAction::$actionClassActions
*/
- protected $actionClassActions = array('delete');
+ protected $actionClassActions = ['delete'];
/**
* @see \wcf\system\clipboard\action\AbstractClipboardAction::$supportedActions
*/
- protected $supportedActions = array('assignToGroup', 'ban', 'delete', 'enable', 'exportMailAddress', 'merge', 'sendMail', 'sendNewPassword');
+ protected $supportedActions = ['assignToGroup', 'ban', 'delete', 'enable', 'exportMailAddress', 'merge', 'sendMail', 'sendNewPassword'];
/**
* @see \wcf\system\clipboard\action\IClipboardAction::execute()
break;
case 'delete':
- $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.com.woltlab.wcf.user.delete.confirmMessage', array(
+ $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.com.woltlab.wcf.user.delete.confirmMessage', [
'count' => $item->getCount()
- )));
+ ]));
break;
case 'exportMailAddress':
break;
case 'sendNewPassword':
- $item->addParameter('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.com.woltlab.wcf.user.sendNewPassword.confirmMessage', array(
+ $item->addParameter('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.com.woltlab.wcf.user.sendNewPassword.confirmMessage', [
'count' => $item->getCount()
- )));
+ ]));
break;
}
protected function validateDelete() {
// check permissions
if (!WCF::getSession()->getPermission('admin.user.canDeleteUser')) {
- return array();
+ return [];
}
return $this->__validateAccessibleGroups(array_keys($this->objects));
protected function validateBan() {
// check permissions
if (!WCF::getSession()->getPermission('admin.user.canBanUser')) {
- return array();
+ return [];
}
return $this->__validateAccessibleGroups(array_keys($this->objects));
}
// no valid users found
- if (empty($userIDs)) return array();
+ if (empty($userIDs)) return [];
// fetch user to group associations
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($userIDs));
+ $conditions->add("userID IN (?)", [$userIDs]);
$sql = "SELECT userID, groupID
FROM wcf".WCF_N."_user_to_group
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $userToGroup = array();
+ $userToGroup = [];
while ($row = $statement->fetchArray()) {
if (!isset($userToGroup[$row['userID']])) {
- $userToGroup[$row['userID']] = array();
+ $userToGroup[$row['userID']] = [];
}
$userToGroup[$row['userID']][] = $row['groupID'];
public function validateSendNewPassword() {
// check permissions
if (!WCF::getSession()->getPermission('admin.user.canEditPassword')) {
- return array();
+ return [];
}
return $this->__validateAccessibleGroups(array_keys($this->objects));
protected function validateEnable() {
// check permissions
if (!WCF::getSession()->getPermission('admin.user.canEnableUser')) {
- return array();
+ return [];
}
- $userIDs = array();
+ $userIDs = [];
foreach ($this->objects as $user) {
if ($user->activationCode) $userIDs[] = $user->userID;
}
protected function validateMerge() {
// check permissions
if (!WCF::getSession()->getPermission('admin.user.canEditUser')) {
- return array();
+ return [];
}
$userIDs = array_keys($this->objects);
- if (count($userIDs) < 2) return array();
+ if (count($userIDs) < 2) return [];
return $userIDs;
}
/**
* @see \wcf\system\clipboard\action\AbstractClipboardAction::$supportedActions
*/
- protected $supportedActions = array('revertContentChanges');
+ protected $supportedActions = ['revertContentChanges'];
/**
* @see \wcf\system\clipboard\action\IClipboardAction::execute()
*/
protected function validateRevertContentChanges() {
if (!MODULE_EDIT_HISTORY) {
- return array();
+ return [];
}
// check permissions
if (!WCF::getSession()->getPermission('admin.content.canBulkRevertContentChanges')) {
- return array();
+ return [];
}
- $userIDs = array();
+ $userIDs = [];
foreach ($this->objects as $user) {
$userIDs[] = $user->userID;
}
public function updateCounter($objectID, $value) {
$entry = new ModerationQueue($objectID);
$editor = new ModerationQueueEditor($entry);
- $editor->updateCounters(array(
+ $editor->updateCounters([
'comments' => $value
- ));
- $editor->update(array(
+ ]);
+ $editor->update([
'lastChangeTime' => TIME_NOW
- ));
+ ]);
}
/**
* @see \wcf\system\comment\manager\ICommentManager::getLink()
*/
public function getLink($objectTypeID, $objectID) {
- return LinkHandler::getInstance()->getLink('User', array('id' => $objectID));
+ return LinkHandler::getInstance()->getLink('User', ['id' => $objectID]);
}
/**
$commentLikeObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.like.likeableObject', 'com.woltlab.wcf.comment');
- $commentIDs = $responseIDs = array();
+ $commentIDs = $responseIDs = [];
foreach ($likes as $like) {
if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) {
$commentIDs[] = $like->objectID;
}
// fetch response
- $userIDs = $responses = array();
+ $userIDs = $responses = [];
if (!empty($responseIDs)) {
$responseList = new CommentResponseList();
$responseList->setObjectIDs($responseIDs);
$comments = $commentList->getObjects();
// fetch users
- $users = array();
+ $users = [];
foreach ($comments as $comment) {
$userIDs[] = $comment->objectID;
if ($comment->userID) {
$like->setIsAccessible();
// short output
- $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.com.woltlab.wcf.user.profileComment', array(
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.com.woltlab.wcf.user.profileComment', [
'commentAuthor' => $comment->userID ? $users[$comment->userID] : null,
'user' => $users[$comment->objectID],
'like' => $like
- ));
+ ]);
$like->setTitle($text);
// output
$like->setIsAccessible();
// short output
- $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.com.woltlab.wcf.user.profileComment.response', array(
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.com.woltlab.wcf.user.profileComment.response', [
'responseAuthor' => $comment->userID ? $users[$response->userID] : null,
'commentAuthor' => $comment->userID ? $users[$comment->userID] : null,
'user' => $users[$comment->objectID],
'like' => $like
- ));
+ ]);
$like->setTitle($text);
// output
* object type definition
* @var array
*/
- protected $conditions = array();
+ protected $conditions = [];
/**
* Creates condition objects for the object with the given id and based
foreach ($conditionObjectTypes as $objectType) {
$conditionData = $objectType->getProcessor()->getData();
if ($conditionData !== null) {
- $conditionAction = new ConditionAction(array(), 'create', array(
- 'data' => array(
+ $conditionAction = new ConditionAction([], 'create', [
+ 'data' => [
'conditionData' => serialize($conditionData),
'objectID' => $objectID,
'objectTypeID' => $objectType->objectTypeID
- )
- ));
+ ]
+ ]);
$conditionAction->executeAction();
}
}
}
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes($definitionName);
- $objectTypeIDs = array();
+ $objectTypeIDs = [];
foreach ($objectTypes as $objectType) {
$objectTypeIDs[] = $objectType->objectTypeID;
}
if (empty($objectTypeIDs)) return;
$conditionList = new ConditionList();
- $conditionList->getConditionBuilder()->add('objectTypeID IN (?)', array($objectTypeIDs));
- $conditionList->getConditionBuilder()->add('objectID IN (?)', array($objectIDs));
+ $conditionList->getConditionBuilder()->add('objectTypeID IN (?)', [$objectTypeIDs]);
+ $conditionList->getConditionBuilder()->add('objectID IN (?)', [$objectIDs]);
$conditionList->readObjects();
if (count($conditionList)) {
}
if (!isset($this->conditions[$definition->definitionID])) {
- $this->conditions[$definition->definitionID] = ConditionCacheBuilder::getInstance()->getData(array(
+ $this->conditions[$definition->definitionID] = ConditionCacheBuilder::getInstance()->getData([
'definitionID' => $definition->definitionID
- ));
+ ]);
}
if (isset($this->conditions[$definition->definitionID][$objectID])) {
return $this->conditions[$definition->definitionID][$objectID];
}
- return array();
+ return [];
}
/**
WHERE objectID = ?
AND uploadTime < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
0,
(TIME_NOW - 86400)
- ));
+ ]);
$attachmentIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (!empty($attachmentIDs)) {
* cached times of the next and after next cronjob execution
* @var integer[]
*/
- protected $cache = array();
+ protected $cache = [];
/**
* list of editors for outstanding cronjobs
* @var CronjobEditor[]
*/
- protected $cronjobEditors = array();
+ protected $cronjobEditors = [];
/**
* @see \wcf\system\SingletonFactory::init()
foreach ($this->cronjobEditors as $cronjobEditor) {
// mark cronjob as being executed
- $cronjobEditor->update(array(
+ $cronjobEditor->update([
'state' => Cronjob::EXECUTING
- ));
+ ]);
// create log entry
- $log = CronjobLogEditor::create(array(
+ $log = CronjobLogEditor::create([
'cronjobID' => $cronjobEditor->cronjobID,
'execTime' => TIME_NOW
- ));
+ ]);
$logEditor = new CronjobLogEditor($log);
// check if all required options are set for cronjob to be executed
$afterNextExec = $cronjobEditor->getNextExec(($nextExec + 120));
// mark cronjob as done
- $cronjobEditor->update(array(
+ $cronjobEditor->update([
'lastExec' => TIME_NOW,
'afterNextExec' => $afterNextExec,
'failCount' => 0,
'nextExec' => $nextExec,
'state' => Cronjob::READY
- ));
+ ]);
}
}
AND cronjob.isDisabled = ?
AND cronjob.failCount < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
TIME_NOW,
TIME_NOW,
0,
Cronjob::MAX_FAIL_COUNT
- ));
+ ]);
while ($row = $statement->fetchArray()) {
$cronjob = new Cronjob(null, $row);
$cronjobEditor = new CronjobEditor($cronjob);
$executeCronjob = true;
- $data = array(
+ $data = [
'state' => Cronjob::PENDING
- );
+ ];
// reset cronjob if it got stuck before and afterNextExec is in the past
if ($cronjobEditor->afterNextExec <= TIME_NOW) {
*/
protected function logResult(CronjobLogEditor $logEditor, SystemException $exception = null) {
if ($exception !== null) {
- $errString = implode("\n", array(
+ $errString = implode("\n", [
$exception->getMessage(),
$exception->getCode(),
$exception->getFile(),
$exception->getLine(),
$exception->getTraceAsString()
- ));
+ ]);
- $logEditor->update(array(
+ $logEditor->update([
'success' => 0,
'error' => $errString
- ));
+ ]);
}
else {
- $logEditor->update(array(
+ $logEditor->update([
'success' => 1
- ));
+ ]);
}
}
WHERE searches <= ?
AND lastSearchTime < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
floor($row['searches'] / 4),
(TIME_NOW - 86400 * 30)
- ));
+ ]);
}
// clean up notifications
$sql = "DELETE FROM wcf".WCF_N."_user_notification
WHERE time < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - 86400 * USER_CLEANUP_NOTIFICATION_LIFETIME)
- ));
+ ]);
// clean up user activity events
$sql = "DELETE FROM wcf".WCF_N."_user_activity_event
WHERE time < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - 86400 * USER_CLEANUP_ACTIVITY_EVENT_LIFETIME)
- ));
+ ]);
// clean up profile visitors
$sql = "DELETE FROM wcf".WCF_N."_user_profile_visitor
WHERE time < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - 86400 * USER_CLEANUP_PROFILE_VISITOR_LIFETIME)
- ));
+ ]);
// tracked visits
$sql = "DELETE FROM wcf".WCF_N."_tracked_visit
$lifetime = ($objectType->lifetime ?: VisitTracker::DEFAULT_LIFETIME);
// delete data
- $statement1->execute(array(
+ $statement1->execute([
$objectType->objectTypeID,
$lifetime
- ));
- $statement2->execute(array(
+ ]);
+ $statement2->execute([
$objectType->objectTypeID,
$lifetime
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
$sql = "DELETE FROM wcf".WCF_N."_cronjob_log
WHERE execTime < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - (86400 * 7))
- ));
+ ]);
// clean up session access log
$sql = "DELETE FROM wcf".WCF_N."_acp_session_access_log
WHERE lastActivityTime < ?
)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - (86400 * 30))
- ));
+ ]);
// clean up session log
$sql = "DELETE FROM wcf".WCF_N."_acp_session_log
WHERE lastActivityTime < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - (86400 * 30))
- ));
+ ]);
// clean up search data
$sql = "DELETE FROM wcf".WCF_N."_search
WHERE searchTime < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - 86400)
- ));
+ ]);
// clean up expired edit history entries
if (MODULE_EDIT_HISTORY) {
$sql = "DELETE FROM wcf".WCF_N."_edit_history_entry
WHERE obsoletedAt < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - 86400 * EDIT_HISTORY_EXPIRATION)
- ));
+ ]);
}
}
else {
$sql = "DELETE FROM wcf".WCF_N."_user_authentication_failure
WHERE time < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
(TIME_NOW - 86400 * USER_AUTHENTICATION_FAILURE_EXPIRATION)
- ));
+ ]);
}
// clean up error logs
AND time < ?
AND confirmTime = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
0,
TIME_NOW - 3600 * 23,
0
- ));
+ ]);
$userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (empty($userIDs)) return;
// get notifications
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("notification.userID IN (?)", array($userIDs));
- $conditions->add("notification.mailNotified = ?", array(0));
- $conditions->add("notification.confirmTime = ?", array(0));
+ $conditions->add("notification.userID IN (?)", [$userIDs]);
+ $conditions->add("notification.mailNotified = ?", [0]);
+ $conditions->add("notification.confirmTime = ?", [0]);
$sql = "SELECT notification.*, notification_event.eventID, object_type.objectType
FROM wcf".WCF_N."_user_notification notification
// mark notifications as done
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($userIDs));
- $conditions->add("mailNotified = ?", array(0));
+ $conditions->add("userID IN (?)", [$userIDs]);
+ $conditions->add("mailNotified = ?", [0]);
$sql = "UPDATE wcf".WCF_N."_user_notification
SET mailNotified = 1
".$conditions;
$statement2->execute($conditions->getParameters());
// collect data
- $eventsToUser = $objectTypes = $eventIDs = $notificationObjects = array();
+ $eventsToUser = $objectTypes = $eventIDs = $notificationObjects = [];
$availableObjectTypes = UserNotificationHandler::getInstance()->getAvailableObjectTypes();
while ($row = $statement->fetchArray()) {
- if (!isset($eventsToUser[$row['userID']])) $eventsToUser[$row['userID']] = array();
+ if (!isset($eventsToUser[$row['userID']])) $eventsToUser[$row['userID']] = [];
$eventsToUser[$row['userID']][] = $row['notificationID'];
// cache object types
if (!isset($objectTypes[$row['objectType']])) {
- $objectTypes[$row['objectType']] = array(
+ $objectTypes[$row['objectType']] = [
'objectType' => $availableObjectTypes[$row['objectType']],
- 'objectIDs' => array(),
- 'objects' => array()
- );
+ 'objectIDs' => [],
+ 'objects' => []
+ ];
}
$objectTypes[$row['objectType']]['objectIDs'][] = $row['objectID'];
// load authors
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("notificationID IN (?)", array(array_keys($notificationObjects)));
+ $conditions->add("notificationID IN (?)", [array_keys($notificationObjects)]);
$sql = "SELECT notificationID, authorID
FROM wcf".WCF_N."_user_notification_author
".$conditions."
ORDER BY time ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $authorIDs = $authorToNotification = array();
+ $authorIDs = $authorToNotification = [];
while ($row = $statement->fetchArray()) {
if ($row['authorID']) {
$authorIDs[] = $row['authorID'];
}
if (!isset($authorToNotification[$row['notificationID']])) {
- $authorToNotification[$row['notificationID']] = array();
+ $authorToNotification[$row['notificationID']] = [];
}
$authorToNotification[$row['notificationID']][] = $row['authorID'];
// load authors
$authors = UserProfileRuntimeCache::getInstance()->getObjects($authorIDs);
- $unknownAuthor = new UserProfile(new User(null, array('userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest'))));
+ $unknownAuthor = new UserProfile(new User(null, ['userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest')]));
// load objects associated with each object type
foreach ($objectTypes as $objectType => $objectData) {
// load required events
$eventList = new UserNotificationEventList();
- $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", array($eventIDs));
+ $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", [$eventIDs]);
$eventList->readObjects();
$eventObjects = $eventList->getObjects();
if ($user->banned) continue;
// add mail header
- $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', array(
+ $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', [
'user' => $user
- ));
+ ]);
foreach ($events as $notificationID) {
$notification = $notificationObjects[$notificationID];
$class->setLanguage($user->getLanguage());
if (isset($authorToNotification[$notification->notificationID])) {
- $eventAuthors = array();
+ $eventAuthors = [];
foreach ($authorToNotification[$notification->notificationID] as $userID) {
if (!$userID) {
$eventAuthors[0] = $unknownAuthor;
$token = $user->notificationMailToken;
if (!$token) {
// generate token if not present
- $token = mb_substr(StringUtil::getHash(serialize(array($user->userID, StringUtil::getRandomID()))), 0, 20);
+ $token = mb_substr(StringUtil::getHash(serialize([$user->userID, StringUtil::getRandomID()])), 0, 20);
$editor = new UserEditor($user);
- $editor->update(array('notificationMailToken' => $token));
+ $editor->update(['notificationMailToken' => $token]);
}
$message .= "\n\n";
- $message .= $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.footer', array(
+ $message .= $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.footer', [
'user' => $user,
'token' => $token
- ));
+ ]);
// build mail
- $mail = new Mail(array($user->username => $user->email), $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.subject', array('count' => count($events))), $message);
+ $mail = new Mail([$user->username => $user->email], $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.subject', ['count' => count($events)]), $message);
$mail->setLanguage($user->getLanguage());
$mail->send();
}
// disable expired paid subscriptions
if (MODULE_PAID_SUBSCRIPTION) {
$subscriptionUserList = new PaidSubscriptionUserList();
- $subscriptionUserList->getConditionBuilder()->add('isActive = ?', array(1));
- $subscriptionUserList->getConditionBuilder()->add('endDate > 0 AND endDate < ?', array(TIME_NOW));
+ $subscriptionUserList->getConditionBuilder()->add('isActive = ?', [1]);
+ $subscriptionUserList->getConditionBuilder()->add('endDate > 0 AND endDate < ?', [TIME_NOW]);
$subscriptionUserList->readObjects();
if (count($subscriptionUserList->getObjects())) {
WHERE status = ?
AND lastChangeTime < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
ModerationQueue::STATUS_DONE,
(TIME_NOW - (86400 * 30))
- ));
+ ]);
$queueIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (!empty($queueIDs)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("queueID IN (?)", array($queueIDs));
+ $conditions->add("queueID IN (?)", [$queueIDs]);
$sql = "DELETE FROM wcf".WCF_N."_moderation_queue
".$conditions;
if (!empty($spiders)) {
$existingSpiders = SpiderCacheBuilder::getInstance()->getData();
- $statementParameters = array();
+ $statementParameters = [];
foreach ($spiders as $spider) {
$identifier = mb_strtolower($spider->getAttribute('ident'));
$name = $xpath->query('ns:name', $spider)->item(0);
$info = $xpath->query('ns:url', $spider)->item(0);
- $statementParameters[$identifier] = array(
+ $statementParameters[$identifier] = [
'spiderIdentifier' => $identifier,
'spiderName' => $name->nodeValue,
'spiderURL' => $info ? $info->nodeValue : ''
- );
+ ];
}
if (!empty($statementParameters)) {
WCF::getDB()->beginTransaction();
foreach ($statementParameters as $parameters) {
- $statement->execute(array(
+ $statement->execute([
$parameters['spiderIdentifier'],
$parameters['spiderName'],
$parameters['spiderURL']
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($existingSpiders as $spider) {
if (!isset($statementParameters[$spider->spiderIdentifier])) {
- $statement->execute(array($spider->spiderIdentifier));
+ $statement->execute([$spider->spiderIdentifier]);
}
}
foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
$data = $objectType->getProcessor()->getData($date);
- $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']));
+ $statement->execute([$objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']]);
}
}
}
AND banExpires <> ?
AND banExpires <= ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
0,
0,
1,
0,
TIME_NOW
- ));
+ ]);
// enable avatars
$sql = "UPDATE wcf".WCF_N."_user
AND disableAvatarExpires <> ?
AND disableAvatarExpires <= ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
0,
0,
1,
0,
TIME_NOW
- ));
+ ]);
// enable signatures
$sql = "UPDATE wcf".WCF_N."_user
AND disableSignatureExpires <> ?
AND disableSignatureExpires <= ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
0,
0,
1,
0,
TIME_NOW
- ));
+ ]);
}
}
parent::execute($cronjob);
$assignments = UserGroupAssignmentCacheBuilder::getInstance()->getData();
- $usersToGroup = array();
+ $usersToGroup = [];
foreach ($assignments as $assignment) {
if (!isset($usersToGroup[$assignment->groupID])) {
- $usersToGroup[$assignment->groupID] = array();
+ $usersToGroup[$assignment->groupID] = [];
}
$usersToGroup[$assignment->groupID] = array_merge($usersToGroup[$assignment->groupID], UserGroupAssignmentHandler::getInstance()->getUsers($assignment));
}
foreach ($usersToGroup as $groupID => $users) {
- $userAction = new UserAction(array_unique($users), 'addToGroups', array(
+ $userAction = new UserAction(array_unique($users), 'addToGroups', [
'addDefaultGroups' => false,
'deleteOldGroups' => false,
- 'groups' => array($groupID)
- ));
+ 'groups' => [$groupID]
+ ]);
$userAction->executeAction();
}
}
WHERE quitStarted > ?
AND quitStarted < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
0,
(TIME_NOW - 7 * 24 * 3600)
- ));
+ ]);
$userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (!empty($userIDs)) {
if (!$this->port) $this->port = 3306; // mysql default port
try {
- $driverOptions = array(
+ $driverOptions = [
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
- );
+ ];
if (!$this->failsafeTest) {
- $driverOptions = array(
+ $driverOptions = [
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
- );
+ ];
}
// disable prepared statement emulation since MySQL 5.1.17 is the minimum required version
*/
public static function fixQuery($query) {
// replace quotes
- $query = preg_replace_callback('~\'([^\'\\\\]+|\\\\.)*\'~', array('self', 'replaceQuotesCallback'), $query);
- $query = preg_replace_callback('~"([^"\\\\]+|\\\\.)*"~', array('self', 'replaceQuotesCallback'), $query);
+ $query = preg_replace_callback('~\'([^\'\\\\]+|\\\\.)*\'~', ['self', 'replaceQuotesCallback'], $query);
+ $query = preg_replace_callback('~"([^"\\\\]+|\\\\.)*"~', ['self', 'replaceQuotesCallback'], $query);
// double quote identifiers (column & table names ...)
$query = preg_replace('~(?<=^|\s|\.|\(|,)([A-Za-z0-9_-]*[a-z]{1}[A-Za-z0-9_-]*)(?=$|\s|\.|\)|,|=)~', '"\\1"', $query);
* @param array $columns
* @param array $indices
*/
- abstract public function createTable($tableName, $columns, $indices = array());
+ abstract public function createTable($tableName, $columns, $indices = []);
/**
* Drops a database table.
* @see \wcf\system\database\editor\DatabaseEditor::getTableNames()
*/
public function getTableNames() {
- $existingTables = array();
+ $existingTables = [];
$sql = "SHOW TABLES FROM `".$this->dbObj->getDatabaseName()."`";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
* @see \wcf\system\database\editor\DatabaseEditor::getColumns()
*/
public function getColumns($tableName) {
- $columns = array();
+ $columns = [];
$regex = new Regex('([a-z]+)\(([0-9]+)\)', Regex::CASE_INSENSITIVE);
$sql = "SHOW COLUMNS FROM `".$tableName."`";
$regex->match($row['Type']);
$typeMatches = $regex->getMatches();
- $columns[] = array('name' => $row['Field'], 'data' => array(
+ $columns[] = ['name' => $row['Field'], 'data' => [
'type' => ((empty($typeMatches)) ? $row['Type'] : $typeMatches[1]),
'length' => ((empty($typeMatches)) ? '' : $typeMatches[2]),
'notNull' => (($row['Null'] == 'YES') ? false : true),
'key' => (($row['Key'] == 'PRI') ? 'PRIMARY' : (($row['Key'] == 'UNI') ? 'UNIQUE' : '')),
'default' => $row['Default'],
'autoIncrement' => ($row['Extra'] == 'auto_increment' ? true : false)
- ));
+ ]];
}
return $columns;
* @see \wcf\system\database\editor\DatabaseEditor::getIndices()
*/
public function getIndices($tableName) {
- $indices = array();
+ $indices = [];
$sql = "SHOW INDEX FROM `".$tableName."`";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
/**
* @see \wcf\system\database\editor\DatabaseEditor::createTable()
*/
- public function createTable($tableName, $columns, $indices = array()) {
+ public function createTable($tableName, $columns, $indices = []) {
$columnDefinition = $indexDefinition = '';
// build column definition
* @see \wcf\system\database\editor\DatabaseEditor::getTableNames()
*/
public function getTableNames() {
- $existingTables = array();
+ $existingTables = [];
$sql = "SELECT tablename
FROM pg_catalog.pg_tables
WHERE schemaname = 'public'
* @see \wcf\system\database\editor\DatabaseEditor::getColumns()
*/
public function getColumns($tableName) {
- $columns = array();
+ $columns = [];
$sql = "SELECT pg_attribute.*, pg_type.typname, pg_constraint.contype, pg_attribute.adsrc
FROM pg_attribute,
pg_class,
AND pg_attribute.attnum > 0
AND pg_class.relname = ?";
$statement = $this->dbObj->prepareStatement($sql);
- $statement->execute(array($tableName));
+ $statement->execute([$tableName]);
while ($row = $statement->fetchArray()) {
- $columns[] = array('name' => $row['attname'], 'data' => array(
+ $columns[] = ['name' => $row['attname'], 'data' => [
'type' => $row['typname'],
'length' => $row['attlen'],
'notNull' => $row['attnotnull'],
'key' => (($row['contype'] == 'p') ? 'PRIMARY' : (($row['contype'] == 'u') ? 'UNIQUE' : '')),
'default' => $row['adsrc'],
'autoIncrement' => ($row['contype'] == 'p')
- ));
+ ]];
}
return $columns;
* @see \wcf\system\database\editor\DatabaseEditor::getIndices()
*/
public function getIndices($tableName) {
- $indices = array();
+ $indices = [];
$sql = "SELECT indexname
FROM pg_indexes
WHERE tablename = ?";
$statement = $this->dbObj->prepareStatement($sql);
- $statement->execute(array($tableName));
+ $statement->execute([$tableName]);
while ($row = $statement->fetchArray()) {
$indices[] = $row['indexname'];
}
/**
* @see \wcf\system\database\editor\DatabaseEditor::createTable()
*/
- public function createTable($tableName, $columns, $indices = array()) {
+ public function createTable($tableName, $columns, $indices = []) {
$columnDefinition = $indexDefinition = '';
// build column definition
* @param mixed $conditions
*/
public function add($conditions) {
- if (!is_array($conditions)) $conditions = array($conditions);
+ if (!is_array($conditions)) $conditions = [$conditions];
foreach ($conditions as $condition) {
if (!empty($this->conditions)) $this->conditions .= $this->concat;
* input parameters
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* Adds a new condition. The parameters array has to be a numbered array.
* @param string $condition
* @param array $parameters
*/
- public function add($condition, array $parameters = array()) {
+ public function add($condition, array $parameters = []) {
if (!empty($parameters)) {
$count = 0;
$callback = function ($matches) use (&$count, $parameters, $condition) {
* list of sql queries
* @var string[]
*/
- protected $queryArray = array();
+ protected $queryArray = [];
/**
* Creates a new SQLParser object.
// get table name
if (preg_match('~^CREATE\s+TABLE\s+(\w+)\s*\(~i', $query, $match)) {
$tableName = $match[1];
- $columns = $indices = array();
+ $columns = $indices = [];
// find columns
if (preg_match_all("~(?:\(|,)\s*(\w+)\s+(\w+)(?:\s*\((\s*(?:\d+(?:\s*,\s*\d+)?|'[^']*'(?:\s*,\s*'[^']*')*))\s*\))?(?:\s+UNSIGNED)?(?:\s+(NOT NULL|NULL))?(?:\s+DEFAULT\s+(\d+.\d+|\d+|NULL|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'))?(?:\s+(AUTO_INCREMENT))?(?:\s+(UNIQUE|PRIMARY)(?: KEY)?)?~i", $query, $matches)) {
$columName = strtoupper($matches[1][$i]);
if ($columName == 'UNIQUE' || $columName == 'KEY' || $columName == 'PRIMARY' || $columName == 'FULLTEXT') continue;
- $column = array('name' => $matches[1][$i]);
+ $column = ['name' => $matches[1][$i]];
$columnType = strtolower($matches[2][$i]);
- $column['data'] = array(
+ $column['data'] = [
'type' => $columnType,
'notNull' => ((!empty($matches[4][$i]) && strtoupper($matches[4][$i]) == 'NOT NULL') ? true : false),
'default' => $matches[5][$i],
'autoIncrement' => (!empty($matches[6][$i]) ? true : false),
'key' => strtoupper($matches[7][$i])
- );
+ ];
if (!empty($matches[3][$i])) {
if ($columnType == 'enum') $column['data']['values'] = $matches[3][$i];
else {
// find indices
if (preg_match_all('~(?:\(|,)\s*(?:(?:(?:(UNIQUE|FULLTEXT)(?:\s+(?:INDEX|KEY))?|(?:INDEX|KEY))(?:\s+(\w+))?)|(PRIMARY) KEY)\s+\((\s*\w+\s*(?:,\s*\w+\s*)*)\)~is', $query, $matches)) {
for ($i = 0, $j = count($matches[0]); $i < $j; $i++) {
- $index = array('name' => $matches[2][$i], 'data' => array());
+ $index = ['name' => $matches[2][$i], 'data' => []];
$index['data']['type'] = strtoupper((!empty($matches[1][$i]) ? $matches[1][$i] : $matches[3][$i]));
$index['data']['columns'] = $matches[4][$i];
$indices[] = $index;
case 'ALTER TABLE':
// add index
if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+ADD\s+(?:(UNIQUE|FULLTEXT)\s+)?(?:INDEX|KEY)\s+(?:(\w+)\s*)?\((\s*\w+\s*(?:,\s*\w+\s*)*)\)~is', $query, $match)) {
- $this->executeAddIndexStatement($match[1], ($match[3] ?: self::getGenericIndexName($match[1], $match[4])), array('type' => strtoupper($match[2]), 'columns' => $match[4]));
+ $this->executeAddIndexStatement($match[1], ($match[3] ?: self::getGenericIndexName($match[1], $match[4])), ['type' => strtoupper($match[2]), 'columns' => $match[4]]);
}
// add foreign key
else if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+ADD\s+FOREIGN KEY\s+(?:(\w+)\s*)?\((\s*\w+\s*(?:,\s*\w+\s*)*)\)\s+REFERENCES\s+(\w+)\s+\((\s*\w+\s*(?:,\s*\w+\s*)*)\)(?:\s+ON\s+DELETE\s+(CASCADE|SET NULL|NO ACTION))?(?:\s+ON\s+UPDATE\s+(CASCADE|SET NULL|NO ACTION))?~is', $query, $match)) {
- $this->executeAddForeignKeyStatement($match[1], ($match[2] ?: self::getGenericIndexName($match[1], $match[3], 'fk')), array(
+ $this->executeAddForeignKeyStatement($match[1], ($match[2] ?: self::getGenericIndexName($match[1], $match[3], 'fk')), [
'columns' => $match[3],
'referencedTable' => $match[4],
'referencedColumns' => $match[5],
'ON DELETE' => isset($match[6]) ? $match[6] : '',
'ON UPDATE' => isset($match[7]) ? $match[7] : ''
- ));
+ ]);
}
// add/change column
else if (preg_match("~^ALTER\s+TABLE\s+(\w+)\s+(?:(ADD)\s+(?:COLUMN\s+)?|(CHANGE)\s+(?:COLUMN\s+)?(\w+)\s+)(\w+)\s+(\w+)(?:\s*\((\s*(?:\d+(?:\s*,\s*\d+)?|'[^']*'(?:\s*,\s*'[^']*')*))\s*\))?(?:\s+UNSIGNED)?(?:\s+(NOT NULL|NULL))?(?:\s+DEFAULT\s+(-?\d+.\d+|-?\d+|NULL|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'))?(?:\s+(AUTO_INCREMENT))?(?:\s+(UNIQUE|PRIMARY)(?: KEY)?)?~is", $query, $match)) {
$columnType = strtolower($match[6]);
- $columnData = array(
+ $columnData = [
'type' => $columnType,
'notNull' => ((!empty($match[8]) && strtoupper($match[8]) == 'NOT NULL') ? true : false),
'default' => (isset($match[9]) ? $match[9] : ''),
'autoIncrement' => (!empty($match[10]) ? true : false),
'key' => (!empty($match[11]) ? strtoupper($match[11]) : '')
- );
+ ];
if (!empty($match[7])) {
if ($columnType == 'enum') $columnData['values'] = $match[7];
else {
case 'CREATE INDEX':
if (preg_match('~^CREATE\s+(?:(UNIQUE|FULLTEXT)\s+)?INDEX\s+(\w+)\s+ON\s+(\w+)\s+\((\s*\w+\s*(?:,\s*\w+\s*)*)\)~is', $query, $match)) {
- $this->executeAddIndexStatement($match[3], ($match[2] ?: self::getGenericIndexName($match[3], $match[4])), array('type' => strtoupper($match[1]), 'columns' => $match[4]));
+ $this->executeAddIndexStatement($match[3], ($match[2] ?: self::getGenericIndexName($match[3], $match[4])), ['type' => strtoupper($match[1]), 'columns' => $match[4]]);
}
else {
throw new SystemException("Unsupported SQL statement '".$query."'");
* @param array $columns
* @param array $indices
*/
- protected function executeCreateTableStatement($tableName, $columns, $indices = array()) {
+ protected function executeCreateTableStatement($tableName, $columns, $indices = []) {
WCF::getDB()->getEditor()->createTable($tableName, $columns, $indices);
}
* list of available object types
* @var array
*/
- protected $availableObjectTypes = array();
+ protected $availableObjectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
(objectTypeID, objectID, message, time, obsoletedAt, userID, username, editReason, obsoletedByUserID)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectTypeID($objectType), $objectID, $message, $time, TIME_NOW, $userID, $username, $editReason, $obsoletedByUserID));
+ $statement->execute([$this->getObjectTypeID($objectType), $objectID, $message, $time, TIME_NOW, $userID, $username, $editReason, $obsoletedByUserID]);
}
/**
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) {
- $statement->execute(array($objectTypeID, $objectID));
+ $statement->execute([$objectTypeID, $objectID]);
}
WCF::getDB()->commitTransaction();
}
GROUP BY revertTo.objectTypeID, revertTo.objectID";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array_merge(
- array(TIME_NOW - $timeframe),
+ [TIME_NOW - $timeframe],
$userIDs,
- array(TIME_NOW - $timeframe),
+ [TIME_NOW - $timeframe],
$userIDs
));
if (empty($entryIDs)) return;
$list = new EditHistoryEntryList();
- $list->getConditionBuilder()->add('entryID IN(?)', array($entryIDs));
+ $list->getConditionBuilder()->add('entryID IN(?)', [$entryIDs]);
$list->readObjects();
foreach ($list as $entry) {
$entry->getObject()->revertVersion($entry);
* @param array &$parameters
* @throws SystemException
*/
- public function fireAction($eventObj, $eventName, array &$parameters = array()) {
+ public function fireAction($eventObj, $eventName, array &$parameters = []) {
// get class name
if (is_object($eventObj)) $className = get_class($eventObj);
else $className = $eventObj;
WHERE sessionID = ?
AND lastActivityTime >= ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
WCF::getSession()->sessionID,
(TIME_NOW - SESSION_TIMEOUT)
- ));
+ ]);
$row = $statement->fetchArray();
if (!empty($row['sessionLogID'])) {
$sessionLogID = $row['sessionLogID'];
- $sessionLogEditor = new ACPSessionLogEditor(new ACPSessionLog(null, array('sessionLogID' => $sessionLogID)));
- $sessionLogEditor->update(array(
+ $sessionLogEditor = new ACPSessionLogEditor(new ACPSessionLog(null, ['sessionLogID' => $sessionLogID]));
+ $sessionLogEditor->update([
'lastActivityTime' => TIME_NOW
- ));
+ ]);
}
else {
// create new session log
- $sessionLog = ACPSessionLogEditor::create(array(
+ $sessionLog = ACPSessionLogEditor::create([
'sessionID' => WCF::getSession()->sessionID,
'userID' => WCF::getUser()->userID,
'ipAddress' => UserUtil::getIpAddress(),
'userAgent' => WCF::getSession()->userAgent,
'time' => TIME_NOW,
'lastActivityTime' => TIME_NOW
- ));
+ ]);
$sessionLogID = $sessionLog->sessionLogID;
}
$requestURI = preg_replace('/(?:\?|&)s=[a-f0-9]{40}/', '', $requestURI);
// save access
- ACPSessionAccessLogEditor::create(array(
+ ACPSessionAccessLogEditor::create([
'sessionLogID' => $sessionLogID,
'ipAddress' => UserUtil::getIpAddress(),
'time' => TIME_NOW,
'requestURI' => $requestURI,
'requestMethod' => WCF::getSession()->requestMethod,
'className' => get_class($eventObj)
- ));
+ ]);
}
}
}
* @param mixed[] $returnValues
* @param string $exceptionID
*/
- public function __construct($message, $errorType = self::INTERNAL_ERROR, $stacktrace = null, $returnValues = array(), $exceptionID = '') {
+ public function __construct($message, $errorType = self::INTERNAL_ERROR, $stacktrace = null, $returnValues = [], $exceptionID = '') {
if ($stacktrace === null) $stacktrace = $this->getTraceAsString();
- $responseData = array(
+ $responseData = [
'code' => $errorType,
'message' => $message,
'returnValues' => $returnValues
- );
+ ];
// include a stacktrace if:
// - debug mode is enabled
* Shows a styled page with the given error message.
*/
public function show() {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'name' => get_class($this),
'file' => $this->getFile(),
'line' => $this->getLine(),
'stacktrace' => $this->getTraceAsString(),
'templateName' => 'userException',
'templateNameApplication' => 'wcf'
- ));
+ ]);
WCF::getTPL()->display('userException');
}
}
public function show() {
@header('HTTP/1.0 403 Forbidden');
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'name' => get_class($this),
'file' => $this->getFile(),
'line' => $this->getLine(),
'stacktrace' => $this->getTraceAsString(),
'templateName' => 'permissionDenied',
'templateNameApplication' => 'wcf'
- ));
+ ]);
WCF::getTPL()->display('permissionDenied');
}
}
* variables for AJAX error handling
* @var array
*/
- protected $variables = array();
+ protected $variables = [];
/**
* Creates a new UserInputException.
* @param string $type kind of this error
* @param array $variables additional variables for AJAX error handling
*/
- public function __construct($field = '', $type = 'empty', array $variables = array()) {
+ public function __construct($field = '', $type = 'empty', array $variables = []) {
$this->field = $field;
$this->type = $type;
$this->variables = $variables;
/**
* @see \Exception::__construct()
*/
- public function __construct($fieldName, $errorMessage = 'empty', array $variables = array()) {
+ public function __construct($fieldName, $errorMessage = 'empty', array $variables = []) {
$this->errorMessage = $errorMessage;
if (mb_strpos($this->errorMessage, '.') === false) {
$this->errorMessage = WCF::getLanguage()->get('wcf.global.form.error.'.$this->errorMessage);
}
$this->fieldName = $fieldName;
- $this->message = WCF::getLanguage()->getDynamicVariable('wcf.ajax.error.invalidParameter', array('fieldName' => $this->fieldName));
+ $this->message = WCF::getLanguage()->getDynamicVariable('wcf.ajax.error.invalidParameter', ['fieldName' => $this->fieldName]);
}
/**
* additional data
* @var array
*/
- public $additionalData = array();
+ public $additionalData = [];
/**
* database host name
* object type => method names
* @var array
*/
- protected $methods = array();
+ protected $methods = [];
/**
* limits for items per run
* @var integer[]
*/
- protected $limits = array();
+ protected $limits = [];
/**
* default limit for items per run
* selected import data
* @var array
*/
- protected $selectedData = array();
+ protected $selectedData = [];
/**
* @see \wcf\system\exporter\IExporter::setData()
throw new SystemException("unknown object type '".$objectType."' given");
}
- $count = call_user_func(array($this, 'count'.$this->methods[$objectType]));
+ $count = call_user_func([$this, 'count'.$this->methods[$objectType]]);
$limit = (isset($this->limits[$objectType]) ? $this->limits[$objectType] : $this->defaultLimit);
return ceil($count / $limit);
}
}
$limit = (isset($this->limits[$objectType]) ? $this->limits[$objectType] : $this->defaultLimit);
- call_user_func(array($this, 'export'.$this->methods[$objectType]), $loopCount * $limit, $limit);
+ call_user_func([$this, 'export'.$this->methods[$objectType]], $loopCount * $limit, $limit);
}
/**
* list of FormElementContainer objects
* @var IFormElementContainer[]
*/
- protected $containers = array();
+ protected $containers = [];
/**
* form document name
* Handles request input variables.
*/
public function handleRequest() {
- $variables = array();
+ $variables = [];
foreach ($_REQUEST as $key => $value) {
if (mb_strpos($key, $this->getName().'_') !== false) {
* list of IFormElement objects
* @var IFormElement[]
*/
- protected $children = array();
+ protected $children = [];
/**
* element description or help text
* container value
* @var array
*/
- protected $value = array();
+ protected $value = [];
/**
* Sets container value.
parent::setValue($value);
}
else {
- $this->value = array_map(array('wcf\util\StringUtil', 'trim'), $value);
+ $this->value = array_map(['wcf\util\StringUtil', 'trim'], $value);
}
}
* list of valid image adapters.
* @var string[]
*/
- protected $imageAdapters = array(
+ protected $imageAdapters = [
'gd' => 'wcf\system\image\adapter\GDImageAdapter',
'imagick' => 'wcf\system\image\adapter\ImagickImageAdapter'
- );
+ ];
/**
* image adapter class name
}
$imageAdapter = $this->imageAdapters[IMAGE_ADAPTER_TYPE];
- $isSupported = call_user_func(array($imageAdapter, 'isSupported'));
+ $isSupported = call_user_func([$imageAdapter, 'isSupported']);
// fallback to GD if image adapter is not available
if (!$isSupported) {
* red, green, blue data of the active color
* @var array
*/
- protected $colorData = array();
+ protected $colorData = [];
/**
* image height
$this->color = imagecolorallocate($this->image, $red, $green, $blue);
// save data of the color
- $this->colorData = array(
+ $this->colorData = [
'red' => $red,
'green' => $green,
'blue' => $blue
- );
+ ];
}
/**
* supported relative positions
* @var string[]
*/
- protected $relativePositions = array(
+ protected $relativePositions = [
'topLeft',
'topCenter',
'topRight',
'bottomLeft',
'bottomCenter',
'bottomRight'
- );
+ ];
/**
* Creates a new ImageAdapter instance.
* available options
* @var array
*/
- protected $options = array();
+ protected $options = [];
/**
* Creates an AbstractACLImporter object.
FROM wcf".WCF_N."_acl_option
WHERE objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->objectTypeID));
+ $statement->execute([$this->objectTypeID]);
while ($row = $statement->fetchArray()) {
$this->options[$row['optionName']] = $row['optionID'];
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
if (!isset($this->options[$additionalData['optionName']])) return 0;
$data['optionID'] = $this->options[$additionalData['optionName']];
(optionID, objectID, groupID, optionValue)
VALUES (?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($data['optionID'], $data['objectID'], $data['groupID'], $data['optionValue']));
+ $statement->execute([$data['optionID'], $data['objectID'], $data['groupID'], $data['optionValue']]);
return 1;
}
(optionID, objectID, userID, optionValue)
VALUES (?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($data['optionID'], $data['objectID'], $data['userID'], $data['optionValue']));
+ $statement->execute([$data['optionID'], $data['objectID'], $data['userID'], $data['optionValue']]);
return 1;
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
// check file location
if (!@file_exists($additionalData['fileLocation'])) return 0;
}
// save attachment
- $attachment = AttachmentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+ $attachment = AttachmentEditor::create(array_merge($data, ['objectTypeID' => $this->objectTypeID]));
// check attachment directory
// and create subdirectory if necessary
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
if (!empty($data['parentCategoryID'])) $data['parentCategoryID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['parentCategoryID']);
- $category = CategoryEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+ $category = CategoryEditor::create(array_merge($data, ['objectTypeID' => $this->objectTypeID]));
ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $category->categoryID);
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
- $comment = CommentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+ $comment = CommentEditor::create(array_merge($data, ['objectTypeID' => $this->objectTypeID]));
ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $comment->commentID);
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
$data['commentID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['commentID']);
WHERE commentID = ?
ORDER BY time ASC, responseID ASC";
$statement = WCF::getDB()->prepareStatement($sql, 5);
- $statement->execute(array($response->commentID));
+ $statement->execute([$response->commentID]);
$responseIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
// update parent comment
responses = responses + 1
WHERE commentID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
serialize($responseIDs),
$response->commentID
- ));
+ ]);
return $response->responseID;
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
if ($data['objectUserID']) $data['objectUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['objectUserID']);
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
if (!$data['userID']) return 0;
(objectID, objectTypeID, objectUserID, userID, time, likeValue)
VALUES (?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$data['objectID'],
$this->objectTypeID,
$data['objectUserID'],
$data['userID'],
$data['time'],
$data['likeValue']
- ));
+ ]);
return 0;
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
- $poll = PollEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+ public function import($oldID, array $data, array $additionalData = []) {
+ $poll = PollEditor::create(array_merge($data, ['objectTypeID' => $this->objectTypeID]));
ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $poll->pollID);
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['pollID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['pollID']);
if (!$data['pollID']) return 0;
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
if (!$data['userID']) return 0;
(pollID, optionID, userID)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($data['pollID'], $data['optionID'], $data['userID']));
+ $statement->execute([$data['pollID'], $data['optionID'], $data['userID']]);
return 1;
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
if (!$data['userID']) return 0;
try {
- $watch = UserObjectWatchEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+ $watch = UserObjectWatchEditor::create(array_merge($data, ['objectTypeID' => $this->objectTypeID]));
return $watch->watchID;
}
catch (DatabaseException $e) {
* @param array $additionalData
* @return mixed new id
*/
- public function import($oldID, array $data, array $additionalData = array());
+ public function import($oldID, array $data, array $additionalData = []);
/**
* Returns database object class name.
* id map cache
* @var array
*/
- protected $idMappingCache = array();
+ protected $idMappingCache = [];
/**
* list of available importers
* @var array
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* list of available importer processors
* @var array
*/
- protected $importers = array();
+ protected $importers = [];
/**
* user merge mode
* list of methods allowed for remote invoke
* @var string[]
*/
- public static $allowInvoke = array('resetMapping');
+ public static $allowInvoke = ['resetMapping'];
/**
* @see \wcf\system\SingletonFactory::init()
$importer = $this->getImporter($type);
$tableName = $indexName = '';
if ($importer->getClassName()) {
- $tableName = call_user_func(array($importer->getClassName(), 'getDatabaseTableName'));
- $indexName = call_user_func(array($importer->getClassName(), 'getDatabaseTableIndexName'));
+ $tableName = call_user_func([$importer->getClassName(), 'getDatabaseTableName']);
+ $indexName = call_user_func([$importer->getClassName(), 'getDatabaseTableIndexName']);
}
$sql = "SELECT import_mapping.newID
AND import_mapping.oldID = ?
".($tableName ? "AND object_table.".$indexName." IS NOT NULL" : '');
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->importHash, $objectTypeID, $oldID));
+ $statement->execute([$this->importHash, $objectTypeID, $oldID]);
$row = $statement->fetchArray();
if ($row !== false) $this->idMappingCache[$objectTypeID][$oldID] = $row['newID'];
}
(importHash, objectTypeID, oldID, newID)
VALUES (?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->importHash, $objectTypeID, $oldID, $newID));
+ $statement->execute([$this->importHash, $objectTypeID, $oldID, $newID]);
unset($this->idMappingCache[$objectTypeID][$oldID]);
}
* Validates accessibility of resetMapping().
*/
public function validateResetMapping() {
- WCF::getSession()->checkPermissions(array('admin.management.canImportData'));
+ WCF::getSession()->checkPermissions(['admin.management.canImportData']);
// reset caches
CacheHandler::getInstance()->flushAll();
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $this->idMappingCache = array();
+ $this->idMappingCache = [];
}
/**
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
// save label group
$labelGroup = LabelGroupEditor::create($data);
foreach ($additionalData['objects'] as $objectTypeID => $objectIDs) {
foreach ($objectIDs as $objectID) {
- $statement->execute(array($labelGroup->groupID, $objectTypeID, $objectID));
+ $statement->execute([$labelGroup->groupID, $objectTypeID, $objectID]);
}
}
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.label.group', $data['groupID']);
if (!$data['groupID']) return 0;
*
* @var string[]
*/
- public $knownCodes = array();
+ public $knownCodes = [];
/**
* Reads out known smiley codes.
$statement->execute();
while ($row = $statement->fetchArray()) {
- $known = array();
+ $known = [];
if (!empty($row['aliases'])) {
$known = explode("\n", $row['aliases']);
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
// copy smiley
$data['smileyPath'] = 'images/smilies/'.basename($additionalData['fileLocation']);
if (!@copy($additionalData['fileLocation'], WCF_DIR.$data['smileyPath'])) return 0;
if (!isset($data['aliases'])) $data['aliases'] = '';
// check aliases
- $aliases = array();
+ $aliases = [];
if (!empty($data['aliases'])) {
$aliases = explode("\n", StringUtil::unifyNewlines($data['aliases']));
foreach ($aliases as $key => $alias) {
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
// check file location
if (!@file_exists($additionalData['fileLocation'])) return 0;
}
// create thumbnails
- $action = new UserAvatarAction(array($avatar), 'generateThumbnails');
+ $action = new UserAvatarAction([$avatar], 'generateThumbnails');
$action->executeAction();
// update owner
SET avatarID = ?
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($avatar->avatarID, $data['userID']));
+ $statement->execute([$avatar->avatarID, $data['userID']]);
return $avatar->avatarID;
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['objectID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['objectID']);
if (!$data['objectID']) return 0;
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
$data['followUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['followUserID']);
if (!$data['userID'] || !$data['followUserID']) return 0;
(userID, followUserID, time)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$data['userID'],
$data['followUserID'],
$data['time']
- ));
+ ]);
return WCF::getDB()->getInsertID('wcf'.WCF_N.'_user_follow', 'followID');
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
if ($data['groupType'] < 4) {
$newGroupID = UserGroup::getGroupByType($data['groupType'])->groupID;
}
else {
- $action = new UserGroupAction(array(), 'create', array(
+ $action = new UserGroupAction([], 'create', [
'data' => $data
- ));
+ ]);
$returnValues = $action->executeAction();
$newGroupID = $returnValues['returnValues']->groupID;
}
* ids of default notification events
* @var integer[]
*/
- protected $eventIDs = array();
+ protected $eventIDs = [];
/**
* list of user options
* @var UserOption[]
*/
- protected $userOptions = array();
+ protected $userOptions = [];
const MERGE_MODE_EMAIL = 4;
const MERGE_MODE_USERNAME_OR_EMAIL = 5;
FROM wcf".WCF_N."_user_notification_event
WHERE preset = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(1));
+ $statement->execute([1]);
$this->eventIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
$userOptionList = new UserOptionList();
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
// whether to perform a merge
$performMerge = false;
}
// handle user options
- $userOptions = array();
+ $userOptions = [];
if (isset($additionalData['options'])) {
foreach ($additionalData['options'] as $optionName => $optionValue) {
if (is_int($optionName)) $optionID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.option', $optionName);
}
}
- $languageIDs = array();
+ $languageIDs = [];
if (isset($additionalData['languages'])) {
foreach ($additionalData['languages'] as $languageCode) {
$language = LanguageFactory::getInstance()->getLanguageByCode($languageCode);
$userEditor->updateUserOptions($userOptions);
// save user groups
- $groupIDs = array();
+ $groupIDs = [];
if (isset($additionalData['groupIDs'])) {
foreach ($additionalData['groupIDs'] as $oldGroupID) {
$newGroupID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $oldGroupID);
}
}
- if (!$user->activationCode) $defaultGroupIDs = UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE, UserGroup::USERS));
- else $defaultGroupIDs = UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE, UserGroup::GUESTS));
+ if (!$user->activationCode) $defaultGroupIDs = UserGroup::getGroupIDsByType([UserGroup::EVERYONE, UserGroup::USERS]);
+ else $defaultGroupIDs = UserGroup::getGroupIDsByType([UserGroup::EVERYONE, UserGroup::GUESTS]);
$groupIDs = array_merge($groupIDs, $defaultGroupIDs);
$sql = "INSERT IGNORE INTO wcf".WCF_N."_user_to_group
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($groupIDs as $groupID) {
- $statement->execute(array(
+ $statement->execute([
$user->userID,
$groupID
- ));
+ ]);
}
// save languages
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($languageIDs as $languageID) {
- $statement->execute(array(
+ $statement->execute([
$user->userID,
$languageID
- ));
+ ]);
}
// save default user events
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($this->eventIDs as $eventID) {
- $statement->execute(array(
+ $statement->execute([
$user->userID,
$eventID
- ));
+ ]);
}
// save mapping
FROM wcf".WCF_N."_user
WHERE username = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($newUsername));
+ $statement->execute([$newUsername]);
$row = $statement->fetchArray();
if (empty($row['userID'])) break;
}
FROM wcf".WCF_N."_language_category
WHERE languageCategory = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('wcf.user.option'));
+ $statement->execute(['wcf.user.option']);
$row = $statement->fetchArray();
$this->languageCategoryID = $row['languageCategoryID'];
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['packageID'] = 1;
// set temporary option name
$data['optionName'] = StringUtil::getRandomID();
$this->createCategory($data['categoryName']);
// save option
- $action = new UserOptionAction(array(), 'create', array('data' => $data));
+ $action = new UserOptionAction([], 'create', ['data' => $data]);
$returnValues = $action->executeAction();
$userOption = $returnValues['returnValues'];
// update generic option name
$editor = new UserOptionEditor($userOption);
- $editor->update(array(
+ $editor->update([
'optionName' => 'option'.$userOption->optionID
- ));
+ ]);
// save name
$sql = "INSERT IGNORE INTO wcf".WCF_N."_language_item
(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)
VALUES (?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
LanguageFactory::getInstance()->getDefaultLanguageID(),
'wcf.user.option.option'.$userOption->optionID,
$additionalData['name'],
0,
$this->languageCategoryID,
1
- ));
+ ]);
ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.option', $oldID, $userOption->optionID);
if ($this->categoryCache === null) {
// get existing categories
$list = new UserOptionCategoryList();
- $list->getConditionBuilder()->add('categoryName = ? OR parentCategoryName = ?', array('profile', 'profile'));
+ $list->getConditionBuilder()->add('categoryName = ? OR parentCategoryName = ?', ['profile', 'profile']);
$list->readObjects();
foreach ($list->getObjects() as $category) $this->categoryCache[] = $category->categoryName;
}
if (!in_array($name, $this->categoryCache)) {
// create category
- UserOptionCategoryEditor::create(array(
+ UserOptionCategoryEditor::create([
'packageID' => 1,
'categoryName' => $name,
'parentCategoryName' => 'profile'
- ));
+ ]);
$this->categoryCache[] = $name;
}
/**
* @see \wcf\system\importer\IImporter::import()
*/
- public function import($oldID, array $data, array $additionalData = array()) {
+ public function import($oldID, array $data, array $additionalData = []) {
$data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']);
if (!$data['groupID']) $data['groupID'] = UserGroup::getGroupByType(UserGroup::USERS)->groupID;
* @param array $options
* @throws SystemException
*/
- public function __construct($filename, $mode = 'wb', $options = array()) {
+ public function __construct($filename, $mode = 'wb', $options = []) {
$this->filename = $filename;
if (!empty($options)) {
$context = stream_context_create($options);
* @param array $options
* @throws SystemException
*/
- public function __construct($host, $port, $timeout = 30, $options = array()) {
+ public function __construct($host, $port, $timeout = 30, $options = []) {
$this->host = $host;
$this->port = $port;
* content of the tar file
* @var array
*/
- protected $contentList = array();
+ protected $contentList = [];
/**
* indicates if tar file is opened
* This does not get the entire to memory but only parts of it.
*/
protected function readContent() {
- $this->contentList = array();
+ $this->contentList = [];
$this->read = true;
$i = 0;
return false;
}
- $header = array();
+ $header = [];
$checksum = 0;
// First part of the header
for ($i = 0; $i < 148; $i++) {
* @throws SystemException
*/
public function add($files, $addDir = '', $removeDir = '') {
- if (!is_array($files)) $files = array($files);
+ if (!is_array($files)) $files = [$files];
if (empty($files)) return false;
$result = true;
}
$this->seek(-4, SEEK_CUR);
- $files = array();
+ $files = [];
while ($this->read(4) === self::CENTRAL_DIRECTORY_SIGNATURE) {
$data = unpack('vversion/vminVersion/vgeneralPurposeBit/vcompression/vmtime/vmdate', $this->read(12));
// calculate timestamp
if ($eof['commentLength'] > 0) $eof['comment'] = $this->read($eof['commentLength']);
else $eof['comment'] = '';
- return array('files' => $files, 'eof' => $eof);
+ return ['files' => $files, 'eof' => $eof];
}
/**
}
}
- return array('header' => $header, 'content' => $content);
+ return ['header' => $header, 'content' => $content];
}
/**
* @category Community Framework
*/
class ZipWriter {
- protected $headers = array();
- protected $data = array();
+ protected $headers = [];
+ protected $data = [];
protected $endOfData = "\x50\x4b\x05\x06\x00\x00\x00\x00";
protected $lastOffset = 0;
protected $zipComment = '';
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
- $this->cache = array(
- 'objectTypes' => array(),
- 'objectTypeNames' => array()
- );
+ $this->cache = [
+ 'objectTypes' => [],
+ 'objectTypeNames' => []
+ ];
$cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.object');
foreach ($cache as $objectType) {
public function getPermissions($optionName, array $labelIDs) {
if (empty($labelIDs)) {
// nothing to validate anyway
- return array();
+ return [];
}
if (empty($this->labelGroups['groups'])) {
// pretend given label ids aren't valid
- $data = array();
+ $data = [];
foreach ($labelIDs as $labelID) $data[$labelID] = false;
return $data;
}
// validate each label
- $data = array();
+ $data = [];
foreach ($labelIDs as $labelID) {
$isValid = false;
// delete previous labels
$conditions = new PreparedStatementConditionBuilder();
- if ($validatePermissions) $conditions->add("labelID IN (?)", array($accessibleLabelIDs));
- $conditions->add("objectTypeID = ?", array($objectTypeID));
- $conditions->add("objectID = ?", array($objectID));
+ if ($validatePermissions) $conditions->add("labelID IN (?)", [$accessibleLabelIDs]);
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("objectID = ?", [$objectID]);
if (!$validatePermissions || ($validatePermissions && !empty($accessibleLabelIDs))) {
$sql = "DELETE FROM wcf".WCF_N."_label_object
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($labelIDs as $labelID) {
- $statement->execute(array(
+ $statement->execute([
$labelID,
$objectTypeID,
$objectID
- ));
+ ]);
}
}
}
*/
public function getAssignedLabels($objectTypeID, array $objectIDs, $validatePermissions = true) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectTypeID));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "SELECT objectID, labelID
FROM wcf".WCF_N."_label_object
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $labels = array();
+ $labels = [];
while ($row = $statement->fetchArray()) {
if (!isset($labels[$row['labelID']])) {
- $labels[$row['labelID']] = array();
+ $labels[$row['labelID']] = [];
}
$labels[$row['labelID']][] = $row['objectID'];
}
// reorder the array by object id
- $data = array();
+ $data = [];
foreach ($labels as $labelID => $objectIDs) {
foreach ($objectIDs as $objectID) {
if (!isset($data[$objectID])) {
- $data[$objectID] = array();
+ $data[$objectID] = [];
}
foreach ($this->labelGroups['groups'] as $group) {
* @return ViewableLabelGroup[]
* @throws SystemException
*/
- public function getLabelGroups(array $groupIDs = array(), $validatePermissions = true, $permission = 'canSetLabel') {
- $data = array();
+ public function getLabelGroups(array $groupIDs = [], $validatePermissions = true, $permission = 'canSetLabel') {
+ $data = [];
if ($validatePermissions) {
$optionID = $this->getOptionID($permission);
$data[$groupID] = $this->labelGroups['groups'][$groupID];
}
- uasort($data, array('\wcf\data\label\group\LabelGroup', 'sortLabelGroups'));
+ uasort($data, ['\wcf\data\label\group\LabelGroup', 'sortLabelGroups']);
return $data;
}
* @return integer[]
*/
public function getAccessibleLabelIDs() {
- $labelIDs = array();
+ $labelIDs = [];
$groups = $this->getLabelGroups();
foreach ($groups as $group) {
*/
public function removeLabels($objectTypeID, array $objectIDs) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectTypeID));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "DELETE FROM wcf".WCF_N."_label_object
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
* list of available label groups
* @var ViewableLabelGroup[]
*/
- protected $labelGroups = array();
+ protected $labelGroups = [];
/**
* object type name
/**
* @see \wcf\system\label\manager\ILabelObjectHandler::getLabelGroupIDs()
*/
- public function getLabelGroupIDs(array $parameters = array()) {
+ public function getLabelGroupIDs(array $parameters = []) {
return array_keys($this->labelGroups);
}
/**
* @see \wcf\system\label\manager\ILabelObjectHandler::getLabelGroups()
*/
- public function getLabelGroups(array $parameters = array()) {
+ public function getLabelGroups(array $parameters = []) {
$groupIDs = $this->getLabelGroupIDs($parameters);
- $data = array();
+ $data = [];
foreach ($groupIDs as $groupID) {
$data[$groupID] = $this->labelGroups[$groupID];
}
- uasort($data, array('\wcf\data\label\group\LabelGroup', 'sortLabelGroups'));
+ uasort($data, ['\wcf\data\label\group\LabelGroup', 'sortLabelGroups']);
return $data;
}
}
}
- $validationErrors = array();
- $satisfiedGroups = array();
+ $validationErrors = [];
+ $satisfiedGroups = [];
foreach ($labelIDs as $groupID => $labelID) {
// only one label per group is allowed
if (is_array($labelID)) {
* @param array $parameters
* @return integer[]
*/
- public function getLabelGroupIDs(array $parameters = array());
+ public function getLabelGroupIDs(array $parameters = []);
/**
* Returns a list of label groups.
* @param array $parameters
* @return ViewableLabelGroup[]
*/
- public function getLabelGroups(array $parameters = array());
+ public function getLabelGroups(array $parameters = []);
/**
* Returns true, if all given label ids are valid and accessible.
* list of object types
* @var ObjectType[]
*/
- public $objectTypes = array();
+ public $objectTypes = [];
/**
* object type id
* initialized languages
* @var Language[]
*/
- protected $languages = array();
+ protected $languages = [];
/**
* active template scripting compiler
FROM wcf".WCF_N."_language
WHERE languageCode = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($languageCode));
+ $statement->execute([$languageCode]);
$row = $statement->fetchArray();
if (isset($row['languageID'])) return new Language($row['languageID']);
}
*/
protected function findPreferredLanguage() {
// get available language codes
- $availableLanguageCodes = array();
+ $availableLanguageCodes = [];
foreach ($this->getLanguages() as $language) {
$availableLanguageCodes[] = $language->languageCode;
}
* @return Language[]
*/
public function getContentLanguages() {
- $availableLanguages = array();
+ $availableLanguages = [];
foreach ($this->getLanguages() as $languageID => $language) {
if ($language->hasContent) {
$availableLanguages[$languageID] = $language;
SET isDefault = 1
WHERE languageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($languageID));
+ $statement->execute([$languageID]);
// rebuild language cache
$this->clearCache();
* loaded like objects
* @var LikeObject[][]
*/
- protected $likeObjectCache = array();
+ protected $likeObjectCache = [];
/**
* cached object types
return $this->likeObjectCache[$objectType->objectTypeID];
}
- return array();
+ return [];
}
/**
$i = 0;
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("like_object.objectTypeID = ?", array($objectType->objectTypeID));
- $conditions->add("like_object.objectID IN (?)", array($objectIDs));
+ $conditions->add("like_object.objectTypeID = ?", [$objectType->objectTypeID]);
+ $conditions->add("like_object.objectID IN (?)", [$objectIDs]);
$parameters = $conditions->getParameters();
if (WCF::getUser()->userID) {
// like data
$cumulativeLikes = 0;
$newValue = $oldValue = null;
- $users = array();
+ $users = [];
// update existing object
if ($likeObject->likeObjectID) {
}
// build update date
- $updateData = array(
+ $updateData = [
'likes' => $likes,
'dislikes' => $dislikes,
'cumulativeLikes' => $cumulativeLikes
- );
+ ];
if ($likeValue == 1) {
$users = unserialize($likeObject->cachedUsers);
if (count($users) < 3) {
- $users[$user->userID] = array('userID' => $user->userID, 'username' => $user->username);
+ $users[$user->userID] = ['userID' => $user->userID, 'username' => $user->username];
$updateData['cachedUsers'] = serialize($users);
}
}
else {
$cumulativeLikes = $likeValue;
$newValue = $likeValue;
- $users = array();
- if ($likeValue == 1) $users = array($user->userID => array('userID' => $user->userID, 'username' => $user->username));
+ $users = [];
+ if ($likeValue == 1) $users = [$user->userID => ['userID' => $user->userID, 'username' => $user->username]];
// create cache
- $likeObject = LikeObjectEditor::create(array(
+ $likeObject = LikeObjectEditor::create([
'objectTypeID' => $likeable->getObjectType()->objectTypeID,
'objectID' => $likeable->getObjectID(),
'objectUserID' => ($likeable->getUserID() ?: null),
'dislikes' => ($likeValue == Like::DISLIKE) ? 1 : 0,
'cumulativeLikes' => $cumulativeLikes,
'cachedUsers' => serialize($users)
- ));
+ ]);
}
// update owner's like counter
if ($likeable->getUserID()) {
if ($like->likeID) {
$userEditor = new UserEditor(new User($likeable->getUserID()));
- $userEditor->updateCounters(array(
+ $userEditor->updateCounters([
'likesReceived' => ($like->likeValue == Like::LIKE ? -1 : 1)
- ));
+ ]);
}
else if ($likeValue == Like::LIKE) {
$userEditor = new UserEditor(new User($likeable->getUserID()));
- $userEditor->updateCounters(array(
+ $userEditor->updateCounters([
'likesReceived' => 1
- ));
+ ]);
}
}
if (!$like->likeID) {
// save like
- $like = LikeEditor::create(array(
+ $like = LikeEditor::create([
'objectID' => $likeable->getObjectID(),
'objectTypeID' => $likeable->getObjectType()->objectTypeID,
'objectUserID' => ($likeable->getUserID() ?: null),
'userID' => $user->userID,
'time' => $time,
'likeValue' => $likeValue
- ));
+ ]);
if ($likeValue == Like::LIKE && $likeable->getUserID()) {
UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID());
}
else {
$likeEditor = new LikeEditor($like);
- $likeEditor->update(array(
+ $likeEditor->update([
'time' => $time,
'likeValue' => $likeValue
- ));
+ ]);
if ($likeable->getUserID()) {
if ($likeValue == Like::DISLIKE) {
- UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($likeable->getUserID() => 1));
+ UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$likeable->getUserID() => 1]);
}
else {
UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID());
WCF::getDB()->rollBackTransaction();
}
- return array(
+ return [
'data' => $this->loadLikeStatus($likeObject, $user),
'like' => $like,
'newValue' => $newValue,
'oldValue' => $oldValue,
'users' => $users
- );
+ ];
}
/**
}
// build update data
- $updateData = array(
+ $updateData = [
'likes' => $likes,
'dislikes' => $dislikes,
'cumulativeLikes' => $cumulativeLikes
- );
+ ];
$users = $likeObject->getUsers();
- $usersArray = array();
+ $usersArray = [];
foreach ($users as $user2) {
- $usersArray[$user2->userID] = array('userID' => $user2->userID, 'username' => $user2->username);
+ $usersArray[$user2->userID] = ['userID' => $user2->userID, 'username' => $user2->username];
}
if (isset($usersArray[$user->userID])) {
if ($likeable->getUserID()) {
if ($like->likeValue == Like::LIKE) {
$userEditor = new UserEditor(new User($likeable->getUserID()));
- $userEditor->updateCounters(array(
+ $userEditor->updateCounters([
'likesReceived' => -1
- ));
+ ]);
- UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($likeable->getUserID() => 1));
+ UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$likeable->getUserID() => 1]);
}
}
WCF::getDB()->rollBackTransaction();
}
- return array(
+ return [
'data' => $this->loadLikeStatus($likeObject, $user),
'newValue' => null,
'oldValue' => $like->likeValue,
'users' => $usersArray
- );
+ ];
}
/**
* @param integer[] $objectIDs
* @param string[] $notificationObjectTypes
*/
- public function removeLikes($objectType, array $objectIDs, array $notificationObjectTypes = array()) {
+ public function removeLikes($objectType, array $objectIDs, array $notificationObjectTypes = []) {
$objectTypeObj = $this->getObjectType($objectType);
// get like objects
$likeObjectList = new LikeObjectList();
- $likeObjectList->getConditionBuilder()->add('like_object.objectTypeID = ?', array($objectTypeObj->objectTypeID));
- $likeObjectList->getConditionBuilder()->add('like_object.objectID IN (?)', array($objectIDs));
+ $likeObjectList->getConditionBuilder()->add('like_object.objectTypeID = ?', [$objectTypeObj->objectTypeID]);
+ $likeObjectList->getConditionBuilder()->add('like_object.objectID IN (?)', [$objectIDs]);
$likeObjectList->readObjects();
$likeObjects = $likeObjectList->getObjects();
$likeObjectIDs = $likeObjectList->getObjectIDs();
// reduce count of received users
- $users = array();
+ $users = [];
foreach ($likeObjects as $likeObject) {
if ($likeObject->likes) {
if (!isset($users[$likeObject->objectUserID])) $users[$likeObject->objectUserID] = 0;
}
}
foreach ($users as $userID => $receivedLikes) {
- $userEditor = new UserEditor(new User(null, array('userID' => $userID)));
- $userEditor->updateCounters(array(
+ $userEditor = new UserEditor(new User(null, ['userID' => $userID]));
+ $userEditor->updateCounters([
'likesReceived' => $receivedLikes * -1
- ));
+ ]);
}
// get like ids
$likeList = new LikeList();
- $likeList->getConditionBuilder()->add('like_table.objectTypeID = ?', array($objectTypeObj->objectTypeID));
- $likeList->getConditionBuilder()->add('like_table.objectID IN (?)', array($objectIDs));
+ $likeList->getConditionBuilder()->add('like_table.objectTypeID = ?', [$objectTypeObj->objectTypeID]);
+ $likeList->getConditionBuilder()->add('like_table.objectID IN (?)', [$objectIDs]);
$likeList->readObjects();
if (count($likeList)) {
- $likeData = array();
+ $likeData = [];
foreach ($likeList as $like) {
$likeData[$like->likeID] = $like->userID;
}
AND like_table.userID = ?)
WHERE like_object.likeObjectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$user->userID,
$likeObject->likeObjectID
- ));
+ ]);
$row = $statement->fetchArray();
return $row;
* list of object types
* @var ObjectType[]
*/
- protected $cache = array();
+ protected $cache = [];
/**
* @see \wcf\system\SingletonFactory::init()
* @return ModificationLog
* @throws SystemException
*/
- protected function _add($objectType, $objectID, $action, array $additionalData = array(), $time = TIME_NOW, $userID = null, $username = null) {
+ protected function _add($objectType, $objectID, $action, array $additionalData = [], $time = TIME_NOW, $userID = null, $username = null) {
$objectTypeObj = $this->getObjectType($objectType);
if ($objectTypeObj === null) {
throw new SystemException("Object type '".$objectType."' not found within definition 'com.woltlab.wcf.modifiableContent'");
else $username = '';
}
- return ModificationLogEditor::create(array(
+ return ModificationLogEditor::create([
'objectTypeID' => $objectTypeObj->objectTypeID,
'objectID' => $objectID,
'action' => $action,
'username' => $username,
'time' => $time,
'additionalData' => serialize($additionalData)
- ));
+ ]);
}
/**
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectTypeObj->objectTypeID));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("objectTypeID = ?", [$objectTypeObj->objectTypeID]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "DELETE FROM wcf".WCF_N."_modification_log
".$conditions;
* mail recipients
* @var string[]
*/
- protected $to = array();
+ protected $to = [];
/**
* mail subject
* mail carbon copy
* @var string[]
*/
- protected $cc = array();
+ protected $cc = [];
/**
* mail blind carbon copy
* @var string[]
*/
- protected $bcc = array();
+ protected $bcc = [];
/**
* mail attachments
* @var array
*/
- protected $attachments = array();
+ protected $attachments = [];
/**
* priority of the mail
* @param integer $priority
* @param string $header
*/
- public function __construct($to = '', $subject = '', $message = '', $from = '', $cc = '', $bcc = '', $attachments = array(), $priority = '', $header = '') {
+ public function __construct($to = '', $subject = '', $message = '', $from = '', $cc = '', $bcc = '', $attachments = [], $priority = '', $header = '') {
$this->setBoundary();
- if (empty($from)) $from = array(MAIL_FROM_NAME => MAIL_FROM_ADDRESS);
+ if (empty($from)) $from = [MAIL_FROM_NAME => MAIL_FROM_ADDRESS];
if (empty($priority)) $priority = 3;
$this->setFrom($from);
* @param string $name filename
*/
public function addAttachment($path, $name = '') {
- $this->attachments[] = array('path' => $path, 'name' => ($name ?: basename($path)));
+ $this->attachments[] = ['path' => $path, 'name' => ($name ?: basename($path))];
}
/**
* mail recipients
* @var array
*/
- protected $recipients = array();
+ protected $recipients = [];
/**
* Creates a new SMTPMailSender object.
* @see \wcf\system\mail\MailSender::sendMail()
*/
public function sendMail(Mail $mail) {
- $this->recipients = array();
+ $this->recipients = [];
if (count($mail->getTo()) > 0) $this->recipients = $mail->getTo();
if (count($mail->getCC()) > 0) $this->recipients = array_merge($this->recipients, $mail->getCC());
if (count($mail->getBCC())> 0) $this->recipients = array_merge($this->recipients, $mail->getBCC());
* list of visible menu items
* @var ITreeMenuItem[]
*/
- public $menuItemList = array();
+ public $menuItemList = [];
/**
* list of the names of the active menu items
* @var string[]
*/
- public $activeMenuItems = array();
+ public $activeMenuItems = [];
/**
* list of all menu items
// call loadCache event
EventHandler::getInstance()->fireAction($this, 'loadCache');
- $this->menuItems = array();
+ $this->menuItems = [];
}
/**
* @param string $menuItem name of the active menu item
*/
public function setActiveMenuItem($menuItem) {
- $newActiveMenuItems = array();
+ $newActiveMenuItems = [];
while (isset($this->menuItemList[$menuItem])) {
$newActiveMenuItems[] = $menuItem;
$menuItem = $this->menuItemList[$menuItem]->parentMenuItem;
public function getMenuItems($parentMenuItem = null) {
if ($parentMenuItem === null) return $this->menuItems;
if (isset($this->menuItems[$parentMenuItem])) return $this->menuItems[$parentMenuItem];
- return array();
+ return [];
}
}
$user = new User($userID);
$this->optionHandler->setUser($user);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'options' => $this->optionHandler->getOptionTree(),
'userID' => $user->userID,
- ));
+ ]);
return WCF::getTPL()->fetch('userProfileAbout');
}
$commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->objectTypeID, $userID);
// assign variables
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'commentCanAdd' => $this->commentManager->canAdd($userID),
'commentList' => $commentList,
'commentObjectTypeID' => $this->objectTypeID,
'userID' => $userID,
'lastCommentTime' => $commentList->getMinCommentTime(),
- 'likeData' => (MODULE_LIKE ? $commentList->getLikeData() : array())
- ));
+ 'likeData' => (MODULE_LIKE ? $commentList->getLikeData() : [])
+ ]);
return WCF::getTPL()->fetch('userProfileCommentList');
}
*/
public function getContent($userID) {
$likeList = new ViewableLikeList();
- $likeList->getConditionBuilder()->add("like_table.objectUserID = ?", array($userID));
- $likeList->getConditionBuilder()->add("like_table.likeValue = ?", array(Like::LIKE));
+ $likeList->getConditionBuilder()->add("like_table.objectUserID = ?", [$userID]);
+ $likeList->getConditionBuilder()->add("like_table.likeValue = ?", [Like::LIKE]);
$likeList->readObjects();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'likeList' => $likeList,
'userID' => $userID,
'lastLikeTime' => $likeList->getLastLikeTime(),
- ));
+ ]);
return WCF::getTPL()->fetch('userProfileLikes');
}
*/
public function getContent($userID) {
$eventList = new ViewableUserActivityEventList();
- $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", array($userID));
+ $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", [$userID]);
$eventList->readObjects();
$lastEventTime = $eventList->getLastEventTime();
UserActivityEventHandler::validateEvents($eventList);
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'eventList' => $eventList,
'lastEventTime' => $lastEventTime,
'placeholder' => WCF::getLanguage()->get('wcf.user.profile.content.recentActivity.noEntries'),
'userID' => $userID
- ));
+ ]);
return WCF::getTPL()->fetch('recentActivities');
}
$enableBBCodes = $preParse = ($object->enableBBCodes) ? 1 : 0;
}
- return array(
+ return [
'enableSmilies' => $enableSmilies,
'enableBBCodes' => $enableBBCodes,
'preParse' => $preParse
- );
+ ];
}
}
$object->validateMessage($this->container, $parameters['data']['message']);
// check for message quote ids
- $parameters['removeQuoteIDs'] = (isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs'])) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : array();
+ $parameters['removeQuoteIDs'] = (isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs'])) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : [];
// check for tmp hash (attachments)
$parameters['tmpHash'] = '';
* @return array
*/
public function createMessage(IMessageQuickReplyAction $object, array &$parameters, $containerActionClassName, $sortOrder, $templateName, $application = 'wcf') {
- $additionalFields = array();
+ $additionalFields = [];
EventHandler::getInstance()->fireAction($this, 'createMessage', $additionalFields);
- $tableIndexName = call_user_func(array($this->container, 'getDatabaseTableIndexName'));
+ $tableIndexName = call_user_func([$this->container, 'getDatabaseTableIndexName']);
$parameters['data'][$tableIndexName] = $parameters['objectID'];
$parameters['data']['time'] = TIME_NOW;
$parameters['data']['userID'] = WCF::getUser()->userID ?: null;
}
$message = $object->create();
- $eventParameters = array('message' => $message);
+ $eventParameters = ['message' => $message];
EventHandler::getInstance()->fireAction($this, 'createdMessage', $eventParameters);
if ($message instanceof IMessage && !$message->isVisible()) {
- return array(
+ return [
'isVisible' => false
- );
+ ];
}
// resolve the page no
// calculate start index
$startIndex = $count - (count($messageList) - 1);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'attachmentList' => $messageList->getAttachmentList(),
'container' => $this->container,
'objects' => $messageList,
'startIndex' => $startIndex,
'sortOrder' => $sortOrder,
- ));
+ ]);
// assign 'to top' link
if (isset($parameters['anchor'])) {
// update visit time (messages shouldn't occur as new upon next visit)
if (is_subclass_of($containerActionClassName, 'wcf\data\IVisitableObjectAction')) {
- $containerAction = new $containerActionClassName(array(($this->container instanceof DatabaseObjectDecorator ? $this->container->getDecoratedObject() : $this->container)), 'markAsRead');
+ $containerAction = new $containerActionClassName([($this->container instanceof DatabaseObjectDecorator ? $this->container->getDecoratedObject() : $this->container)], 'markAsRead');
$containerAction->executeAction();
}
- return array(
+ return [
'lastPostTime' => $message->time,
'template' => WCF::getTPL()->fetch($templateName, $application)
- );
+ ];
}
else {
// redirect
- return array(
+ return [
'url' => $object->getRedirectUrl($this->container, $message)
- );
+ ];
}
}
* censored words
* @var string[]
*/
- protected $censoredWords = array();
+ protected $censoredWords = [];
/**
* word delimiters
* list of words
* @var string[]
*/
- protected $words = array();
+ protected $words = [];
/**
* list of matches
* @var array
*/
- protected $matches = array();
+ protected $matches = [];
/**
* @see \wcf\system\SingletonFactory::init()
continue;
}
- $displayedCensoredWord = str_replace(array('~', '*'), '', $censoredWord);
+ $displayedCensoredWord = str_replace(['~', '*'], '', $censoredWord);
// check if censored word contains at least one delimiter
if (preg_match('!'.$this->delimiters.'+!', $displayedCensoredWord)) {
*/
public function test($text) {
// reset values
- $this->matches = $this->words = array();
+ $this->matches = $this->words = [];
// string to lower case
$text = mb_strtolower($text);
public function parseMessage($message) {
$parsedAttachmentIDs = array_unique(ArrayUtil::toIntegerArray(array_merge(self::getFirstParameters($message, 'attach'), self::getTextParameters($message, 'attach'))));
if (!empty($parsedAttachmentIDs)) {
- $attachmentIDs = array();
+ $attachmentIDs = [];
foreach ($parsedAttachmentIDs as $parsedAttachmentID) {
if ($parsedAttachmentID) $attachmentIDs[] = $parsedAttachmentID;
}
if (!empty($attachmentIDs)) {
$attachmentList = new AttachmentList();
- $attachmentList->getConditionBuilder()->add("attachment.attachmentID IN (?)", array($attachmentIDs));
+ $attachmentList->getConditionBuilder()->add("attachment.attachmentID IN (?)", [$attachmentIDs]);
$attachmentList->readObjectIDs();
return $attachmentList->getObjectIDs();
$attachmentList->readObjects();
// group attachments by object type
- $groupedAttachments = array();
+ $groupedAttachments = [];
foreach ($attachmentList->getObjects() as $attachment) {
- if (!isset($groupedAttachments[$attachment->objectTypeID])) $groupedAttachments[$attachment->objectTypeID] = array();
+ if (!isset($groupedAttachments[$attachment->objectTypeID])) $groupedAttachments[$attachment->objectTypeID] = [];
$groupedAttachments[$attachment->objectTypeID][] = $attachment;
}
* caches message to embedded object assignments
* @var array
*/
- protected $messageEmbeddedObjects = array();
+ protected $messageEmbeddedObjects = [];
/**
* caches embedded objects
* @var array
*/
- protected $embeddedObjects = array();
+ protected $embeddedObjects = [];
/**
* object type of the active message
$message = BBCodeParser::getInstance()->removeCodeTags($message);
// delete existing assignments
- $this->removeObjects($messageObjectType, array($messageID));
+ $this->removeObjects($messageObjectType, [$messageID]);
// get object type id
$messageObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $messageObjectType);
if (!empty($objectIDs)) {
$returnValue = true;
foreach ($objectIDs as $objectID) {
- $statement->execute(array($messageObjectTypeID, $messageID, $handler->objectTypeID, $objectID));
+ $statement->execute([$messageObjectTypeID, $messageID, $handler->objectTypeID, $objectID]);
}
}
}
*/
public function removeObjects($messageObjectType, array $messageIDs) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('messageObjectTypeID = ?', array(ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $messageObjectType)));
- $conditionBuilder->add('messageID IN (?)', array($messageIDs));
+ $conditionBuilder->add('messageObjectTypeID = ?', [ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $messageObjectType)]);
+ $conditionBuilder->add('messageID IN (?)', [$messageIDs]);
$sql = "DELETE FROM wcf".WCF_N."_message_embedded_object
".$conditionBuilder;
*/
public function loadObjects($messageObjectType, array $messageIDs) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('messageObjectTypeID = ?', array(ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $messageObjectType)));
- $conditionBuilder->add('messageID IN (?)', array($messageIDs));
+ $conditionBuilder->add('messageObjectTypeID = ?', [ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $messageObjectType)]);
+ $conditionBuilder->add('messageID IN (?)', [$messageIDs]);
// get object ids
$sql = "SELECT *
".$conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
- $embeddedObjects = array();
+ $embeddedObjects = [];
while ($row = $statement->fetchArray()) {
if (isset($this->embeddedObjects[$row['embeddedObjectTypeID']][$row['embeddedObjectID']])) {
// embedded object already loaded
}
// group objects by object type
- if (!isset($embeddedObjects[$row['embeddedObjectTypeID']])) $embeddedObjects[$row['embeddedObjectTypeID']] = array();
+ if (!isset($embeddedObjects[$row['embeddedObjectTypeID']])) $embeddedObjects[$row['embeddedObjectTypeID']] = [];
$embeddedObjects[$row['embeddedObjectTypeID']][] = $row['embeddedObjectID'];
// store message to embedded object assignment
if (!isset($this->messageEmbeddedObjects[$row['messageObjectTypeID']][$row['messageID']][$row['embeddedObjectTypeID']])) {
- $this->messageEmbeddedObjects[$row['messageObjectTypeID']][$row['messageID']][$row['embeddedObjectTypeID']] = array();
+ $this->messageEmbeddedObjects[$row['messageObjectTypeID']][$row['messageID']][$row['embeddedObjectTypeID']] = [];
}
$this->messageEmbeddedObjects[$row['messageObjectTypeID']][$row['messageID']][$row['embeddedObjectTypeID']][] = $row['embeddedObjectID'];
}
// load objects
foreach ($embeddedObjects as $embeddedObjectTypeID => $objectIDs) {
- if (!isset($this->embeddedObjects[$embeddedObjectTypeID])) $this->embeddedObjects[$embeddedObjectTypeID] = array();
+ if (!isset($this->embeddedObjects[$embeddedObjectTypeID])) $this->embeddedObjects[$embeddedObjectTypeID] = [];
foreach ($this->getEmbeddedObjectHandler($embeddedObjectTypeID)->loadObjects(array_unique($objectIDs)) as $objectID => $object) {
$this->embeddedObjects[$embeddedObjectTypeID][$objectID] = $object;
}
*/
public function getObjects($embeddedObjectType) {
$embeddedObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message.embeddedObject', $embeddedObjectType);
- $returnValue = array();
+ $returnValue = [];
if (!empty($this->messageEmbeddedObjects[$this->activeMessageObjectTypeID][$this->activeMessageID][$embeddedObjectTypeID])) {
foreach ($this->messageEmbeddedObjects[$this->activeMessageObjectTypeID][$this->activeMessageID][$embeddedObjectTypeID] as $embeddedObjectID) {
if (isset($this->embeddedObjects[$embeddedObjectTypeID][$embeddedObjectID])) {
*/
protected function getEmbeddedObjectHandlers() {
if ($this->embeddedObjectHandlers === null) {
- $this->embeddedObjectHandlers = array();
+ $this->embeddedObjectHandlers = [];
foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.message.embeddedObject') as $objectType) {
$this->embeddedObjectHandlers[$objectType->objectTypeID] = $objectType->getProcessor();
}
* list of quoted message
* @var QuotedMessage[]
*/
- public $quotedMessages = array();
+ public $quotedMessages = [];
/**
* @see \wcf\system\message\quote\IMessageQuoteHandler::render()
*/
public function render(array $data, $supportPaste = false) {
$messages = $this->getMessages($data);
- $userIDs = $userProfiles = array();
+ $userIDs = $userProfiles = [];
foreach ($messages as $message) {
$userID = $message->getUserID();
if ($userID) {
$userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'messages' => $this->getMessages($data),
'supportPaste' => $supportPaste,
'userProfiles' => $userProfiles
- ));
+ ]);
return WCF::getTPL()->fetch($this->templateName);
}
public function renderQuotes(array $data, $render = true, $renderAsString = true) {
$messages = $this->getMessages($data);
- $renderedQuotes = array();
+ $renderedQuotes = [];
foreach ($messages as $message) {
foreach ($message as $quoteID => $quote) {
$quotedMessage = $message->getFullQuote($quoteID);
* list of full quotes for insertation
* @var string[]
*/
- public $fullQuotes = array();
+ public $fullQuotes = [];
/**
* quotable database object
* list of quotes (shortened)
* @var string[]
*/
- public $quotes = array();
+ public $quotes = [];
/**
* current iterator index
throw new SystemException("DatabaseObject class name '" . $this->className . "' is missing or invalid");
}
- $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
- $tableName = call_user_func(array($this->className, 'getDatabaseTableName'));
+ $indexName = call_user_func([$this->className, 'getDatabaseTableIndexName']);
+ $tableName = call_user_func([$this->className, 'getDatabaseTableName']);
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add($indexName . " IN (?)", array(array_keys($queues)));
+ $conditions->add($indexName . " IN (?)", [array_keys($queues)]);
$sql = "SELECT " . $indexName . "
FROM " . $tableName . "
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectTypeID));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "SELECT queueID
FROM wcf".WCF_N."_moderation_queue
* @param integer $containerID
* @param array $additionalData
*/
- protected function addEntry($objectTypeID, $objectID, $containerID = 0, array $additionalData = array()) {
+ protected function addEntry($objectTypeID, $objectID, $containerID = 0, array $additionalData = []) {
$sql = "SELECT queueID
FROM wcf".WCF_N."_moderation_queue
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID
- ));
+ ]);
$row = $statement->fetchArray();
if ($row === false) {
- $objectAction = new ModerationQueueAction(array(), 'create', array(
- 'data' => array(
+ $objectAction = new ModerationQueueAction([], 'create', [
+ 'data' => [
'objectTypeID' => $objectTypeID,
'objectID' => $objectID,
'containerID' => $containerID,
'userID' => (WCF::getUser()->userID ?: null),
'time' => TIME_NOW,
'additionalData' => serialize($additionalData)
- )
- ));
+ ]
+ ]);
$objectAction->executeAction();
}
else {
- $objectAction = new ModerationQueueAction(array($row['queueID']), 'update', array(
- 'data' => array(
+ $objectAction = new ModerationQueueAction([$row['queueID']], 'update', [
+ 'data' => [
'status' => ModerationQueue::STATUS_OUTSTANDING,
'containerID' => $containerID,
'userID' => (WCF::getUser()->userID ?: null),
'time' => TIME_NOW,
'additionalData' => serialize($additionalData)
- )
- ));
+ ]
+ ]);
$objectAction->executeAction();
}
*/
protected function removeEntries($objectTypeID, array $objectIDs) {
$queueList = new ModerationQueueList();
- $queueList->getConditionBuilder()->add("moderation_queue.objectTypeID = ?", array($objectTypeID));
- $queueList->getConditionBuilder()->add("moderation_queue.objectID IN (?)", array($objectIDs));
+ $queueList->getConditionBuilder()->add("moderation_queue.objectTypeID = ?", [$objectTypeID]);
+ $queueList->getConditionBuilder()->add("moderation_queue.objectID IN (?)", [$objectIDs]);
$queueList->readObjects();
if (count($queueList)) {
* @see \wcf\system\moderation\queue\IModerationQueueManager::getLink()
*/
public function getLink($queueID) {
- return LinkHandler::getInstance()->getLink('ModerationActivation', array('id' => $queueID));
+ return LinkHandler::getInstance()->getLink('ModerationActivation', ['id' => $queueID]);
}
/**
* @param array $additionalData
* @throws SystemException
*/
- public function addModeratedContent($objectType, $objectID, array $additionalData = array()) {
+ public function addModeratedContent($objectType, $objectID, array $additionalData = []) {
if (!$this->isValid($objectType)) {
throw new SystemException("Object type '".$objectType."' is not valid for definition 'com.woltlab.wcf.moderation.activation'");
}
* list of definition names by definition id
* @var string[]
*/
- protected $definitions = array();
+ protected $definitions = [];
/**
* list of moderation types
* @var ObjectType[]
*/
- protected $moderationTypes = array();
+ protected $moderationTypes = [];
/**
* list of object type names categorized by type
* @var integer[][]
*/
- protected $objectTypeNames = array();
+ protected $objectTypeNames = [];
/**
* list of object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
}
$this->definitions[$definition->definitionID] = $definition->definitionName;
- $this->objectTypeNames[$definition->definitionName] = array();
+ $this->objectTypeNames[$definition->definitionName] = [];
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes($definition->definitionName);
foreach ($objectTypes as $objectType) {
* @return integer[]
*/
public function getObjectTypeIDs(array $definitionIDs) {
- $objectTypeIDs = array();
+ $objectTypeIDs = [];
foreach ($definitionIDs as $definitionID) {
if (isset($this->definitions[$definitionID])) {
foreach ($this->objectTypeNames[$this->definitions[$definitionID]] as $objectTypeID) {
// count outstanding and assigned queues
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("moderation_queue_to_user.userID = ?", array(WCF::getUser()->userID));
- $conditions->add("moderation_queue_to_user.isAffected = ?", array(1));
- $conditions->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
+ $conditions->add("moderation_queue_to_user.userID = ?", [WCF::getUser()->userID]);
+ $conditions->add("moderation_queue_to_user.isAffected = ?", [1]);
+ $conditions->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING]]);
$sql = "SELECT COUNT(*)
FROM wcf".WCF_N."_moderation_queue_to_user moderation_queue_to_user
// count outstanding and assigned queues
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("moderation_queue_to_user.userID = ?", array(WCF::getUser()->userID));
- $conditions->add("moderation_queue_to_user.isAffected = ?", array(1));
- $conditions->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
- $conditions->add("moderation_queue.time > ?", array(VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.moderation.queue')));
+ $conditions->add("moderation_queue_to_user.userID = ?", [WCF::getUser()->userID]);
+ $conditions->add("moderation_queue_to_user.isAffected = ?", [1]);
+ $conditions->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING]]);
+ $conditions->add("moderation_queue.time > ?", [VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.moderation.queue')]);
$conditions->add("(moderation_queue.time > tracked_visit.visitTime OR tracked_visit.visitTime IS NULL)");
$sql = "SELECT COUNT(*)
$queueList->readObjects();
if (count($queueList)) {
- $queues = array();
+ $queues = [];
foreach ($queueList as $queue) {
if (!isset($queues[$queue->objectTypeID])) {
- $queues[$queue->objectTypeID] = array();
+ $queues[$queue->objectTypeID] = [];
}
$queues[$queue->objectTypeID][$queue->queueID] = $queue;
WCF::getDB()->beginTransaction();
foreach ($assignments as $queueID => $isAffected) {
- $statement->execute(array(
+ $statement->execute([
$queueID,
WCF::getUser()->userID,
($isAffected ? 1 : 0)
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
AND moderation_queue_to_user.isAffected = ?
AND moderation_queue.status <> ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
WCF::getUser()->userID,
1,
ModerationQueue::STATUS_DONE
- ));
+ ]);
- $queues = array();
+ $queues = [];
while ($row = $statement->fetchArray()) {
$objectTypeID = $row['objectTypeID'];
if (!isset($queues[$objectTypeID])) {
- $queues[$objectTypeID] = array();
+ $queues[$objectTypeID] = [];
}
$queues[$objectTypeID][$row['objectID']] = $row['queueID'];
}
if (!empty($queues)) {
- $queueIDs = array();
+ $queueIDs = [];
foreach ($queues as $objectTypeID => $objectQueues) {
$queueIDs = array_merge($queueIDs, $this->getProcessor($this->definitions[$this->objectTypes[$objectTypeID]->definitionID], null, $objectTypeID)->identifyOrphans($objectQueues));
}
public function removeOrphans(array $queueIDs) {
if (!empty($queueIDs)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("queueID IN (?)", array($queueIDs));
+ $conditions->add("queueID IN (?)", [$queueIDs]);
$sql = "DELETE FROM wcf".WCF_N."_moderation_queue
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
UserStorageHandler::getInstance()->resetAll('unreadModerationCount');
}
else {
- UserStorageHandler::getInstance()->reset(array($userID), 'outstandingModerationCount');
- UserStorageHandler::getInstance()->reset(array($userID), 'unreadModerationCount');
+ UserStorageHandler::getInstance()->reset([$userID], 'outstandingModerationCount');
+ UserStorageHandler::getInstance()->reset([$userID], 'unreadModerationCount');
}
}
* @return string[]
*/
public function getDefinitionNamesByObjectTypeIDs() {
- $definitionNames = array();
+ $definitionNames = [];
foreach ($this->objectTypeNames as $definitionName => $objectTypes) {
foreach ($objectTypes as $objectTypeID) {
$definitionNames[$objectTypeID] = $definitionName;
* @return string[]
*/
public function getDefinitionNamesByObjectType($objectType) {
- $definitionNames = array();
+ $definitionNames = [];
foreach ($this->objectTypeNames as $definitionName => $objectTypes) {
if (isset($objectTypes[$objectType])) {
$definitionNames[] = $definitionName;
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID
- ));
+ ]);
return $statement->fetchSingleColumn() > 0;
}
AND objectID = ?
AND status IN (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
ModerationQueue::STATUS_OUTSTANDING,
ModerationQueue::STATUS_PROCESSING
- ));
+ ]);
return $statement->fetchColumn() > 0;
}
* @see \wcf\system\moderation\queue\IModerationQueueManager::getLink()
*/
public function getLink($queueID) {
- return LinkHandler::getInstance()->getLink('ModerationReport', array('id' => $queueID));
+ return LinkHandler::getInstance()->getLink('ModerationReport', ['id' => $queueID]);
}
/**
* @param array $additionalData
* @throws SystemException
*/
- public function addReport($objectType, $objectID, $message, array $additionalData = array()) {
+ public function addReport($objectType, $objectID, $message, array $additionalData = []) {
if (!$this->isValid($objectType)) {
throw new SystemException("Object type '".$objectType."' is not valid for definition 'com.woltlab.wcf.moderation.report'");
}
/**
* @see \wcf\system\moderation\queue\AbstractModerationQueueManager::addEntry()
*/
- protected function addEntry($objectTypeID, $objectID, $containerID = 0, array $additionalData = array()) {
+ protected function addEntry($objectTypeID, $objectID, $containerID = 0, array $additionalData = []) {
$sql = "SELECT queueID
FROM wcf".WCF_N."_moderation_queue
WHERE objectTypeID = ?
AND objectID = ?
AND status <> ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
ModerationQueue::STATUS_DONE
- ));
+ ]);
$row = $statement->fetchArray();
if ($row === false) {
- $objectAction = new ModerationQueueAction(array(), 'create', array(
- 'data' => array(
+ $objectAction = new ModerationQueueAction([], 'create', [
+ 'data' => [
'objectTypeID' => $objectTypeID,
'objectID' => $objectID,
'containerID' => $containerID,
'userID' => (WCF::getUser()->userID ?: null),
'time' => TIME_NOW,
'additionalData' => serialize($additionalData)
- )
- ));
+ ]
+ ]);
$objectAction->executeAction();
}
else {
- $objectAction = new ModerationQueueAction(array($row['queueID']), 'update', array(
- 'data' => array(
+ $objectAction = new ModerationQueueAction([$row['queueID']], 'update', [
+ 'data' => [
'status' => ModerationQueue::STATUS_OUTSTANDING,
'containerID' => $containerID,
'userID' => (WCF::getUser()->userID ?: null),
'time' => TIME_NOW,
'additionalData' => serialize($additionalData)
- )
- ));
+ ]
+ ]);
$objectAction->executeAction();
}
* list with all enabled notices
* @var Notice[]
*/
- protected $notices = array();
+ protected $notices = [];
/**
* @see \wcf\system\SingletonFacetory::init()
* @return Notice[]
*/
public function getVisibleNotices() {
- $notices = array();
+ $notices = [];
foreach ($this->notices as $notice) {
if ($notice->isDismissed()) continue;
$categoryList = $categoryTree->getIterator();
$categoryList->setMaxDepth(0);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'categoryList' => $categoryList,
'option' => $option,
'value' => (!is_array($value) ? explode("\n", $value) : $value)
- ));
+ ]);
return WCF::getTPL()->fetch('categoryMultiSelectOptionType');
}
* @see \wcf\system\option\IOptionType::validate()
*/
public function validate(Option $option, $newValue) {
- if (!is_array($newValue)) $newValue = array();
+ if (!is_array($newValue)) $newValue = [];
$newValue = ArrayUtil::toIntegerArray($newValue);
foreach ($newValue as $categoryID) {
* @see \wcf\system\option\IOptionType::getData()
*/
public function getData(Option $option, $newValue) {
- if (!is_array($newValue)) $newValue = array();
+ if (!is_array($newValue)) $newValue = [];
return implode("\n", ArrayUtil::toIntegerArray($newValue));
}
}
if (!empty($value['ageFrom'])) $ageFrom = intval($value['ageFrom']);
if (!empty($value['ageTo'])) $ageTo = intval($value['ageTo']);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'valueAgeFrom' => $ageFrom,
'valueAgeTo' => $ageTo
- ));
+ ]);
return WCF::getTPL()->fetch('birthdaySearchableOptionType');
}
$dateFrom = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P'.($ageTo + 1).'Y'))->add(new \DateInterval('P1D'));
$dateTo = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P'.$ageFrom.'Y'));
- $conditions->add('option_value.userOption'.User::getUserOptionID('birthdayShowYear').' = ?', array(1));
+ $conditions->add('option_value.userOption'.User::getUserOptionID('birthdayShowYear').' = ?', [1]);
if ($ageFrom && $ageTo) {
- $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d')));
+ $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', [$dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d')]);
}
else if ($ageFrom) {
- $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array('1893-01-01', $dateTo->format('Y-m-d')));
+ $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', ['1893-01-01', $dateTo->format('Y-m-d')]);
}
else {
- $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), DateUtil::getDateTimeByTimestamp(TIME_NOW)->add(new \DateInterval('P1D'))->format('Y-m-d')));
+ $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', [$dateFrom->format('Y-m-d'), DateUtil::getDateTimeByTimestamp(TIME_NOW)->add(new \DateInterval('P1D'))->format('Y-m-d')]);
}
return true;
$dateFrom = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P'.($ageTo + 1).'Y'))->add(new \DateInterval('P1D'));
$dateTo = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P'.$ageFrom.'Y'));
- $userList->getConditionBuilder()->add('user_option_value.userOption'.User::getUserOptionID('birthdayShowYear').' = ?', array(1));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.User::getUserOptionID('birthdayShowYear').' = ?', [1]);
if ($ageFrom && $ageTo) {
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d')));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', [$dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d')]);
}
else if ($ageFrom) {
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array('1893-01-01', $dateTo->format('Y-m-d')));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', ['1893-01-01', $dateTo->format('Y-m-d')]);
}
else {
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), DateUtil::getDateTimeByTimestamp(TIME_NOW)->add(new \DateInterval('P1D'))->format('Y-m-d')));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', [$dateFrom->format('Y-m-d'), DateUtil::getDateTimeByTimestamp(TIME_NOW)->add(new \DateInterval('P1D'))->format('Y-m-d')]);
}
}
public function getFormElement(Option $option, $value) {
$options = Option::parseEnableOptions($option->enableOptions);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'disableOptions' => $options['disableOptions'],
'enableOptions' => $options['enableOptions'],
'option' => $option,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('booleanOptionType');
}
$value = intval($value);
if (!$value) return false;
- $conditions->add("option_value.userOption".$option->optionID." = ?", array(1));
+ $conditions->add("option_value.userOption".$option->optionID." = ?", [1]);
return true;
}
$value = intval($value);
if (!$value) return;
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' = ?', array(1));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' = ?', [1]);
}
/**
$selectOptions = CaptchaHandler::getInstance()->getCaptchaSelection();
if ($option->allowemptyvalue) {
$selectOptions = array_merge(
- array(
+ [
'' => WCF::getLanguage()->get('wcf.captcha.useNoCaptcha')
- ),
+ ],
$selectOptions
);
}
- return WCF::getTPL()->fetch('selectOptionType', 'wcf', array(
+ return WCF::getTPL()->fetch('selectOptionType', 'wcf', [
'selectOptions' => $selectOptions,
'option' => $option,
'value' => $value
- ));
+ ]);
}
/**
* upload handler for option files
* @var UploadHandler[]
*/
- protected $uploadHandlers = array();
+ protected $uploadHandlers = [];
/**
* Creates the upload handler for the given option.
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('fileOptionType');
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'inputClass' => $this->inputClass,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('integerOptionType');
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- $allowedBBCodes = array();
+ $allowedBBCodes = [];
if ($option->allowedbbcodepermission) {
$allowedBBCodes = explode(',', WCF::getSession()->getPermission($option->allowedbbcodepermission));
}
}
BBCodeHandler::getInstance()->setAllowedBBCodes($allowedBBCodes);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(),
'option' => $option,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('messageOptionType');
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'selectOptions' => $this->getSelectOptions($option),
'value' => (!is_array($value) ? explode("\n", $value) : $value)
- ));
+ ]);
return WCF::getTPL()->fetch($this->formElementTemplate);
}
* @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
*/
public function getSearchFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'searchOption' => $value !== null && ($value !== $option->defaultValue || isset($_POST['searchOptions'][$option->optionName])),
'selectOptions' => $this->getSelectOptions($option),
'value' => (!is_array($value) ? explode("\n", $value) : $value)
- ));
+ ]);
return WCF::getTPL()->fetch($this->searchableFormElementTemplate);
}
* @see \wcf\system\option\IOptionType::validate()
*/
public function validate(Option $option, $newValue) {
- if (!is_array($newValue)) $newValue = array();
+ if (!is_array($newValue)) $newValue = [];
$options = $this->getSelectOptions($option);
foreach ($newValue as $value) {
if (!isset($options[$value])) {
* @see \wcf\system\option\IOptionType::getData()
*/
public function getData(Option $option, $newValue) {
- if (!is_array($newValue)) $newValue = array();
+ if (!is_array($newValue)) $newValue = [];
return implode("\n", $newValue);
}
* options of the active category
* @var Option[]
*/
- public $options = array();
+ public $options = [];
/**
* type object cache
* @var IOptionType[]
*/
- public $typeObjects = array();
+ public $typeObjects = [];
/**
* language item pattern
* option values
* @var mixed[]
*/
- public $optionValues = array();
+ public $optionValues = [];
/**
* raw option values
* @var mixed[]
*/
- public $rawValues = array();
+ public $rawValues = [];
/**
* true, if options support i18n
* @see \wcf\system\option\IOptionHandler::validate()
*/
public function validate() {
- $errors = array();
+ $errors = [];
foreach ($this->options as $option) {
try {
* @see \wcf\system\option\IOptionHandler::getOptionTree()
*/
public function getOptionTree($parentCategoryName = '', $level = 0) {
- $tree = array();
+ $tree = [];
if (isset($this->cachedCategoryStructure[$parentCategoryName])) {
// get super categories
foreach ($this->cachedCategoryStructure[$parentCategoryName] as $superCategoryName) {
$superCategoryObject = $this->cachedCategories[$superCategoryName];
- $superCategory = array(
+ $superCategory = [
'object' => $superCategoryObject,
- 'categories' => array(),
- 'options' => array()
- );
+ 'categories' => [],
+ 'options' => []
+ ];
if ($this->checkCategory($superCategoryObject)) {
if ($level <= 1) {
* @see \wcf\system\option\IOptionHandler::getCategoryOptions()
*/
public function getCategoryOptions($categoryName = '', $inherit = true) {
- $children = array();
+ $children = [];
// get sub categories
if ($inherit && isset($this->cachedCategoryStructure[$categoryName])) {
* @see \wcf\system\option\IOptionHandler::save()
*/
public function save($categoryName = null, $optionPrefix = null) {
- $saveOptions = array();
+ $saveOptions = [];
if ($this->supportI18n && ($categoryName === null || $optionPrefix === null)) {
throw new SystemException("category name or option prefix missing");
// get form element html
$html = $this->getFormElement($option->optionType, $option);
- return array(
+ return [
'object' => $option,
'html' => $html,
'cssClassName' => $this->getTypeObject($option->optionType)->getCSSClassName(),
'hideLabelInSearch' => $this->getTypeObject($option->optionType)->hideLabelInSearch()
- );
+ ];
}
/**
}
else {
if ($this->abbreviations === null) {
- $this->abbreviations = array();
+ $this->abbreviations = [];
$applications = ApplicationHandler::getInstance()->getApplications();
foreach ($applications as $application) {
* Gets all options and option categories from cache.
*/
protected function readCache() {
- $cache = call_user_func(array($this->cacheClass, 'getInstance'));
+ $cache = call_user_func([$this->cacheClass, 'getInstance']);
// get cache contents
- $this->cachedCategories = $cache->getData(array(), 'categories');
- $this->cachedOptions = $cache->getData(array(), 'options');
- $this->cachedCategoryStructure = $cache->getData(array(), 'categoryStructure');
- $this->cachedOptionToCategories = $cache->getData(array(), 'optionToCategories');
+ $this->cachedCategories = $cache->getData([], 'categories');
+ $this->cachedOptions = $cache->getData([], 'options');
+ $this->cachedCategoryStructure = $cache->getData([], 'categoryStructure');
+ $this->cachedOptionToCategories = $cache->getData([], 'optionToCategories');
// allow option manipulation
EventHandler::getInstance()->fireAction($this, 'afterReadCache');
public function getFormElement(Option $option, $value) {
$selectOptions = PaymentMethodHandler::getInstance()->getPaymentMethodSelection();
- return WCF::getTPL()->fetch('paymentMethodSelectOptionType', 'wcf', array(
+ return WCF::getTPL()->fetch('paymentMethodSelectOptionType', 'wcf', [
'selectOptions' => $selectOptions,
'option' => $option,
'value' => explode(',', $value)
- ));
+ ]);
}
/**
*/
public function validate(Option $option, $newValue) {
if (!is_array($newValue)) {
- $newValue = array();
+ $newValue = [];
}
$selectOptions = PaymentMethodHandler::getInstance()->getPaymentMethodSelection();
*/
public function getFormElement(Option $option, $value) {
$availableOptions = $option->parseMultipleEnableOptions();
- $options = array(
- 'disableOptions' => array(),
- 'enableOptions' => array()
- );
+ $options = [
+ 'disableOptions' => [],
+ 'enableOptions' => []
+ ];
foreach ($availableOptions as $key => $enableOptions) {
$optionData = Option::parseEnableOptions($enableOptions);
$options['enableOptions'][$key] = $optionData['enableOptions'];
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'disableOptions' => $options['disableOptions'],
'enableOptions' => $options['enableOptions'],
'option' => $option,
'selectOptions' => $this->getSelectOptions($option),
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch($this->templateName);
}
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
if (!isset($_POST['searchOptions'][$option->optionName])) return false;
- $conditions->add("option_value.userOption".$option->optionID." = ?", array(StringUtil::trim($value)));
+ $conditions->add("option_value.userOption".$option->optionID." = ?", [StringUtil::trim($value)]);
return true;
}
* @inheritDoc
*/
public function addCondition(UserList $userList, Option $option, $value) {
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' = ?', array(StringUtil::trim($value)));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' = ?', [StringUtil::trim($value)]);
}
/**
public function getFormElement(Option $option, $value) {
$options = $this->parseEnableOptions($option);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'disableOptions' => $options['disableOptions'],
'enableOptions' => $options['enableOptions'],
'option' => $option,
'selectOptions' => $this->getSelectOptions($option),
'value' => $value,
'allowEmptyValue' => ($this->allowEmptyValue || $option->allowEmptyValue)
- ));
+ ]);
return WCF::getTPL()->fetch('selectOptionType');
}
public function getSearchFormElement(Option $option, $value) {
$options = $this->parseEnableOptions($option);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'disableOptions' => $options['disableOptions'],
'enableOptions' => $options['enableOptions'],
'option' => $option,
'searchOption' => ($value !== null && $value !== $option->defaultValue) || isset($_POST['searchOptions'][$option->optionName]),
'selectOptions' => $this->getSelectOptions($option),
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('selectSearchableOptionType');
}
}
}
- return array(
+ return [
'disableOptions' => $disableOptions,
'enableOptions' => $enableOptions
- );
+ ];
}
/**
public function getFormElement(Option $option, $value) {
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'inputType' => $this->inputType,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textI18nOptionType');
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'inputType' => $this->inputType,
'inputClass' => $this->inputClass,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textOptionType');
}
* @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
*/
public function getSearchFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'inputType' => $this->inputType,
'inputClass' => $this->inputClass,
'searchOption' => $value !== null && ($value !== $option->defaultValue || isset($_POST['searchOptions'][$option->optionName])),
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textSearchableOptionType');
}
$value = StringUtil::trim($value);
if ($value == '') {
- $conditions->add("option_value.userOption".$option->optionID." = ?", array(''));
+ $conditions->add("option_value.userOption".$option->optionID." = ?", ['']);
}
else {
- $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%'));
+ $conditions->add("option_value.userOption".$option->optionID." LIKE ?", ['%'.addcslashes($value, '_%').'%']);
}
return true;
public function addCondition(UserList $userList, Option $option, $value) {
$value = StringUtil::trim($value);
if ($value == '') {
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' = ?', array(''));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' = ?', ['']);
}
else {
- $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' LIKE ?', array('%'.addcslashes($value, '_%').'%'));
+ $userList->getConditionBuilder()->add('user_option_value.userOption'.$option->optionID.' LIKE ?', ['%'.addcslashes($value, '_%').'%']);
}
}
public function getFormElement(Option $option, $value) {
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textareaI18nOptionType');
}
$value = implode("\n", $ips);
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textareaOptionType');
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textareaOptionType');
}
* @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
*/
public function getSearchFormElement(Option $option, $value) {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'searchOption' => $value !== null && ($value !== $option->defaultValue || isset($_POST['searchOptions'][$option->optionName])),
'value' => $value
- ));
+ ]);
return WCF::getTPL()->fetch('textareaSearchableOptionType');
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- $timezoneOptions = array();
+ $timezoneOptions = [];
foreach (DateUtil::getAvailableTimezones() as $timezone) {
$timezoneOptions[$timezone] = WCF::getLanguage()->get('wcf.date.timezone.'.str_replace('/', '.', strtolower($timezone)));
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'selectOptions' => $timezoneOptions,
'value' => ($value ?: TIMEZONE)
- ));
+ ]);
return WCF::getTPL()->fetch('selectOptionType');
}
if (isset($optionValue[1])) $month = intval($optionValue[1]);
if (isset($optionValue[2])) $day = intval($optionValue[2]);
- return array('year' => $year, 'month' => $month, 'day' => $day);
+ return ['year' => $year, 'month' => $month, 'day' => $day];
}
}
MessageParser::getInstance()->setOutputType('text/html');
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'option' => $option,
'value' => MessageParser::getInstance()->parse($value),
- ));
+ ]);
return WCF::getTPL()->fetch('messageUserOptionOutput');
}
}
// multiselect
if (mb_strpos($value, "\n") !== false) {
$values = explode("\n", $value);
- $result = array();
+ $result = [];
foreach ($values as $value) {
if (isset($options[$value])) {
$result[] = $options[$value];
* @param \wcf\data\user\User $user
*/
public function setUser(User $user) {
- $this->optionValues = array();
+ $this->optionValues = [];
$this->user = $user;
$this->init();
* Resets the option values.
*/
public function resetOptionValues() {
- $this->optionValues = array();
+ $this->optionValues = [];
}
/**
*/
public function getData(Option $option, $newValue) {
if (!is_array($newValue)) {
- $newValue = array();
+ $newValue = [];
}
return implode(',', $newValue);
$this->loadBBCodeSelection();
}
- $selectedBBCodes = array();
+ $selectedBBCodes = [];
if ($value == 'all') {
$selectedBBCodes = $this->bbCodes;
}
$selectedBBCodes = explode(',', $value);
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'bbCodes' => $this->bbCodes,
'option' => $option,
'selectedBBCodes' => $selectedBBCodes
- ));
+ ]);
return WCF::getTPL()->fetch('bbCodeSelectOptionType');
}
$defaultValue = $this->bbCodes;
}
else if (empty($defaultValue) || $defaultValue == 'none') {
- $defaultValue = array();
+ $defaultValue = [];
}
else {
$defaultValue = explode(',', StringUtil::unifyNewlines($defaultValue));
$groupValue = $this->bbCodes;
}
else if (empty($groupValue) || $groupValue == 'none') {
- $groupValue = array();
+ $groupValue = [];
}
else {
$groupValue = explode(',', StringUtil::unifyNewlines($groupValue));
*/
public function validate(Option $option, $newValue) {
if (!is_array($newValue)) {
- $newValue = array();
+ $newValue = [];
}
if ($this->bbCodes === null) {
* @see \wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
public function merge($defaultValue, $groupValue) {
- $defaultValue = empty($defaultValue) ? array() : explode("\n", StringUtil::unifyNewlines($defaultValue));
- $groupValue = empty($groupValue) ? array() : explode("\n", StringUtil::unifyNewlines($groupValue));
+ $defaultValue = empty($defaultValue) ? [] : explode("\n", StringUtil::unifyNewlines($defaultValue));
+ $groupValue = empty($groupValue) ? [] : explode("\n", StringUtil::unifyNewlines($groupValue));
return implode("\n", array_unique(array_merge($defaultValue, $groupValue)));
}
* @see \wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
public function merge($defaultValue, $groupValue) {
- $defaultValue = empty($defaultValue) ? array() : explode("\n", StringUtil::unifyNewlines($defaultValue));
- $groupValue = empty($groupValue) ? array() : explode("\n", StringUtil::unifyNewlines($groupValue));
+ $defaultValue = empty($defaultValue) ? [] : explode("\n", StringUtil::unifyNewlines($defaultValue));
+ $groupValue = empty($groupValue) ? [] : explode("\n", StringUtil::unifyNewlines($groupValue));
return implode("\n", array_unique(array_merge($defaultValue, $groupValue)));
}
$groups = UserGroup::getGroupsByType();
// get new value
- if (!is_array($newValue)) $newValue = array();
+ if (!is_array($newValue)) $newValue = [];
$selectedGroups = ArrayUtil::toIntegerArray($newValue);
// check groups
* @see \wcf\system\option\IOptionType::getData()
*/
public function getData(Option $option, $newValue) {
- if (!is_array($newValue)) $newValue = array();
+ if (!is_array($newValue)) $newValue = [];
$newValue = ArrayUtil::toIntegerArray($newValue);
sort($newValue, SORT_NUMERIC);
return implode(',', $newValue);
* @see \wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
public function merge($defaultValue, $groupValue) {
- $defaultValue = empty($defaultValue) ? array() : explode(',', StringUtil::unifyNewlines($defaultValue));
- $groupValue = empty($groupValue) ? array() : explode(',', StringUtil::unifyNewlines($groupValue));
+ $defaultValue = empty($defaultValue) ? [] : explode(',', StringUtil::unifyNewlines($defaultValue));
+ $groupValue = empty($groupValue) ? [] : explode(',', StringUtil::unifyNewlines($groupValue));
return implode(',', array_unique(array_merge($defaultValue, $groupValue)));
}
* @see \wcf\system\option\IOptionType::compare()
*/
public function compare($value1, $value2) {
- $value1 = ($value1) ? explode(',', $value1) : array();
- $value2 = ($value2) ? explode(',', $value2) : array();
+ $value1 = ($value1) ? explode(',', $value1) : [];
+ $value2 = ($value2) ? explode(',', $value2) : [];
// check if value1 contains more elements than value2
$diff = array_diff($value1, $value2);
// get by other packages registered files
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add('packageID <> ?', array($this->packageInstallation->getPackageID()));
- $conditions->add('templateName IN (?)', array($files));
- $conditions->add('application = ?', array($this->application));
+ $conditions->add('packageID <> ?', [$this->packageInstallation->getPackageID()]);
+ $conditions->add('templateName IN (?)', [$files]);
+ $conditions->add('application = ?', [$this->application]);
if ($this->supportsTemplateGroups) {
$conditions->add("templateGroupID IS NULL");
}
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $lockedFiles = array();
+ $lockedFiles = [];
while ($row = $statement->fetchArray()) {
$lockedFiles[$row['templateName']] = $row['packageID'];
}
// fetch already installed acp templates
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add('packageID = ?', array($this->packageInstallation->getPackageID()));
- $conditions->add('templateName IN (?)', array($files));
- $conditions->add('application = ?', array($this->application));
+ $conditions->add('packageID = ?', [$this->packageInstallation->getPackageID()]);
+ $conditions->add('templateName IN (?)', [$files]);
+ $conditions->add('application = ?', [$this->application]);
$sql = "SELECT templateName
FROM wcf".WCF_N."_".$this->tableName."
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($files as $file) {
- $statement->execute(array(
+ $statement->execute([
$this->packageInstallation->getPackageID(),
$file,
$this->application
- ));
+ ]);
}
}
}
// get registered files of other packages for the
// same application
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add('packageID <> ?', array($this->packageInstallation->getPackageID()));
- $conditions->add('filename IN (?)', array($files));
- $conditions->add('application = ?', array($this->application));
+ $conditions->add('packageID <> ?', [$this->packageInstallation->getPackageID()]);
+ $conditions->add('filename IN (?)', [$files]);
+ $conditions->add('application = ?', [$this->application]);
$sql = "SELECT filename, packageID
FROM wcf".WCF_N."_package_installation_file_log
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $lockedFiles = array();
+ $lockedFiles = [];
while ($row = $statement->fetchArray()) {
$lockedFiles[$row['filename']] = $row['packageID'];
}
WCF::getDB()->beginTransaction();
foreach ($files as $file) {
- $statement->execute(array(
+ $statement->execute([
$this->packageInstallation->getPackageID(),
$file,
$this->application
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
* general package information
* @var array
*/
- protected $packageInfo = array();
+ protected $packageInfo = [];
/**
* author information
* @var array
*/
- protected $authorInfo = array();
+ protected $authorInfo = [];
/**
* list of requirements
* @var array
*/
- protected $requirements = array();
+ protected $requirements = [];
/**
* list of optional packages
* @var array
*/
- protected $optionals = array();
+ protected $optionals = [];
/**
* list of excluded packages
* @var array
*/
- protected $excludedPackages = array();
+ protected $excludedPackages = [];
/**
* list of instructions
* @var mixed[][]
*/
- protected $instructions = array(
- 'install' => array(),
- 'update' => array()
- );
+ protected $instructions = [
+ 'install' => [],
+ 'update' => []
+ ];
/**
* list of php requirements
* @var mixed[][]
*/
- protected $phpRequirements = array();
+ protected $phpRequirements = [];
/**
* default name of the package.xml file
public function openArchive() {
// check whether archive exists and is a TAR archive
if (!file_exists($this->archive)) {
- throw new PackageValidationException(PackageValidationException::FILE_NOT_FOUND, array('archive' => $this->archive));
+ throw new PackageValidationException(PackageValidationException::FILE_NOT_FOUND, ['archive' => $this->archive]);
}
// open archive and read package information
// search package.xml in package archive
// throw error message if not found
if ($this->tar->getIndexByFilename(self::INFO_FILE) === false) {
- throw new PackageValidationException(PackageValidationException::MISSING_PACKAGE_XML, array('archive' => $this->archive));
+ throw new PackageValidationException(PackageValidationException::MISSING_PACKAGE_XML, ['archive' => $this->archive]);
}
// extract package.xml, parse XML
$packageName = $package->getAttribute('name');
if (!Package::isValidPackageName($packageName)) {
// package name is not a valid package identifier
- throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, array('packageName' => $packageName));
+ throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, ['packageName' => $packageName]);
}
$this->packageInfo['name'] = $packageName;
case 'packagedescription':
case 'readme':
case 'license':
- if (!isset($this->packageInfo[$element->tagName])) $this->packageInfo[$element->tagName] = array();
+ if (!isset($this->packageInfo[$element->tagName])) $this->packageInfo[$element->tagName] = [];
$languageCode = 'default';
if ($element->hasAttribute('language')) {
case 'version':
if (!Package::isValidVersion($element->nodeValue)) {
- throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_VERSION, array('packageVersion' => $element->nodeValue));
+ throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_VERSION, ['packageVersion' => $element->nodeValue]);
}
$this->packageInfo['version'] = $element->nodeValue;
$elements = $xpath->query('child::ns:requiredpackages/ns:requiredpackage', $package);
foreach ($elements as $element) {
if (!Package::isValidPackageName($element->nodeValue)) {
- throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, array('packageName' => $element->nodeValue));
+ throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, ['packageName' => $element->nodeValue]);
}
// read attributes
- $data = array('name' => $element->nodeValue);
+ $data = ['name' => $element->nodeValue];
$attributes = $xpath->query('attribute::*', $element);
foreach ($attributes as $attribute) {
$data[$attribute->name] = $attribute->value;
$elements = $xpath->query('child::ns:optionalpackages/ns:optionalpackage', $package);
foreach ($elements as $element) {
if (!Package::isValidPackageName($element->nodeValue)) {
- throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, array('packageName' => $element->nodeValue));
+ throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, ['packageName' => $element->nodeValue]);
}
// read attributes
- $data = array('name' => $element->nodeValue);
+ $data = ['name' => $element->nodeValue];
$attributes = $xpath->query('attribute::*', $element);
foreach ($attributes as $attribute) {
$data[$attribute->name] = $attribute->value;
$elements = $xpath->query('child::ns:excludedpackages/ns:excludedpackage', $package);
foreach ($elements as $element) {
if (!Package::isValidPackageName($element->nodeValue)) {
- throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, array('packageName' => $element->nodeValue));
+ throw new PackageValidationException(PackageValidationException::INVALID_PACKAGE_NAME, ['packageName' => $element->nodeValue]);
}
// read attributes
- $data = array('name' => $element->nodeValue);
+ $data = ['name' => $element->nodeValue];
$attributes = $xpath->query('attribute::*', $element);
foreach ($attributes as $attribute) {
$data[$attribute->name] = $attribute->value;
// get instructions
$elements = $xpath->query('./ns:instructions', $package);
foreach ($elements as $element) {
- $instructionData = array();
+ $instructionData = [];
$instructions = $xpath->query('./ns:instruction', $element);
/** @var \DOMElement $instruction */
foreach ($instructions as $instruction) {
- $data = array();
+ $data = [];
$attributes = $xpath->query('attribute::*', $instruction);
foreach ($attributes as $attribute) {
$data[$attribute->name] = $attribute->value;
}
- $instructionData[] = array(
+ $instructionData[] = [
'attributes' => $data,
'pip' => $instruction->getAttribute('type'),
'value' => $instruction->nodeValue
- );
+ ];
}
$fromVersion = $element->getAttribute('fromversion');
// add com.woltlab.wcf to package requirements
if (!isset($this->requirements['com.woltlab.wcf']) && $this->packageInfo['name'] != 'com.woltlab.wcf') {
- $this->requirements['com.woltlab.wcf'] = array('name' => 'com.woltlab.wcf');
+ $this->requirements['com.woltlab.wcf'] = ['name' => 'com.woltlab.wcf'];
}
if ($this->package != null) {
}
if ($validFromVersion === null) {
- $this->instructions['update'] = array();
+ $this->instructions['update'] = [];
}
else {
$this->instructions['update'] = $this->instructions['update'][$validFromVersion];
FROM wcf".WCF_N."_package
WHERE package = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->packageInfo['name']));
+ $statement->execute([$this->packageInfo['name']]);
return $statement->fetchSingleColumn() > 0;
}
WHERE isApplication = ?
AND package LIKE ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
1,
'%.'.Package::getAbbreviation($this->packageInfo['name'])
- ));
+ ]);
return $statement->fetchSingleColumn() > 0;
}
* @return array
*/
public function getAllExistingRequirements() {
- $existingRequirements = array();
- $existingPackages = array();
+ $existingRequirements = [];
+ $existingPackages = [];
if ($this->package !== null) {
$sql = "SELECT package.*
FROM wcf".WCF_N."_package_requirement requirement
ON (package.packageID = requirement.requirement)
WHERE requirement.packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->package->packageID));
+ $statement->execute([$this->package->packageID]);
while ($row = $statement->fetchArray()) {
$existingRequirements[$row['package']] = $row;
}
}
// build sql
- $packageNames = array();
+ $packageNames = [];
$requirements = $this->getRequirements();
foreach ($requirements as $requirement) {
if (isset($existingRequirements[$requirement['name']])) {
- $existingPackages[$requirement['name']] = array();
+ $existingPackages[$requirement['name']] = [];
$existingPackages[$requirement['name']][$existingRequirements[$requirement['name']]['packageID']] = $existingRequirements[$requirement['name']];
}
else {
// check whether the required packages do already exist
if (!empty($packageNames)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package.package IN (?)", array($packageNames));
+ $conditions->add("package.package IN (?)", [$packageNames]);
$sql = "SELECT package.*
FROM wcf".WCF_N."_package package
}
if (!isset($existingPackages[$row['package']])) {
- $existingPackages[$row['package']] = array();
+ $existingPackages[$row['package']] = [];
}
$existingPackages[$row['package']][$row['packageID']] = $row;
*/
public function getExistingRequirements() {
// build sql
- $packageNames = array();
+ $packageNames = [];
foreach ($this->requirements as $requirement) {
$packageNames[] = $requirement['name'];
}
// check whether the required packages do already exist
- $existingPackages = array();
+ $existingPackages = [];
if (!empty($packageNames)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package IN (?)", array($packageNames));
+ $conditions->add("package IN (?)", [$packageNames]);
$sql = "SELECT *
FROM wcf".WCF_N."_package
$statement->execute($conditions->getParameters());
while ($row = $statement->fetchArray()) {
if (!isset($existingPackages[$row['package']])) {
- $existingPackages[$row['package']] = array();
+ $existingPackages[$row['package']] = [];
}
$existingPackages[$row['package']][$row['packageVersion']] = $row;
// sort multiple packages by version number
foreach ($existingPackages as $packageName => $instances) {
- uksort($instances, array('wcf\data\package\Package', 'compareVersion'));
+ uksort($instances, ['wcf\data\package\Package', 'compareVersion']);
// get package with highest version number (get last package)
$existingPackages[$packageName] = array_pop($instances);
$existingPackages = $this->getExistingRequirements();
// check for open requirements
- $openRequirements = array();
+ $openRequirements = [];
foreach ($this->requirements as $requirement) {
if (isset($existingPackages[$requirement['name']])) {
// package does already exist
// search the requested tar archive in our package archive.
// throw error message if not found.
if (($fileIndex = $this->tar->getIndexByFilename($filename)) === false) {
- throw new PackageValidationException(PackageValidationException::FILE_NOT_FOUND, array(
+ throw new PackageValidationException(PackageValidationException::FILE_NOT_FOUND, [
'archive' => $this->archive,
'targetArchive' => $filename
- ));
+ ]);
}
// requested tar archive was found
* @return Package[]
*/
public function getConflictedExcludingPackages() {
- $conflictedPackages = array();
+ $conflictedPackages = [];
$sql = "SELECT package.*, package_exclusion.*
FROM wcf".WCF_N."_package_exclusion package_exclusion
LEFT JOIN wcf".WCF_N."_package package
ON (package.packageID = package_exclusion.packageID)
WHERE excludedPackage = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->packageInfo['name']));
+ $statement->execute([$this->packageInfo['name']]);
while ($row = $statement->fetchArray()) {
if (!empty($row['excludedPackageVersion'])) {
if (Package::compareVersion($this->packageInfo['version'], $row['excludedPackageVersion'], '<')) {
* @return Package[]
*/
public function getConflictedExcludedPackages() {
- $conflictedPackages = array();
+ $conflictedPackages = [];
if (!empty($this->excludedPackages)) {
- $excludedPackages = array();
+ $excludedPackages = [];
foreach ($this->excludedPackages as $excludedPackageData) {
$excludedPackages[$excludedPackageData['name']] = $excludedPackageData['version'];
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package IN (?)", array(array_keys($excludedPackages)));
+ $conditions->add("package IN (?)", [array_keys($excludedPackages)]);
$sql = "SELECT *
FROM wcf".WCF_N."_package
FROM wcf".WCF_N."_language_category
WHERE languageCategory = ?";
$statement2 = WCF::getDB()->prepareStatement($sql);
- $statement2->execute(array('wcf.acp.package'));
+ $statement2->execute(['wcf.acp.package']);
$languageCategory = $statement2->fetchObject('wcf\data\language\category\LanguageCategory');
}
else {
// update description and name
$packageEditor = new PackageEditor($package);
- $packageEditor->update(array(
+ $packageEditor->update([
'packageDescription' => 'wcf.acp.package.packageDescription.package'.$this->queue->packageID,
'packageName' => 'wcf.acp.package.packageName.package'.$this->queue->packageID
- ));
+ ]);
}
/**
$value = $infoValues[$language->languageCode];
}
- $statement->execute(array(
+ $statement->execute([
$language->languageID,
'wcf.acp.package.'.$infoName.'.package'.$package->packageID,
$value,
$languageCategory->languageCategoryID,
1
- ));
+ ]);
}
}
$shiftNodes = true;
}
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'parentQueueID' => $queue->queueID,
'processNo' => $this->queue->processNo,
'userID' => WCF::getUser()->userID,
'packageName' => $package['packageName'],
'archive' => $package['archive'],
'action' => $queue->action
- ));
+ ]);
$installation = new PackageInstallationDispatcher($queue);
$installation->nodeBuilder->setParentNode($node);
FROM wcf".WCF_N."_package
WHERE packageDir = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('../'));
+ $statement->execute(['../']);
if ($statement->fetchSingleColumn()) {
// use abbreviation
$defaultPath .= strtolower(Package::getAbbreviation($this->getPackage()->package)) . '/';
// set package dir
$packageEditor = new PackageEditor($this->getPackage());
- $packageEditor->update(array(
+ $packageEditor->update([
'packageDir' => FileUtil::getRelativePath(WCF_DIR, $packageDir)
- ));
+ ]);
// determine domain path, in some environments (e.g. ISPConfig) the $_SERVER paths are
// faked and differ from the real filesystem path
FROM wcf".WCF_N."_application
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(1));
+ $statement->execute([1]);
$row = $statement->fetchArray();
$wcfDomainPath = $row['domainPath'];
// update application path
$application = new Application($this->getPackage()->packageID);
$applicationEditor = new ApplicationEditor($application);
- $applicationEditor->update(array(
+ $applicationEditor->update([
'domainPath' => $domainPath,
'cookiePath' => $domainPath
- ));
+ ]);
// create directory and set permissions
@mkdir($packageDir, 0777, true);
*/
public static function openQueue($parentQueueID = 0, $processNo = 0) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID = ?", array(WCF::getUser()->userID));
- $conditions->add("parentQueueID = ?", array($parentQueueID));
- if ($processNo != 0) $conditions->add("processNo = ?", array($processNo));
- $conditions->add("done = ?", array(0));
+ $conditions->add("userID = ?", [WCF::getUser()->userID]);
+ $conditions->add("parentQueueID = ?", [$parentQueueID]);
+ if ($processNo != 0) $conditions->add("processNo = ?", [$processNo]);
+ $conditions->add("done = ?", [0]);
$sql = "SELECT *
FROM wcf".WCF_N."_package_installation_queue
exit;
}
else {
- $url = LinkHandler::getInstance()->getLink('PackageInstallationConfirm', array(), 'queueID='.$packageInstallation['queueID']);
+ $url = LinkHandler::getInstance()->getLink('PackageInstallationConfirm', [], 'queueID='.$packageInstallation['queueID']);
HeaderUtil::redirect($url);
exit;
}
AND done = 0
ORDER BY queueID ASC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(WCF::getUser()->userID));
+ $statement->execute([WCF::getUser()->userID]);
$row = $statement->fetchArray();
if (!$row) {
FROM wcf".WCF_N."_package_installation_queue
WHERE processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->queue->processNo));
+ $statement->execute([$this->queue->processNo]);
while ($row = $statement->fetchArray()) {
@unlink($row['archive']);
}
$sql = "DELETE FROM wcf".WCF_N."_package_installation_queue
WHERE processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->queue->processNo));
+ $statement->execute([$this->queue->processNo]);
// clear language files once whole installation is completed
LanguageEditor::deleteLanguageFiles();
public function updatePackage() {
if (empty($this->queue->packageName)) {
$queueEditor = new PackageInstallationQueueEditor($this->queue);
- $queueEditor->update(array(
+ $queueEditor->update([
'packageName' => $this->getArchive()->getLocalizedPackageInfo('packageName')
- ));
+ ]);
// reload queue
$this->queue = new PackageInstallationQueue($this->queue->queueID);
* @return mixed[][]
*/
public static function validatePHPRequirements(array $requirements) {
- $errors = array();
+ $errors = [];
// validate php version
if (isset($requirements['version'])) {
}
if (!$passed) {
- $errors['version'] = array(
+ $errors['version'] = [
'required' => $requirements['version'],
'installed' => PHP_VERSION
- );
+ ];
}
}
$passed = (extension_loaded($extension)) ? true : false;
if (!$passed) {
- $errors['extension'][] = array(
+ $errors['extension'][] = [
'extension' => $extension
- );
+ ];
}
}
}
$passed = self::compareSetting($setting, $value, $iniValue);
if (!$passed) {
- $errors['setting'][] = array(
+ $errors['setting'][] = [
'setting' => $setting,
'required' => $value,
'installed' => ($iniValue === false) ? '(unknown)' : $iniValue
- );
+ ];
}
}
}
$passed = self::functionExists($function);
if (!$passed) {
- $errors['function'][] = array(
+ $errors['function'][] = [
'function' => $function
- );
+ ];
}
}
}
}
if (!$passed) {
- $errors['class'][] = array(
+ $errors['class'][] = [
'class' => $class
- );
+ ];
}
}
if ($compareValue === false) return false;
$value = mb_strtolower($value);
- $trueValues = array('1', 'on', 'true');
- $falseValues = array('0', 'off', 'false');
+ $trueValues = ['1', 'on', 'true'];
+ $falseValues = ['0', 'off', 'false'];
// handle values considered as 'true'
if (in_array($value, $trueValues)) {
WHERE queueID = ?
AND formName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$queue->queueID,
$formName
- ));
+ ]);
return $statement->fetchSingleColumn() > 0;
}
(queueID, formName, document)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$queue->queueID,
$document->getName(),
base64_encode(serialize($document))
- ));
+ ]);
}
/**
WHERE queueID = ?
AND formName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
base64_encode(serialize($document)),
$queue->queueID,
$document->formName // TODO: FormDocument::$formName does not exist, FormDocument::getName()?
- ));
+ ]);
}
/**
$sql = "DELETE FROM wcf".WCF_N."_package_installation_form
WHERE queueID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($queue->queueID));
+ $statement->execute([$queue->queueID]);
}
/**
WHERE queueID = ?
AND formName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$queue->queueID,
$formName
- ));
+ ]);
$row = $statement->fetchArray();
if ($row) {
* list of requirements to be checked before package installation
* @var mixed[][]
*/
- public $requirements = array();
+ public $requirements = [];
/**
* current sequence number within one node
* list of packages about to be installed
* @var string[]
*/
- protected static $pendingPackages = array();
+ protected static $pendingPackages = [];
/**
* Creates a new instance of PackageInstallationNodeBuilder
WHERE processNo = ?
AND parentNode = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->processNo,
$parentNode
- ));
+ ]);
$row = $statement->fetchArray();
if (!$row) {
FROM wcf".WCF_N."_package_installation_queue
WHERE queueID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($queueID));
+ $statement->execute([$queueID]);
$row = $statement->fetchArray();
if (!$row) {
FROM wcf".WCF_N."_package_installation_queue
WHERE queueID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($queueID));
+ $statement->execute([$queueID]);
$row = $statement->fetchArray();
return $row['action'];
AND node = ?
ORDER BY sequenceNo ASC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->processNo,
$node
- ));
- $data = array();
+ ]);
+ $data = [];
while ($row = $statement->fetchArray()) {
$data[] = $row;
}
WHERE processNo = ?
AND node = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->processNo,
$node
- ));
+ ]);
}
/**
$sql = "DELETE FROM wcf".WCF_N."_package_installation_node
WHERE processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->processNo
- ));
+ ]);
$sql = "DELETE FROM wcf".WCF_N."_package_installation_form
WHERE queueID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID
- ));
+ ]);
}
/**
* @return integer
*/
public function calculateProgress($node) {
- $progress = array(
+ $progress = [
'done' => 0,
'outstanding' => 0
- );
+ ];
$sql = "SELECT done
FROM wcf".WCF_N."_package_installation_node
WHERE processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->processNo
- ));
+ ]);
while ($row = $statement->fetchArray()) {
if ($row['done']) {
$progress['done']++;
WHERE parentNode = ?
AND processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$newNode,
$node,
$this->installation->queue->processNo
- ));
+ ]);
// create a copy of current node (prevents empty nodes)
$sql = "SELECT nodeType, nodeData, done
AND processNo = ?
AND sequenceNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$node,
$this->installation->queue->processNo,
$sequenceNo
- ));
+ ]);
$row = $statement->fetchArray();
$sql = "INSERT INTO wcf".WCF_N."_package_installation_node
(queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData, done)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID,
$this->installation->queue->processNo,
0,
$row['nodeType'],
$row['nodeData'],
$row['done']
- ));
+ ]);
// move other child-nodes greater than $sequenceNo into new node
$sql = "UPDATE wcf".WCF_N."_package_installation_node
AND processNo = ?
AND sequenceNo > ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$node,
$newNode,
$sequenceNo,
$node,
$this->installation->queue->processNo,
$sequenceNo
- ));
+ ]);
}
/**
WHERE parentNode = ?
AND processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$newNode,
$beforeNode,
$this->installation->queue->processNo
- ));
+ ]);
// execute callback
$callback($beforeNode, $newNode);
WHERE parentNode = ?
AND processNo = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$newParentNode,
$oldParentNode,
$this->installation->queue->processNo
- ));
+ ]);
}
/**
(queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID,
$this->installation->queue->processNo,
$this->sequenceNo,
$this->node,
$this->parentNode,
'package',
- serialize(array(
+ serialize([
'package' => $this->installation->getArchive()->getPackageInfo('name'),
'packageName' => $this->installation->getArchive()->getLocalizedPackageInfo('packageName'),
'packageDescription' => $this->installation->getArchive()->getLocalizedPackageInfo('packageDescription'),
'installDate' => TIME_NOW,
'updateDate' => TIME_NOW,
'requirements' => $this->requirements
- ))
- ));
+ ])
+ ]);
}
/**
}
// requirements will be checked once package is about to be installed
- $this->requirements[$packageName] = array(
+ $this->requirements[$packageName] = [
'minVersion' => (isset($package['minversion'])) ? $package['minversion'] : '',
'packageID' => $package['packageID']
- );
+ ];
continue;
}
FROM wcf".WCF_N."_package
WHERE package = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($archive->getPackageInfo('name')));
+ $statement->execute([$archive->getPackageInfo('name')]);
$row = $statement->fetchArray();
$packageID = ($row === false) ? null : $row['packageID'];
}
// create new queue
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'parentQueueID' => $queue->queueID,
'processNo' => $queue->processNo,
'userID' => WCF::getUser()->userID,
'packageName' => $archive->getLocalizedPackageInfo('packageName'),
'archive' => $fileName,
'action' => ($packageID ? 'update' : 'install')
- ));
+ ]);
self::$pendingPackages[$archive->getPackageInfo('name')] = $archive->getPackageInfo('version');
$this->node = $this->getToken();
- $pluginNodes = array();
+ $pluginNodes = [];
$this->emptyNode = true;
$instructions = ($this->installation->getAction() == 'install') ? $this->installation->getArchive()->getInstallInstructions() : $this->installation->getArchive()->getUpdateInstructions();
$this->node = $this->getToken();
$this->sequenceNo = 0;
}
- $pluginNodes[] = array(
+ $pluginNodes[] = [
'data' => $pip,
'node' => $this->node,
'parentNode' => $this->parentNode,
'sequenceNo' => $this->sequenceNo
- );
+ ];
// create a new node for following PIPs, unless it is the last one
if ($i < $count) {
else {
$this->sequenceNo++;
- $pluginNodes[] = array(
+ $pluginNodes[] = [
'data' => $pip,
'node' => $this->node,
'parentNode' => $this->parentNode,
'sequenceNo' => $this->sequenceNo
- );
+ ];
$this->emptyNode = false;
}
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($pluginNodes as $index => $nodeData) {
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID,
$this->installation->queue->processNo,
$nodeData['sequenceNo'],
$nodeData['parentNode'],
'pip',
serialize($nodeData['data'])
- ));
+ ]);
}
}
}
* not really matter at this point).
*/
protected function buildOptionalNodes() {
- $packages = array();
+ $packages = [];
$optionalPackages = $this->installation->getArchive()->getOptionals();
foreach ($optionalPackages as $package) {
$isInstallable = false;
}
- $packages[] = array(
+ $packages[] = [
'archive' => $fileName,
'isInstallable' => $isInstallable,
'package' => $archive->getPackageInfo('name'),
'packageName' => $archive->getLocalizedPackageInfo('packageName'),
'packageDescription' => $archive->getLocalizedPackageInfo('packageDescription'),
'selected' => 0
- );
+ ];
self::$pendingPackages[$archive->getPackageInfo('name')] = $archive->getPackageInfo('version');
}
(queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID,
$this->installation->queue->processNo,
$this->sequenceNo,
$this->parentNode,
'optionalPackages',
serialize($packages)
- ));
+ ]);
}
}
*/
protected function buildChildQueues() {
$queueList = new PackageInstallationQueueList();
- $queueList->getConditionBuilder()->add("package_installation_queue.parentQueueID = ?", array($this->installation->queue->queueID));
+ $queueList->getConditionBuilder()->add("package_installation_queue.parentQueueID = ?", [$this->installation->queue->queueID]);
$queueList->getConditionBuilder()->add("package_installation_queue.queueID NOT IN (SELECT queueID FROM wcf".WCF_N."_package_installation_node)");
$queueList->readObjects();
// work-around for iterative package updates
if ($this->installation->queue->action == 'update' && $queue->package == $this->installation->queue->package) {
- $installation->setPreviousPackage(array(
+ $installation->setPreviousPackage([
'package' => $this->installation->getArchive()->getPackageInfo('name'),
'packageVersion' => $this->installation->getArchive()->getPackageInfo('version')
- ));
+ ]);
}
$installation->nodeBuilder->setParentNode($this->node);
WHERE processNo = ?
AND node = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$processNo,
$node
- ));
+ ]);
$row = $statement->fetchArray();
return $row['queueID'];
* list of existing database tables
* @var array
*/
- protected $existingTables = array();
+ protected $existingTables = [];
/**
* list of logged tables
* @var array
*/
- protected $knownTables = array();
+ protected $knownTables = [];
/**
* list of conflicted database tables
* @var array
*/
- protected $conflicts = array();
+ protected $conflicts = [];
/**
* list of created/deleted tables
* @var array
*/
- protected $tableLog = array();
+ protected $tableLog = [];
/**
* list of created/deleted columns
* @var array
*/
- protected $columnLog = array();
+ protected $columnLog = [];
/**
* list of created/deleted indices
* @var array
*/
- protected $indexLog = array();
+ protected $indexLog = [];
/**
* Creates a new PackageInstallationSQLParser object.
* @return array conflicts
*/
public function test() {
- $this->conflicts = array();
+ $this->conflicts = [];
// get all existing tables from database
$this->existingTables = WCF::getDB()->getEditor()->getTableNames();
$sql = "DELETE FROM wcf".WCF_N."_package_installation_sql_log
WHERE sqlTable = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($logEntry['tableName']));
+ $statement->execute([$logEntry['tableName']]);
if ($logEntry['action'] == 'insert') {
$sql = "INSERT INTO wcf".WCF_N."_package_installation_sql_log
(packageID, sqlTable)
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$logEntry['packageID'],
$logEntry['tableName']
- ));
+ ]);
}
}
$insertStatement = WCF::getDB()->prepareStatement($sql);
foreach ($this->columnLog as $logEntry) {
- $deleteStatement->execute(array(
+ $deleteStatement->execute([
$logEntry['tableName'],
$logEntry['columnName']
- ));
+ ]);
if ($logEntry['action'] == 'insert') {
- $insertStatement->execute(array(
+ $insertStatement->execute([
$logEntry['packageID'],
$logEntry['tableName'],
$logEntry['columnName']
- ));
+ ]);
}
}
}
$insertStatement = WCF::getDB()->prepareStatement($sql);
foreach ($this->indexLog as $logEntry) {
- $deleteStatement->execute(array(
+ $deleteStatement->execute([
$logEntry['tableName'],
$logEntry['indexName']
- ));
+ ]);
if ($logEntry['action'] == 'insert') {
- $insertStatement->execute(array(
+ $insertStatement->execute([
$logEntry['packageID'],
$logEntry['tableName'],
$logEntry['indexName']
- ));
+ ]);
}
}
}
WHERE sqlTable = ?
AND sqlColumn = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$tableName,
$columnName
- ));
+ ]);
$row = $statement->fetchArray();
if (!empty($row['packageID'])) return $row['packageID'];
else if (isset($this->knownTables[$tableName])) return $this->knownTables[$tableName];
WHERE sqlTable = ?
AND sqlIndex = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$tableName,
$indexName
- ));
+ ]);
$row = $statement->fetchArray();
if (!empty($row['packageID'])) return $row['packageID'];
else if (isset($this->knownTables[$tableName])) return $this->knownTables[$tableName];
/**
* @see \wcf\system\database\util\SQLParser::executeCreateTableStatement()
*/
- protected function executeCreateTableStatement($tableName, $columns, $indices = array()) {
+ protected function executeCreateTableStatement($tableName, $columns, $indices = []) {
if ($this->test) {
if (in_array($tableName, $this->existingTables)) {
if (isset($this->knownTables[$tableName]) && $this->knownTables[$tableName] != $this->package->packageID) {
throw new SystemException("Cannot recreate table '".$tableName."'. A package can only overwrite own tables.");
}
else {
- if (!isset($this->conflicts['CREATE TABLE'])) $this->conflicts['CREATE TABLE'] = array();
+ if (!isset($this->conflicts['CREATE TABLE'])) $this->conflicts['CREATE TABLE'] = [];
$this->conflicts['CREATE TABLE'][] = $tableName;
}
}
}
else {
// log
- $this->tableLog[] = array('tableName' => $tableName, 'packageID' => $this->package->packageID, 'action' => 'insert');
+ $this->tableLog[] = ['tableName' => $tableName, 'packageID' => $this->package->packageID, 'action' => 'insert'];
// execute
parent::executeCreateTableStatement($tableName, $columns, $indices);
}
else {
// log
- $this->columnLog[] = array('tableName' => $tableName, 'columnName' => $columnName, 'packageID' => $this->package->packageID, 'action' => 'insert');
+ $this->columnLog[] = ['tableName' => $tableName, 'columnName' => $columnName, 'packageID' => $this->package->packageID, 'action' => 'insert'];
// execute
parent::executeAddColumnStatement($tableName, $columnName, $columnData);
else {
// log
if ($oldColumnName != $newColumnName) {
- $this->columnLog[] = array('tableName' => $tableName, 'columnName' => $oldColumnName, 'packageID' => $this->package->packageID, 'action' => 'delete');
- $this->columnLog[] = array('tableName' => $tableName, 'columnName' => $newColumnName, 'packageID' => $this->package->packageID, 'action' => 'insert');
+ $this->columnLog[] = ['tableName' => $tableName, 'columnName' => $oldColumnName, 'packageID' => $this->package->packageID, 'action' => 'delete'];
+ $this->columnLog[] = ['tableName' => $tableName, 'columnName' => $newColumnName, 'packageID' => $this->package->packageID, 'action' => 'insert'];
}
// execute
protected function executeAddIndexStatement($tableName, $indexName, $indexData) {
if (!$this->test) {
// log
- $this->indexLog[] = array('tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'insert');
+ $this->indexLog[] = ['tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'insert'];
// execute
parent::executeAddIndexStatement($tableName, $indexName, $indexData);
protected function executeAddForeignKeyStatement($tableName, $indexName, $indexData) {
if (!$this->test) {
// log
- $this->indexLog[] = array('tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'insert');
+ $this->indexLog[] = ['tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'insert'];
// execute
parent::executeAddForeignKeyStatement($tableName, $indexName, $indexData);
}
else {
// log
- $this->columnLog[] = array('tableName' => $tableName, 'columnName' => $columnName, 'packageID' => $this->package->packageID, 'action' => 'delete');
+ $this->columnLog[] = ['tableName' => $tableName, 'columnName' => $columnName, 'packageID' => $this->package->packageID, 'action' => 'delete'];
// execute
parent::executeDropColumnStatement($tableName, $columnName);
}
else {
// log
- $this->indexLog[] = array('tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'delete');
+ $this->indexLog[] = ['tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'delete'];
// execute
parent::executeDropIndexStatement($tableName, $indexName);
}
else {
// log
- $this->indexLog[] = array('tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'delete');
+ $this->indexLog[] = ['tableName' => $tableName, 'indexName' => $indexName, 'packageID' => $this->package->packageID, 'action' => 'delete'];
// execute
parent::executeDropForeignKeyStatement($tableName, $indexName);
}
else {
// log
- $this->tableLog[] = array('tableName' => $tableName, 'packageID' => $this->package->packageID, 'action' => 'delete');
+ $this->tableLog[] = ['tableName' => $tableName, 'packageID' => $this->package->packageID, 'action' => 'delete'];
// execute
parent::executeDropTableStatement($tableName);
* stack of package installations / updates
* @var array
*/
- protected $packageInstallationStack = array();
+ protected $packageInstallationStack = [];
/**
* list of package update servers
* @var PackageUpdateServer[]
*/
- protected $packageUpdateServers = array();
+ protected $packageUpdateServers = [];
/**
* list of packages to update or install
* @var array
*/
- protected $selectedPackages = array();
+ protected $selectedPackages = [];
/**
* virtual package versions
* @var array
*/
- protected $virtualPackageVersions = array();
+ protected $virtualPackageVersions = [];
/**
* Creates a new instance of PackageInstallationScheduler
$download = $this->downloadPackage($package, $packageUpdateVersions, $validateInstallInstructions);
// add to stack
- $data = array(
+ $data = [
'packageName' => $packageUpdateVersions[0]['packageName'],
'packageVersion' => $packageUpdateVersions[0]['packageVersion'],
'package' => $package,
'packageID' => 0,
'archive' => $download,
'action' => 'install'
- );
+ ];
if ($stackPosition == -1) $this->packageInstallationStack[] = $data;
else $this->packageInstallationStack[$stackPosition] = $data;
*/
protected function resolveRequirements($packageUpdateVersionID) {
// resolve requirements
- $requiredPackages = array();
- $requirementsCache = array();
+ $requiredPackages = [];
+ $requirementsCache = [];
$sql = "SELECT *
FROM wcf".WCF_N."_package_update_requirement
WHERE packageUpdateVersionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($packageUpdateVersionID));
+ $statement->execute([$packageUpdateVersionID]);
while ($row = $statement->fetchArray()) {
$requiredPackages[] = $row['package'];
$requirementsCache[] = $row;
if (!empty($requiredPackages)) {
// find installed packages
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package IN (?)", array($requiredPackages));
+ $conditions->add("package IN (?)", [$requiredPackages]);
- $installedPackages = array();
+ $installedPackages = [];
$sql = "SELECT packageID, package, packageVersion
FROM wcf".WCF_N."_package
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
while ($row = $statement->fetchArray()) {
- if (!isset($installedPackages[$row['package']])) $installedPackages[$row['package']] = array();
+ if (!isset($installedPackages[$row['package']])) $installedPackages[$row['package']] = [];
$installedPackages[$row['package']][$row['packageID']] = (isset($this->virtualPackageVersions[$row['packageID']]) ? $this->virtualPackageVersions[$row['packageID']] : $row['packageVersion']);
}
if (isset($installedPackages[$row['package']])) {
// package already installed -> check version
// sort multiple instances by version number
- uasort($installedPackages[$row['package']], array('wcf\data\package\Package', 'compareVersion'));
+ uasort($installedPackages[$row['package']], ['wcf\data\package\Package', 'compareVersion']);
foreach ($installedPackages[$row['package']] as $packageID => $packageVersion) {
if (empty($row['minversion']) || Package::compareVersion($row['minversion'], $packageVersion, '<=')) {
if ($packageUpdateVersion['filename']) {
$request = new HTTPRequest(
$packageUpdateVersion['filename'],
- (!empty($authData) ? array('auth' => $authData) : array()),
- array(
+ (!empty($authData) ? ['auth' => $authData] : []),
+ [
'apiVersion' => PackageUpdate::API_VERSION
- )
+ ]
);
}
else {
// create request
$request = new HTTPRequest(
$this->packageUpdateServers[$packageUpdateVersion['packageUpdateServerID']]->getDownloadURL(),
- (!empty($authData) ? array('auth' => $authData) : array()),
- array(
+ (!empty($authData) ? ['auth' => $authData] : []),
+ [
'apiVersion' => PackageUpdate::API_VERSION,
'packageName' => $packageUpdateVersion['package'],
'packageVersion' => $packageUpdateVersion['packageVersion']
- )
+ ]
);
}
// check response
if ($response['statusCode'] != 200) {
- throw new SystemException(WCF::getLanguage()->getDynamicVariable('wcf.acp.package.error.downloadFailed', array('__downloadPackage' => $package)) . ' ('.$response['body'].')');
+ throw new SystemException(WCF::getLanguage()->getDynamicVariable('wcf.acp.package.error.downloadFailed', ['__downloadPackage' => $package]) . ' ('.$response['body'].')');
}
// write content to tmp file
* @return array
*/
public function getExcludedPackages() {
- $excludedPackages = array();
+ $excludedPackages = [];
if (!empty($this->packageInstallationStack)) {
- $packageInstallations = array();
- $packageIdentifier = array();
+ $packageInstallations = [];
+ $packageIdentifier = [];
foreach ($this->packageInstallationStack as $packageInstallation) {
$packageInstallation['newVersion'] = ($packageInstallation['action'] == 'update' ? $packageInstallation['toVersion'] : $packageInstallation['packageVersion']);
$packageInstallations[] = $packageInstallation;
// check exclusions of the new packages
// get package update ids
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package IN (?)", array($packageIdentifier));
+ $conditions->add("package IN (?)", [$packageIdentifier]);
$sql = "SELECT packageUpdateID, package
FROM wcf".WCF_N."_package_update
// get exclusions of the new packages
// build conditions
$conditions = '';
- $statementParameters = array();
+ $statementParameters = [];
foreach ($packageInstallations as $packageInstallation) {
if (!empty($conditions)) $conditions .= ' OR ';
$conditions .= "(packageUpdateID = ? AND packageVersion = ?)";
foreach ($packageInstallations as $key => $packageInstallation) {
if ($packageInstallation['package'] == $row['package']) {
if (!isset($packageInstallations[$key]['excludedPackages'])) {
- $packageInstallations[$key]['excludedPackages'] = array();
+ $packageInstallations[$key]['excludedPackages'] = [];
}
- $packageInstallations[$key]['excludedPackages'][$row['excludedPackage']] = array('package' => $row['excludedPackage'], 'version' => $row['excludedPackageVersion']);
+ $packageInstallations[$key]['excludedPackages'][$row['excludedPackage']] = ['package' => $row['excludedPackage'], 'version' => $row['excludedPackageVersion']];
// check version
if (!empty($row['excludedPackageVersion'])) {
}
}
- $excludedPackages[] = array(
+ $excludedPackages[] = [
'package' => $row['package'],
'packageName' => $packageInstallations[$key]['packageName'],
'packageVersion' => $packageInstallations[$key]['newVersion'],
'existingPackage' => $row['excludedPackage'],
'existingPackageName' => WCF::getLanguage()->get($row['packageName']),
'existingPackageVersion' => $row['packageVersion']
- );
+ ];
}
}
}
// check excluded packages of the existing packages
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("excludedPackage IN (?)", array($packageIdentifier));
+ $conditions->add("excludedPackage IN (?)", [$packageIdentifier]);
$sql = "SELECT package.*, package_exclusion.*
FROM wcf".WCF_N."_package_exclusion package_exclusion
}
}
- $excludedPackages[] = array(
+ $excludedPackages[] = [
'package' => $row['excludedPackage'],
'packageName' => $packageInstallation['packageName'],
'packageVersion' => $packageInstallation['newVersion'],
'existingPackage' => $row['package'],
'existingPackageName' => WCF::getLanguage()->get($row['packageName']),
'existingPackageVersion' => $row['packageVersion']
- );
+ ];
}
}
}
)
AND packageVersion LIKE ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$package->package,
$match[1].'%'
- ));
+ ]);
$packageVersions = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (count($packageVersions) > 1) {
// sort by version number
- usort($packageVersions, array('wcf\data\package\Package', 'compareVersion'));
+ usort($packageVersions, ['wcf\data\package\Package', 'compareVersion']);
// get highest version
$version = array_pop($packageVersions);
}
// get all fromversion
- $fromversions = array();
+ $fromversions = [];
$sql = "SELECT puv.packageVersion, puf.fromversion
FROM wcf".WCF_N."_package_update_fromversion puf
LEFT JOIN wcf".WCF_N."_package_update_version puv
)
)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($package->package));
+ $statement->execute([$package->package]);
while ($row = $statement->fetchArray()) {
- if (!isset($fromversions[$row['packageVersion']])) $fromversions[$row['packageVersion']] = array();
+ if (!isset($fromversions[$row['packageVersion']])) $fromversions[$row['packageVersion']] = [];
$fromversions[$row['packageVersion']][$row['fromversion']] = $row['fromversion'];
}
// sort by version number
- uksort($fromversions, array('wcf\data\package\Package', 'compareVersion'));
+ uksort($fromversions, ['wcf\data\package\Package', 'compareVersion']);
// find shortest update thread
$updateThread = $this->findShortestUpdateThread($package->package, $fromversions, $packageVersion, $version);
$download = $this->downloadPackage($package->package, $packageUpdateVersions);
// add to stack
- $this->packageInstallationStack[] = array(
+ $this->packageInstallationStack[] = [
'packageName' => $package->getName(),
'fromversion' => $fromversion,
'toVersion' => $toVersion,
'packageID' => $packageID,
'archive' => $download,
'action' => 'update'
- );
+ ];
// update virtual versions
$this->virtualPackageVersions[$packageID] = $toVersion;
// find direct update
foreach ($fromversions[$newVersion] as $fromversion) {
if (Package::checkFromversion($currentVersion, $fromversion)) {
- return array($currentVersion => $newVersion);
+ return [$currentVersion => $newVersion];
}
}
// find intermediate update
$packageVersions = array_keys($fromversions);
- $updateThreadList = array();
+ $updateThreadList = [];
foreach ($fromversions[$newVersion] as $fromversion) {
- $innerUpdateThreadList = array();
+ $innerUpdateThreadList = [];
// find matching package versions
foreach ($packageVersions as $packageVersion) {
if (Package::checkFromversion($packageVersion, $fromversion) && Package::compareVersion($packageVersion, $currentVersion, '>') && Package::compareVersion($packageVersion, $newVersion, '<')) {
- $innerUpdateThreadList[] = $this->findShortestUpdateThread($package, $fromversions, $currentVersion, $packageVersion) + array($packageVersion => $newVersion);
+ $innerUpdateThreadList[] = $this->findShortestUpdateThread($package, $fromversions, $currentVersion, $packageVersion) + [$packageVersion => $newVersion];
}
}
if (!empty($innerUpdateThreadList)) {
// sort by length
- usort($innerUpdateThreadList, array($this, 'compareUpdateThreadLists'));
+ usort($innerUpdateThreadList, [$this, 'compareUpdateThreadLists']);
// add to thread list
$updateThreadList[] = array_shift($innerUpdateThreadList);
}
// sort by length
- usort($updateThreadList, array($this, 'compareUpdateThreadLists'));
+ usort($updateThreadList, [$this, 'compareUpdateThreadLists']);
// take shortest
return array_shift($updateThreadList);
}
// fetch ordered pips
- $pips = array();
+ $pips = [];
$sql = "SELECT pluginName, className,
CASE pluginName WHEN 'packageinstallationplugin' THEN 1 WHEN 'file' THEN 2 ELSE 0 END AS pluginOrder
FROM wcf".WCF_N."_package_installation_plugin
$sequenceNo = 0;
foreach ($pips as $pip) {
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID,
$this->installation->queue->processNo,
$sequenceNo,
$this->node,
$this->parentNode,
'pip',
- serialize(array(
+ serialize([
'pluginName' => $pip['pluginName'],
'className' => $pip['className']
- ))
- ));
+ ])
+ ]);
$sequenceNo++;
}
(queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->queue->queueID,
$this->installation->queue->processNo,
0,
$this->parentNode,
'package',
'a:0:{}'
- ));
+ ]);
}
}
* @param integer[] $packageUpdateServerIDs
* @param boolean $ignoreCache
*/
- public function refreshPackageDatabase(array $packageUpdateServerIDs = array(), $ignoreCache = false) {
+ public function refreshPackageDatabase(array $packageUpdateServerIDs = [], $ignoreCache = false) {
// get update server data
$tmp = PackageUpdateServer::getActiveUpdateServers($packageUpdateServerIDs);
// loop servers
- $updateServers = array();
+ $updateServers = [];
$foundWoltLabServer = false;
foreach ($tmp as $updateServer) {
if ($ignoreCache || $updateServer->lastUpdateTime < TIME_NOW - 600) {
if ($errorMessage) {
// save error status
$updateServerEditor = new PackageUpdateServerEditor($updateServer);
- $updateServerEditor->update(array(
+ $updateServerEditor->update([
'status' => 'offline',
'errorMessage' => $errorMessage
- ));
+ ]);
}
}
* @throws SystemException
*/
protected function getPackageUpdateXML(PackageUpdateServer $updateServer, $forceHTTP = false) {
- $settings = array();
+ $settings = [];
$authData = $updateServer->getAuthData();
if ($authData) $settings['auth'] = $authData;
$allNewPackages = $this->parsePackageUpdateXML($reply['body']);
}
- $data = array(
+ $data = [
'lastUpdateTime' => TIME_NOW,
'status' => 'online',
'errorMessage' => ''
- );
+ ];
// check if server indicates support for a newer API
if ($updateServer->apiVersion == '2.0' && !empty($reply['httpHeaders']['wcf-update-server-api'])) {
}
}
- $metaData = array();
+ $metaData = [];
if ($updateServer->apiVersion == '2.1' || (isset($data['apiVersion']) && $data['apiVersion'] == '2.1')) {
if (empty($reply['httpHeaders']['etag']) && empty($reply['httpHeaders']['last-modified'])) {
throw new SystemException("Missing required HTTP headers 'etag' and 'last-modified'.");
throw new SystemException("Missing required HTTP header 'wcf-update-server-ssl'.");
}
- $metaData['list'] = array();
+ $metaData['list'] = [];
if (!empty($reply['httpHeaders']['etag'])) $metaData['list']['etag'] = reset($reply['httpHeaders']['etag']);
if (!empty($reply['httpHeaders']['last-modified'])) $metaData['list']['lastModified'] = reset($reply['httpHeaders']['last-modified']);
$sql = "DELETE FROM wcf".WCF_N."_package_update
WHERE packageUpdateServerID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($updateServer->packageUpdateServerID));
+ $statement->execute([$updateServer->packageUpdateServerID]);
// save packages
if (!empty($allNewPackages)) {
$xml->loadXML('packageUpdateServer.xml', $content);
$xpath = $xml->xpath();
- $allNewPackages = array();
+ $allNewPackages = [];
$packages = $xpath->query('/ns:section/ns:package');
foreach ($packages as $package) {
if (!Package::isValidPackageName($package->getAttribute('name'))) {
*/
protected function parsePackageUpdateXMLBlock(\DOMXPath $xpath, \DOMNode $package) {
// define default values
- $packageInfo = array(
+ $packageInfo = [
'author' => '',
'authorURL' => '',
'isApplication' => 0,
'packageDescription' => '',
- 'versions' => array()
- );
+ 'versions' => []
+ ];
// parse package information
$elements = $xpath->query('./ns:packageinformation/*', $package);
$elements = $xpath->query('./ns:versions/ns:version', $package);
foreach ($elements as $element) {
$versionNo = $element->getAttribute('name');
- $packageInfo['versions'][$versionNo] = array(
+ $packageInfo['versions'][$versionNo] = [
'isAccessible' => ($element->getAttribute('accessible') == 'true' ? true : false),
'isCritical' => ($element->getAttribute('critical') == 'true' ? true : false)
- );
+ ];
$children = $xpath->query('child::*', $element);
foreach ($children as $child) {
$minVersion = $requiredPackage->getAttribute('minversion');
$required = $requiredPackage->nodeValue;
- $packageInfo['versions'][$versionNo]['requiredPackages'][$required] = array();
+ $packageInfo['versions'][$versionNo]['requiredPackages'][$required] = [];
if (!empty($minVersion)) {
$packageInfo['versions'][$versionNo]['requiredPackages'][$required]['minversion'] = $minVersion;
}
break;
case 'optionalpackages':
- $packageInfo['versions'][$versionNo]['optionalPackages'] = array();
+ $packageInfo['versions'][$versionNo]['optionalPackages'] = [];
$optionalPackages = $xpath->query('child::*', $child);
foreach ($optionalPackages as $optionalPackage) {
$exclusion = $excludedPackage->nodeValue;
$version = $excludedPackage->getAttribute('version');
- $packageInfo['versions'][$versionNo]['excludedPackages'][$exclusion] = array();
+ $packageInfo['versions'][$versionNo]['excludedPackages'][$exclusion] = [];
if (!empty($version)) {
$packageInfo['versions'][$versionNo]['excludedPackages'][$exclusion]['version'] = $version;
}
break;
case 'license':
- $packageInfo['versions'][$versionNo]['license'] = array(
+ $packageInfo['versions'][$versionNo]['license'] = [
'license' => $child->nodeValue,
'licenseURL' => ($child->hasAttribute('url') ? $child->getAttribute('url') : '')
- );
+ ];
break;
}
}
*/
protected function savePackageUpdates(array &$allNewPackages, $packageUpdateServerID) {
// insert updates
- $excludedPackagesParameters = $fromversionParameters = $insertParameters = $optionalInserts = $requirementInserts = array();
+ $excludedPackagesParameters = $fromversionParameters = $insertParameters = $optionalInserts = $requirementInserts = [];
WCF::getDB()->beginTransaction();
foreach ($allNewPackages as $identifier => $packageData) {
// create new database entry
- $packageUpdate = PackageUpdateEditor::create(array(
+ $packageUpdate = PackageUpdateEditor::create([
'packageUpdateServerID' => $packageUpdateServerID,
'package' => $identifier,
'packageName' => $packageData['packageName'],
'author' => $packageData['author'],
'authorURL' => $packageData['authorURL'],
'isApplication' => $packageData['isApplication']
- ));
+ ]);
$packageUpdateID = $packageUpdate->packageUpdateID;
else $packageFile = '';
// create new database entry
- $version = PackageUpdateVersionEditor::create(array(
+ $version = PackageUpdateVersionEditor::create([
'filename' => $packageFile,
'license' => (isset($versionData['license']['license']) ? $versionData['license']['license'] : ''),
'licenseURL' => (isset($versionData['license']['license']) ? $versionData['license']['licenseURL'] : ''),
'packageDate' => $versionData['packageDate'],
'packageUpdateID' => $packageUpdateID,
'packageVersion' => $packageVersion
- ));
+ ]);
$packageUpdateVersionID = $version->packageUpdateVersionID;
// register requirement(s) of this update package version.
if (isset($versionData['requiredPackages'])) {
foreach ($versionData['requiredPackages'] as $requiredIdentifier => $required) {
- $requirementInserts[] = array(
+ $requirementInserts[] = [
'packageUpdateVersionID' => $packageUpdateVersionID,
'package' => $requiredIdentifier,
'minversion' => (isset($required['minversion']) ? $required['minversion'] : '')
- );
+ ];
}
}
// register optional packages of this update package version
if (isset($versionData['optionalPackages'])) {
foreach ($versionData['optionalPackages'] as $optionalPackage) {
- $optionalInserts[] = array(
+ $optionalInserts[] = [
'packageUpdateVersionID' => $packageUpdateVersionID,
'package' => $optionalPackage
- );
+ ];
}
}
// register excluded packages of this update package version.
if (isset($versionData['excludedPackages'])) {
foreach ($versionData['excludedPackages'] as $excludedIdentifier => $exclusion) {
- $excludedPackagesParameters[] = array(
+ $excludedPackagesParameters[] = [
'packageUpdateVersionID' => $packageUpdateVersionID,
'excludedPackage' => $excludedIdentifier,
'excludedPackageVersion' => (isset($exclusion['version']) ? $exclusion['version'] : '')
- );
+ ];
}
}
// register fromversions of this update package version.
if (isset($versionData['fromversions'])) {
foreach ($versionData['fromversions'] as $fromversion) {
- $fromversionInserts[] = array(
+ $fromversionInserts[] = [
'packageUpdateVersionID' => $packageUpdateVersionID,
'fromversion' => $fromversion
- );
+ ];
}
}
}
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($requirementInserts as $requirement) {
- $statement->execute(array(
+ $statement->execute([
$requirement['packageUpdateVersionID'],
$requirement['package'],
$requirement['minversion']
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($optionalInserts as $requirement) {
- $statement->execute(array(
+ $statement->execute([
$requirement['packageUpdateVersionID'],
$requirement['package']
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($excludedPackagesParameters as $excludedPackage) {
- $statement->execute(array(
+ $statement->execute([
$excludedPackage['packageUpdateVersionID'],
$excludedPackage['excludedPackage'],
$excludedPackage['excludedPackageVersion']
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($fromversionInserts as $fromversion) {
- $statement->execute(array(
+ $statement->execute([
$fromversion['packageUpdateVersionID'],
$fromversion['fromversion']
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
* @return array
*/
public function getAvailableUpdates($removeRequirements = true, $removeOlderMinorReleases = false) {
- $updates = array();
+ $updates = [];
// get update server data
$updateServers = PackageUpdateServer::getActiveUpdateServers();
if (empty($packageUpdateServerIDs)) return $updates;
// get existing packages and their versions
- $existingPackages = array();
+ $existingPackages = [];
$sql = "SELECT packageID, package, packageDescription, packageName,
packageVersion, packageDate, author, authorURL, isApplication
FROM wcf".WCF_N."_package";
// get all update versions
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("pu.packageUpdateServerID IN (?)", array($packageUpdateServerIDs));
+ $conditions->add("pu.packageUpdateServerID IN (?)", [$packageUpdateServerIDs]);
$conditions->add("package IN (SELECT DISTINCT package FROM wcf".WCF_N."_package)");
$sql = "SELECT pu.packageUpdateID, pu.packageUpdateServerID, pu.package,
if (Package::compareVersion($existingVersion['packageVersion'], $row['packageVersion'], '<')) {
// package data
if (!isset($updates[$existingVersion['packageID']])) {
- $existingVersion['versions'] = array();
+ $existingVersion['versions'] = [];
$updates[$existingVersion['packageID']] = $existingVersion;
}
// version data
if (!isset($updates[$existingVersion['packageID']]['versions'][$row['packageVersion']])) {
- $updates[$existingVersion['packageID']]['versions'][$row['packageVersion']] = array(
+ $updates[$existingVersion['packageID']]['versions'][$row['packageVersion']] = [
'isCritical' => $row['isCritical'],
'packageDate' => $row['packageDate'],
'packageVersion' => $row['packageVersion'],
- 'servers' => array()
- );
+ 'servers' => []
+ ];
}
// server data
- $updates[$existingVersion['packageID']]['versions'][$row['packageVersion']]['servers'][] = array(
+ $updates[$existingVersion['packageID']]['versions'][$row['packageVersion']]['servers'][] = [
'packageUpdateID' => $row['packageUpdateID'],
'packageUpdateServerID' => $row['packageUpdateServerID'],
'packageUpdateVersionID' => $row['packageUpdateVersionID'],
'filename' => $row['filename']
- );
+ ];
}
}
}
// sort package versions
// and remove old versions
foreach ($updates as $packageID => $data) {
- uksort($updates[$packageID]['versions'], array('wcf\data\package\Package', 'compareVersion'));
+ uksort($updates[$packageID]['versions'], ['wcf\data\package\Package', 'compareVersion']);
$updates[$packageID]['version'] = end($updates[$packageID]['versions']);
}
// remove older minor releases from list, e.g. only display 1.0.2, even if 1.0.1 is available
if ($removeOlderMinorReleases) {
foreach ($updates as &$updateData) {
- $highestVersions = array();
+ $highestVersions = [];
foreach ($updateData['versions'] as $versionNumber => $dummy) {
if (preg_match('~^(\d+\.\d+)\.~', $versionNumber, $matches)) {
$major = $matches[1];
ON (p.package = pur.package)
WHERE pur.packageUpdateVersionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($packageUpdateVersionID));
+ $statement->execute([$packageUpdateVersionID]);
while ($row = $statement->fetchArray()) {
if (isset($updates[$row['packageID']])) {
$updates = $this->removeUpdateRequirements($updates, $updates[$row['packageID']]['version']['servers'][0]['packageUpdateVersionID']);
}
// get versions
- $versions = array();
+ $versions = [];
$sql = "SELECT puv.*, pu.*, pus.loginUsername, pus.loginPassword
FROM wcf".WCF_N."_package_update_version puv
LEFT JOIN wcf".WCF_N."_package_update pu
AND puv.packageVersion = ?
AND pus.isDisabled = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$package,
$version,
0
- ));
+ ]);
while ($row = $statement->fetchArray()) {
$versions[] = $row;
}
*/
public function getNewestPackageVersion($package) {
// get all versions
- $versions = array();
+ $versions = [];
$sql = "SELECT packageVersion
FROM wcf".WCF_N."_package_update_version
WHERE packageUpdateID IN (
WHERE package = ?
)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($package));
+ $statement->execute([$package]);
while ($row = $statement->fetchArray()) {
$versions[$row['packageVersion']] = $row['packageVersion'];
}
// sort by version number
- usort($versions, array('wcf\data\package\Package', 'compareVersion'));
+ usort($versions, ['wcf\data\package\Package', 'compareVersion']);
// take newest (last)
return array_pop($versions);
public function cacheDownload($package, $version, $filename) {
$cachedDownloads = WCF::getSession()->getVar('cachedPackageUpdateDownloads');
if (!is_array($cachedDownloads)) {
- $cachedDownloads = array();
+ $cachedDownloads = [];
}
// store in session
* package update version
* @var array
*/
- protected $packageUpdateVersion = array();
+ protected $packageUpdateVersion = [];
/**
* HTTP request object
* @param \wcf\data\package\update\server\PackageUpdateServer $updateServer
* @param array $packageUpdateVersion
*/
- public function __construct(HTTPRequest $request, PackageUpdateServer $updateServer, array $packageUpdateVersion = array()) {
+ public function __construct(HTTPRequest $request, PackageUpdateServer $updateServer, array $packageUpdateVersion = []) {
$this->request = $request;
$this->updateServer = $updateServer;
$this->packageUpdateVersion = $packageUpdateVersion;
* @return string
*/
public function getRenderedTemplate() {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'packageUpdateVersion' => $this->packageUpdateVersion,
'request' => $this->request,
'updateServer' => $this->updateServer
- ));
+ ]);
return WCF::getTPL()->fetch('packageUpdateUnauthorized');
}
unset($file);
// get existing templates
- $existingTemplates = $updateTemplateIDs = array();
+ $existingTemplates = $updateTemplateIDs = [];
$sql = "SELECT templateName, templateID
FROM wcf".WCF_N."_template
WHERE packageID = ?
AND application = ?
AND templateGroupID IS NULL";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($packageID, $this->application));
+ $statement->execute([$packageID, $this->application]);
while ($row = $statement->fetchArray()) {
$existingTemplates[$row['templateName']] = $row['templateID'];
}
continue;
}
- $statement->execute(array(
+ $statement->execute([
$packageID,
$file,
TIME_NOW,
$this->application
- ));
+ ]);
}
if (!empty($updateTemplateIDs)) {
// update old templates
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('templateID IN (?)', array($updateTemplateIDs));
+ $conditionBuilder->add('templateID IN (?)', [$updateTemplateIDs]);
$sql = "UPDATE wcf".WCF_N."_template
SET lastModificationTime = ?
".$conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array(TIME_NOW), $conditionBuilder->getParameters()));
+ $statement->execute(array_merge([TIME_NOW], $conditionBuilder->getParameters()));
}
}
}
* list of loaded acl object type ids sorted by their option type name
* @var integer[]
*/
- protected $optionTypeIDs = array();
+ protected $optionTypeIDs = [];
/**
* @see \wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
protected function importCategories(\DOMXPath $xpath) {
$elements = $xpath->query('/ns:data/ns:import/ns:categories/ns:category');
foreach ($elements as $element) {
- $data = array('categoryName' => $element->getAttribute('name'));
+ $data = ['categoryName' => $element->getAttribute('name')];
// get child elements
$children = $xpath->query('child::*', $element);
AND objectTypeID = ?
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$category['categoryName'],
$objectTypeID,
$this->installation->getPackageID()
- ));
+ ]);
$row = $statement->fetchArray();
if (!$row) {
// insert new category
(packageID, objectTypeID, categoryName)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
$objectTypeID,
$category['categoryName']
- ));
+ ]);
}
}
protected function importOptions(\DOMXPath $xpath) {
$elements = $xpath->query('/ns:data/ns:import/ns:options/ns:option');
foreach ($elements as $element) {
- $data = array();
+ $data = [];
$children = $xpath->query('child::*', $element);
foreach ($children as $child) {
$data[$child->tagName] = $child->nodeValue;
WHERE categoryName = ?
AND objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$data['categoryname'],
$objectTypeID
- ));
+ ]);
if (!$statement->fetchSingleColumn()) {
throw new SystemException("unknown category '".$data['categoryname']."' for acl object type '".$data['objecttype']."' given");
}
}
- $data = array(
+ $data = [
'categoryName' => (isset($data['categoryname'])) ? $data['categoryname'] : '',
'optionName' => $element->getAttribute('name'),
'objectTypeID' => $objectTypeID
- );
+ ];
// check for option existence
$sql = "SELECT optionID
AND objectTypeID = ?
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$data['optionName'],
$data['objectTypeID'],
$this->installation->getPackageID()
- ));
+ ]);
$row = $statement->fetchArray();
if (!$row) {
$sql = "INSERT INTO wcf".WCF_N."_".$this->tableName."
(packageID, objectTypeID, optionName, categoryName)
VALUES (?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
$data['objectTypeID'],
$data['optionName'],
$data['categoryName']
- ));
+ ]);
}
else {
$sql = "UPDATE wcf".WCF_N."_".$this->tableName."
SET categoryName = ?
WHERE optionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$data['categoryName'],
$row['optionID']
- ));
+ ]);
}
}
}
WHERE definitionName = 'com.woltlab.wcf.acl'
)";
$statement = WCF::getDB()->prepareStatement($sql, 1);
- $statement->execute(array($optionType));
+ $statement->execute([$optionType]);
$row = $statement->fetchArray();
if (!$row) {
throw new SystemException("unknown object type '".$optionType."' given");
WCF::getDB()->beginTransaction();
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
$showOrder = (isset($data['elements']['showorder'])) ? $data['elements']['showorder'] : null;
$showOrder = $this->getShowOrder($showOrder);
- return array(
+ return [
'className' => $data['elements']['classname'],
'providerName' => $data['attributes']['name'],
'showOrder' => $showOrder
- );
+ ];
}
/**
FROM wcf".WCF_N."_".$this->tableName."
WHERE providerName = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['providerName'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
FROM wcf".WCF_N."_acp_template
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
- $templates = array();
+ $templates = [];
while ($row = $statement->fetchArray()) {
if (!isset($templates[$row['application']])) {
- $templates[$row['application']] = array();
+ $templates[$row['application']] = [];
}
$templates[$row['application']][] = 'acp/templates/'.$row['templateName'].'.tpl';
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
$showOrder = $this->getShowOrder($showOrder, $parent, 'parentMenuItem');
// merge values and default values
- return array(
+ return [
'menuItem' => $data['attributes']['name'],
'menuItemController' => isset($data['elements']['controller']) ? $data['elements']['controller'] : '',
'menuItemLink' => (isset($data['elements']['link'])) ? $data['elements']['link'] : '',
'parentMenuItem' => (isset($data['elements']['parent'])) ? $data['elements']['parent'] : '',
'permissions' => (isset($data['elements']['permissions'])) ? $data['elements']['permissions'] : '',
'showOrder' => $showOrder
- );
+ ];
}
/**
FROM ".$this->application.WCF_N."_".$this->tableName."
WHERE menuItem = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($data['parentMenuItem']));
+ $statement->execute([$data['parentMenuItem']]);
if (!$statement->fetchSingleColumn()) {
throw new SystemException("Unable to find parent 'menu item' with name '".$data['parentMenuItem']."' for 'menu item' with name '".$data['menuItem']."'.");
FROM ".$this->application.WCF_N."_".$this->tableName."
WHERE menuItem = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['menuItem'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
protected function deleteItems(\DOMXPath $xpath) {
// delete options
$elements = $xpath->query('/ns:data/ns:delete/ns:option');
- $options = array();
+ $options = [];
foreach ($elements as $element) {
$options[] = $element->getAttribute('name');
}
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($options as $option) {
- $statement->execute(array(
+ $statement->execute([
$option,
$this->installation->getPackageID()
- ));
+ ]);
}
}
// delete categories
$elements = $xpath->query('/ns:data/ns:delete/ns:optioncategory');
- $categories = array();
+ $categories = [];
foreach ($elements as $element) {
$categories[] = $element->getAttribute('name');
}
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($categories as $category) {
- $statement->execute(array(
+ $statement->execute([
$category,
$this->installation->getPackageID()
- ));
+ ]);
}
// delete categories
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($categories as $category) {
- $statement->execute(array(
+ $statement->execute([
$category,
$this->installation->getPackageID()
- ));
+ ]);
}
}
}
protected function importCategories(\DOMXPath $xpath) {
$elements = $xpath->query('/ns:data/ns:import/ns:categories/ns:category');
foreach ($elements as $element) {
- $data = array();
+ $data = [];
// get child elements
$children = $xpath->query('child::*', $element);
}
// build data block with defaults
- $data = array(
+ $data = [
'categoryName' => $element->getAttribute('name'),
'options' => (isset($data['options'])) ? $data['options'] : '',
'parentCategoryName' => (isset($data['parent'])) ? $data['parent'] : '',
'permissions' => (isset($data['permissions'])) ? $data['permissions'] : '',
'showOrder' => (isset($data['showorder'])) ? intval($data['showorder']) : null
- );
+ ];
// adjust show order
if ($data['showOrder'] !== null || $this->installation->getAction() != 'update') {
FROM ".$this->application.WCF_N."_".$this->tableName."_category
WHERE categoryName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($data['parentCategoryName']));
+ $statement->execute([$data['parentCategoryName']]);
if (!$statement->fetchSingleColumn()) {
throw new SystemException("Unable to find parent 'option category' with name '".$data['parentCategoryName']."' for category with name '".$data['categoryName']."'.");
protected function importOptions(\DOMXPath $xpath) {
$elements = $xpath->query('/ns:data/ns:import/ns:options/ns:option');
foreach ($elements as $element) {
- $data = array();
+ $data = [];
$children = $xpath->query('child::*', $element);
foreach ($children as $child) {
$data[$child->tagName] = $child->nodeValue;
$data['name'] = $element->getAttribute('name');
if (!preg_match("/^[\w-\.]+$/", $data['name'])) {
- $matches = array();
+ $matches = [];
preg_match_all("/(\W)/", $data['name'], $matches);
throw new SystemException("The option '".$data['name']."' has at least one non-alphanumeric character (underscore is permitted): (".implode("), ( ", $matches[1]).").");
}
FROM ".$this->application.WCF_N."_".$this->tableName."_category
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
return ($hasUninstallOptions || $statement->fetchSingleColumn() > 0);
}
$sql = "DELETE FROM ".$this->application.WCF_N."_".$this->tableName."_category
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
}
/**
FROM ".$this->application.WCF_N."_".$this->tableName."_category
WHERE categoryName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$category['categoryName']
- ));
+ ]);
$row = $statement->fetchArray();
if (empty($row['categoryID'])) {
// insert new category
VALUES (?, ?, ?, ?, ?".($category['showOrder'] !== null ? ", ?" : "").")";
$statement = WCF::getDB()->prepareStatement($sql);
- $data = array(
+ $data = [
$this->installation->getPackageID(),
$category['categoryName'],
$category['parentCategoryName'],
$category['permissions'],
$category['options']
- );
+ ];
if ($category['showOrder'] !== null) $data[] = $category['showOrder'];
$statement->execute($data);
WHERE categoryID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $data = array(
+ $data = [
$category['parentCategoryName'],
$category['permissions'],
$category['options']
- );
+ ];
if ($category['showOrder'] !== null) $data[] = $category['showOrder'];
$data[] = $row['categoryID'];
* install/update instructions
* @var array
*/
- public $instruction = array();
+ public $instruction = [];
/**
* Creates a new AbstractPackageInstallationPlugin object.
* @param \wcf\system\package\PackageInstallationDispatcher $installation
* @param array $instruction
*/
- public function __construct(PackageInstallationDispatcher $installation, $instruction = array()) {
+ public function __construct(PackageInstallationDispatcher $installation, $instruction = []) {
$this->installation = $installation;
$this->instruction = $instruction;
FROM ".$this->application.WCF_N."_".$this->tableName."
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
return $statement->fetchSingleColumn() > 0;
}
$sql = "DELETE FROM ".$this->application.WCF_N."_".$this->tableName."
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
}
/**
/**
* @see \wcf\system\package\plugin\AbstractPackageInstallationPlugin::install()
*/
- public function __construct(PackageInstallationDispatcher $installation, $instruction = array()) {
+ public function __construct(PackageInstallationDispatcher $installation, $instruction = []) {
parent::__construct($installation, $instruction);
// autoset 'tableName' property
if (empty($this->tableName) && !empty($this->className)) {
- $this->tableName = call_user_func(array($this->className, 'getDatabaseTableAlias'));
+ $this->tableName = call_user_func([$this->className, 'getDatabaseTableAlias']);
}
// autoset 'tagName' property
*/
protected function deleteItems(\DOMXPath $xpath) {
$elements = $xpath->query('/ns:data/ns:delete/ns:'.$this->tagName);
- $items = array();
+ $items = [];
foreach ($elements as $element) {
- $data = array(
- 'attributes' => array(),
- 'elements' => array(),
+ $data = [
+ 'attributes' => [],
+ 'elements' => [],
'value' => $element->nodeValue
- );
+ ];
// get attributes
$attributes = $xpath->query('attribute::*', $element);
protected function importItems(\DOMXPath $xpath) {
$elements = $xpath->query('/ns:data/ns:import/ns:'.$this->tagName);
foreach ($elements as $element) {
- $data = array(
- 'attributes' => array(),
- 'elements' => array(),
+ $data = [
+ 'attributes' => [],
+ 'elements' => [],
'nodeValue' => ''
- );
+ ];
// fetch attributes
$attributes = $xpath->query('attribute::*', $element);
}
// ensure a valid parameter for import()
- if ($row === false) $row = array();
+ if ($row === false) $row = [];
// import items
$this->import($row, $data);
// create new item
$this->prepareCreate($data);
- return call_user_func(array($this->className, 'create'), $data);
+ return call_user_func([$this->className, 'create'], $data);
}
else {
// update existing item
- $baseClass = call_user_func(array($this->className, 'getBaseClass'));
+ $baseClass = call_user_func([$this->className, 'getBaseClass']);
/** @var \wcf\data\DatabaseObjectEditor $itemEditor */
$itemEditor = new $this->className(new $baseClass(null, $row));
if ($showOrder === null) {
// get greatest showOrder value
$conditions = new PreparedStatementConditionBuilder();
- if ($columnName !== null) $conditions->add($columnName." = ?", array($parentName));
+ if ($columnName !== null) $conditions->add($columnName." = ?", [$parentName]);
$sql = "SELECT MAX(showOrder) AS showOrder
FROM ".$this->application.WCF_N."_".$this->tableName.$tableNameExtension."
".($columnName !== null ? "AND ".$columnName." = ?" : "");
$statement = WCF::getDB()->prepareStatement($sql);
- $data = array($showOrder);
+ $data = [$showOrder];
if ($columnName !== null) $data[] = $parentName;
$statement->execute($data);
* list of pages per action id
* @var mixed[][]
*/
- protected $pages = array();
+ protected $pages = [];
/**
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$item['elements']['actionclassname'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
// read pages
if ($element->tagName == 'pages') {
- $nodeValue = array();
+ $nodeValue = [];
$pages = $xpath->query('child::ns:page', $element);
foreach ($pages as $page) {
$showOrder = (isset($data['elements']['showorder'])) ? intval($data['elements']['showorder']) : null;
$showOrder = $this->getShowOrder($showOrder, $data['elements']['actionclassname'], 'actionClassName');
- return array(
+ return [
'actionClassName' => $data['elements']['actionclassname'],
'actionName' => $data['attributes']['name'],
'pages' => $data['elements']['pages'],
'showOrder' => $showOrder
- );
+ ];
}
/**
WHERE actionName = ?
AND actionClassName = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['actionName'],
$data['actionClassName'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
$sql = "DELETE FROM wcf".WCF_N."_clipboard_page
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
if (!empty($this->pages)) {
// insert pages
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($this->pages as $actionID => $pages) {
foreach ($pages as $pageClassName) {
- $statement->execute(array(
+ $statement->execute([
$pageClassName,
$this->installation->getPackageID(),
$actionID
- ));
+ ]);
}
}
}
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
*/
protected function prepareImport(array $data) {
- return array(
+ return [
'objectName' => $data['elements']['objectname']
- );
+ ];
}
/**
FROM wcf".WCF_N."_".$this->tableName."
WHERE objectName = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['objectName'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
protected function getElement(\DOMXPath $xpath, array &$elements, \DOMElement $element) {
if ($element->tagName == 'description') {
if (!isset($elements['description'])) {
- $elements['description'] = array();
+ $elements['description'] = [];
}
$elements['description'][$element->getAttribute('language')] = $element->nodeValue;
foreach ($items as $item) {
if (!isset($item['attributes']['name'])) {
- $legacyStatement->execute(array(
+ $legacyStatement->execute([
$item['elements']['classname'],
$this->installation->getPackageID()
- ));
+ ]);
}
else {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
}
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
*/
protected function prepareImport(array $data) {
- return array(
+ return [
'canBeDisabled' => (isset($data['elements']['canbedisabled'])) ? intval($data['elements']['canbedisabled']) : 1,
'canBeEdited' => (isset($data['elements']['canbeedited'])) ? intval($data['elements']['canbeedited']) : 1,
'className' => (isset($data['elements']['classname'])) ? $data['elements']['classname'] : '',
'startHour' => $data['elements']['starthour'],
'startMinute' => $data['elements']['startminute'],
'startMonth' => $data['elements']['startmonth']
- );
+ ];
}
/**
// update cronjob name
if (!$cronjob->cronjobName) {
$cronjobEditor = new CronjobEditor($cronjob);
- $cronjobEditor->update(array(
+ $cronjobEditor->update([
'cronjobName' => Cronjob::AUTOMATIC_NAME_PREFIX.$cronjob->cronjobID
- ));
+ ]);
$cronjob = new Cronjob($cronjob->cronjobID);
}
FROM wcf".WCF_N."_".$this->tableName."
WHERE packageID = ?
AND cronjobName = ?";
- $parameters = array(
+ $parameters = [
$this->installation->getPackageID(),
$data['cronjobName']
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
foreach ($items as $item) {
if (!isset($item['attributes']['name'])) {
- $legacyStatement->execute(array(
+ $legacyStatement->execute([
$this->installation->getPackageID(),
(isset($item['elements']['environment']) ? $item['elements']['environment'] : 'user'),
$item['elements']['eventclassname'],
$item['elements']['eventname'],
(isset($item['elements']['inherit'])) ? $item['elements']['inherit'] : 0,
$item['elements']['listenerclassname']
- ));
+ ]);
}
else {
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
$item['attributes']['name']
- ));
+ ]);
}
}
}
if ($nice < -128) $nice = -128;
else if ($nice > 127) $nice = 127;
- return array(
+ return [
'environment' => (isset($data['elements']['environment']) ? $data['elements']['environment'] : 'user'),
'eventClassName' => $data['elements']['eventclassname'],
'eventName' => $data['elements']['eventname'],
'niceValue' => $nice,
'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''),
'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '')
- );
+ ];
}
/**
// update event listener name
if (!$eventListener->listenerName) {
$eventListenerEditor = new EventListenerEditor($eventListener);
- $eventListenerEditor->update(array(
+ $eventListenerEditor->update([
'listenerName' => EventListener::AUTOMATIC_NAME_PREFIX.$eventListener->listenerID
- ));
+ ]);
$eventListener = new EventListener($eventListener->listenerID);
}
AND eventClassName = ?
AND eventName = ?
AND listenerClassName = ?";
- $parameters = array(
+ $parameters = [
$this->installation->getPackageID(),
$data['environment'],
$data['eventClassName'],
$data['eventName'],
$data['listenerClassName']
- );
+ ];
}
else {
$sql = "SELECT *
FROM wcf".WCF_N."_".$this->tableName."
WHERE packageID = ?
AND listenerName = ?";
- $parameters = array(
+ $parameters = [
$this->installation->getPackageID(),
$data['listenerName']
- );
+ ];
}
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
(packageID, filename, application)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
'config.inc.php',
Package::getAbbreviation($this->installation->getPackage()->package)
- ));
+ ]);
// load application
WCF::loadRuntimeApplication($this->installation->getPackageID());
FROM wcf".WCF_N."_package_installation_file_log
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
- $files = array();
+ $files = [];
while ($row = $statement->fetchArray()) {
if (!isset($files[$row['application']])) {
- $files[$row['application']] = array();
+ $files[$row['application']] = [];
}
$files[$row['application']][] = $row['filename'];
AbstractPackageInstallationPlugin::install();
// get language files
- $languageFiles = array();
+ $languageFiles = [];
$multipleFiles = false;
$filename = $this->instruction['value'];
if (strpos($filename, '*') !== false) {
}
// get installed languages
- $installedLanguages = array();
+ $installedLanguages = [];
$sql = "SELECT *
FROM wcf".WCF_N."_language
ORDER BY isDefault DESC";
FROM wcf".WCF_N."_language_item
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
- $itemIDs = array();
- $categoryIDs = array();
+ $statement->execute([$this->installation->getPackageID()]);
+ $itemIDs = [];
+ $categoryIDs = [];
while ($row = $statement->fetchArray()) {
$itemIDs[] = $row['languageItemID'];
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($itemIDs as $itemID) {
- $statement->execute(array(
+ $statement->execute([
$itemID,
$this->installation->getPackageID()
- ));
+ ]);
}
$this->deleteEmptyCategories(array_keys($categoryIDs), $this->installation->getPackageID());
protected function deleteEmptyCategories(array $categoryIDs, $packageID) {
// Get empty categories which where changed by this package.
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("language_category.languageCategoryID IN (?)", array($categoryIDs));
+ $conditions->add("language_category.languageCategoryID IN (?)", [$categoryIDs]);
$sql = "SELECT COUNT(item.languageItemID) AS count,
language_category.languageCategoryID,
language_category.languageCategory ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $categoriesToDelete = array();
+ $categoriesToDelete = [];
while ($row = $statement->fetchArray()) {
if ($row['count'] == 0) {
$categoriesToDelete[$row['languageCategoryID']] = $row['languageCategory'];
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($categoriesToDelete as $category) {
- $statement->execute(array($category));
+ $statement->execute([$category]);
}
}
}
FROM wcf".WCF_N."_menu_item
WHERE identifier = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['identifier'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
FROM wcf".WCF_N."_menu
WHERE identifier = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['identifier'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
*/
protected function prepareImport(array $data) {
- return array(
+ return [
'interfaceName' => (isset($data['elements']['interfacename']) ? $data['elements']['interfacename'] : ''),
'definitionName' => $data['elements']['name'],
'categoryName' => (isset($data['elements']['categoryname']) ? $data['elements']['categoryname'] : '')
- );
+ ];
}
/**
$sql = "SELECT *
FROM wcf".WCF_N."_".$this->tableName."
WHERE definitionName = ?";
- $parameters = array($data['definitionName']);
+ $parameters = [$data['definitionName']];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
* list of names of tags which aren't considered as additional data
* @var string[]
*/
- public static $reservedTags = array('classname', 'definitionname', 'name');
+ public static $reservedTags = ['classname', 'definitionname', 'name'];
/**
* Gets the definition id by name
FROM wcf".WCF_N."_object_type_definition
WHERE definitionName = ?";
$statement = WCF::getDB()->prepareStatement($sql, 1);
- $statement->execute(array($definitionName));
+ $statement->execute([$definitionName]);
$row = $statement->fetchArray();
if (empty($row['definitionID'])) throw new SystemException("unknown object type definition '".$definitionName."' given");
return $row['definitionID'];
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->getDefinitionID($item['elements']['definitionname']),
$this->installation->getPackageID()
- ));
+ ]);
}
}
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
*/
protected function prepareImport(array $data) {
- $additionalData = array();
+ $additionalData = [];
foreach ($data['elements'] as $tagName => $nodeValue) {
if (!in_array($tagName, self::$reservedTags)) $additionalData[$tagName] = $nodeValue;
}
- return array(
+ return [
'definitionID' => $this->getDefinitionID($data['elements']['definitionname']),
'objectType' => $data['elements']['name'],
'className' => (isset($data['elements']['classname']) ? $data['elements']['classname'] : ''),
'additionalData' => serialize($additionalData)
- );
+ ];
}
/**
WHERE objectType = ?
AND definitionID = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['objectType'],
$data['definitionID'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
* list of names of tags which aren't considered as additional data
* @var string[]
*/
- public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'validationpattern', 'enableoptions', 'showorder', 'hidden', 'selectoptions', 'categoryname', 'permissions', 'options', 'attrs', 'cdata', 'supporti18n', 'requirei18n');
+ public static $reservedTags = ['name', 'optiontype', 'defaultvalue', 'validationpattern', 'enableoptions', 'showorder', 'hidden', 'selectoptions', 'categoryname', 'permissions', 'options', 'attrs', 'cdata', 'supporti18n', 'requirei18n'];
/**
* @see \wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
if (isset($option['requirei18n'])) $requireI18n = $option['requirei18n'];
// collect additional tags and their values
- $additionalData = array();
+ $additionalData = [];
foreach ($option as $tag => $value) {
if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
}
// build update or create data
- $data = array(
+ $data = [
'categoryName' => $categoryName,
'optionType' => $optionType,
'validationPattern' => $validationPattern,
'supportI18n' => $supportI18n,
'requireI18n' => $requireI18n,
'additionalData' => serialize($additionalData)
- );
+ ];
// try to find an existing option for updating
$sql = "SELECT *
FROM wcf".WCF_N."_".$this->tableName."
WHERE optionName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$optionName
- ));
+ ]);
$row = $statement->fetchArray();
// result was 'false' thus create a new item
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
*/
protected function prepareImport(array $data) {
- return array(
+ return [
'className' => $data['nodeValue'],
'pluginName' => $data['attributes']['name'],
'priority' => ($this->installation->getPackage()->package == 'com.woltlab.wcf' ? 1 : 0)
- );
+ ];
}
/**
FROM wcf".WCF_N."_".$this->tableName."
WHERE pluginName = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['pluginName'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
// replace app1_ with app{WCF_N}_ in the table names for
// all applications
$packageList = new PackageList();
- $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
+ $packageList->getConditionBuilder()->add('package.isApplication = ?', [1]);
$packageList->readObjects();
foreach ($packageList as $package) {
$abbreviation = Package::getAbbreviation($package->package);
$parser = new PackageInstallationSQLParser($queries, $this->installation->getPackage(), $this->installation->getAction());
$conflicts = $parser->test();
if (!empty($conflicts) && (isset($conflicts['CREATE TABLE']) || isset($conflicts['DROP TABLE']))) {
- $unknownCreateTable = isset($conflicts['CREATE TABLE']) ? $conflicts['CREATE TABLE'] : array();
- $unknownDropTable = isset($conflicts['DROP TABLE']) ? $conflicts['DROP TABLE'] : array();
+ $unknownCreateTable = isset($conflicts['CREATE TABLE']) ? $conflicts['CREATE TABLE'] : [];
+ $unknownDropTable = isset($conflicts['DROP TABLE']) ? $conflicts['DROP TABLE'] : [];
$errorMessage = "Can't";
if (!empty($unknownDropTable)) {
WHERE packageID = ?
ORDER BY sqlIndex DESC, sqlColumn DESC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
- $entries = array();
+ $statement->execute([$this->installation->getPackageID()]);
+ $entries = [];
while ($row = $statement->fetchArray()) {
$entries[] = $row;
}
WHERE packageID = ?
AND filename = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
$this->instruction['value']
- ));
+ ]);
}
}
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
$showOrder = (isset($data['elements']['showOrder'])) ? intval($data['elements']['showOrder']) : null;
$showOrder = $this->getShowOrder($showOrder, null, 'showOrder');
- return array(
+ return [
'sitemapName' => $data['attributes']['name'],
'className' => $data['elements']['classname'],
'showOrder' => $showOrder,
'options' => (isset($data['elements']['options'])) ? $data['elements']['options'] : '',
'permissions' => (isset($data['elements']['permissions'])) ? $data['elements']['permissions'] : ''
- );
+ ];
}
/**
FROM wcf".WCF_N."_".$this->tableName."
WHERE sitemapName = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['sitemapName'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
*/
protected function prepareImport(array $data) {
- return array(
+ return [
'smileyCode' => $data['attributes']['name'],
'smileyTitle' => $data['elements']['title'],
'smileyPath' => $data['elements']['path'],
'aliases' => (isset($data['elements']['aliases']) ? $data['elements']['aliases'] : '')
- );
+ ];
}
/**
FROM wcf".WCF_N."_".$this->tableName."
WHERE smileyCode = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['smileyCode'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
// get all style of this package
$isDefault = false;
$styleList = new StyleList();
- $styleList->getConditionBuilder()->add("packageID = ?", array($this->installation->getPackageID()));
+ $styleList->getConditionBuilder()->add("packageID = ?", [$this->installation->getPackageID()]);
$styleList->readObjects();
foreach ($styleList->getObjects() as $style) {
AND templateName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
$item['elements']['environment'],
$item['elements']['eventname'],
$item['attributes']['name'],
$item['elements']['templatename']
- ));
+ ]);
}
}
$niceValue = 127;
}
- return array(
+ return [
'environment' => $data['elements']['environment'],
'eventName' => $data['elements']['eventname'],
'niceValue' => $niceValue,
'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''),
'templateCode' => $data['elements']['templatecode'],
'templateName' => $data['elements']['templatename']
- );
+ ];
}
/**
AND templateName = ?
AND eventName = ?
AND environment = ?";
- $parameters = array(
+ $parameters = [
$this->installation->getPackageID(),
$data['name'],
$data['templateName'],
$data['eventName'],
$data['environment']
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
/**
ON (template_group.templateGroupID = template.templateGroupID)
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
- $templates = array();
+ $templates = [];
while ($row = $statement->fetchArray()) {
if (!isset($templates[$row['application']])) {
- $templates[$row['application']] = array();
+ $templates[$row['application']] = [];
}
$templates[$row['application']][] = 'templates/'.$row['templateGroupFolderName'].$row['templateName'].'.tpl';
* list of names of tags which aren't considered as additional data
* @var string[]
*/
- public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'admindefaultvalue', 'userdefaultvalue', 'moddefaultvalue', 'validationpattern', 'showorder', 'categoryname', 'selectoptions', 'enableoptions', 'permissions', 'options', 'attrs', 'cdata', 'usersonly');
+ public static $reservedTags = ['name', 'optiontype', 'defaultvalue', 'admindefaultvalue', 'userdefaultvalue', 'moddefaultvalue', 'validationpattern', 'showorder', 'categoryname', 'selectoptions', 'enableoptions', 'permissions', 'options', 'attrs', 'cdata', 'usersonly'];
/**
* @see \wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
if (isset($option['usersonly'])) $usersOnly = $option['usersonly'];
// collect additional tags and their values
- $additionalData = array();
+ $additionalData = [];
foreach ($option as $tag => $value) {
if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
}
WHERE optionName = ?
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$optionName,
$this->installation->getPackageID()
- ));
+ ]);
$row = $statement->fetchArray();
- $data = array(
+ $data = [
'categoryName' => $categoryName,
'optionType' => $optionType,
'defaultValue' => (isset($option['userdefaultvalue']) ? $userDefaultValue : $defaultValue),
'options' => $options,
'usersOnly' => $usersOnly,
'additionalData' => serialize($additionalData)
- );
+ ];
if (!empty($row['optionID'])) {
$groupOption = new UserGroupOption(null, $row);
$optionID = $groupOptionEditor->optionID;
$this->getGroupIDs();
- $values = array();
+ $values = [];
foreach ($this->groupIDs['all'] as $groupID) {
$values[$groupID] = $defaultValue;
}
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($values as $groupID => $value) {
- $statement->execute(array(
+ $statement->execute([
$groupID,
$optionID,
$value
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
*/
protected function getGroupIDs() {
if ($this->groupIDs === null) {
- $this->groupIDs = array(
- 'admin' => array(),
- 'mod' => array(),
- 'all' => array(),
- 'registered' => array()
- );
+ $this->groupIDs = [
+ 'admin' => [],
+ 'mod' => [],
+ 'all' => [],
+ 'registered' => []
+ ];
$sql = "SELECT groupID, groupType
FROM wcf".WCF_N."_user_group";
* preset event ids
* @var integer[]
*/
- protected $presetEventIDs = array();
+ protected $presetEventIDs = [];
/**
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
AND eventName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$this->installation->getPackageID(),
$item['elements']['name']
- ));
+ ]);
}
}
WHERE definitionName = 'com.woltlab.wcf.notification.objectType'
)";
$statement = WCF::getDB()->prepareStatement($sql, 1);
- $statement->execute(array($data['elements']['objecttype']));
+ $statement->execute([$data['elements']['objecttype']]);
$row = $statement->fetchArray();
if (empty($row['objectTypeID'])) throw new SystemException("unknown notification object type '".$data['elements']['objecttype']."' given");
$objectTypeID = $row['objectTypeID'];
$presetMailNotificationType = $data['elements']['presetmailnotificationtype'];
}
- return array(
+ return [
'eventName' => $data['elements']['name'],
'className' => $data['elements']['classname'],
'objectTypeID' => $objectTypeID,
'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''),
'preset' => (!empty($data['elements']['preset']) ? 1 : 0),
'presetMailNotificationType' => $presetMailNotificationType
- );
+ ];
}
/**
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($this->presetEventIDs as $eventID => $mailNotificationType) {
- $statement->execute(array($eventID, $mailNotificationType));
+ $statement->execute([$eventID, $mailNotificationType]);
}
WCF::getDB()->commitTransaction();
}
FROM wcf".WCF_N."_".$this->tableName."
WHERE objectTypeID = ?
AND eventName = ?";
- $parameters = array(
+ $parameters = [
$data['objectTypeID'],
$data['eventName']
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
* list of names of tags which aren't considered as additional data
* @var string[]
*/
- public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'validationpattern', 'required', 'editable', 'visible', 'searchable', 'showorder', 'outputclass', 'selectoptions', 'enableoptions', 'isdisabled', 'categoryname', 'permissions', 'options', 'attrs', 'cdata');
+ public static $reservedTags = ['name', 'optiontype', 'defaultvalue', 'validationpattern', 'required', 'editable', 'visible', 'searchable', 'showorder', 'outputclass', 'selectoptions', 'enableoptions', 'isdisabled', 'categoryname', 'permissions', 'options', 'attrs', 'cdata'];
/**
* @see \wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveCategory()
*/
protected function saveCategory($category, $categoryXML = null) {
// use for create and update
- $data = array(
+ $data = [
'parentCategoryName' => $category['parentCategoryName'],
'permissions' => $category['permissions'],
'options' => $category['options']
- );
+ ];
// append show order if explicitly stated
if ($category['showOrder'] !== null) $data['showOrder'] = $category['showOrder'];
if (isset($option['options'])) $options = $option['options'];
// collect additional tags and their values
- $additionalData = array();
+ $additionalData = [];
foreach ($option as $tag => $value) {
if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
}
WHERE optionName = ?
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$optionName,
$this->installation->getPackageID()
- ));
+ ]);
$result = $statement->fetchArray();
// build data array
- $data = array(
+ $data = [
'categoryName' => $categoryName,
'optionType' => $optionType,
'defaultValue' => $defaultValue,
'options' => $options,
'additionalData' => serialize($additionalData),
'originIsSystem' => 1
- );
+ ];
// update option
if (!empty($result['optionID']) && $this->installation->getAction() == 'update') {
FROM wcf".WCF_N."_user_option
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->installation->getPackageID()));
+ $statement->execute([$this->installation->getPackageID()]);
while ($row = $statement->fetchArray()) {
WCF::getDB()->getEditor()->dropColumn('wcf'.WCF_N.'_user_option_value', 'userOption'.$row['optionID']);
}
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($items as $item) {
- $statement->execute(array(
+ $statement->execute([
$item['attributes']['name'],
$this->installation->getPackageID()
- ));
+ ]);
}
}
$showOrder = $this->getShowOrder($showOrder);
// merge values and default values
- return array(
+ return [
'menuItem' => $data['attributes']['name'],
'options' => (isset($data['elements']['options'])) ? $data['elements']['options'] : '',
'permissions' => (isset($data['elements']['permissions'])) ? $data['elements']['permissions'] : '',
'showOrder' => $showOrder,
'className' => $data['elements']['classname']
- );
+ ];
}
/**
FROM wcf".WCF_N."_".$this->tableName."
WHERE menuItem = ?
AND packageID = ?";
- $parameters = array(
+ $parameters = [
$data['menuItem'],
$this->installation->getPackageID()
- );
+ ];
- return array(
+ return [
'sql' => $sql,
'parameters' => $parameters
- );
+ ];
}
}
* list of excluded packages grouped by package
* @var string[]
*/
- protected static $excludedPackages = array();
+ protected static $excludedPackages = [];
/**
* package archive object
* list of direct requirements delivered by this package
* @var PackageValidationArchive[]
*/
- protected $children = array();
+ protected $children = [];
/**
* nesting depth
PackageValidationManager::getInstance()->addVirtualPackage($package, $this->archive->getPackageInfo('version'));
// cache excluded packages
- self::$excludedPackages[$package] = array();
+ self::$excludedPackages[$package] = [];
$excludedPackages = $this->archive->getExcludedPackages();
for ($i = 0, $count = count($excludedPackages); $i < $count; $i++) {
if (!isset(self::$excludedPackages[$package][$excludedPackages[$i]['name']])) {
- self::$excludedPackages[$package][$excludedPackages[$i]['name']] = array();
+ self::$excludedPackages[$package][$excludedPackages[$i]['name']] = [];
}
self::$excludedPackages[$package][$excludedPackages[$i]['name']][] = $excludedPackages[$i]['version'];
FROM wcf".WCF_N."_package
WHERE package = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($requirement['name']));
+ $statement->execute([$requirement['name']]);
$package = $statement->fetchObject('wcf\data\package\Package');
- throw new PackageValidationException(PackageValidationException::MISSING_REQUIREMENT, array(
+ throw new PackageValidationException(PackageValidationException::MISSING_REQUIREMENT, [
'package' => $package,
'packageName' => $requirement['name'],
'packageVersion' => $requirement['minversion']
- ));
+ ]);
}
$archive = $this->archive->extractTar($requirement['file']);
// delivered package does not provide the minimum required version
if (Package::compareVersion($requiredVersion, $this->archive->getPackageInfo('version'), '>')) {
- throw new PackageValidationException(PackageValidationException::INSUFFICIENT_VERSION, array(
+ throw new PackageValidationException(PackageValidationException::INSUFFICIENT_VERSION, [
'packageName' => $package->packageName,
'packageVersion' => $package->packageVersion,
'deliveredPackageVersion' => $this->archive->getPackageInfo('version')
- ));
+ ]);
}
// package is not installed yet
if ($package === null) {
$instructions = $this->archive->getInstallInstructions();
if (empty($instructions)) {
- throw new PackageValidationException(PackageValidationException::NO_INSTALL_PATH, array('packageName' => $this->archive->getPackageInfo('name')));
+ throw new PackageValidationException(PackageValidationException::NO_INSTALL_PATH, ['packageName' => $this->archive->getPackageInfo('name')]);
}
if ($validationMode == PackageValidationManager::VALIDATION_RECURSIVE) {
else {
// package is already installed, check update path
if (!$this->archive->isValidUpdate($package)) {
- throw new PackageValidationException(PackageValidationException::NO_UPDATE_PATH, array(
+ throw new PackageValidationException(PackageValidationException::NO_UPDATE_PATH, [
'packageName' => $package->packageName,
'packageVersion' => $package->packageVersion,
'deliveredPackageVersion' => $this->archive->getPackageInfo('version')
- ));
+ ]);
}
if ($validationMode === PackageValidationManager::VALIDATION_RECURSIVE) {
for ($i = 0, $length = count($instructions); $i < $length; $i++) {
$instruction = $instructions[$i];
if (!PackageValidationManager::getInstance()->validatePackageInstallationPluginInstruction($this->archive, $instruction['pip'], $instruction['value'])) {
- throw new PackageValidationException(PackageValidationException::MISSING_INSTRUCTION_FILE, array(
+ throw new PackageValidationException(PackageValidationException::MISSING_INSTRUCTION_FILE, [
'pip' => $instruction['pip'],
'type' => $type,
'value' => $instruction['value']
- ));
+ ]);
}
}
}
ON (package.packageID = package_exclusion.packageID)
WHERE excludedPackage = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getArchive()->getPackageInfo('name')));
- $excludingPackages = array();
+ $statement->execute([$this->getArchive()->getPackageInfo('name')]);
+ $excludingPackages = [];
while ($row = $statement->fetchArray()) {
$excludingPackage = $row['package'];
}
if (!empty($excludingPackages)) {
- throw new PackageValidationException(PackageValidationException::EXCLUDING_PACKAGES, array('packages' => $excludingPackages));
+ throw new PackageValidationException(PackageValidationException::EXCLUDING_PACKAGES, ['packages' => $excludingPackages]);
}
// excluded packages: current -> installed
if (!empty(self::$excludedPackages[$package])) {
// get installed packages
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("package IN (?)", array(array_keys(self::$excludedPackages[$package])));
+ $conditions->add("package IN (?)", [array_keys(self::$excludedPackages[$package])]);
$sql = "SELECT *
FROM wcf".WCF_N."_package
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $packages = array();
+ $packages = [];
while ($row = $statement->fetchArray()) {
$packages[$row['package']] = new Package(null, $row);
}
- $excludedPackages = array();
+ $excludedPackages = [];
foreach ($packages as $excludedPackage => $packageObj) {
$version = PackageValidationManager::getInstance()->getVirtualPackage($excludedPackage);
if ($version === null) {
}
if (!empty($excludedPackages)) {
- throw new PackageValidationException(PackageValidationException::EXCLUDED_PACKAGES, array('packages' => $excludedPackages));
+ throw new PackageValidationException(PackageValidationException::EXCLUDED_PACKAGES, ['packages' => $excludedPackages]);
}
}
}
* list of additional details for each subtype
* @var string[]
*/
- protected $details = array();
+ protected $details = [];
/**
* missing archive, expects the detail 'archive' and optionally 'targetArchive' (extracting archive from the archive)
* @param integer $code
* @param string[] $details
*/
- public function __construct($code, array $details = array()) {
+ public function __construct($code, array $details = []) {
$this->details = $details;
parent::__construct($this->getLegacyMessage($code), $code);
* list of known package installation plugins
* @var string[]
*/
- protected $packageInstallationPlugins = array();
+ protected $packageInstallationPlugins = [];
/**
* package validation archive object
* virtual package list containing package => packageVersion
* @var string[]
*/
- protected $virtualPackageList = array();
+ protected $virtualPackageList = [];
/**
* validation will only check if the primary package looks like it can be installed or updated
* @return boolean
*/
public function validate($archive, $deepInspection) {
- $this->virtualPackageList = array();
+ $this->virtualPackageList = [];
$this->packageValidationArchive = new PackageValidationArchive($archive);
if ($deepInspection) {
*/
public function getPackageValidationArchiveList() {
$packageValidationArchive = new PackageValidationArchive('');
- $packageValidationArchive->setChildren(array($this->packageValidationArchive));
+ $packageValidationArchive->setChildren([$this->packageValidationArchive]);
return new \RecursiveIteratorIterator($packageValidationArchive, \RecursiveIteratorIterator::SELF_FIRST);
}
*/
public function validatePackageInstallationPluginInstruction(PackageArchive $archive, $pip, $instruction) {
if (isset($this->packageInstallationPlugins[$pip])) {
- return call_user_func(array($this->packageInstallationPlugins[$pip], 'isValid'), $archive, $instruction);
+ return call_user_func([$this->packageInstallationPlugins[$pip], 'isValid'], $archive, $instruction);
}
return true;
* list of available page object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
}
}
- $selection = array();
+ $selection = [];
foreach ($objectTypes as $objectType) {
$categoryName = WCF::getLanguage()->get('wcf.page.category.'.$objectType->categoryname);
if (!isset($selection[$categoryName])) {
- $selection[$categoryName] = array();
+ $selection[$categoryName] = [];
}
$selection[$categoryName][$objectType->objectTypeID] = WCF::getLanguage()->get('wcf.page.'.$objectType->objectType);
* payment methods
* @var array
*/
- protected $paymentMethods = array();
+ protected $paymentMethods = [];
/**
* payment method object types
* @var array
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
* @return string[]
*/
public function getPaymentMethodSelection() {
- $selection = array();
+ $selection = [];
foreach ($this->objectTypes as $objectType) {
$selection[$objectType->objectType] = WCF::getLanguage()->get('wcf.payment.'.$objectType->objectType);
}
* @see \wcf\system\payment\method\IPaymentMethod::getSupportedCurrencies()
*/
public function getSupportedCurrencies() {
- return array(
+ return [
'AUD', // Australian Dollar
'BRL', // Brazilian Real
'CAD', // Canadian Dollar
'THB', // Thai Baht
'TRY', // Turkish Lira
'USD' // U.S. Dollar
- );
+ ];
}
/**
<input type="hidden" name="lc" value="'.strtoupper(WCF::getLanguage()->languageCode).'" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
- <input type="hidden" name="notify_url" value="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('PaypalCallback', array('appendSession' => false))).'" />
+ <input type="hidden" name="notify_url" value="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('PaypalCallback', ['appendSession' => false])).'" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="return" value="'.StringUtil::encodeHTML($returnURL).'" />
<input type="hidden" name="lc" value="'.strtoupper(WCF::getLanguage()->languageCode).'" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
- <input type="hidden" name="notify_url" value="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('PaypalCallback', array('appendSession' => false))).'" />
+ <input type="hidden" name="notify_url" value="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('PaypalCallback', ['appendSession' => false])).'" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="return" value="'.StringUtil::encodeHTML($returnURL).'" />
* @see \wcf\system\payment\method\IPaymentMethod::getSupportedCurrencies()
*/
public function getSupportedCurrencies() {
- return array(
+ return [
'EUR' // Euro
- );
+ ];
}
/**
// active/extend subscription
if ($userSubscription === null) {
// create new subscription
- $action = new PaidSubscriptionUserAction(array(), 'create', array(
+ $action = new PaidSubscriptionUserAction([], 'create', [
'user' => $user,
'subscription' => $subscription
- ));
+ ]);
$returnValues = $action->executeAction();
$userSubscription = $returnValues['returnValues'];
}
else {
// extend existing subscription
- $action = new PaidSubscriptionUserAction(array($userSubscription), 'extend');
+ $action = new PaidSubscriptionUserAction([$userSubscription], 'extend');
$action->executeAction();
}
$logMessage = 'payment completed';
if ($status == 'reversed') {
if ($userSubscription !== null) {
// revoke subscription
- $action = new PaidSubscriptionUserAction(array($userSubscription), 'revoke');
+ $action = new PaidSubscriptionUserAction([$userSubscription], 'revoke');
$action->executeAction();
}
$logMessage = 'payment reversed';
if ($status == 'canceled_reversal') {
if ($userSubscription !== null) {
// restore subscription
- $action = new PaidSubscriptionUserAction(array($userSubscription), 'restore');
+ $action = new PaidSubscriptionUserAction([$userSubscription], 'restore');
$action->executeAction();
}
$logMessage = 'reversal canceled';
}
// log success
- $action = new PaidSubscriptionTransactionLogAction(array(), 'create', array('data' => array(
+ $action = new PaidSubscriptionTransactionLogAction([], 'create', ['data' => [
'subscriptionUserID' => $userSubscription->subscriptionUserID,
'userID' => $user->userID,
'subscriptionID' => $subscription->subscriptionID,
'transactionID' => $transactionID,
'logMessage' => $logMessage,
'transactionDetails' => serialize($transactionDetails)
- )));
+ ]]);
$action->executeAction();
}
catch (SystemException $e) {
// log failure
- $action = new PaidSubscriptionTransactionLogAction(array(), 'create', array('data' => array(
+ $action = new PaidSubscriptionTransactionLogAction([], 'create', ['data' => [
'subscriptionUserID' => ($userSubscription !== null ? $userSubscription->subscriptionUserID : null),
'userID' => ($user !== null ? $user->userID : null),
'subscriptionID' => ($subscription !== null ? $subscription->subscriptionID : null),
'transactionID' => $transactionID,
'logMessage' => $e->getMessage(),
'transactionDetails' => serialize($transactionDetails)
- )));
+ ]]);
$action->executeAction();
throw $e;
}
* list of object types
* @var ObjectType[]
*/
- protected $cache = array();
+ protected $cache = [];
/**
* current object id
* poll data
* @var mixed[]
*/
- protected $pollData = array(
+ protected $pollData = [
'endTime' => '',
'isChangeable' => 0,
'isPublic' => 0,
'question' => '',
'resultsRequireVote' => 0,
'sortByVotes' => 0
- );
+ ];
/**
* poll id
* list of poll options
* @var string[]
*/
- protected $pollOptions = array();
+ protected $pollOptions = [];
/**
* @see \wcf\system\SingletonFactory::init()
*/
public function removePolls(array $pollIDs) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("pollID IN (?)", array($pollIDs));
+ $conditions->add("pollID IN (?)", [$pollIDs]);
$sql = "DELETE FROM wcf".WCF_N."_poll
".$conditions;
}
// populate poll data
- $this->pollData = array(
+ $this->pollData = [
'endTime' => $this->poll->endTime,
'isChangeable' => $this->poll->isChangeable,
'isPublic' => $this->poll->isPublic,
'question' => $this->poll->question,
'resultsRequireVote' => $this->poll->resultsRequireVote,
'sortByVotes' => $this->poll->sortByVotes
- );
+ ];
// load poll options
$sql = "SELECT optionID, optionValue
WHERE pollID = ?
ORDER BY showOrder ASC";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->poll->pollID));
+ $statement->execute([$this->poll->pollID]);
while ($row = $statement->fetchArray()) {
$this->pollOptions[] = $row;
}
*/
public function readFormParameters() {
// reset poll data and options prior to reading form input
- $this->pollData = $this->pollOptions = array();
+ $this->pollData = $this->pollOptions = [];
// poll data
if (isset($_POST['pollEndTime'])) {
if (isset($_POST['pollOptions']) && is_array($_POST['pollOptions'])) {
foreach ($_POST['pollOptions'] as $showOrder => $value) {
list($optionID, $optionValue) = explode('_', $value, 2);
- $this->pollOptions[$showOrder] = array(
+ $this->pollOptions[$showOrder] = [
'optionID' => intval($optionID),
'optionValue' => StringUtil::trim($optionValue)
- );
+ ];
}
}
}
$data['objectTypeID'] = $this->cache[$this->objectType]->objectTypeID;
$data['time'] = TIME_NOW;
- $action = new PollAction(array(), 'create', array(
+ $action = new PollAction([], 'create', [
'data' => $data,
'options' => $this->pollOptions
- ));
+ ]);
$returnValues = $action->executeAction();
$this->poll = $returnValues['returnValues'];
}
else {
// remove poll
if (empty($this->pollData['question'])) {
- $action = new PollAction(array($this->poll), 'delete');
+ $action = new PollAction([$this->poll], 'delete');
$action->executeAction();
$this->poll = null;
}
else {
// update existing poll
- $action = new PollAction(array($this->poll), 'update', array(
+ $action = new PollAction([$this->poll], 'update', [
'data' => $this->pollData,
'options' => $this->pollOptions
- ));
+ ]);
$action->executeAction();
}
}
* Assigns variables for poll management or display.
*/
public function assignVariables() {
- $variables = array(
+ $variables = [
'__showPoll' => true,
'pollID' => ($this->poll === null ? 0 : $this->poll->pollID),
'pollOptions' => $this->pollOptions
- );
+ ];
foreach ($this->pollData as $key => $value) {
if ($key == 'endTime') {
if (!$value) $value = '';
// invalid poll ids
if (empty($polls)) {
- return array();
+ return [];
}
// fetch options for every poll
*/
public function getPollOptions(array $pollIDs) {
$optionList = new PollOptionList();
- $optionList->getConditionBuilder()->add("poll_option.pollID IN (?)", array($pollIDs));
+ $optionList->getConditionBuilder()->add("poll_option.pollID IN (?)", [$pollIDs]);
// check for user votes
if (WCF::getUser()->userID) {
throw new SystemException("'".$className."' does not extend 'wcf\system\SingletonFactory'");
}
- $object = call_user_func(array($className, 'getInstance'));
+ $object = call_user_func([$className, 'getInstance']);
return $object;
}
}
throw new UserInputException('recaptchaString', 'false');
}
- $request = new HTTPRequest('https://www.google.com/recaptcha/api/siteverify?secret='.rawurlencode(RECAPTCHA_PRIVATEKEY).'&response='.rawurlencode($response).'&remoteip='.rawurlencode(UserUtil::getIpAddress()), array('timeout' => 10));
+ $request = new HTTPRequest('https://www.google.com/recaptcha/api/siteverify?secret='.rawurlencode(RECAPTCHA_PRIVATEKEY).'&response='.rawurlencode($response).'&remoteip='.rawurlencode(UserUtil::getIpAddress()), ['timeout' => 10]);
try {
$request->execute();
* schema for outgoing links
* @var mixed[][]
*/
- protected $buildSchema = array();
+ protected $buildSchema = [];
/**
* route is restricted to ACP
* list of required components
* @var string[]
*/
- protected $requireComponents = array();
+ protected $requireComponents = [];
/**
* parsed request data
* @var mixed[]
*/
- protected $routeData = array();
+ protected $routeData = [];
/**
* Creates a new flexible route instace.
* @param string $buildSchema
*/
public function setBuildSchema($buildSchema) {
- $this->buildSchema = array();
+ $this->buildSchema = [];
$buildSchema = ltrim($buildSchema, '/');
$components = preg_split('~({(?:[a-z]+)})~', $buildSchema, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- $delimiters = array('/', '-', '.', '_');
+ $delimiters = ['/', '-', '.', '_'];
foreach ($components as $component) {
$type = 'component';
$type = 'separator';
}
- $this->buildSchema[] = array(
+ $this->buildSchema[] = [
'type' => $type,
'value' => $component
- );
+ ];
}
}
}
else {
@header('HTTP/1.1 503 Service Unavailable');
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'templateName' => 'offline',
'templateNameApplication' => 'wcf'
- ));
+ ]);
WCF::getTPL()->display('offline');
}
* schema component options
* @var array
*/
- protected $parameterOptions = array();
+ protected $parameterOptions = [];
/**
* route name
* route schema data
* @var array
*/
- protected $routeSchema = array();
+ protected $routeSchema = [];
/**
* parsed route data
* cached list of transformed controller names
* @var string[]
*/
- protected static $controllerNames = array();
+ protected static $controllerNames = [];
/**
* list of application abbreviation and default controller name
throw new SystemException("Placeholder expected, but invalid string '" . $part . "' given.");
}
- $part = str_replace(array('{', '}'), '', $part);
+ $part = str_replace(['{', '}'], '', $part);
if ($part == 'controller') {
if ($this->controller !== null) {
throw new SystemException('Controller may not be part of the scheme if a route controller is given.');
* @param boolean $isOptional
*/
public function setParameterOption($key, $default = null, $regexPattern = null, $isOptional = false) {
- $this->parameterOptions[$key] = array(
+ $this->parameterOptions[$key] = [
'default' => $default,
'isOptional' => $isOptional,
'regexPattern' => $regexPattern
- );
+ ];
}
/**
*/
public function matches($requestURL) {
$urlParts = $this->getParts($requestURL);
- $data = array();
+ $data = [];
// handle each route schema component
for ($i = 0, $size = count($this->routeSchema); $i < $size; $i++) {
*/
protected static function loadDefaultControllers() {
if (self::$defaultControllers === null) {
- self::$defaultControllers = array();
+ self::$defaultControllers = [];
foreach (ApplicationHandler::getInstance()->getApplications() as $application) {
$app = WCF::getApplicationObject($application);
* list of available routes
* @var IRoute[]
*/
- protected $routes = array();
+ protected $routes = [];
/**
* parsed route data
* @param array $removeComponents
* @return string
*/
- public static function getPath(array $removeComponents = array()) {
+ public static function getPath(array $removeComponents = []) {
if (empty(self::$path)) {
self::$path = FileUtil::addTrailingSlash(dirname($_SERVER['SCRIPT_NAME']));
}
*/
protected function loadDefaultControllers() {
if ($this->defaultControllers === null) {
- $this->defaultControllers = array();
+ $this->defaultControllers = [];
foreach (ApplicationHandler::getInstance()->getApplications() as $application) {
$app = WCF::getApplicationObject($application);
FROM wcf".WCF_N."_object_type_definition
WHERE definitionName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('com.woltlab.wcf.searchableObjectType'));
+ $statement->execute(['com.woltlab.wcf.searchableObjectType']);
$row = $statement->fetchArray();
$objectTypeList = new ObjectTypeList();
- $objectTypeList->getConditionBuilder()->add("object_type.definitionID = ?", array($row['definitionID']));
+ $objectTypeList->getConditionBuilder()->add("object_type.definitionID = ?", [$row['definitionID']]);
$objectTypeList->readObjects();
foreach ($objectTypeList as $objectType) {
* @param integer $limit
* @return array
*/
- public function search($q, array $objectTypes, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, array $additionalConditions = array(), $orderBy = 'time DESC', $limit = 1000);
+ public function search($q, array $objectTypes, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, array $additionalConditions = [], $orderBy = 'time DESC', $limit = 1000);
}
* list of available object types
* @var array
*/
- protected $availableObjectTypes = array();
+ protected $availableObjectTypes = [];
/**
* search engine object
$className = 'wcf\system\search\mysql\MysqlSearchEngine';
}
- $this->searchEngine = call_user_func(array($className, 'getInstance'));
+ $this->searchEngine = call_user_func([$className, 'getInstance']);
}
return $this->searchEngine;
/**
* @see \wcf\system\search\ISearchEngine::search()
*/
- public function search($q, array $objectTypes, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, array $additionalConditions = array(), $orderBy = 'time DESC', $limit = 1000) {
+ public function search($q, array $objectTypes, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, array $additionalConditions = [], $orderBy = 'time DESC', $limit = 1000) {
return $this->getSearchEngine()->search($q, $objectTypes, $subjectOnly, $searchIndexCondition, $additionalConditions, $orderBy, $limit);
}
* list of available object types
* @var array
*/
- protected $availableObjectTypes = array();
+ protected $availableObjectTypes = [];
/**
* list of application packages
* @var Package[]
*/
- protected static $packages = array();
+ protected static $packages = [];
/**
* search index manager object
$className = 'wcf\system\search\mysql\MysqlSearchIndexManager';
}
- $this->searchIndexManager = call_user_func(array($className, 'getInstance'));
+ $this->searchIndexManager = call_user_func([$className, 'getInstance']);
}
return $this->searchIndexManager;
if (!empty($tableName)) {
if (empty(self::$packages)) {
$packageList = new PackageList();
- $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
+ $packageList->getConditionBuilder()->add('package.isApplication = ?', [1]);
$packageList->readObjects();
self::$packages = $packageList->getObjects();
FROM wcf".WCF_N."_search_keyword
WHERE keyword = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($keyword));
+ $statement->execute([$keyword]);
if (($object = $statement->fetchObject('wcf\data\search\keyword\SearchKeyword')) !== null) {
- $action = new SearchKeywordAction(array($object), 'update', array('data' => array(
+ $action = new SearchKeywordAction([$object], 'update', ['data' => [
'searches' => $object->searches + 1,
'lastSearchTime' => TIME_NOW
- )));
+ ]]);
$action->executeAction();
}
else {
- $action = new SearchKeywordAction(array(), 'create', array('data' => array(
+ $action = new SearchKeywordAction([], 'create', ['data' => [
'keyword' => mb_substr($keyword, 0, 255),
'searches' => 1,
'lastSearchTime' => TIME_NOW
- )));
+ ]]);
$action->executeAction();
}
}
}
}
else {
- $matches = array();
+ $matches = [];
$shiftLength = static::MAX_LENGTH;
// find first match of each keyword
foreach ($this->searchQuery as $keyword) {
$start = mb_strripos($text, $keyword);
if ($start !== false) {
$shiftLength -= mb_strlen($keyword);
- $matches[$keyword] = array('start' => $start, 'end' => $start + mb_strlen($keyword));
+ $matches[$keyword] = ['start' => $start, 'end' => $start + mb_strlen($keyword)];
}
}
* list of application abbreviations
* @var string[]
*/
- public $abbreviations = array();
+ public $abbreviations = [];
/**
* list of acp search provider
* @throws SystemException
*/
public function search($query, $limit = 10) {
- $data = array();
+ $data = [];
$maxResultsPerProvider = ceil($limit / 2);
$totalResultCount = 0;
}
if (!empty($suffix)) {
- $abbreviations = array();
+ $abbreviations = [];
foreach ($this->abbreviations as $abbreviation) {
$abbreviations[] = $abbreviation . $suffix;
}
* result list
* @var ACPSearchResult[]
*/
- protected $results = array();
+ protected $results = [];
/**
* Creates a new ACPSearchResultList.
public function reduceResults($count) {
// more results than available should be whiped, just set it to 0
if ($count >= count($this->results)) {
- $this->results = array();
+ $this->results = [];
}
else {
while ($count > 0) {
* list of categories
* @var DatabaseObject[]
*/
- protected $categories = array();
+ protected $categories = [];
/**
* class name for category list
* list of top category names (level 1 and 2)
* @var string[]
*/
- protected $topCategories = array();
+ protected $topCategories = [];
/**
* Creates a new categorized ACP search result provider.
}
// create level 2 categories
- $topCategories = array();
+ $topCategories = [];
foreach ($this->categories as $category) {
if ($category->parentCategoryName && in_array($category->parentCategoryName, $this->topCategories)) {
$topCategories[] = $category->categoryName;
* @see \wcf\system\search\acp\IACPSearchResultProvider::search()
*/
public function search($query) {
- $results = array();
+ $results = [];
// search by language item
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("languageID = ?", array(WCF::getLanguage()->languageID));
+ $conditions->add("languageID = ?", [WCF::getLanguage()->languageID]);
// filter by language item
$languageItemsConditions = '';
- $languageItemsParameters = array();
+ $languageItemsParameters = [];
foreach (ACPSearchHandler::getInstance()->getAbbreviations('.acp.menu.link.%') as $abbreviation) {
if (!empty($languageItemsConditions)) $languageItemsConditions .= " OR ";
$languageItemsConditions .= "languageItem LIKE ?";
$languageItemsParameters[] = $abbreviation;
}
$conditions->add("(".$languageItemsConditions.")", $languageItemsParameters);
- $conditions->add("languageItemValue LIKE ?", array('%'.$query.'%'));
+ $conditions->add("languageItemValue LIKE ?", ['%'.$query.'%']);
$sql = "SELECT languageItem, languageItemValue
FROM wcf".WCF_N."_language_item
ORDER BY languageItemValue ASC";
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $languageItems = array();
+ $languageItems = [];
while ($row = $statement->fetchArray()) {
$languageItems[$row['languageItem']] = $row['languageItemValue'];
}
if (empty($languageItems)) {
- return array();
+ return [];
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("menuItem IN (?)", array(array_keys($languageItems)));
+ $conditions->add("menuItem IN (?)", [array_keys($languageItems)]);
$conditions->add("menuItemController <> ''");
$sql = "SELECT *
}
$parentMenuItem = $menuItem->parentMenuItem;
- $parentMenuItems = array();
+ $parentMenuItems = [];
while ($parentMenuItem && isset($menuItems[$parentMenuItem])) {
array_unshift($parentMenuItems, $parentMenuItem);
$parentMenuItem = $menuItems[$parentMenuItem]->parentMenuItem;
}
- $results[] = new ACPSearchResult($languageItems[$menuItem->menuItem], $menuItem->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array(
+ $results[] = new ACPSearchResult($languageItems[$menuItem->menuItem], $menuItem->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', [
'pieces' => $parentMenuItems
- )));
+ ]));
}
return $results;
* @see \wcf\system\search\acp\IACPSearchResultProvider::search()
*/
public function search($query) {
- $results = array();
+ $results = [];
// search by language item
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("languageID = ?", array(WCF::getLanguage()->languageID));
- $conditions->add("languageItem LIKE ?", array('wcf.acp.option.%'));
- $conditions->add("languageItemValue LIKE ?", array('%'.$query.'%'));
+ $conditions->add("languageID = ?", [WCF::getLanguage()->languageID]);
+ $conditions->add("languageItem LIKE ?", ['wcf.acp.option.%']);
+ $conditions->add("languageItemValue LIKE ?", ['%'.$query.'%']);
$sql = "SELECT languageItem, languageItemValue
FROM wcf".WCF_N."_language_item
ORDER BY languageItemValue ASC";
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $languageItems = array();
- $optionNames = array();
+ $languageItems = [];
+ $optionNames = [];
while ($row = $statement->fetchArray()) {
$optionName = preg_replace('~^([a-z]+)\.acp\.option\.~', '', $row['languageItem']);
}
if (empty($optionNames)) {
- return array();
+ return [];
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("optionName IN (?)", array($optionNames));
+ $conditions->add("optionName IN (?)", [$optionNames]);
$sql = "SELECT optionName, categoryName, options, permissions, hidden
FROM wcf".WCF_N."_option
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $optionCategories = OptionCacheBuilder::getInstance()->getData(array(), 'categories');
+ $optionCategories = OptionCacheBuilder::getInstance()->getData([], 'categories');
while ($option = $statement->fetchObject('wcf\data\option\Option')) {
// category is not accessible
continue;
}
- $link = LinkHandler::getInstance()->getLink('Option', array('id' => $this->getCategoryID($this->getTopCategory($option->categoryName)->parentCategoryName)), 'optionName='.$option->optionName.'#'.$this->getCategoryName($option->categoryName));
+ $link = LinkHandler::getInstance()->getLink('Option', ['id' => $this->getCategoryID($this->getTopCategory($option->categoryName)->parentCategoryName)], 'optionName='.$option->optionName.'#'.$this->getCategoryName($option->categoryName));
$categoryName = $option->categoryName;
- $parentCategories = array();
+ $parentCategories = [];
while (isset($optionCategories[$categoryName])) {
array_unshift($parentCategories, 'wcf.acp.option.category.'.$optionCategories[$categoryName]->categoryName);
$categoryName = $optionCategories[$categoryName]->parentCategoryName;
}
- $results[] = new ACPSearchResult($languageItems[$option->optionName], $link, WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array(
+ $results[] = new ACPSearchResult($languageItems[$option->optionName], $link, WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', [
'pieces' => $parentCategories
- )));
+ ]));
}
return $results;
*/
public function search($query) {
if (!WCF::getSession()->getPermission('admin.configuration.package.canUpdatePackage') && !WCF::getSession()->getPermission('admin.configuration.package.canUninstallPackage')) {
- return array();
+ return [];
}
- $results = array();
+ $results = [];
// search by language item
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("languageID = ?", array(WCF::getLanguage()->languageID));
- $conditions->add("languageItem LIKE ?", array('wcf.acp.package.packageName.package%'));
- $conditions->add("languageItemValue LIKE ?", array('%'.$query.'%'));
+ $conditions->add("languageID = ?", [WCF::getLanguage()->languageID]);
+ $conditions->add("languageItem LIKE ?", ['wcf.acp.package.packageName.package%']);
+ $conditions->add("languageItemValue LIKE ?", ['%'.$query.'%']);
$sql = "SELECT languageItem
FROM wcf".WCF_N."_language_item
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $packageIDs = array();
+ $packageIDs = [];
while ($row = $statement->fetchArray()) {
$packageIDs[] = str_replace('wcf.acp.package.packageName.package', '', $row['languageItem']);
}
$conditions = new PreparedStatementConditionBuilder(false);
if (!empty($packageIDs)) {
- $conditions->add("packageID IN (?)", array($packageIDs));
+ $conditions->add("packageID IN (?)", [$packageIDs]);
}
$sql = "SELECT *
OR package LIKE ?
".(count($conditions->getParameters()) ? "OR ".$conditions : "");
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array(
+ $statement->execute(array_merge([
'%'.$query.'%',
'%'.$query.'%'
- ), $conditions->getParameters()));
+ ], $conditions->getParameters()));
while ($package = $statement->fetchObject('wcf\data\package\Package')) {
- $results[] = new ACPSearchResult($package->getName(), LinkHandler::getInstance()->getLink('Package', array(
+ $results[] = new ACPSearchResult($package->getName(), LinkHandler::getInstance()->getLink('Package', [
'id' => $package->packageID,
'title' => $package->getName()
- )));
+ ]));
}
return $results;
*/
public function search($query) {
if (!WCF::getSession()->getPermission('admin.user.canEditUser')) {
- return array();
+ return [];
}
- $results = array();
+ $results = [];
$sql = "SELECT *
FROM wcf".WCF_N."_user
WHERE username LIKE ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($query.'%'));
+ $statement->execute([$query.'%']);
while ($user = $statement->fetchObject('wcf\data\user\User')) {
if (UserGroup::isAccessibleGroup($user->getGroupIDs())) {
- $results[] = new ACPSearchResult($user->username, LinkHandler::getInstance()->getLink('UserEdit', array(
+ $results[] = new ACPSearchResult($user->username, LinkHandler::getInstance()->getLink('UserEdit', [
'object' => $user
- )));
+ ]));
}
}
* @see \wcf\system\search\acp\IACPSearchResultProvider::search()
*/
public function search($query) {
- $results = array();
+ $results = [];
// search by language item
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("languageID = ?", array(WCF::getLanguage()->languageID));
- $conditions->add("languageItem LIKE ?", array('wcf.acp.group.option.%'));
- $conditions->add("languageItemValue LIKE ?", array('%'.$query.'%'));
+ $conditions->add("languageID = ?", [WCF::getLanguage()->languageID]);
+ $conditions->add("languageItem LIKE ?", ['wcf.acp.group.option.%']);
+ $conditions->add("languageItemValue LIKE ?", ['%'.$query.'%']);
$sql = "SELECT languageItem, languageItemValue
FROM wcf".WCF_N."_language_item
ORDER BY languageItemValue ASC";
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $languageItems = array();
+ $languageItems = [];
while ($row = $statement->fetchArray()) {
// ignore descriptions
if (substr($row['languageItem'], -12) == '.description') {
}
if (empty($languageItems)) {
- return array();
+ return [];
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("optionName IN (?)", array(array_keys($languageItems)));
+ $conditions->add("optionName IN (?)", [array_keys($languageItems)]);
$sql = "SELECT optionID, optionName, categoryName, permissions, options
FROM wcf".WCF_N."_user_group_option
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $optionCategories = UserGroupOptionCacheBuilder::getInstance()->getData(array(), 'categories');
+ $optionCategories = UserGroupOptionCacheBuilder::getInstance()->getData([], 'categories');
while ($userGroupOption = $statement->fetchObject('wcf\data\user\group\option\UserGroupOption')) {
// category is not accessible
continue;
}
- $link = LinkHandler::getInstance()->getLink('UserGroupOption', array('id' => $userGroupOption->optionID));
+ $link = LinkHandler::getInstance()->getLink('UserGroupOption', ['id' => $userGroupOption->optionID]);
$categoryName = $userGroupOption->categoryName;
- $parentCategories = array();
+ $parentCategories = [];
while (isset($optionCategories[$categoryName])) {
array_unshift($parentCategories, 'wcf.acp.group.option.category.'.$optionCategories[$categoryName]->categoryName);
$categoryName = $optionCategories[$categoryName]->parentCategoryName;
}
- $results[] = new ACPSearchResult($languageItems[$userGroupOption->optionName], $link, WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array(
+ $results[] = new ACPSearchResult($languageItems[$userGroupOption->optionName], $link, WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', [
'pieces' => $parentCategories
- )));
+ ]));
}
return $results;
/**
* @see \wcf\system\search\AbstractSearchEngine::$specialCharacters
*/
- protected $specialCharacters = array('(', ')', '@', '+', '-', '"', '<', '>', '~', '*');
+ protected $specialCharacters = ['(', ')', '@', '+', '-', '"', '<', '>', '~', '*'];
/**
* @see \wcf\system\search\ISearchEngine::search()
*/
- public function search($q, array $objectTypes, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, array $additionalConditions = array(), $orderBy = 'time DESC', $limit = 1000) {
+ public function search($q, array $objectTypes, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, array $additionalConditions = [], $orderBy = 'time DESC', $limit = 1000) {
// build search query
$sql = '';
- $parameters = array();
+ $parameters = [];
foreach ($objectTypes as $objectTypeName) {
$objectType = SearchEngine::getInstance()->getObjectType($objectTypeName);
}
// send search query
- $messages = array();
+ $messages = [];
$statement = WCF::getDB()->prepareStatement($sql, $limit);
$statement->execute($parameters);
while ($row = $statement->fetchArray()) {
- $messages[] = array(
+ $messages[] = [
'objectID' => $row['objectID'],
'objectType' => $row['objectType']
- );
+ ];
}
return $messages;
$q = $this->parseSearchQuery($q);
$fulltextCondition = new PreparedStatementConditionBuilder(false);
- $fulltextCondition->add("MATCH (subject".(!$subjectOnly ? ', message, metaData' : '').") AGAINST (? IN BOOLEAN MODE)", array($q));
+ $fulltextCondition->add("MATCH (subject".(!$subjectOnly ? ', message, metaData' : '').") AGAINST (? IN BOOLEAN MODE)", [$q]);
if ($orderBy == 'relevance ASC' || $orderBy == 'relevance DESC') {
$relevanceCalc = "MATCH (subject".(!$subjectOnly ? ', message, metaData' : '').") AGAINST ('".escapeString($q)."') + (5 / (1 + POW(LN(1 + (".TIME_NOW." - time) / 2592000), 2))) AS relevance";
".(!empty($orderBy) && $fulltextCondition === null ? 'ORDER BY '.$orderBy : '')."
LIMIT ".($limit == 1000 ? SearchEngine::INNER_SEARCH_LIMIT : $limit);
- return array(
+ return [
'fulltextCondition' => $fulltextCondition,
'searchIndexCondition' => $searchIndexCondition,
'sql' => $sql
- );
+ ];
}
/**
}
catch (DatabaseException $e) {
// fallback if user is disallowed to issue 'SHOW VARIABLES'
- $row = array('Value' => 4);
+ $row = ['Value' => 4];
}
$this->ftMinWordLen = $row['Value'];
(objectID, subject, message, time, userID, username, languageID, metaData)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($objectID, $subject, $message, $time, $userID, $username, $languageID, $metaData));
+ $statement->execute([$objectID, $subject, $message, $time, $userID, $username, $languageID, $metaData]);
}
/**
*/
public function update($objectType, $objectID, $message, $subject, $time, $userID, $username, $languageID = null, $metaData = '') {
// delete existing entry
- $this->delete($objectType, array($objectID));
+ $this->delete($objectType, [$objectID]);
// save new entry
$this->add($objectType, $objectID, $message, $subject, $time, $userID, $username, $languageID, $metaData);
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) {
- $statement->execute(array($objectID));
+ $statement->execute([$objectID]);
}
WCF::getDB()->commitTransaction();
}
FROM wcf".WCF_N."_package_installation_sql_log
WHERE sqlTable = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($tableName));
+ $statement->execute([$tableName]);
if ($statement->fetchSingleColumn()) {
// table already exists
return false;
}
- $columns = array(
- array('name' => 'objectID', 'data' => array('length' => 10, 'notNull' => true, 'type' => 'int')),
- array('name' => 'subject', 'data' => array('default' => '', 'length' => 255, 'notNull' => true, 'type' => 'varchar')),
- array('name' => 'message', 'data' => array('type' => 'mediumtext')),
- array('name' => 'metaData', 'data' => array('type' => 'mediumtext')),
- array('name' => 'time', 'data' => array('default' => 0, 'length' => 10, 'notNull' => true, 'type' => 'int')),
- array('name' => 'userID', 'data' => array('default' => '', 'length' => 10, 'type' => 'int')),
- array('name' => 'username', 'data' => array('default' => '', 'length' => 255,'notNull' => true, 'type' => 'varchar')),
- array('name' => 'languageID', 'data' => array('default' => 0, 'length' => 10, 'notNull' => true, 'type' => 'int'))
- );
+ $columns = [
+ ['name' => 'objectID', 'data' => ['length' => 10, 'notNull' => true, 'type' => 'int']],
+ ['name' => 'subject', 'data' => ['default' => '', 'length' => 255, 'notNull' => true, 'type' => 'varchar']],
+ ['name' => 'message', 'data' => ['type' => 'mediumtext']],
+ ['name' => 'metaData', 'data' => ['type' => 'mediumtext']],
+ ['name' => 'time', 'data' => ['default' => 0, 'length' => 10, 'notNull' => true, 'type' => 'int']],
+ ['name' => 'userID', 'data' => ['default' => '', 'length' => 10, 'type' => 'int']],
+ ['name' => 'username', 'data' => ['default' => '', 'length' => 255,'notNull' => true, 'type' => 'varchar']],
+ ['name' => 'languageID', 'data' => ['default' => 0, 'length' => 10, 'notNull' => true, 'type' => 'int']]
+ ];
- $indices = array(
- array('name' => 'objectAndLanguage', 'data' => array('columns' => 'objectID, languageID', 'type' => 'UNIQUE')),
- array('name' => 'fulltextIndex', 'data' => array('columns' => 'subject, message, metaData', 'type' => 'FULLTEXT')),
- array('name' => 'fulltextIndexSubjectOnly', 'data' => array('columns' => 'subject', 'type' => 'FULLTEXT')),
- array('name' => 'language', 'data' => array('columns' => 'languageID', 'type' => 'KEY')),
- array('name' => 'user', 'data' => array('columns' => 'userID, time', 'type'=> 'KEY'))
- );
+ $indices = [
+ ['name' => 'objectAndLanguage', 'data' => ['columns' => 'objectID, languageID', 'type' => 'UNIQUE']],
+ ['name' => 'fulltextIndex', 'data' => ['columns' => 'subject, message, metaData', 'type' => 'FULLTEXT']],
+ ['name' => 'fulltextIndexSubjectOnly', 'data' => ['columns' => 'subject', 'type' => 'FULLTEXT']],
+ ['name' => 'language', 'data' => ['columns' => 'languageID', 'type' => 'KEY']],
+ ['name' => 'user', 'data' => ['columns' => 'userID, time', 'type'=> 'KEY']]
+ ];
WCF::getDB()->getEditor()->createTable($tableName, $columns, $indices);
(packageID, sqlTable)
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectType->packageID,
$tableName
- ));
+ ]);
return true;
}
* various environment variables
* @var array
*/
- protected $environment = array();
+ protected $environment = [];
/**
* group data and permissions
* list of names of permissions only available for users
* @var string[]
*/
- protected $usersOnlyPermissions = array();
+ protected $usersOnlyPermissions = [];
/**
* Provides access to session data.
*/
protected function init() {
$this->isACP = (class_exists(WCFACP::class, false) || !PACKAGE_ID);
- $this->usersOnlyPermissions = UserGroupOptionCacheBuilder::getInstance()->getData(array(), 'usersOnlyOptions');
+ $this->usersOnlyPermissions = UserGroupOptionCacheBuilder::getInstance()->getData([], 'usersOnlyOptions');
}
/**
*/
public function load($sessionEditorClassName, $sessionID) {
$this->sessionEditorClassName = $sessionEditorClassName;
- $this->sessionClassName = call_user_func(array($sessionEditorClassName, 'getBaseClass'));
- $this->supportsVirtualSessions = call_user_func(array($this->sessionClassName, 'supportsVirtualSessions'));
+ $this->sessionClassName = call_user_func([$sessionEditorClassName, 'getBaseClass']);
+ $this->supportsVirtualSessions = call_user_func([$this->sessionClassName, 'supportsVirtualSessions']);
// try to get existing session
if (!empty($sessionID)) {
/** @var \wcf\data\DatabaseObjectEditor $sessionEditor */
$sessionEditor = new $this->sessionEditorClassName($this->session);
- $sessionEditor->update(array(
+ $sessionEditor->update([
'sessionID' => $newSessionID
- ));
+ ]);
// fetch new session data from database
$this->session = new $this->sessionClassName($newSessionID);
* Initializes environment variables.
*/
protected function initEnvironment() {
- $this->environment = array(
+ $this->environment = [
'lastRequestURI' => $this->session->requestURI,
'lastRequestMethod' => $this->session->requestMethod,
'ipAddress' => UserUtil::getIpAddress(),
'userAgent' => UserUtil::getUserAgent(),
'requestURI' => UserUtil::getRequestURI(),
'requestMethod' => (!empty($_SERVER['REQUEST_METHOD']) ? substr($_SERVER['REQUEST_METHOD'], 0, 7) : '')
- );
+ ];
}
/**
protected function loadVariables() {
@$this->variables = unserialize($this->virtualSession->sessionVariables);
if (!is_array($this->variables)) {
- $this->variables = array();
+ $this->variables = [];
}
}
if ($this->virtualSession === null || $forceReload) {
$this->virtualSession = null;
if ($this->isACP) {
- $virtualSessionAction = new ACPSessionVirtualAction(array(), 'create', array('data' => array('sessionID' => $this->session->sessionID)));
+ $virtualSessionAction = new ACPSessionVirtualAction([], 'create', ['data' => ['sessionID' => $this->session->sessionID]]);
}
else {
- $virtualSessionAction = new SessionVirtualAction(array(), 'create', array('data' => array('sessionID' => $this->session->sessionID)));
+ $virtualSessionAction = new SessionVirtualAction([], 'create', ['data' => ['sessionID' => $this->session->sessionID]]);
}
try {
$sessionID = StringUtil::getRandomID();
// get user automatically
- $this->user = UserAuthenticationFactory::getInstance()->getUserAuthentication()->loginAutomatically(call_user_func(array($this->sessionClassName, 'supportsPersistentLogins')));
+ $this->user = UserAuthenticationFactory::getInstance()->getUserAuthentication()->loginAutomatically(call_user_func([$this->sessionClassName, 'supportsPersistentLogins']));
// create user
if ($this->user === null) {
}
else if (!$this->supportsVirtualSessions) {
// delete all other sessions of this user
- call_user_func(array($this->sessionEditorClassName, 'deleteUserSessions'), array($this->user->userID));
+ call_user_func([$this->sessionEditorClassName, 'deleteUserSessions'], [$this->user->userID]);
}
$createNewSession = true;
// find existing session
- $session = call_user_func(array($this->sessionClassName, 'getSessionByUserID'), $this->user->userID);
+ $session = call_user_func([$this->sessionClassName, 'getSessionByUserID'], $this->user->userID);
if ($session !== null) {
// inherit existing session
if ($createNewSession) {
// save session
- $sessionData = array(
+ $sessionData = [
'sessionID' => $sessionID,
'userID' => $this->user->userID,
'ipAddress' => UserUtil::getIpAddress(),
'lastActivityTime' => TIME_NOW,
'requestURI' => UserUtil::getRequestURI(),
'requestMethod' => (!empty($_SERVER['REQUEST_METHOD']) ? substr($_SERVER['REQUEST_METHOD'], 0, 7) : '')
- );
+ ];
if ($spiderID !== null) $sessionData['spiderID'] = $spiderID;
try {
- $this->session = call_user_func(array($this->sessionEditorClassName, 'create'), $sessionData);
+ $this->session = call_user_func([$this->sessionEditorClassName, 'create'], $sessionData);
}
catch (DatabaseException $e) {
// MySQL error 23000 = unique key
// do not check against the message itself, some weird systems localize them
if ($e->getCode() == 23000) {
// find existing session
- $session = call_user_func(array($this->sessionClassName, 'getSessionByUserID'), $this->user->userID);
+ $session = call_user_func([$this->sessionClassName, 'getSessionByUserID'], $this->user->userID);
if ($session === null) {
// MySQL reported a unique key error, but no corresponding session exists, rethrow exception
FROM wcf".WCF_N."_user_to_group
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->user->userID));
+ $statement->execute([$this->user->userID]);
$groupIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
}
else {
// get group data from cache
$this->groupData = UserGroupPermissionCacheBuilder::getInstance()->getData($groupIDs);
if (isset($this->groupData['groupIDs']) && $this->groupData['groupIDs'] != $groupIDs) {
- $this->groupData = array();
+ $this->groupData = [];
}
}
protected function loadLanguageIDs() {
if ($this->languageIDs !== null) return;
- $this->languageIDs = array();
+ $this->languageIDs = [];
if (!$this->user->userID) {
return;
FROM wcf".WCF_N."_user_to_language
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->user->userID));
+ $statement->execute([$this->user->userID]);
$this->languageIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
}
else {
* @param boolean $hideSession if true, database won't be updated
*/
public function changeUser(User $user, $hideSession = false) {
- $eventParameters = array('user' => $user, 'hideSession' => $hideSession);
+ $eventParameters = ['user' => $user, 'hideSession' => $hideSession];
EventHandler::getInstance()->fireAction($this, 'beforeChangeUser', $eventParameters);
// there are still other virtual sessions, create a new session
if ($sessionCount) {
// save session
- $sessionData = array(
+ $sessionData = [
'sessionID' => StringUtil::getRandomID(),
'userID' => $user->userID,
'ipAddress' => UserUtil::getIpAddress(),
'lastActivityTime' => TIME_NOW,
'requestURI' => UserUtil::getRequestURI(),
'requestMethod' => (!empty($_SERVER['REQUEST_METHOD']) ? substr($_SERVER['REQUEST_METHOD'], 0, 7) : '')
- );
+ ];
- $this->session = call_user_func(array($this->sessionEditorClassName, 'create'), $sessionData);
+ $this->session = call_user_func([$this->sessionEditorClassName, 'create'], $sessionData);
HeaderUtil::setCookie('cookieHash'.$this->cookieSuffix, $this->session->sessionID);
}
// this was the last virtual session, re-use current session
// update session
$sessionEditor = new $this->sessionEditorClassName($this->session);
- $sessionEditor->update(array(
+ $sessionEditor->update([
'userID' => $user->userID
- ));
+ ]);
}
break;
default:
if (!$this->supportsVirtualSessions) {
// delete all other sessions of this user
- call_user_func(array($this->sessionEditorClassName, 'deleteUserSessions'), array($user->userID));
+ call_user_func([$this->sessionEditorClassName, 'deleteUserSessions'], [$user->userID]);
}
// find existing session for this user
- $session = call_user_func(array($this->sessionClassName, 'getSessionByUserID'), $user->userID);
+ $session = call_user_func([$this->sessionClassName, 'getSessionByUserID'], $user->userID);
// no session exists, re-use current session
if ($session === null) {
try {
$this->register('__changeSessionID', true);
- $sessionEditor->update(array(
+ $sessionEditor->update([
'userID' => $user->userID
- ));
+ ]);
}
catch (DatabaseException $e) {
// MySQL error 23000 = unique key
if ($this->doNotUpdate) return;
// set up data
- $data = array(
+ $data = [
'ipAddress' => UserUtil::getIpAddress(),
'userAgent' => $this->userAgent,
'requestURI' => $this->requestURI,
'requestMethod' => $this->requestMethod,
'lastActivityTime' => TIME_NOW
- );
+ ];
if (!class_exists('wcf\system\CLIWCF', false) && PACKAGE_ID && RequestHandler::getInstance()->getActiveRequest() && RequestHandler::getInstance()->getActiveRequest()->getRequestObject() instanceof ITrackablePage && RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->isTracked()) {
$data['controller'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getController();
$data['parentObjectType'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getParentObjectType();
// update last activity time
/** @var \wcf\data\DatabaseObjectEditor $sessionEditor */
$sessionEditor = new $this->sessionEditorClassName($this->session);
- $sessionEditor->update(array(
+ $sessionEditor->update([
'lastActivityTime' => TIME_NOW
- ));
+ ]);
if ($this->virtualSession instanceof ACPSessionVirtual) {
if ($this->isACP) {
public function delete() {
// clear storage
if ($this->user->userID) {
- self::resetSessions(array($this->user->userID));
+ self::resetSessions([$this->user->userID]);
// update last activity time
if (!$this->isACP) {
$editor = new UserEditor($this->user);
- $editor->update(array('lastActivityTime' => TIME_NOW));
+ $editor->update(['lastActivityTime' => TIME_NOW]);
}
}
*
* @param integer[] $userIDs
*/
- public static function resetSessions(array $userIDs = array()) {
+ public static function resetSessions(array $userIDs = []) {
if (!empty($userIDs)) {
UserStorageHandler::getInstance()->reset($userIDs, 'groupIDs');
UserStorageHandler::getInstance()->reset($userIDs, 'languageIDs');
WHERE spiderID = ?
AND userID IS NULL";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($spiderID));
+ $statement->execute([$spiderID]);
$row = $statement->fetchArray();
if ($row !== false) {
// fix session validation
$tar = new Tar($this->source);
// distinct directories and files
- $directories = array();
- $files = array();
+ $directories = [];
+ $files = [];
foreach ($tar->getContentList() as $index => $file) {
if (empty($this->folder) || mb_strpos($file['filename'], $this->folder) === 0) {
if (!empty($this->folder)) {
$this->checkFiles($files);
// now create the directories
- $errors = array();
+ $errors = [];
foreach ($directories as $dir) {
try {
$this->createDir($dir);
protected function uninstall() {
if ($this->checkTargetDir()) {
// delete all files
- $directories = array();
+ $directories = [];
foreach ($this->files as $file) {
$this->deleteFile($this->targetDir.$file);
* @return Sitemap[]
*/
public function getTree() {
- $tree = array();
+ $tree = [];
if (!empty($this->cache)) {
foreach ($this->cache as $sitemap) {
AND comment_response.time BETWEEN ? AND ?
)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$date,
$date + 86399,
$objectTypeID,
$date,
$date + 86399
- ));
+ ]);
$counter = $statement->fetchColumn();
$sql = "SELECT (
AND comment_response.time < ?
)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$date + 86400,
$objectTypeID,
$date + 86400
- ));
+ ]);
$total = $statement->fetchColumn();
- return array(
+ return [
'counter' => $counter,
'total' => $total
- );
+ ];
}
}
FROM ".$tableName."
WHERE ".$dateColumnName." BETWEEN ? AND ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($date, $date + 86399));
+ $statement->execute([$date, $date + 86399]);
return $statement->fetchColumn();
}
FROM ".$tableName."
WHERE ".$dateColumnName." < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($date + 86400));
+ $statement->execute([$date + 86400]);
return $statement->fetchColumn();
}
FROM " . $tableName . "
WHERE " . $dateColumnName . " BETWEEN ? AND ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($date, $date + 86399));
+ $statement->execute([$date, $date + 86399]);
return $statement->fetchColumn();
}
FROM " . $tableName . "
WHERE " . $dateColumnName . " < ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($date + 86400));
+ $statement->execute([$date + 86400]);
return $statement->fetchColumn();
}
* @see \wcf\system\stat\IStatDailyHandler::getData()
*/
public function getData($date) {
- return array(
+ return [
'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_attachment', 'uploadTime'),
'total' => $this->getTotal($date, 'wcf'.WCF_N.'_attachment', 'uploadTime')
- );
+ ];
}
}
* @see \wcf\system\stat\IStatDailyHandler::getData()
*/
public function getData($date) {
- return array(
+ return [
'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_attachment', 'uploadTime'),
'total' => $this->getTotal($date, 'wcf'.WCF_N.'_attachment', 'uploadTime')
- );
+ ];
}
}
WHERE time BETWEEN ? AND ?
AND likeValue = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($date, $date + 86399, $this->likeValue));
+ $statement->execute([$date, $date + 86399, $this->likeValue]);
$counter = intval($statement->fetchColumn());
$sql = "SELECT COUNT(*)
WHERE time < ?
AND likeValue = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($date + 86400, $this->likeValue));
+ $statement->execute([$date + 86400, $this->likeValue]);
$total = intval($statement->fetchColumn());
- return array(
+ return [
'counter' => $counter,
'total' => $total
- );
+ ];
}
}
* @see \wcf\system\stat\IStatDailyHandler::getData()
*/
public function getData($date) {
- return array(
+ return [
'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_user', 'registrationDate'),
'total' => $this->getTotal($date, 'wcf'.WCF_N.'_user', 'registrationDate')
- );
+ ];
}
}
* style information cache
* @var array
*/
- protected $cache = array();
+ protected $cache = [];
/**
* active style object
* @return Style[]
*/
public function getAvailableStyles() {
- $styles = array();
+ $styles = [];
foreach ($this->cache['styles'] as $styleID => $style) {
if (!$style->isDisabled || WCF::getSession()->getPermission('admin.style.canUseDisabledStyle')) {
* list of tags
* @var TagCloudTag[]
*/
- protected $tags = array();
+ protected $tags = [];
/**
* max value of tag counter
* active language ids
* @var integer[]
*/
- protected $languageIDs = array();
+ protected $languageIDs = [];
/**
* Contructs a new TagCloud object.
*
* @param integer[] $languageIDs
*/
- public function __construct(array $languageIDs = array()) {
+ public function __construct(array $languageIDs = []) {
$this->languageIDs = $languageIDs;
if (empty($this->languageIDs)) {
$this->languageIDs = array_keys(LanguageFactory::getInstance()->getLanguages());
AND objectID = ?
AND languageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
$languageID
- ));
+ ]);
}
// get tag ids
- $tagIDs = array();
+ $tagIDs = [];
foreach ($tags as $tag) {
if (empty($tag)) continue;
$tagObj = Tag::getTag($tag, $languageID);
if ($tagObj === null) {
// create new tag
- $tagAction = new TagAction(array(), 'create', array('data' => array(
+ $tagAction = new TagAction([], 'create', ['data' => [
'name' => $tag,
'languageID' => $languageID
- )));
+ ]]);
$tagAction->executeAction();
$returnValues = $tagAction->getReturnValues();
WCF::getDB()->beginTransaction();
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($tagIDs as $tagID) {
- $statement->execute(array($objectID, $tagID, $objectTypeID, $languageID));
+ $statement->execute([$objectID, $tagID, $objectTypeID, $languageID]);
}
WCF::getDB()->commitTransaction();
}
AND objectID = ?
".($languageID !== null ? "AND languageID = ?" : "");
$statement = WCF::getDB()->prepareStatement($sql);
- $parameters = array(
+ $parameters = [
$objectTypeID,
$objectID
- );
+ ];
if ($languageID !== null) $parameters[] = $languageID;
$statement->execute($parameters);
}
$objectTypeID = $this->getObjectTypeID($objectType);
$conditionsBuilder = new PreparedStatementConditionBuilder();
- $conditionsBuilder->add('objectTypeID = ?', array($objectTypeID));
- $conditionsBuilder->add('objectID IN (?)', array($objectIDs));
+ $conditionsBuilder->add('objectTypeID = ?', [$objectTypeID]);
+ $conditionsBuilder->add('objectID IN (?)', [$objectIDs]);
$sql = "DELETE FROM wcf".WCF_N."_tag_to_object
".$conditionsBuilder;
* @param integer[] $languageIDs
* @return Tag[]
*/
- public function getObjectTags($objectType, $objectID, array $languageIDs = array()) {
- $tags = $this->getObjectsTags($objectType, array($objectID), $languageIDs);
+ public function getObjectTags($objectType, $objectID, array $languageIDs = []) {
+ $tags = $this->getObjectsTags($objectType, [$objectID], $languageIDs);
- return isset($tags[$objectID]) ? $tags[$objectID] : array();
+ return isset($tags[$objectID]) ? $tags[$objectID] : [];
}
/**
* @param integer[] $languageIDs
* @return array
*/
- public function getObjectsTags($objectType, array $objectIDs, array $languageIDs = array()) {
+ public function getObjectsTags($objectType, array $objectIDs, array $languageIDs = []) {
$objectTypeID = $this->getObjectTypeID($objectType);
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("tag_to_object.objectTypeID = ?", array($objectTypeID));
- $conditions->add("tag_to_object.objectID IN (?)", array($objectIDs));
+ $conditions->add("tag_to_object.objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("tag_to_object.objectID IN (?)", [$objectIDs]);
if (!empty($languageIDs)) {
foreach ($languageIDs as $index => $languageID) {
if (!$languageID) unset($languageIDs[$index]);
}
if (!empty($languageIDs)) {
- $conditions->add("tag_to_object.languageID IN (?)", array($languageIDs));
+ $conditions->add("tag_to_object.languageID IN (?)", [$languageIDs]);
}
}
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $tags = array();
+ $tags = [];
while ($tag = $statement->fetchObject('wcf\data\tag\Tag')) {
if (!isset($tags[$tag->objectID])) {
- $tags[$tag->objectID] = array();
+ $tags[$tag->objectID] = [];
}
$tags[$tag->objectID][$tag->tagID] = $tag;
}
* object type ids
* @var integer[]
*/
- protected $objectTypeIDs = array();
+ protected $objectTypeIDs = [];
/**
* Contructs a new TypedTagCloud object.
* @param string $objectType
* @param integer[] $languageIDs
*/
- public function __construct($objectType, array $languageIDs = array()) {
+ public function __construct($objectType, array $languageIDs = []) {
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.tagging.taggableObject', $objectType);
$this->objectTypeIDs[] = $objectTypeObj->objectTypeID;
* Loads the tag cloud cache.
*/
protected function loadCache() {
- $this->tags = TypedTagCloudCacheBuilder::getInstance()->getData(array(
+ $this->tags = TypedTagCloudCacheBuilder::getInstance()->getData([
'languageIDs' => $this->languageIDs,
'objectTypeIDs' => $this->objectTypeIDs
- ));
+ ]);
}
}
protected function init() {
parent::init();
- $this->templatePaths = array('wcf' => WCF_DIR.'acp/templates/');
+ $this->templatePaths = ['wcf' => WCF_DIR.'acp/templates/'];
$this->compileDir = WCF_DIR.'acp/templates/compiled/';
if (!defined('NO_IMPORTS')) {
* directories used as template source
* @var string[]
*/
- public $templatePaths = array();
+ public $templatePaths = [];
/**
* namespace containing template modifiers and plugins
* list of registered prefilters
* @var string[]
*/
- protected $prefilters = array();
+ protected $prefilters = [];
/**
* cached list of known template groups
* @var array
*/
- protected $templateGroupCache = array();
+ protected $templateGroupCache = [];
/**
* active template group id
* all available template variables and those assigned during runtime
* @var mixed[][]
*/
- protected $v = array();
+ protected $v = [];
/**
* all cached variables for usage after execution in sandbox
* @var mixed[][]
*/
- protected $sandboxVars = array();
+ protected $sandboxVars = [];
/**
* contains all templates with assigned template listeners.
* @var string[][][]
*/
- protected $templateListeners = array();
+ protected $templateListeners = [];
/**
* true, if template listener code was already loaded
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
- $this->templatePaths = array('wcf' => WCF_DIR.'templates/');
+ $this->templatePaths = ['wcf' => WCF_DIR.'templates/'];
$this->pluginNamespace = 'wcf\system\template\plugin\\';
$this->compileDir = WCF_DIR.'templates/compiled/';
* Assigns some system variables.
*/
protected function assignSystemVariables() {
- $this->v['tpl'] = array();
+ $this->v['tpl'] = [];
// assign super globals
$this->v['tpl']['get'] =& $_GET;
// system info
$this->v['tpl']['now'] = TIME_NOW;
$this->v['tpl']['template'] = '';
- $this->v['tpl']['includedTemplates'] = array();
+ $this->v['tpl']['includedTemplates'] = [];
// section / foreach / capture arrays
- $this->v['tpl']['section'] = $this->v['tpl']['foreach'] = $this->v['tpl']['capture'] = array();
+ $this->v['tpl']['section'] = $this->v['tpl']['foreach'] = $this->v['tpl']['capture'] = [];
}
/**
* during runtime as it could leed to an unexpected behaviour.
*/
public function clearAllAssign() {
- $this->v = array();
+ $this->v = [];
}
/**
// check if compilation is necessary
if (($metaData === null) || !$this->isCompiled($templateName, $sourceFilename, $compiledFilename, $application, $metaData)) {
// compile
- $this->compileTemplate($templateName, $sourceFilename, $compiledFilename, array(
+ $this->compileTemplate($templateName, $sourceFilename, $compiledFilename, [
'application' => $application,
'data' => $metaData,
'filename' => $metaDataFilename
- ));
+ ]);
}
// assign current package id
* @param boolean $sandbox enables execution in sandbox
* @return string
*/
- public function fetch($templateName, $application = 'wcf', array $variables = array(), $sandbox = false) {
+ public function fetch($templateName, $application = 'wcf', array $variables = [], $sandbox = false) {
// enable sandbox
if ($sandbox) {
$this->enableSandbox();
* @param boolean $sandbox enables execution in sandbox
* @return string
*/
- public function fetchString($compiledSource, array $variables = array(), $sandbox = true) {
+ public function fetchString($compiledSource, array $variables = [], $sandbox = true) {
// enable sandbox
if ($sandbox) {
$this->enableSandbox();
* @param array $variables
* @param boolean $sandbox enables execution in sandbox
*/
- protected function includeTemplate($templateName, $application, array $variables = array(), $sandbox = true) {
+ protected function includeTemplate($templateName, $application, array $variables = [], $sandbox = true) {
// enable sandbox
if ($sandbox) {
$this->enableSandbox();
*/
protected function loadTemplateListenerCode() {
if (!$this->templateListenersLoaded) {
- $this->templateListeners = TemplateListenerCodeCacheBuilder::getInstance()->getData(array('environment' => $this->environment));
+ $this->templateListeners = TemplateListenerCodeCacheBuilder::getInstance()->getData(['environment' => $this->environment]);
$this->templateListenersLoaded = true;
}
}
* to PHP's function_exists function
* @var string[]
*/
- protected $unknownPHPFunctions = array('isset', 'unset', 'empty');
+ protected $unknownPHPFunctions = ['isset', 'unset', 'empty'];
/**
* PHP functions that can not be used in the modifier syntax
* @var string[]
*/
- protected $disabledPHPFunctions = array(
+ protected $disabledPHPFunctions = [
'system', 'exec', 'passthru', 'shell_exec', // command line execution
'include', 'require', 'include_once', 'require_once', // includes
'eval', 'virtual', 'call_user_func_array', 'call_user_func', 'assert' // code execution
- );
+ ];
/**
* pattern to match variable operators like -> or .
* list of automatically loaded tenplate plugins
* @var string[]
*/
- protected $autoloadPlugins = array();
+ protected $autoloadPlugins = [];
/**
* stack with template tags data
* @var array
*/
- protected $tagStack = array();
+ protected $tagStack = [];
/**
* list of loaded compiler plugin objects
* @var ICompilerTemplatePlugin[]
*/
- protected $compilerPlugins = array();
+ protected $compilerPlugins = [];
/**
* stack used to compile the capture tag
* @var array
*/
- protected $captureStack = array();
+ protected $captureStack = [];
/**
* left delimiter of template syntax
* list of static includes per template
* @var string[]
*/
- protected $staticIncludes = array();
+ protected $staticIncludes = [];
/**
* Creates a new TemplateScriptingCompiler object.
* @return string
* @throws SystemException
*/
- public function compileString($identifier, $sourceContent, array $metaData = array(), $isolated = false) {
+ public function compileString($identifier, $sourceContent, array $metaData = [], $isolated = false) {
if ($isolated) {
- $previousData = array(
+ $previousData = [
'autoloadPlugins' => $this->autoloadPlugins,
'currentIdentifier' => $this->currentIdentifier,
'currentLineNo' => $this->currentLineNo,
'tagStack' => $this->tagStack
- );
+ ];
}
else {
- $this->staticIncludes = array();
+ $this->staticIncludes = [];
}
// reset vars
- $this->autoloadPlugins = $this->tagStack = array();
+ $this->autoloadPlugins = $this->tagStack = [];
$this->currentIdentifier = $identifier;
$this->currentLineNo = 1;
$sourceContent = $this->removeComments($sourceContent);
// match all template tags
- $matches = array();
+ $matches = [];
preg_match_all("~".$this->ldq."(.*?)".$this->rdq."~s", $sourceContent, $matches);
$templateTags = $matches[1];
$textBlocks = preg_split("~".$this->ldq.".*?".$this->rdq."~s", $sourceContent);
// compile the template tags into php-code
- $compiledTags = array();
+ $compiledTags = [];
for ($i = 0, $j = count($templateTags); $i < $j; $i++) {
$this->currentLineNo += mb_substr_count($textBlocks[$i], "\n");
$compiledTags[] = $this->compileTag($templateTags[$i], $identifier, $metaData);
$this->tagStack = $previousData['tagStack'];
}
- return array(
- 'meta' => array(
+ return [
+ 'meta' => [
'include' => $this->staticIncludes
- ),
+ ],
'template' => $compiledAutoloadPlugins.$compiledContent
- );
+ ];
}
/**
return $this->compileOutputTag($tag);
}
- $match = array();
+ $match = [];
// replace 'else if' with 'elseif'
$tag = preg_replace('~^else\s+if(?=\s)~i', 'elseif', $tag);
}
}
- $this->captureStack[] = array('name' => $args['name'], 'variable' => $args['assign'], 'append' => $append);
+ $this->captureStack[] = ['name' => $args['name'], 'variable' => $args['assign'], 'append' => $append];
return '<?php ob_start(); ?>';
}
else {
if ($staticInclude) {
$phpCode = '';
if (!isset($this->staticIncludes[$application])) {
- $this->staticIncludes[$application] = array();
+ $this->staticIncludes[$application] = [];
}
if (!in_array($templateName, $this->staticIncludes[$application])) {
}
// pass remaining tag args as variables
- $variables = array();
+ $variables = [];
if (!empty($args)) {
foreach ($args as $variable => $value) {
if (substr($value, 0, 1) == "'") {
$sourceFilename = $this->template->getSourceFilename($templateName, $application);
$metaDataFilename = $this->template->getMetaDataFilename($templateName);
- $data = $this->compileString($templateName, file_get_contents($sourceFilename), array(
+ $data = $this->compileString($templateName, file_get_contents($sourceFilename), [
'application' => $application,
'data' => null,
'filename' => ''
- ), true);
+ ], true);
return $phpCode . $data['template'];
}
}
// parse tag arguments
- $matches = array();
+ $matches = [];
// find all variables
preg_match_all('~\s+(\w+)\s*=\s*([^=]*)(?=\s|$)~s', $tagArgs, $matches);
- $args = array();
+ $args = [];
for ($i = 0, $j = count($matches[1]); $i < $j; $i++) {
$name = $matches[1][$i];
$string = $this->compileVariableTag($matches[2][$i], false);
*/
protected function compileIfTag($tagArgs, $elseif = false) {
$tagArgs = $this->replaceQuotes($tagArgs);
- $tagArgs = str_replace(array(' ', "\n"), '', $tagArgs);
+ $tagArgs = str_replace([' ', "\n"], '', $tagArgs);
// split tags
preg_match_all('~('.$this->conditionOperatorPattern.')~', $tagArgs, $matches);
* @param string $tag
*/
public function pushTag($tag) {
- $this->tagStack[] = array($tag, $this->currentLineNo);
+ $this->tagStack[] = [$tag, $this->currentLineNo];
}
/**
$values = preg_split('~(?:'.$this->variableOperatorPattern.')~', $compiledTag);
// parse tags
- $statusStack = array(0 => 'start');
+ $statusStack = [0 => 'start'];
$result = '';
$modifierData = null;
for ($i = 0, $j = count($values); $i < $j; $i++) {
}
}
- $statusStack = array(0 => 'modifier');
- $modifierData = array('name' => '', 'parameter' => array(0 => $result));
+ $statusStack = [0 => 'modifier'];
+ $modifierData = ['name' => '', 'parameter' => [0 => $result]];
$result = '';
break;
* @return string
*/
public function replaceLiterals($string) {
- return preg_replace_callback("~".$this->ldq."literal".$this->rdq."(.*?)".$this->ldq."/literal".$this->rdq."~s", array($this, 'replaceLiteralsCallback'), $string);
+ return preg_replace_callback("~".$this->ldq."literal".$this->rdq."(.*?)".$this->ldq."/literal".$this->rdq."~s", [$this, 'replaceLiteralsCallback'], $string);
}
/**
* @return string
*/
public function replaceQuotes($string) {
- $string = preg_replace_callback('~\'([^\'\\\\]+|\\\\.)*\'~', array($this, 'replaceSingleQuotesCallback'), $string);
- $string = preg_replace_callback('~"([^"\\\\]+|\\\\.)*"~', array($this, 'replaceDoubleQuotesCallback'), $string);
+ $string = preg_replace_callback('~\'([^\'\\\\]+|\\\\.)*\'~', [$this, 'replaceSingleQuotesCallback'], $string);
+ $string = preg_replace_callback('~"([^"\\\\]+|\\\\.)*"~', [$this, 'replaceDoubleQuotesCallback'], $string);
return $string;
}
* @return string
*/
public function replaceConstants($string) {
- return preg_replace_callback('~(?<=^|'.$this->variableOperatorPattern.')(?i)((?:\-?\d+(?:\.\d+)?)|true|false|null)(?=$|'.$this->variableOperatorPattern.')~', array($this, 'replaceConstantsCallback'), $string);
+ return preg_replace_callback('~(?<=^|'.$this->variableOperatorPattern.')(?i)((?:\-?\d+(?:\.\d+)?)|true|false|null)(?=$|'.$this->variableOperatorPattern.')~', [$this, 'replaceConstantsCallback'], $string);
}
/**
* counter data
* @var array
*/
- protected $counters = array();
+ protected $counters = [];
/**
* @see \wcf\system\template\IFunctionTemplatePlugin::execute()
}
if (!isset($this->counters[$tagArgs['name']])) {
- $this->counters[$tagArgs['name']] = array(
+ $this->counters[$tagArgs['name']] = [
'skip' => isset($tagArgs['skip']) ? $tagArgs['skip'] : 1,
'direction' => isset($tagArgs['direction']) ? $tagArgs['direction'] : 'up',
'assign' => (isset($tagArgs['assign']) && !empty($tagArgs['assign'])) ? $tagArgs['assign'] : null,
'print' => isset($tagArgs['print']) ? $tagArgs['print'] : false,
'count' => isset($tagArgs['start']) ? $tagArgs['start'] : 1
- );
+ ];
}
$counter =& $this->counters[$tagArgs['name']];
* cycle data
* @var array
*/
- protected $cycles = array();
+ protected $cycles = [];
/**
* @see \wcf\system\template\IFunctionTemplatePlugin::execute()
$ldq = preg_quote($compiler->getLeftDelimiter(), '~');
$rdq = preg_quote($compiler->getRightDelimiter(), '~');
- $sourceContent = preg_replace_callback("~{$ldq}hascontent( assign='(?P<assign>.*)')?{$rdq}(?P<before>.*){$ldq}content{$rdq}(?P<content>.*){$ldq}\/content{$rdq}(?P<after>.*)({$ldq}hascontentelse{$rdq}(?P<else>.*))?{$ldq}\/hascontent{$rdq}~sU", array('self', 'replaceContentCallback'), $sourceContent);
+ $sourceContent = preg_replace_callback("~{$ldq}hascontent( assign='(?P<assign>.*)')?{$rdq}(?P<before>.*){$ldq}content{$rdq}(?P<content>.*){$ldq}\/content{$rdq}(?P<after>.*)({$ldq}hascontentelse{$rdq}(?P<else>.*))?{$ldq}\/hascontent{$rdq}~sU", ['self', 'replaceContentCallback'], $sourceContent);
return $sourceContent;
}
// get selected values
if (isset($tagArgs['selected'])) {
- if (!is_array($tagArgs['selected'])) $tagArgs['selected'] = array($tagArgs['selected']);
+ if (!is_array($tagArgs['selected'])) $tagArgs['selected'] = [$tagArgs['selected']];
}
else {
- $tagArgs['selected'] = array();
+ $tagArgs['selected'] = [];
}
if (!isset($tagArgs['separator'])) {
$tagArgs['separator'] = '';
* selected values
* @var string[]
*/
- protected $selected = array();
+ protected $selected = [];
/**
* @see \wcf\system\template\IFunctionTemplatePlugin::execute()
$tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']);
}
else {
- $tagArgs['options'] = array();
+ $tagArgs['options'] = [];
}
}
else {
}
}
else {
- $tagArgs['options'] = array();
+ $tagArgs['options'] = [];
}
}
}
// get selected values
- $this->selected = array();
+ $this->selected = [];
if (isset($tagArgs['selected'])) {
$this->selected = $tagArgs['selected'];
- if (!is_array($this->selected)) $this->selected = array($this->selected);
+ if (!is_array($this->selected)) $this->selected = [$this->selected];
}
// create option list
* local tag stack
* @var string[]
*/
- protected $tagStack = array();
+ protected $tagStack = [];
/**
* @see \wcf\system\template\ICompilerTemplatePlugin::executeStart()
$hash = StringUtil::getRandomID();
$glue = isset($tagArgs['glue']) ? $tagArgs['glue'] : "', '";
- $this->tagStack[] = array('hash' => $hash, 'glue' => $glue);
+ $this->tagStack[] = ['hash' => $hash, 'glue' => $glue];
$phpCode = "<?php\n";
$phpCode .= "\$_length".$hash." = count(".$tagArgs['from'].");\n";
* allowed file extensions
* @var string[]
*/
- protected $fileExtensions = array();
+ protected $fileExtensions = [];
/**
* regex for validation of allowed file extension
public function getImageData() {
if (strpos($this->getMimeType(), 'image/') == 0) {
if (($imageData = @getimagesize($this->getLocation())) !== false) {
- return array(
+ return [
'width' => $imageData[0],
'height' => $imageData[1],
'mimeType' => $imageData['mime'],
- );
+ ];
}
}
* list of uploaded files
* @var UploadFile[]
*/
- protected $files = array();
+ protected $files = [];
/**
* list of validation errors.
* @var array
*/
- protected $erroneousFiles = array();
+ protected $erroneousFiles = [];
/**
* Creates a new UploadHandler object.
protected function __construct(array $rawFileData) {
if (is_array($rawFileData['name'])) {
// iOS work-around
- $newRawFileData = array(
- 'name' => array(),
- 'type' => array(),
- 'tmp_name' => array(),
- 'error' => array(),
- 'size' => array()
- );
+ $newRawFileData = [
+ 'name' => [],
+ 'type' => [],
+ 'tmp_name' => [],
+ 'error' => [],
+ 'size' => []
+ ];
$i = 0;
foreach (array_keys($rawFileData['name']) as $internalFileID) {
$newRawFileData['name'][$i] = '__wcf_' . $internalFileID . '_' . $rawFileData['name'][$internalFileID]; // __wcf_X_filename.ext
* list of user profiles shared across all instances of GroupedUserList
* @var UserProfile[]
*/
- protected static $users = array();
+ protected static $users = [];
/**
* group name
* list of user ids assigned for this group
* @var integer[]
*/
- protected $userIDs = array();
+ protected $userIDs = [];
/**
* Creates a new grouped list of users.
* Loads user profiles for outstanding user ids.
*/
public static function loadUsers() {
- $userIDs = array();
+ $userIDs = [];
foreach (self::$users as $userID => $user) {
if ($user === null) {
$userIDs[] = $userID;
* loaded months
* @var integer[]
*/
- protected $monthsLoaded = array();
+ protected $monthsLoaded = [];
/**
* user birthdays
* @var integer[]
*/
- protected $birthdays = array();
+ protected $birthdays = [];
/**
* Loads the birthday cache.
*/
protected function loadMonth($month) {
if (!isset($this->monthsLoaded[$month])) {
- $this->birthdays = array_merge($this->birthdays, UserBirthdayCacheBuilder::getInstance()->getData(array('month' => $month)));
+ $this->birthdays = array_merge($this->birthdays, UserBirthdayCacheBuilder::getInstance()->getData(['month' => $month]));
$this->monthsLoaded[$month] = true;
}
}
$index = ($month < 10 ? '0' : '') . $month . '-' . ($day < 10 ? '0' : '') . $day;
if (isset($this->birthdays[$index])) return $this->birthdays[$index];
- return array();
+ return [];
}
}
* @see \wcf\system\user\activity\event\IUserActivityEvent::prepare()
*/
public function prepare(array $events) {
- $objectIDs = array();
+ $objectIDs = [];
foreach ($events as $event) {
$objectIDs[] = $event->objectID;
}
if (isset($users[$event->objectID])) {
$event->setIsAccessible();
- $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.follow', array('user' => $users[$event->objectID]));
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.follow', ['user' => $users[$event->objectID]]);
$event->setTitle($text);
}
else {
return;
}
- $commentIDs = array();
+ $commentIDs = [];
foreach ($events as $event) {
$commentIDs[] = $event->objectID;
}
$comments = $commentList->getObjects();
// fetch users
- $userIDs = $users = array();
+ $userIDs = $users = [];
foreach ($comments as $comment) {
$userIDs[] = $comment->objectID;
}
$event->setIsAccessible();
$user = $users[$comment->objectID];
- $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileComment', array('user' => $user));
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileComment', ['user' => $user]);
$event->setTitle($text);
// output
* cached object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
* @return \wcf\data\user\activity\event\UserActivityEvent
* @throws SystemException
*/
- public function fireEvent($objectType, $objectID, $languageID = null, $userID = null, $time = TIME_NOW, $additionalData = array()) {
+ public function fireEvent($objectType, $objectID, $languageID = null, $userID = null, $time = TIME_NOW, $additionalData = []) {
$objectTypeID = $this->getObjectTypeID($objectType);
if ($objectTypeID === null) {
throw new SystemException("Unknown recent activity event '".$objectType."'");
if ($userID === null) $userID = WCF::getUser()->userID;
- $eventAction = new UserActivityEventAction(array(), 'create', array(
- 'data' => array(
+ $eventAction = new UserActivityEventAction([], 'create', [
+ 'data' => [
'objectTypeID' => $objectTypeID,
'objectID' => $objectID,
'languageID' => $languageID,
'userID' => $userID,
'time' => $time,
'additionalData' => serialize($additionalData)
- )
- ));
+ ]
+ ]);
$returnValues = $eventAction->executeAction();
return $returnValues['returnValues'];
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("objectTypeID = ?", array($objectTypeID));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("objectTypeID = ?", [$objectTypeID]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "DELETE FROM wcf".WCF_N."_user_activity_event
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($eventIDs as $eventID) {
- $statement->execute(array($eventID));
+ $statement->execute([$eventID]);
}
}
}
* list of user activity point object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* maps the user activity point object type ids to their object type names
* @var string[]
*/
- protected $objectTypeNames = array();
+ protected $objectTypeNames = [];
/**
* @see \wcf\system\SingletonFactory::init()
* @param mixed[] $additionalData
* @throws SystemException
*/
- public function fireEvent($objectType, $objectID, $userID = null, array $additionalData = array()) {
+ public function fireEvent($objectType, $objectID, $userID = null, array $additionalData = []) {
$objectTypeObj = $this->getObjectTypeByName($objectType);
if ($objectTypeObj === null) {
throw new SystemException("Object type '".$objectType."' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'");
UPDATE activityPoints = activityPoints + VALUES(activityPoints),
items = items + 1";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$userID,
$objectTypeObj->objectTypeID,
$objectTypeObj->points
- ));
+ ]);
$sql = "UPDATE wcf".WCF_N."_user
SET activityPoints = activityPoints + ?
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeObj->points,
$userID
- ));
+ ]);
// update user ranks
- $this->updateUserRanks(array($userID));
+ $this->updateUserRanks([$userID]);
// check if the user will be automatically added to new user groups
// because of the new activity points
- UserGroupAssignmentHandler::getInstance()->checkUsers(array($userID));
+ UserGroupAssignmentHandler::getInstance()->checkUsers([$userID]);
}
/**
// update user_activity_point
$values = '';
- $parameters = $userIDs = array();
+ $parameters = $userIDs = [];
foreach ($itemsToUser as $userID => $items) {
if (!empty($values)) $values .= ',';
$values .= '(?, ?, ?, ?)';
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($userToItems as $userID => $items) {
- $statement->execute(array(
+ $statement->execute([
($items * $objectTypeObj->points),
$items,
$objectTypeObj->objectTypeID,
$userID
- ));
+ ]);
}
// update total activity points per user
public function updateUsers(array $userIDs) {
$userIDs = array_unique($userIDs);
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($userIDs));
+ $conditions->add("userID IN (?)", [$userIDs]);
$sql = "UPDATE wcf".WCF_N."_user user_table
SET activityPoints = COALESCE((
items = 0
WHERE objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($objectTypeObj->objectTypeID));
+ $statement->execute([$objectTypeObj->objectTypeID]);
}
/**
throw new SystemException("'" . $this->className . "' does not implement 'wcf\system\user\authentication\IUserAuthentication'");
}
- $this->userAuthentication = call_user_func(array($this->className, 'getInstance'));
+ $this->userAuthentication = call_user_func([$this->className, 'getInstance']);
}
/**
* list of collapsed object ids per object type id
* @var integer[][]
*/
- protected $collapsedContent = array();
+ protected $collapsedContent = [];
/**
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
- $this->cache = array(
- 'objectTypes' => array(),
- 'objectTypeIDs' => array()
- );
+ $this->cache = [
+ 'objectTypes' => [],
+ 'objectTypeIDs' => []
+ ];
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.collapsibleContent');
foreach ($objectTypes as $objectType) {
*/
public function getCollapsedContent($objectTypeID) {
if (!isset($this->collapsedContent[$objectTypeID])) {
- $this->collapsedContent[$objectTypeID] = array();
+ $this->collapsedContent[$objectTypeID] = [];
if (WCF::getUser()->userID) {
$data = UserStorageHandler::getInstance()->getField('collapsedContent-'.$objectTypeID);
WHERE objectTypeID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
WCF::getUser()->userID
- ));
+ ]);
$this->collapsedContent[$objectTypeID] = $statement->fetchAll(\PDO::FETCH_COLUMN);
// update storage data
AND objectID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
WCF::getUser()->userID
- ));
+ ]);
$row = $statement->fetchArray();
if (!$row) {
(objectTypeID, objectID, userID)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
WCF::getUser()->userID
- ));
+ ]);
}
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID);
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'collapsedContent-'.$objectTypeID);
}
else {
$collapsedContent = WCF::getSession()->getVar('collapsedContent');
if ($collapsedContent === null || !is_array($collapsedContent)) {
- $collapsedContent = array();
+ $collapsedContent = [];
}
if (!in_array($objectID, $collapsedContent)) {
- $collapsedContent[$objectTypeID] = array();
+ $collapsedContent[$objectTypeID] = [];
}
$collapsedContent[$objectTypeID][] = $objectID;
AND objectID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
WCF::getUser()->userID
- ));
+ ]);
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID);
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'collapsedContent-'.$objectTypeID);
}
else {
$collapsedContent = WCF::getSession()->getVar('collapsedContent');
if ($collapsedContent === null || !is_array($collapsedContent)) {
- $collapsedContent = array();
+ $collapsedContent = [];
}
if (isset($collapsedContent[$objectTypeID])) {
WHERE objectTypeID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
WCF::getUser()->userID
- ));
+ ]);
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID);
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'collapsedContent-'.$objectTypeID);
}
else {
$collapsedContent = WCF::getSession()->getVar('collapsedContent');
if ($collapsedContent === null || !is_array($collapsedContent)) {
- $collapsedContent = array();
+ $collapsedContent = [];
}
if (isset($collapsedContent[$objectTypeID])) {
}
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('objectTypeID = ?', array($objectTypeID));
+ $conditionBuilder->add('objectTypeID = ?', [$objectTypeID]);
if ($objectID) {
- $conditionBuilder->add('objectID = ?', array($objectID));
+ $conditionBuilder->add('objectID = ?', [$objectID]);
}
$sql = "DELETE FROM wcf".WCF_N."_user_collapsible_content
* list of methods allowed for remote invoke
* @var string[]
*/
- public static $allowInvoke = array('toggle');
+ public static $allowInvoke = ['toggle'];
/**
* Toggles a sidebar.
* list of grouped user group assignment condition object types
* @var array
*/
- protected $groupedObjectTypes = array();
+ protected $groupedObjectTypes = [];
/**
* Checks if the users with the given ids should be assigned to new user
$assignments = UserGroupAssignmentCacheBuilder::getInstance()->getData();
foreach ($userList as $user) {
$groupIDs = $user->getGroupIDs();
- $newGroupIDs = array();
+ $newGroupIDs = [];
foreach ($assignments as $assignment) {
if (in_array($assignment->groupID, $groupIDs) || in_array($assignment->groupID, $newGroupIDs)) {
}
if (!empty($newGroupIDs)) {
- $userAction = new UserAction(array($user), 'addToGroups', array(
+ $userAction = new UserAction([$user], 'addToGroups', [
'addDefaultGroups' => false,
'deleteOldGroups' => false,
'groups' => $newGroupIDs
- ));
+ ]);
$userAction->executeAction();
}
}
*/
public function getUsers(UserGroupAssignment $assignment) {
$userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID NOT IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID = ?)', array(
+ $userList->getConditionBuilder()->add('user_table.userID NOT IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID = ?)', [
$assignment->groupID
- ));
+ ]);
$conditions = $assignment->getConditions();
foreach ($conditions as $condition) {
if (!$objectType->conditiongroup) continue;
if (!isset($this->groupedObjectTypes[$objectType->conditiongroup])) {
- $this->groupedObjectTypes[$objectType->conditiongroup] = array();
+ $this->groupedObjectTypes[$objectType->conditiongroup] = [];
}
$this->groupedObjectTypes[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
* list of available object types
* @var array
*/
- protected $availableObjectTypes = array();
+ protected $availableObjectTypes = [];
/**
* list of available events
* @var array
*/
- protected $availableEvents = array();
+ protected $availableEvents = [];
/**
* number of outstanding notifications
* list of object types
* @var ObjectType[]
*/
- protected $objectTypes = array();
+ protected $objectTypes = [];
/**
* @see \wcf\system\SingletonFactory::init()
* @param integer $baseObjectID
* @throws SystemException
*/
- public function fireEvent($eventName, $objectType, IUserNotificationObject $notificationObject, array $recipientIDs, array $additionalData = array(), $baseObjectID = 0) {
+ public function fireEvent($eventName, $objectType, IUserNotificationObject $notificationObject, array $recipientIDs, array $additionalData = [], $baseObjectID = 0) {
// check given object type and event name
if (!isset($this->availableEvents[$objectType][$eventName])) {
throw new SystemException("Unknown event ".$objectType."-".$eventName." given");
}
}
if ($userProfile === null) {
- $userProfile = new UserProfile(new User(null, array()));
+ $userProfile = new UserProfile(new User(null, []));
}
// set object data
- $event->setObject(new UserNotification(null, array()), $notificationObject, $userProfile, $additionalData);
+ $event->setObject(new UserNotification(null, []), $notificationObject, $userProfile, $additionalData);
- $parameters = array(
+ $parameters = [
'eventName' => $eventName,
'objectType' => $objectType,
'notificationObject' => $notificationObject,
'objectTypeObject' => $objectTypeObject,
'userProfile' => $userProfile,
'event' => $event
- );
+ ];
EventHandler::getInstance()->fireAction($this, 'fireEvent', $parameters);
// find existing notifications
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($recipientIDs));
- $conditions->add("eventID = ?", array($event->eventID));
- $conditions->add("eventHash = ?", array($event->getEventHash()));
- $conditions->add("confirmTime = ?", array(0));
+ $conditions->add("userID IN (?)", [$recipientIDs]);
+ $conditions->add("eventID = ?", [$event->eventID]);
+ $conditions->add("eventHash = ?", [$event->getEventHash()]);
+ $conditions->add("confirmTime = ?", [0]);
$sql = "SELECT notificationID, userID
FROM wcf".WCF_N."_user_notification
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $notifications = array();
+ $notifications = [];
while ($row = $statement->fetchArray()) {
$notifications[$row['userID']] = $row['notificationID'];
}
// check if event supports stacking and author should be added
if (!empty($notifications) && $event->isStackable()) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("notificationID IN (?)", array(array_values($notifications)));
+ $conditions->add("notificationID IN (?)", [array_values($notifications)]);
if ($notificationObject->getAuthorID()) {
- $conditions->add("authorID = ?", array($notificationObject->getAuthorID()));
+ $conditions->add("authorID = ?", [$notificationObject->getAuthorID()]);
}
else {
$conditions->add("authorID IS NULL");
WCF::getDB()->beginTransaction();
foreach ($notificationIDs as $notificationID) {
- $statement->execute(array(
+ $statement->execute([
1,
$notificationObject->getAuthorID() ? 0 : 1,
$notificationID
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
// get recipients
$recipientList = new UserNotificationEventRecipientList();
- $recipientList->getConditionBuilder()->add('event_to_user.eventID = ?', array($event->eventID));
- $recipientList->getConditionBuilder()->add('event_to_user.userID IN (?)', array($recipientIDs));
+ $recipientList->getConditionBuilder()->add('event_to_user.eventID = ?', [$event->eventID]);
+ $recipientList->getConditionBuilder()->add('event_to_user.userID IN (?)', [$recipientIDs]);
$recipientList->readObjects();
$recipients = $recipientList->getObjects();
if (!empty($recipients)) {
- $data = array(
+ $data = [
'authorID' => ($event->getAuthorID() ?: null),
- 'data' => array(
+ 'data' => [
'eventID' => $event->eventID,
'authorID' => ($event->getAuthorID() ?: null),
'objectID' => $notificationObject->getObjectID(),
'mailNotified' => ($event->supportsEmailNotification() ? 0 : 1),
'time' => TIME_NOW,
'additionalData' => serialize($additionalData)
- ),
+ ],
'recipients' => $recipients
- );
+ ];
if ($event->isStackable()) {
$data['notifications'] = $notifications;
- $action = new UserNotificationAction(array(), 'createStackable', $data);
+ $action = new UserNotificationAction([], 'createStackable', $data);
}
else {
$data['data']['timesTriggered'] = 1;
- $action = new UserNotificationAction(array(), 'createDefault', $data);
+ $action = new UserNotificationAction([], 'createDefault', $data);
}
$result = $action->executeAction();
WHERE userID = ?
AND confirmTime = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
WCF::getUser()->userID,
0
- ));
+ ]);
$this->notificationCount = $statement->fetchSingleColumn();
FROM wcf".WCF_N."_user_notification
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(WCF::getUser()->userID));
+ $statement->execute([WCF::getUser()->userID]);
return $statement->fetchSingleColumn();
}
public function getMixedNotifications() {
$notificationCount = $this->getNotificationCount(true);
- $notifications = array();
+ $notifications = [];
if ($notificationCount > 0) {
$notifications = $this->fetchNotifications(5, 0, 0);
}
protected function fetchNotifications($limit, $offset, $filterByConfirmed = null) {
// build enormous query
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("notification.userID = ?", array(WCF::getUser()->userID));
+ $conditions->add("notification.userID = ?", [WCF::getUser()->userID]);
if ($filterByConfirmed !== null) {
// consider only unconfirmed notifications
if ($filterByConfirmed == 0) {
- $conditions->add("notification.confirmTime = ?", array(0));
+ $conditions->add("notification.confirmTime = ?", [0]);
}
else {
// consider only notifications marked as confirmed in the past 48 hours (86400 = 1 day)
- $conditions->add("notification.confirmTime >= ?", array(TIME_NOW - (2 * 86400)));
+ $conditions->add("notification.confirmTime >= ?", [TIME_NOW - (2 * 86400)]);
}
}
$statement = WCF::getDB()->prepareStatement($sql, $limit, $offset);
$statement->execute($conditions->getParameters());
- $notifications = array();
+ $notifications = [];
while ($notification = $statement->fetchObject('\wcf\data\user\notification\UserNotification')) {
$notifications[$notification->notificationID] = $notification;
}
public function processNotifications(array $notificationObjects) {
// return an empty set if no notifications exist
if (empty($notificationObjects)) {
- return array(
+ return [
'count' => 0,
- 'notifications' => array()
- );
+ 'notifications' => []
+ ];
}
- $eventIDs = $notificationIDs = $objectTypes = array();
+ $eventIDs = $notificationIDs = $objectTypes = [];
foreach ($notificationObjects as $notification) {
// cache object types
if (!isset($objectTypes[$notification->objectType])) {
- $objectTypes[$notification->objectType] = array(
+ $objectTypes[$notification->objectType] = [
'objectType' => $this->availableObjectTypes[$notification->objectType],
- 'objectIDs' => array(),
- 'objects' => array()
- );
+ 'objectIDs' => [],
+ 'objects' => []
+ ];
}
$objectTypes[$notification->objectType]['objectIDs'][] = $notification->objectID;
// load authors
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("notificationID IN (?)", array($notificationIDs));
+ $conditions->add("notificationID IN (?)", [$notificationIDs]);
$sql = "SELECT notificationID, authorID
FROM wcf".WCF_N."_user_notification_author
".$conditions."
ORDER BY time ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $authorIDs = $authorToNotification = array();
+ $authorIDs = $authorToNotification = [];
while ($row = $statement->fetchArray()) {
if ($row['authorID']) {
$authorIDs[] = $row['authorID'];
}
if (!isset($authorToNotification[$row['notificationID']])) {
- $authorToNotification[$row['notificationID']] = array();
+ $authorToNotification[$row['notificationID']] = [];
}
$authorToNotification[$row['notificationID']][] = $row['authorID'];
// load authors
$authors = UserProfile::getUserProfiles($authorIDs);
- $unknownAuthor = new UserProfile(new User(null, array('userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest'))));
+ $unknownAuthor = new UserProfile(new User(null, ['userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest')]));
// load objects associated with each object type
foreach ($objectTypes as $objectType => $objectData) {
// load required events
$eventList = new UserNotificationEventList();
- $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", array($eventIDs));
+ $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", [$eventIDs]);
$eventList->readObjects();
$eventObjects = $eventList->getObjects();
// build notification data
- $notifications = array();
- $deleteNotifications = array();
+ $notifications = [];
+ $deleteNotifications = [];
foreach ($notificationObjects as $notification) {
$object = $objectTypes[$notification->objectType]['objects'][$notification->objectID];
if ($object->__unknownNotificationObject) {
);
if (isset($authorToNotification[$notification->notificationID])) {
- $eventAuthors = array();
+ $eventAuthors = [];
foreach ($authorToNotification[$notification->notificationID] as $userID) {
if (!$userID) {
$eventAuthors[0] = $unknownAuthor;
}
}
- $data = array(
+ $data = [
'authors' => count($class->getAuthors()),
'event' => $class,
'notificationID' => $notification->notificationID,
'time' => $notification->time
- );
+ ];
$data['confirmed'] = ($notification->confirmTime > 0);
$notificationAction->executeAction();
// reset notification counter
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'userNotificationCount');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'userNotificationCount');
}
- return array(
+ return [
'count' => count($notifications),
'notifications' => $notifications
- );
+ ];
}
/**
* @return IUserNotificationEvent[]
*/
public function getEvents($objectType) {
- if (!isset($this->availableEvents[$objectType])) return array();
+ if (!isset($this->availableEvents[$objectType])) return [];
return $this->availableEvents[$objectType];
}
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("eventID = ?", array($eventID));
- $conditions->add("objectID = ?", array($objectID));
- if ($authorID !== null) $conditions->add("authorID = ?", array($authorID));
- if ($time !== null) $conditions->add("time = ?", array($time));
+ $conditions->add("eventID = ?", [$eventID]);
+ $conditions->add("objectID = ?", [$objectID]);
+ if ($authorID !== null) $conditions->add("authorID = ?", [$authorID]);
+ if ($time !== null) $conditions->add("time = ?", [$time]);
$sql = "SELECT notificationID
FROM wcf".WCF_N."_user_notification
$event->setLanguage($user->getLanguage());
// add mail header
- $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', array(
+ $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', [
'user' => $user
- ))."\n\n";
+ ])."\n\n";
// get message
$message .= $event->getEmailMessage();
$token = $user->notificationMailToken;
if (!$token) {
// generate token if not present
- $token = mb_substr(StringUtil::getHash(serialize(array($user->userID, StringUtil::getRandomID()))), 0, 20);
+ $token = mb_substr(StringUtil::getHash(serialize([$user->userID, StringUtil::getRandomID()])), 0, 20);
$editor = new UserEditor($user);
- $editor->update(array('notificationMailToken' => $token));
+ $editor->update(['notificationMailToken' => $token]);
}
- $message .= "\n\n".$user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.footer', array(
+ $message .= "\n\n".$user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.footer', [
'user' => $user,
'token' => $token,
'notification' => $notification
- ));
+ ]);
// build mail
- $mail = new Mail(array($user->username => $user->email), $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.subject', array('title' => $event->getEmailTitle())), $message);
+ $mail = new Mail([$user->username => $user->email], $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.subject', ['title' => $event->getEmailTitle()]), $message);
$mail->setLanguage($user->getLanguage());
$mail->send();
}
* @param integer[] $recipientIDs
* @param integer[] $objectIDs
*/
- public function deleteNotifications($eventName, $objectType, array $recipientIDs, array $objectIDs = array()) {
+ public function deleteNotifications($eventName, $objectType, array $recipientIDs, array $objectIDs = []) {
$this->markAsConfirmed($eventName, $objectType, $recipientIDs, $objectIDs);
}
FROM wcf".WCF_N."_user_notification_event
WHERE objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectTypeObj->objectTypeID
- ));
+ ]);
$eventIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
if (!empty($eventIDs)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("eventID IN (?)", array($eventIDs));
- $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("eventID IN (?)", [$eventIDs]);
+ $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "SELECT userID
FROM wcf".WCF_N."_user_notification
* @param integer[] $objectIDs
* @throws SystemException
*/
- public function markAsConfirmed($eventName, $objectType, array $recipientIDs, array $objectIDs = array()) {
+ public function markAsConfirmed($eventName, $objectType, array $recipientIDs, array $objectIDs = []) {
// check given object type and event name
if (!isset($this->availableEvents[$objectType][$eventName])) {
throw new SystemException("Unknown event ".$objectType."-".$eventName." given");
// mark as confirmed
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("eventID = ?", array($event->eventID));
- if (!empty($recipientIDs)) $conditions->add("userID IN (?)", array($recipientIDs));
- if (!empty($objectIDs)) $conditions->add("objectID IN (?)", array($objectIDs));
+ $conditions->add("eventID = ?", [$event->eventID]);
+ if (!empty($recipientIDs)) $conditions->add("userID IN (?)", [$recipientIDs]);
+ if (!empty($objectIDs)) $conditions->add("objectID IN (?)", [$objectIDs]);
$sql = "UPDATE wcf".WCF_N."_user_notification
SET confirmTime = ?
WHERE confirmTime = ?
)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(0));
+ $statement->execute([0]);
// reset storage
if (!empty($recipientIDs)) {
* @param integer $notificationID
*/
public function markAsConfirmedByID($notificationID) {
- $this->markAsConfirmedByIDs(array($notificationID));
+ $this->markAsConfirmedByIDs([$notificationID]);
}
/**
}
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("notificationID IN (?)", array($notificationIDs));
+ $conditions->add("notificationID IN (?)", [$notificationIDs]);
// mark notifications as confirmed
$sql = "UPDATE wcf".WCF_N."_user_notification
$statement->execute($conditions->getParameters());
// reset user storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'userNotificationCount');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'userNotificationCount');
}
/**
WHERE eventID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($event->eventID, WCF::getUser()->userID));
+ $statement->execute([$event->eventID, WCF::getUser()->userID]);
$row = $statement->fetchArray();
if ($row === false) return false;
return $row['mailNotificationType'];
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::setObject()
*/
- public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = array()) {
+ public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []) {
parent::setObject($notification, $object, $author, $additionalData);
$this->prepare();
* @param \wcf\data\user\UserProfile $author
* @param mixed[] $additionalData
*/
- public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = array());
+ public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []);
/**
* Sets the language for the event
public function getTitle() {
$count = count($this->getAuthors());
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.title.stacked', array('count' => $count));
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.title.stacked', ['count' => $count]);
}
return $this->getLanguage()->get('wcf.user.notification.follow.title');
$count = count($authors);
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.message.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.message.stacked', [
'author' => $this->author,
'authors' => $authors,
'count' => $count,
'others' => $count - 1
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.message', array('author' => $this->author));
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.message', ['author' => $this->author]);
}
/**
$count = count($authors);
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.mail.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.mail.stacked', [
'author' => $this->author,
'authors' => $authors,
'count' => $count,
'others' => $count - 1,
'notificationType' => $notificationType
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.mail', array('author' => $this->author));
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.mail', ['author' => $this->author]);
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
*/
public function getLink() {
- return LinkHandler::getInstance()->getLink('User', array('object' => $this->author));
+ return LinkHandler::getInstance()->getLink('User', ['object' => $this->author]);
}
/**
public function getTitle() {
$count = count($this->getAuthors());
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', [
'count' => $count,
'timesTriggered' => $this->notification->timesTriggered
- ));
+ ]);
}
return $this->getLanguage()->get('wcf.user.notification.comment.title');
}
$count = count($authors);
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', [
'author' => $this->author,
'authors' => array_values($authors),
'count' => $count,
'others' => $count - 1,
'guestTimesTriggered' => $this->notification->guestTimesTriggered
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', [
'author' => $this->author
- ));
+ ]);
}
/**
}
$count = count($authors);
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', [
'author' => $this->author,
'authors' => array_values($authors),
'count' => $count,
'owner' => $user,
'notificationType' => $notificationType,
'guestTimesTriggered' => $this->notification->guestTimesTriggered
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', [
'comment' => $this->userNotificationObject,
'author' => $this->author,
'owner' => $user,
'notificationType' => $notificationType
- ));
+ ]);
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
*/
public function getLink() {
- return LinkHandler::getInstance()->getLink('User', array('id' => $this->userNotificationObject->objectID), '#wall');
+ return LinkHandler::getInstance()->getLink('User', ['id' => $this->userNotificationObject->objectID], '#wall');
}
/**
* @see \wcf\system\user\notification\object\type\IUserNotificationObjectType::getObjectsByIDs()
*/
public function getObjectsByIDs(array $objectIDs) {
- $indexName = call_user_func(array(static::$objectClassName, 'getDatabaseTableIndexName'));
+ $indexName = call_user_func([static::$objectClassName, 'getDatabaseTableIndexName']);
$objectList = new static::$objectListClassName();
$objectList->setObjectIDs($objectIDs);
// '__unknownNotificationObject' tells the notification API
// that the object does not exist anymore so that the related
// notification can be deleted automatically
- $objects[$objectID] = new static::$decoratorClassName(new static::$objectClassName(null, array(
+ $objects[$objectID] = new static::$decoratorClassName(new static::$objectClassName(null, [
'__unknownNotificationObject' => true,
$indexName => $objectID
- )));
+ ]));
}
}
FROM wcf".WCF_N."_comment
WHERE commentID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($objectID));
+ $statement->execute([$objectID]);
$row = $statement->fetchArray();
return ($row ? $row['objectID'] : 0);
* @see \wcf\system\user\object\watch\UserObjectWatchHandler::resetObjects();
*/
public function resetObject($objectType, $objectID) {
- $this->resetObjects($objectType, array($objectID));
+ $this->resetObjects($objectType, [$objectID]);
}
/**
// get subscriber
$conditionsBuilder = new PreparedStatementConditionBuilder();
- $conditionsBuilder->add('objectTypeID = ?', array($objectTypeObj->objectTypeID));
- $conditionsBuilder->add('objectID IN (?)', array($objectIDs));
+ $conditionsBuilder->add('objectTypeID = ?', [$objectTypeObj->objectTypeID]);
+ $conditionsBuilder->add('objectID IN (?)', [$objectIDs]);
$sql = "SELECT userID
FROM wcf".WCF_N."_user_object_watch
".$conditionsBuilder;
* @param integer[] $objectIDs
* @param integer[] $userIDs
*/
- public function deleteObjects($objectType, array $objectIDs, array $userIDs = array()) {
+ public function deleteObjects($objectType, array $objectIDs, array $userIDs = []) {
// get object type id
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', $objectType);
// delete objects
$conditionsBuilder = new PreparedStatementConditionBuilder();
- $conditionsBuilder->add('objectTypeID = ?', array($objectTypeObj->objectTypeID));
- $conditionsBuilder->add('objectID IN (?)', array($objectIDs));
- if (!empty($userIDs)) $conditionsBuilder->add('userID IN (?)', array($userIDs));
+ $conditionsBuilder->add('objectTypeID = ?', [$objectTypeObj->objectTypeID]);
+ $conditionsBuilder->add('objectID IN (?)', [$objectIDs]);
+ if (!empty($userIDs)) $conditionsBuilder->add('userID IN (?)', [$userIDs]);
$sql = "DELETE FROM wcf".WCF_N."_user_object_watch
".$conditionsBuilder;
* @param IUserNotificationObject $notificationObject
* @param array $additionalData
*/
- public function updateObject($objectType, $objectID, $notificationEventName, $notificationObjectType, IUserNotificationObject $notificationObject, array $additionalData = array()) {
+ public function updateObject($objectType, $objectID, $notificationEventName, $notificationObjectType, IUserNotificationObject $notificationObject, array $additionalData = []) {
// get object type id
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', $objectType);
// get subscriber
- $userIDs = $recipientIDs = array();
+ $userIDs = $recipientIDs = [];
$sql = "SELECT userID, notification
FROM wcf".WCF_N."_user_object_watch
WHERE objectTypeID = ?
AND objectID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($objectTypeObj->objectTypeID, $objectID));
+ $statement->execute([$objectTypeObj->objectTypeID, $objectID]);
while ($row = $statement->fetchArray()) {
$userIDs[] = $row['userID'];
if ($row['notification'] && $notificationObject->getAuthorID() != $row['userID']) $recipientIDs[] = $row['userID'];
* user ids
* @var integer[]
*/
- protected $userIDs = array();
+ protected $userIDs = [];
/**
* list of users
return '';
}
- return WCF::getLanguage()->getDynamicVariable($languageVariable, array('user' => $this->users[$user->objectID]));
+ return WCF::getLanguage()->getDynamicVariable($languageVariable, ['user' => $this->users[$user->objectID]]);
}
/**
* Loads the users.
*/
protected function readUsers() {
- $this->users = array();
+ $this->users = [];
if (empty($this->userIDs)) return;
$this->userIDs = array_unique($this->userIDs);
* cached signatures
* @var string
*/
- protected $signatures = array();
+ protected $signatures = [];
/**
* Returns a parsed user signature.
* data cache
* @var mixed[][]
*/
- protected $cache = array();
+ protected $cache = [];
/**
* list of outdated data records
* @var mixed[][]
*/
- protected $resetFields = array();
+ protected $resetFields = [];
/**
* list of updated or new data records
* @var mixed[][]
*/
- protected $updateFields = array();
+ protected $updateFields = [];
/**
* Loads storage for a given set of users.
* @param integer[] $userIDs
*/
public function loadStorage(array $userIDs) {
- $tmp = array();
+ $tmp = [];
foreach ($userIDs as $userID) {
if (!isset($this->cache[$userID])) $tmp[] = $userID;
}
if (empty($tmp)) return;
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($tmp));
+ $conditions->add("userID IN (?)", [$tmp]);
$sql = "SELECT *
FROM wcf".WCF_N."_user_storage
$statement->execute($conditions->getParameters());
while ($row = $statement->fetchArray()) {
if (!isset($this->cache[$row['userID']])) {
- $this->cache[$row['userID']] = array();
+ $this->cache[$row['userID']] = [];
}
$this->cache[$row['userID']][$row['field']] = $row['fieldValue'];
* @return mixed[]
*/
public function getStorage(array $userIDs, $field) {
- $data = array();
+ $data = [];
foreach ($userIDs as $userID) {
if (isset($this->cache[$userID][$field])) {
// make sure stored data is loaded
if (!isset($this->cache[$userID])) {
- $this->loadStorage(array($userID));
+ $this->loadStorage([$userID]);
}
if (isset($this->cache[$userID][$field])) {
$sql = "DELETE FROM wcf".WCF_N."_user_storage
WHERE field = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($field));
+ $statement->execute([$field]);
foreach ($this->cache as $userID => $fields) {
if (isset($fields[$field])) {
* Removes and inserts data records on shutdown.
*/
public function shutdown() {
- $toReset = array();
+ $toReset = [];
// remove outdated entries
foreach ($this->resetFields as $userID => $fields) {
foreach ($fields as $field) {
- if (!isset($toReset[$field])) $toReset[$field] = array();
+ if (!isset($toReset[$field])) $toReset[$field] = [];
$toReset[$field][] = $userID;
}
}
foreach ($this->updateFields as $userID => $fieldValues) {
foreach ($fieldValues as $field => $fieldValue) {
- if (!isset($toReset[$field])) $toReset[$field] = array();
+ if (!isset($toReset[$field])) $toReset[$field] = [];
$toReset[$field][] = $userID;
}
}
foreach ($toReset as $field => $userIDs) {
sort($userIDs);
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($userIDs));
- $conditions->add("field = ?", array($field));
+ $conditions->add("userID IN (?)", [$userIDs]);
+ $conditions->add("field = ?", [$field]);
$sql = "DELETE FROM wcf".WCF_N."_user_storage
".$conditions;
ksort($fieldValues);
foreach ($fieldValues as $field => $fieldValue) {
- $statement->execute(array(
+ $statement->execute([
$userID,
$field,
$fieldValue
- ));
+ ]);
}
}
}
usleep(mt_rand(0, .1e6)); // 0 to .1 seconds
}
}
- $this->resetFields = $this->updateFields = array();
+ $this->resetFields = $this->updateFields = [];
}
/**
* Removes the entire user storage data.
*/
public function clear() {
- $this->resetFields = $this->updateFields = array();
+ $this->resetFields = $this->updateFields = [];
$sql = "DELETE FROM wcf".WCF_N."_user_storage";
$statement = WCF::getDB()->prepareStatement($sql);
* list of available object types
* @var array
*/
- protected $availableObjectTypes = array();
+ protected $availableObjectTypes = [];
/**
* user visits
// cache does not exist or is outdated
if ($data === null) {
- $this->userVisits = array();
+ $this->userVisits = [];
$sql = "SELECT objectTypeID, visitTime
FROM wcf".WCF_N."_tracked_visit_type
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(WCF::getUser()->userID));
+ $statement->execute([WCF::getUser()->userID]);
while ($row = $statement->fetchArray()) {
$this->userVisits[$row['objectTypeID']] = $row['visitTime'];
}
}
if (!$this->userVisits) {
- $this->userVisits = array();
+ $this->userVisits = [];
}
}
AND objectID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectTypeID($objectType), $objectID, WCF::getUser()->userID));
+ $statement->execute([$this->getObjectTypeID($objectType), $objectID, WCF::getUser()->userID]);
$row = $statement->fetchArray();
if ($row) return $row['visitTime'];
}
WHERE objectTypeID = ?
AND userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectTypeID($objectType), WCF::getUser()->userID));
+ $statement->execute([$this->getObjectTypeID($objectType), WCF::getUser()->userID]);
}
}
(objectTypeID, objectID, userID, visitTime)
VALUES (?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectTypeID($objectType), $objectID, WCF::getUser()->userID, $time));
+ $statement->execute([$this->getObjectTypeID($objectType), $objectID, WCF::getUser()->userID, $time]);
}
else {
WCF::getSession()->register('trackedUserVisit_'.$this->getObjectTypeID($objectType).'_'.$objectID, $time);
(objectTypeID, userID, visitTime)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectTypeID($objectType), WCF::getUser()->userID, $time));
+ $statement->execute([$this->getObjectTypeID($objectType), WCF::getUser()->userID, $time]);
// delete obsolete object visits
$sql = "DELETE FROM wcf".WCF_N."_tracked_visit
AND userID = ?
AND visitTime <= ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->getObjectTypeID($objectType), WCF::getUser()->userID, $time));
+ $statement->execute([$this->getObjectTypeID($objectType), WCF::getUser()->userID, $time]);
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'trackedUserVisits');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'trackedUserVisits');
}
else {
$this->getVisitTime($objectType);
* @see \wcf\system\worker\IWorker::validate()
*/
public function validate() {
- WCF::getSession()->checkPermissions(array('admin.management.canRebuildData'));
+ WCF::getSession()->checkPermissions(['admin.management.canRebuildData']);
}
/**
* list of additional parameters
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* @see \wcf\system\worker\IWorker::__construct()
parent::initObjectList();
$this->objectList->sqlOrderBy = 'attachment.attachmentID';
- $this->objectList->getConditionBuilder()->add('attachment.isImage = ?', array(1));
+ $this->objectList->getConditionBuilder()->add('attachment.isImage = ?', [1]);
}
/**
foreach ($this->objectList as $attachment) {
try {
- $action = new AttachmentAction(array($attachment), 'generateThumbnails');
+ $action = new AttachmentAction([$attachment], 'generateThumbnails');
$action->executeAction();
}
catch (SystemException $e) {}
* @see \wcf\system\worker\IWorker::validate()
*/
public function validate() {
- WCF::getSession()->checkPermissions(array('admin.management.canImportData'));
+ WCF::getSession()->checkPermissions(['admin.management.canImportData']);
if (!isset($this->parameters['objectType'])) {
throw new SystemException("parameter 'objectType' missing");
$statement->execute();
}
- $itemsToUser = array();
- $likeObjectData = array();
+ $itemsToUser = [];
+ $likeObjectData = [];
foreach ($this->objectList as $like) {
if ($like->objectUserID && $like->likeValue == Like::LIKE) {
if (!isset($itemsToUser[$like->objectUserID])) {
}
if (!isset($likeObjectData[$like->objectTypeID])) {
- $likeObjectData[$like->objectTypeID] = array();
+ $likeObjectData[$like->objectTypeID] = [];
}
if (!isset($likeObjectData[$like->objectTypeID][$like->objectID])) {
- $likeObjectData[$like->objectTypeID][$like->objectID] = array(
+ $likeObjectData[$like->objectTypeID][$like->objectID] = [
'likes' => 0,
'dislikes' => 0,
'cumulativeLikes' => 0,
'objectUserID' => $like->objectUserID
- );
+ ];
}
if ($like->likeValue == Like::LIKE) {
WCF::getDB()->beginTransaction();
foreach ($likeObjectData as $objectTypeID => $objects) {
foreach ($objects as $objectID => $data) {
- $statement->execute(array(
+ $statement->execute([
$objectTypeID,
$objectID,
$data['objectUserID'],
$data['likes'],
$data['dislikes'],
$data['cumulativeLikes']
- ));
+ ]);
}
}
WCF::getDB()->commitTransaction();
AND likeValue = ?
ORDER BY time DESC";
$statement = WCF::getDB()->prepareStatement($sql, 3);
- $userData = $userIDs = array();
+ $userData = $userIDs = [];
foreach ($this->objectList as $likeObject) {
- $userData[$likeObject->likeObjectID] = array();
+ $userData[$likeObject->likeObjectID] = [];
- $statement->execute(array(
+ $statement->execute([
$likeObject->objectID,
$likeObject->objectTypeID,
Like::LIKE
- ));
+ ]);
while ($row = $statement->fetchArray()) {
$userData[$likeObject->likeObjectID][] = $row['userID'];
$userIDs[] = $row['userID'];
// fetch usernames
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($userIDs));
+ $conditions->add("userID IN (?)", [$userIDs]);
$sql = "SELECT userID, username
FROM wcf".WCF_N."_user
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $usernames = array();
+ $usernames = [];
while ($row = $statement->fetchArray()) {
$usernames[$row['userID']] = $row['username'];
}
WCF::getDB()->beginTransaction();
foreach ($userData as $likeObjectID => $data) {
foreach ($data as &$value) {
- $value = array(
+ $value = [
'userID' => $value,
'username' => $usernames[$value]
- );
+ ];
}
unset($value);
- $statement->execute(array(
+ $statement->execute([
serialize($data),
$likeObjectID
- ));
+ ]);
}
WCF::getDB()->commitTransaction();
}
* @see \wcf\system\worker\IWorker::validate()
*/
public function validate() {
- WCF::getSession()->checkPermissions(array('admin.user.canMailUser'));
+ WCF::getSession()->checkPermissions(['admin.user.canMailUser']);
if (!isset($this->parameters['mailID'])) {
throw new SystemException("mailID missing");
public function countObjects() {
$this->conditions = new PreparedStatementConditionBuilder();
if ($this->mailData['action'] == '') {
- $this->conditions->add("user.userID IN (?)", array($this->mailData['userIDs']));
+ $this->conditions->add("user.userID IN (?)", [$this->mailData['userIDs']]);
}
else {
- $this->conditions->add("user.activationCode = ?", array(0));
- $this->conditions->add("user.banned = ?", array(0));
+ $this->conditions->add("user.activationCode = ?", [0]);
+ $this->conditions->add("user.banned = ?", [0]);
if ($this->mailData['action'] == 'group') {
- $this->conditions->add("user.userID IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", array($this->mailData['groupIDs']));
+ $this->conditions->add("user.userID IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", [$this->mailData['groupIDs']]);
}
}
*/
protected function sendMail(User $user) {
try {
- $mail = new Mail(array($user->username => $user->email), $this->mailData['subject'], str_replace('{$username}', $user->username, $this->mailData['text']), $this->mailData['from']);
+ $mail = new Mail([$user->username => $user->email], $this->mailData['subject'], str_replace('{$username}', $user->username, $this->mailData['text']), $this->mailData['from']);
if ($this->mailData['enableHTML']) $mail->setContentType('text/html');
$mail->setLanguage($user->getLanguage());
$mail->send();
*/
public function countObjects() {
$userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID IN (?)', array($this->parameters['userIDs']));
+ $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$this->parameters['userIDs']]);
return $userList->countObjects();
}
public function execute() {
$userList = new UserList();
$userList->decoratorClassName = 'wcf\data\user\UserEditor';
- $userList->getConditionBuilder()->add('user_table.userID IN (?)', array($this->parameters['userIDs']));
+ $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$this->parameters['userIDs']]);
$userList->sqlLimit = $this->limit;
$userList->sqlOffset = $this->limit * $this->loopCount;
$userList->readObjects();
protected function sendNewPassword(UserEditor $userEditor) {
$newPassword = PasswordUtil::getRandomPassword((REGISTER_PASSWORD_MIN_LENGTH > 12 ? REGISTER_PASSWORD_MIN_LENGTH : 12));
- $userAction = new UserAction(array($userEditor), 'update', array(
- 'data' => array(
+ $userAction = new UserAction([$userEditor], 'update', [
+ 'data' => [
'password' => $newPassword
- )
- ));
+ ]
+ ]);
$userAction->executeAction();
// send mail
- $mail = new Mail(array($userEditor->username => $userEditor->email), $userEditor->getLanguage()->getDynamicVariable('wcf.acp.user.sendNewPassword.mail.subject'), $userEditor->getLanguage()->getDynamicVariable('wcf.acp.user.sendNewPassword.mail', array(
+ $mail = new Mail([$userEditor->username => $userEditor->email], $userEditor->getLanguage()->getDynamicVariable('wcf.acp.user.sendNewPassword.mail.subject'), $userEditor->getLanguage()->getDynamicVariable('wcf.acp.user.sendNewPassword.mail', [
'password' => $newPassword,
'username' => $userEditor->username,
- )));
+ ]));
$mail->send();
}
* @see \wcf\system\worker\IWorker::validate()
*/
public function validate() {
- WCF::getSession()->checkPermissions(array('admin.user.canEditPassword'));
+ WCF::getSession()->checkPermissions(['admin.user.canEditPassword']);
if (!isset($this->parameters['userIDs']) || !is_array($this->parameters['userIDs']) || empty($this->parameters['userIDs'])) {
throw new SystemException("'userIDs' parameter is missing or invalid");
// get object types
foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
$data = $objectType->getProcessor()->getData($d->getTimestamp());
- $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']));
+ $statement->execute([$objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']]);
}
$d->add(new \DateInterval('P1D'));
* object types
* @var ObjectType[]
*/
- public $objectTypes = array();
+ public $objectTypes = [];
/**
* @see \wcf\system\worker\IWorker
* @see \wcf\system\worker\IWorker::validate()
*/
public function validate() {
- WCF::getSession()->checkPermissions(array('admin.user.canEditActivityPoints'));
+ WCF::getSession()->checkPermissions(['admin.user.canEditActivityPoints']);
}
/**
SET activityPoints = items * ?
WHERE objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$objectType->points,
$objectType->objectTypeID
- ));
+ ]);
}
$i++;
public function execute() {
parent::execute();
- $users = $userIDs = array();
+ $users = $userIDs = [];
foreach ($this->getObjectList() as $user) {
$users[] = new UserEditor($user);
$userIDs[] = $user->userID;
// update like counter
if (MODULE_LIKE) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('user_table.userID IN (?)', array($userIDs));
+ $conditionBuilder->add('user_table.userID IN (?)', [$userIDs]);
$sql = "UPDATE wcf".WCF_N."_user user_table
SET likesReceived = (
SELECT COUNT(*)
}
// get parameters
- $params1 = array($array1, $array2);
- $params2 = array($array2, $array1);
+ $params1 = [$array1, $array2];
+ $params2 = [$array2, $array1];
if ($callback !== null) {
$params1[] = $callback;
$params2[] = $callback;
* @return string
*/
public static function generateTable(array $table) {
- $columnSize = array();
+ $columnSize = [];
foreach ($table as $row) {
$i = 0;
foreach ($row as $column) {
* result date
* @var integer[]
*/
- protected static $result = array();
+ protected static $result = [];
/**
* time base used as reference for finding the next execution time
* since it varies from month to month)
* @var integer[]
*/
- public static $ranges = array(
- 'minute' => array(0, 59),
- 'hour' => array(0, 23),
- 'dom' => array(1, 31),
- 'month' => array(1, 12),
- 'dow' => array(0, 6)
- );
+ public static $ranges = [
+ 'minute' => [0, 59],
+ 'hour' => [0, 23],
+ 'dom' => [1, 31],
+ 'month' => [1, 12],
+ 'dow' => [0, 6]
+ ];
/**
* Calculates timestamp for next execution based on cron-like expressions and a given time base.
public static function calculateNextExec($minute, $hour, $dom, $month, $dow, $timeBase = TIME_NOW) {
// initialize fields
self::$timeBase = $timeBase;
- self::$result = array(
+ self::$result = [
'minute' => 0,
'hour' => 0,
'day' => 0,
'month' => 0,
'year' => 0
- );
+ ];
- $fields = array(
+ $fields = [
'minute' => $minute,
'hour' => $hour,
'dom' => $dom,
'month' => $month,
'dow' => $dow
- );
+ ];
self::$domRestricted = ($dom != '*') ? true : false;
self::$dowRestricted = ($dow != '*') ? true : false;
- $dayNames = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
- $monthNames = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
+ $dayNames = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+ $monthNames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
// calculate values based upon each expression
- $values = array();
+ $values = [];
foreach ($fields as $fieldName => $fieldValue) {
$fieldValue = mb_strtolower($fieldValue);
$dow = gmdate('w', gmmktime(0, 0, 1, $month, $i, $year));
if (in_array($dow, $values['dow'])) {
- return array(
+ return [
'day' => $i,
'month' => $month,
'year' => $year
- );
+ ];
}
}
for ($i = $day; $i <= $days; $i++) {
if (in_array($i, $values['dom'])) {
- return array(
+ return [
'day' => $i,
'month' => $month,
'year' => $year
- );
+ ];
}
}
* @return array
*/
protected static function calculateValue($fieldName, $fieldValue) {
- $values = array();
+ $values = [];
// examinate first char
$char = mb_substr($fieldValue, 0, 1);
return explode(',', $fieldValue);
}
- return array($fieldValue);
+ return [$fieldValue];
}
/**
protected static function getRanges($value) {
// this is a single value
if (mb_strpos($value, '-') === false) {
- return array($value);
+ return [$value];
}
$step = 1;
* @return array
*/
protected static function calculateRange($startValue, $endValue, $step = 1) {
- $values = array();
+ $values = [];
for ($i = $startValue; $i <= $endValue; $i = $i + $step) {
$values[] = $i;
$step = '[1-9]?[0-9]';
$months = 'jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec';
$days = 'mon|tue|wed|thu|fri|sat|sun';
- $namesArr = array();
+ $namesArr = [];
switch ($name) {
// check if startMinute is a valid minute or a list of valid minutes.
* list of available time zones
* @var string[]
*/
- protected static $availableTimezones = array(
+ protected static $availableTimezones = [
// there is not support for UTC-12:00 in php
// '...', // (UTC-12:00) International Date Line West
'Pacific/Samoa', // (UTC-11:00) Midway Island, American Samoa
'Pacific/Fiji', // (UTC+12:00) Fiji
'Pacific/Tongatapu', // (UTC+13:00) Nukualofa
'Pacific/Apia', // (UTC+13:00) Samoa
- );
+ ];
/**
* first day of the week
}
if ($fullInterval) {
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.full.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.full.'.$direction, [
'days' => $days - 7 * $weeks,
'firstElement' => $years ? 'years' : ($months ? 'months' : ($weeks ? 'weeks' : ($days ? 'days' : ($hours ? 'hours' : 'minutes')))),
'hours' => $hours,
'months' => $months,
'weeks' => $weeks,
'years' => $years
- ));
+ ]);
}
if ($years) {
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.years.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.years.'.$direction, [
'years' => $years
- ));
+ ]);
}
if ($months) {
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.months.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.months.'.$direction, [
'months' => $months
- ));
+ ]);
}
if ($weeks) {
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.weeks.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.weeks.'.$direction, [
'weeks' => $weeks
- ));
+ ]);
}
if ($days) {
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.days.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.days.'.$direction, [
'days' => $days
- ));
+ ]);
}
if ($hours) {
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.hours.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.hours.'.$direction, [
'hours' => $hours
- ));
+ ]);
}
- return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.minutes.'.$direction, array(
+ return WCF::getLanguage()->getDynamicVariable('wcf.date.interval.minutes.'.$direction, [
'minutes' => $minutes
- ));
+ ]);
}
/**
if ($language->languageCode != 'en') {
// full textual representation of the day of the week (l)
if (strpos($format, 'l') !== false) {
- $date = str_replace(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'), array(
+ $date = str_replace(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], [
$language->get('wcf.date.day.sunday'),
$language->get('wcf.date.day.monday'),
$language->get('wcf.date.day.tuesday'),
$language->get('wcf.date.day.thursday'),
$language->get('wcf.date.day.friday'),
$language->get('wcf.date.day.saturday')
- ), $date);
+ ], $date);
}
// textual representation of a day, three letters (D)
if (strpos($format, 'D') !== false) {
- $date = str_replace(array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'), array(
+ $date = str_replace(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], [
$language->get('wcf.date.day.sun'),
$language->get('wcf.date.day.mon'),
$language->get('wcf.date.day.tue'),
$language->get('wcf.date.day.thu'),
$language->get('wcf.date.day.fri'),
$language->get('wcf.date.day.sat')
- ), $date);
+ ], $date);
}
// full textual representation of a month (F)
if (strpos($format, 'F') !== false) {
- $date = str_replace(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'), array(
+ $date = str_replace(['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], [
$language->get('wcf.date.month.january'),
$language->get('wcf.date.month.february'),
$language->get('wcf.date.month.march'),
$language->get('wcf.date.month.october'),
$language->get('wcf.date.month.november'),
$language->get('wcf.date.month.december')
- ), $date);
+ ], $date);
}
// short textual representation of a month (M)
if (strpos($format, 'M') !== false) {
- $date = str_replace(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), array(
+ $date = str_replace(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], [
$language->get('wcf.date.month.short.jan'),
$language->get('wcf.date.month.short.feb'),
$language->get('wcf.date.month.short.mar'),
$language->get('wcf.date.month.short.oct'),
$language->get('wcf.date.month.short.nov'),
$language->get('wcf.date.month.short.dec')
- ), $date);
+ ], $date);
}
}
public static function getWeekDays() {
if (self::$weekDays === null) {
if (self::getFirstDayOfTheWeek() == 1) {
- self::$weekDays = array(
+ self::$weekDays = [
1 => 'monday',
2 => 'tuesday',
3 => 'wednesday',
5 => 'friday',
6 => 'saturday',
0 => 'sunday'
- );
+ ];
}
else {
- self::$weekDays = array(
+ self::$weekDays = [
0 => 'sunday',
1 => 'monday',
2 => 'tuesday',
4 => 'thursday',
5 => 'friday',
6 => 'saturday'
- );
+ ];
}
}
public static function getShortWeekDays() {
if (self::$shortWeekDays === null) {
if (self::getFirstDayOfTheWeek() == 1) {
- self::$shortWeekDays = array(
+ self::$shortWeekDays = [
1 => 'mon',
2 => 'tue',
3 => 'wed',
5 => 'fri',
6 => 'sat',
0 => 'sun'
- );
+ ];
}
else {
- self::$shortWeekDays = array(
+ self::$shortWeekDays = [
0 => 'sun',
1 => 'mon',
2 => 'tue',
4 => 'thu',
5 => 'fri',
6 => 'sat'
- );
+ ];
}
}
* original array, as given by the user
* @var array
*/
- protected $a = array();
+ protected $a = [];
/**
* modified array, as given by the user
* @var array
*/
- protected $b = array();
+ protected $b = [];
/**
* size of a
if ($this->d !== null) return;
$lcs = $this->getLCS();
- $this->d = array();
+ $this->d = [];
$positionA = 0;
$positionB = 0;
foreach ($lcs as $item) {
// find next matching item in a, every item in between must be removed
while ($positionA < $this->sizeA && $this->a[$positionA] !== $item) {
- $this->d[] = array(self::REMOVED, $this->a[$positionA++]);
+ $this->d[] = [self::REMOVED, $this->a[$positionA++]];
}
// find next matching item in b, every item in between must be removed
while ($positionB < $this->sizeB && $this->b[$positionB] !== $item) {
- $this->d[] = array(self::ADDED, $this->b[$positionB++]);
+ $this->d[] = [self::ADDED, $this->b[$positionB++]];
}
// we are back in our longest common subsequence
- $this->d[] = array(self::SAME, $item);
+ $this->d[] = [self::SAME, $item];
$positionA++;
$positionB++;
}
// append remaining items of `a` and `b`
while ($positionA < $this->sizeA) {
- $this->d[] = array(self::REMOVED, $this->a[$positionA++]);
+ $this->d[] = [self::REMOVED, $this->a[$positionA++]];
}
while ($positionB < $this->sizeB) {
- $this->d[] = array(self::ADDED, $this->b[$positionB++]);
+ $this->d[] = [self::ADDED, $this->b[$positionB++]];
}
}
public function getUnixDiff($context = 2) {
$d = $this->getRawDiff();
- $result = array();
+ $result = [];
$result[] = "--- a";
$result[] = "+++ b";
* all files with full path
* @var string[]
*/
- protected $files = array();
+ protected $files = [];
/**
* all files with filename as key and DirectoryIterator object as value
* @var \DirectoryIterator[]
*/
- protected $fileObjects = array();
+ protected $fileObjects = [];
/**
* directory size in bytes
* all recursive and non-recursive instances of DirectoryUtil
* @var DirectoryUtil[][]
*/
- protected static $instances = array(
- true => array(), // recursive instances
- false => array() // non-recursive instances
- );
+ protected static $instances = [
+ true => [], // recursive instances
+ false => [] // non-recursive instances
+ ];
/**
* Creates a new instance of DirectoryUtil.
*/
public function clearCaches() {
// clear cached list of files
- $this->files = array();
- $this->fileObjects = array();
+ $this->files = [];
+ $this->fileObjects = [];
// clear cached size
$this->size = 0;
}
}
- return array();
+ return [];
}
/**
* @return array
*/
public static function getFormattedExifData(array $rawExifData) {
- $exifData = array();
+ $exifData = [];
// unit is second (unsigned rational)
if (isset($rawExifData['ExposureTime']) && is_string($rawExifData['ExposureTime'])) {
* http options
* @var array
*/
- protected $options = array(
+ protected $options = [
'filename' => '',
'mimeType' => 'application/octet-stream',
'filesize' => 0,
'lastModificationTime' => 0,
'expirationDate' => 0,
'maxAge' => 0
- );
+ ];
/**
* list of header items
* @var array
*/
- protected $headers = array();
+ protected $headers = [];
/**
* start byte
* given options
* @var array
*/
- private $options = array();
+ private $options = [];
/**
* given post parameters
* @var array
*/
- private $postParameters = array();
+ private $postParameters = [];
/**
* given files
* @var array
*/
- private $files = array();
+ private $files = [];
/**
* indicates if request will be made via SSL
* request headers
* @var string[][]
*/
- private $headers = array();
+ private $headers = [];
/**
* legacy headers
* @var string[]
*/
- private $legacyHeaders = array();
+ private $legacyHeaders = [];
/**
* request body
* reply headers
* @var string[]
*/
- private $replyHeaders = array();
+ private $replyHeaders = [];
/**
* reply body
* @param mixed $postParameters Parameters to send via POST
* @param array $files Files to attach to the request
*/
- public function __construct($url, array $options = array(), $postParameters = array(), array $files = array()) {
+ public function __construct($url, array $options = [], $postParameters = [], array $files = []) {
$this->setURL($url);
$this->postParameters = $postParameters;
*/
public function execute() {
// connect
- $remoteFile = new RemoteFile(($this->useSSL ? 'ssl://' : '').$this->host, $this->port, $this->options['timeout'], array(
- 'ssl' => array(
+ $remoteFile = new RemoteFile(($this->useSSL ? 'ssl://' : '').$this->host, $this->port, $this->options['timeout'], [
+ 'ssl' => [
'peer_name' => $this->originHost
- )
- ));
+ ]
+ ]);
if ($this->originUseSSL && PROXY_SERVER_HTTP) {
if ($this->useSSL) throw new SystemException("Unable to proxy HTTPS when using TLS for proxy connection");
$request .= "Host: ".$this->originHost.":".$this->originPort."\r\n";
$request .= "\r\n";
$remoteFile->puts($request);
- $this->replyHeaders = array();
+ $this->replyHeaders = [];
while (!$remoteFile->eof()) {
$line = $remoteFile->gets();
if (rtrim($line) === '') {
$remoteFile->puts($request);
$inHeader = true;
- $this->replyHeaders = array();
+ $this->replyHeaders = [];
$this->replyBody = '';
$chunkLength = 0;
$bodyLength = 0;
* Parses the reply headers.
*/
private function parseReplyHeaders() {
- $headers = array();
+ $headers = [];
$lastKey = '';
foreach ($this->replyHeaders as $header) {
if (strpos($header, ':') === false) {
- $headers[trim($header)] = array(trim($header));
+ $headers[trim($header)] = [trim($header)];
continue;
}
list($key, $value) = explode(':', $header, 2);
$lastKey = $key;
- if (!isset($headers[$key])) $headers[$key] = array();
+ if (!isset($headers[$key])) $headers[$key] = [];
$headers[$key][] = trim($value);
}
}
// 4.2 Field names are case-insensitive.
$this->replyHeaders = array_change_key_case($headers);
- if (isset($this->replyHeaders['transfer-encoding'])) $this->replyHeaders['transfer-encoding'] = array(implode(',', $this->replyHeaders['transfer-encoding']));
+ if (isset($this->replyHeaders['transfer-encoding'])) $this->replyHeaders['transfer-encoding'] = [implode(',', $this->replyHeaders['transfer-encoding'])];
$this->legacyHeaders = array_map('end', $headers);
// get status code
// be retrieved using a GET method on that resource.
if ($this->statusCode == '303') {
$newRequest->options['method'] = 'GET';
- $newRequest->postParameters = array();
+ $newRequest->postParameters = [];
$newRequest->addHeader('content-length', '');
$newRequest->addHeader('content-type', '');
}
* @return array
*/
public function getReply() {
- return array(
+ return [
'statusCode' => $this->statusCode,
'headers' => $this->legacyHeaders,
'httpHeaders' => $this->replyHeaders,
'body' => $this->replyBody,
'url' => $this->url
- );
+ ];
}
/**
$this->headers[$name][] = $value;
}
else {
- $this->headers[$name] = array($value);
+ $this->headers[$name] = [$value];
}
}
* Resets reply data when cloning.
*/
private function __clone() {
- $this->replyHeaders = array();
+ $this->replyHeaders = [];
$this->replyBody = '';
$this->statusCode = 0;
}
@header('X-Frame-Options: SAMEORIGIN');
}
- ob_start(array('wcf\util\HeaderUtil', 'parseOutput'));
+ ob_start(['wcf\util\HeaderUtil', 'parseOutput']);
}
/**
self::$output = $output;
// move script tags to the bottom of the page
- $javascript = array();
+ $javascript = [];
self::$output = preg_replace_callback('~(?P<conditionBefore><!--\[IF [^<]+\s*)?<script data-relocate="true"(?P<script>.*?</script>\s*)(?P<conditionAfter><!\[ENDIF]-->\s*)?~s', function($matches) use (&$javascript) {
$match = '';
if (isset($matches['conditionBefore'])) $match .= $matches['conditionBefore'];
* @param string $status
*/
public static function delayedRedirect($location, $message, $delay = 5, $status = 'success') {
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'url' => $location,
'message' => $message,
'wait' => $delay,
'templateName' => 'redirect',
'templateNameApplication' => 'wcf',
'status' => $status
- ));
+ ]);
WCF::getTPL()->display('redirect');
}
$lambda = $longitude * pi() / 180;
$phi = $latitude * pi() / 180;
- return array(
+ return [
6371 * cos($phi) * cos($lambda), // x
6371 * cos($phi) * sin($lambda), // y
6371 * sin($phi) // z
- );
+ ];
}
private function __construct() { }
return $matches[1];
}
- return array();
+ return [];
}
/**
* @return string[]
*/
public static function getQuotedUsers($text) {
- $usernames = array();
+ $usernames = [];
if (preg_match_all("~(?:\[(quote)=(?:')?(.+?)(?:')?(?:,[^\]]*)?\]|\[/quote\])~i", $text, $matches)) {
$level = 0;
* @return array
*/
public static function parseSelectOptions($selectOptions) {
- $result = array();
+ $result = [];
$options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($selectOptions)));
foreach ($options as $option) {
$key = $value = $option;
* @return array
*/
public static function parseMultipleEnableOptions($enableOptions) {
- $result = array();
+ $result = [];
if (!empty($enableOptions)) {
$options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($enableOptions)));
$key = -1;
* list of supported encryption type by software identifier
* @var string[]
*/
- private static $supportedEncryptionTypes = array(
+ private static $supportedEncryptionTypes = [
'ipb2', // Invision Power Board 2.x
'ipb3', // Invision Power Board 3.x
'mybb1', // MyBB 1.x
'joomla3', // Joomla 3.x
'cryptMD5',
'invalid', // Never going to match anything
- );
+ ];
/**
* blowfish cost factor
* local string stack
* @var string[][]
*/
- protected static $stringStack = array();
+ protected static $stringStack = [];
/**
* Replaces a string with an unique hash value.
$hash = $delimiter.StringUtil::getHash(self::$i.uniqid(microtime()).$string).$delimiter;
if (!isset(self::$stringStack[$type])) {
- self::$stringStack[$type] = array();
+ self::$stringStack[$type] = [];
}
self::$stringStack[$type][$hash] = $string;
return self::$stringStack[$type];
}
- return array();
+ return [];
}
private function __construct() { }
* @return string[]
*/
public static function split($string, $length = 1) {
- $result = array();
+ $result = [];
for ($i = 0, $max = mb_strlen($string); $i < $max; $i += $length) {
$result[] = mb_substr($string, $i, $length);
}
if (mb_strlen(self::stripHTML($string)) <= $length) {
return $string;
}
- $openTags = array();
+ $openTags = [];
$truncatedString = '';
// initalize length counter with the ending length
FROM wcf".WCF_N."_user
WHERE username = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($name));
+ $statement->execute([$name]);
return $statement->fetchSingleColumn() == 0;
}
FROM wcf".WCF_N."_user
WHERE email = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($email));
+ $statement->execute([$email]);
return $statement->fetchSingleColumn() == 0;
}
if (substr($ip, 0, 7) == '::ffff:') {
$ip = substr($ip, 7);
if (preg_match('~^([a-f0-9]{1,4}):([a-f0-9]{1,4})$~', $ip, $matches)) {
- $ip = array(
+ $ip = [
base_convert($matches[1], 16, 10),
base_convert($matches[2], 16, 10)
- );
+ ];
- $ipParts = array();
+ $ipParts = [];
$tmp = $ip[0] % 256;
$ipParts[] = ($ip[0] - $tmp) / 256;
$ipParts[] = $tmp;
* @return string[][]
*/
protected function pollErrors() {
- $errors = array();
+ $errors = [];
$errorList = libxml_get_errors();
foreach ($errorList as $error) {
- $errors[] = array(
+ $errors[] = [
'message' => $error->message,
'line' => $error->line,
'file' => $this->path
- );
+ ];
}
libxml_clear_errors();
* @param array $errors
* @throws SystemException
*/
- protected function throwException($message, array $errors = array()) {
+ protected function throwException($message, array $errors = []) {
if (!empty($errors)) {
$description = '<b>LibXML output:</b><pre>';
foreach ($errors as $error) {
* @param string[] $attributes
* @throws SystemException
*/
- public function beginDocument($rootElement, $namespace, $schemaLocation, array $attributes = array()) {
+ public function beginDocument($rootElement, $namespace, $schemaLocation, array $attributes = []) {
if ($this->activeDocument) {
throw new SystemException("Could not begin a new document unless the previous is finished");
}
$this->xml->startDocument('1.0', 'UTF-8');
$this->startElement($rootElement);
- $attributes = array_merge($attributes, array(
+ $attributes = array_merge($attributes, [
'xmlns' => $namespace,
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => $namespace . ' ' . $schemaLocation
- ));
+ ]);
$this->writeAttributes($attributes);
$this->activeDocument = true;
* @param string $element
* @param string[] $attributes
*/
- public function startElement($element, array $attributes = array()) {
+ public function startElement($element, array $attributes = []) {
$this->xml->startElement($element);
$this->openElements++;
* @param string $cdata
* @param string[] $attributes
*/
- public function writeElement($element, $cdata, array $attributes = array()) {
+ public function writeElement($element, $cdata, array $attributes = []) {
$this->startElement($element);
// write attributes
* @param string $value
*/
public function writeAttribute($attribute, $value) {
- $this->writeAttributes(array($attribute => $value));
+ $this->writeAttributes([$attribute => $value]);
}
/**