* Shows the user add form.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage acp.form
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
- public $neededPermissions = array('admin.user.canAddUser');
+ public $neededPermissions = ['admin.user.canAddUser'];
/**
* username
* user group ids
* @var array<integer>
*/
- public $groupIDs = array();
+ public $groupIDs = [];
/**
* language id
* visible languages
* @var array<integer>
*/
- public $visibleLanguages = array();
+ public $visibleLanguages = [];
/**
* title of the user
*/
public $disableSignatureExpires = '';
+ /**
+ * tree of available user options
+ * @var array
+ */
+ public $optionTree = [];
+
/**
* @see \wcf\form\IForm::readFormParameters()
*/
// validate user groups
if (!empty($this->groupIDs)) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("groupID IN (?)", array($this->groupIDs));
- $conditions->add("groupType NOT IN (?)", array(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS)));
+ $conditions->add("groupID IN (?)", [$this->groupIDs]);
+ $conditions->add("groupType NOT IN (?)", [[UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]]);
$sql = "SELECT groupID
FROM wcf".WCF_N."_user_group
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $this->groupIDs = array();
+ $this->groupIDs = [];
while ($row = $statement->fetchArray()) {
- if (UserGroup::isAccessibleGroup(array($row['groupID']))) {
+ if (UserGroup::isAccessibleGroup([$row['groupID']])) {
$this->groupIDs[] = $row['groupID'];
}
}
// create
$saveOptions = $this->optionHandler->save();
$this->additionalFields['languageID'] = $this->languageID;
- $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
- );
+ ];
if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) {
$disableSignatureExpires = 0;
$data['data']['disableSignatureExpires'] = $disableSignatureExpires;
}
- $this->objectAction = new UserAction(array(), 'create', $data);
+ $this->objectAction = new UserAction([], 'create', $data);
$this->objectAction->executeAction();
$this->saved();
// show empty add form
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'success' => true
- ));
+ ]);
// reset values
$this->signatureEnableHtml = $this->disableSignature = 0;
$this->signatureEnableSmilies = $this->signatureEnableBBCodes = 1;
$this->username = $this->email = $this->confirmEmail = $this->password = $this->confirmPassword = $this->userTitle = '';
$this->signature = $this->disableSignatureReason = $this->disableSignatureExpires = '';
- $this->groupIDs = array();
+ $this->groupIDs = [];
$this->languageID = $this->getDefaultFormLanguageID();
$this->optionHandler->resetOptionValues();
}
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'username' => $this->username,
'email' => $this->email,
'confirmEmail' => $this->confirmEmail,
'disableSignature' => $this->disableSignature,
'disableSignatureReason' => $this->disableSignatureReason,
'disableSignatureExpires' => $this->disableSignatureExpires
- ));
+ ]);
}
/**
*/
class UserGroupEditForm extends UserGroupAddForm {
/**
- * @see \wcf\page\AbstractPage::$activeMenuItem
+ * @inheritDoc
*/
public $activeMenuItem = 'wcf.acp.menu.link.group';
/**
- * @see \wcf\page\AbstractPage::$neededPermissions
+ * @inheritDoc
*/
- public $neededPermissions = array('admin.user.canEditGroup');
+ public $neededPermissions = ['admin.user.canEditGroup'];
/**
* id of the edited user group
/**
* user group editor object
- * @var \wcf\data\user\group\UserGroupEditor
+ * @var UserGroupEditor
*/
public $group = null;
/**
- * @see \wcf\page\IPage::readParameters()
+ * @inheritDoc
*/
public function readParameters() {
parent::readParameters();
}
/**
- * @see \wcf\acp\form\AbstractOptionListForm::initOptionHandler()
+ * @inheritDoc
*/
protected function initOptionHandler() {
// does nothing, we call OptionHandler::init() after we set the
}
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
if (empty($_POST)) {
$this->priority = $this->group->priority;
$this->userOnlineMarking = $this->group->userOnlineMarking;
$this->showOnTeamPage = $this->group->showOnTeamPage;
- $options = $this->optionHandler->getCategoryOptions();
-
- // get default values
- if ($this->group->groupType != UserGroup::EVERYONE) {
- $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE);
- foreach ($options as $option) {
- $value = $defaultGroup->getGroupOption($option['object']->optionName);
- if ($value !== null) {
- $this->optionValues[$option['object']->optionName] = $value;
- }
- }
- }
-
- foreach ($options as $option) {
- $value = $this->group->getGroupOption($option['object']->optionName);
- if ($value !== null) {
- $this->optionValues[$option['object']->optionName] = $value;
- }
- }
}
parent::readData();
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
I18nHandler::getInstance()->assignVariables(!empty($_POST));
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'groupID' => $this->group->groupID,
'group' => $this->group,
'action' => 'edit',
'availableUserGroups' => UserGroup::getAccessibleGroups()
- ));
+ ]);
// add warning when the initiator is in the group
if ($this->group->isMember()) {
}
/**
- * @see \wcf\form\IForm::save()
+ * @inheritDoc
*/
public function save() {
AbstractForm::save();
I18nHandler::getInstance()->save('groupDescription', $this->groupDescription, 'wcf.acp.group', 1);
}
- $data = array(
- 'data' => array_merge($this->additionalFields, array(
+ $this->objectAction = new UserGroupAction([$this->groupID], 'update', [
+ 'data' => array_merge($this->additionalFields, [
'groupName' => $this->groupName,
'groupDescription' => $this->groupDescription,
'priority' => $this->priority,
'userOnlineMarking' => $this->userOnlineMarking,
'showOnTeamPage' => $this->showOnTeamPage
- )),
+ ]),
'options' => $optionValues
- );
- $this->objectAction = new UserGroupAction(array($this->groupID), 'update', $data);
+ ]);
$this->objectAction->executeAction();
$this->saved();
* Compares two templates.
*
* @author Tim Duesterhus
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage acp.form
*/
class TemplateDiffPage extends AbstractPage {
/**
- * @see \wcf\page\AbstractPage::$activeMenuItem
+ * @inheritDoc
*/
public $activeMenuItem = 'wcf.acp.menu.link.template';
/**
* template object
- * @var \wcf\data\template\Template
+ * @var Template
*/
public $template = null;
/**
* template to compare with
- * @var \wcf\data\template\Template
+ * @var Template
*/
public $parent = null;
/**
* differences between both templates
- * @var \wcf\util\Diff
+ * @var Diff
*/
public $diff = null;
/**
- * @see \wcf\page\IPage::readParameters()
+ * template group hierarchy
+ * @var array
+ */
+ public $templateGroupHierarchy = [];
+
+ /**
+ * @inheritDoc
*/
public function readParameters() {
parent::readParameters();
}
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
parent::readData();
$templateGroupList->readObjects();
// build template group hierarchy (template groups that are parents of the template group of the selected template)
- $this->templateGroupHierarchy = array();
+ $this->templateGroupHierarchy = [];
$templateGroup = $templateGroupList->search($this->template->templateGroupID);
while ($templateGroup !== null) {
- $this->templateGroupHierarchy[$templateGroup->templateGroupID] = array('group' => $templateGroup, 'hasTemplate' => false);
+ $this->templateGroupHierarchy[$templateGroup->templateGroupID] = ['group' => $templateGroup, 'hasTemplate' => false];
$templateGroup = $templateGroupList->search($templateGroup->parentTemplateGroupID);
}
- $this->templateGroupHierarchy[0] = array('group' => array(), 'hasTemplate' => false);
+ $this->templateGroupHierarchy[0] = ['group' => [], 'hasTemplate' => false];
// find matching templates in the hierarchy
$templateList = new TemplateList();
- $templateList->getConditionBuilder()->add('templateName = ?', array($this->template->templateName));
- $templateList->getConditionBuilder()->add('application = ?', array($this->template->application));
- $templateList->getConditionBuilder()->add('(template.templateGroupID IN(?) OR template.templateGroupID IS NULL)', array(array_keys($this->templateGroupHierarchy)));
+ $templateList->getConditionBuilder()->add('templateName = ?', [$this->template->templateName]);
+ $templateList->getConditionBuilder()->add('application = ?', [$this->template->application]);
+ $templateList->getConditionBuilder()->add('(template.templateGroupID IN(?) OR template.templateGroupID IS NULL)', [array_keys($this->templateGroupHierarchy)]);
$templateList->readObjects();
foreach ($templateList as $template) {
$this->templateGroupHierarchy[($template->templateGroupID ?: 0)]['hasTemplate'] = $template->templateID;
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'templateID' => $this->templateID,
'template' => $this->template,
'parentID' => $this->parentID,
'parent' => $this->parent,
'diff' => $this->diff,
'templateGroupHierarchy' => array_reverse($this->templateGroupHierarchy, true)
- ));
+ ]);
}
}
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\option\IOptionHandler;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\DateUtil;
class UserListPage extends SortablePage {
/**
* list of displayed column names
- * @var array<string>
+ * @var string[]
*/
- public $columnHeads = array();
+ public $columnHeads = [];
/**
* list of selected columns
- * @var array<string>
+ * @var string[]
*/
- public $columns = array('registrationDate', 'lastActivityTime');
+ public $columns = ['registrationDate', 'lastActivityTime'];
/**
* applies special CSS classes for selected columns
* @var array
*/
- public $columnStyling = array(
+ public $columnStyling = [
'registrationDate' => 'columnDate',
'lastActivityTime' => 'columnDate',
'profileHits' => 'columnDigits',
'activityPoints' => 'columnDigits',
'likesReceived' => 'columnDigits'
- );
+ ];
/**
* list of column values
- * @var array<string>
+ * @var string[]
*/
- public $columnValues = array();
+ public $columnValues = [];
/**
- * @see \wcf\page\SortablePage::$defaultSortField
+ * @inheritDoc
*/
public $defaultSortField = 'username';
/**
- * @see \wcf\page\MultipleLinkPage::$itemsPerPage
+ * @inheritDoc
*/
public $itemsPerPage = 50;
/**
* list of marked user ids
- * @var array<integer>
+ * @var integer[]
*/
- public $markedUsers = array();
+ public $markedUsers = [];
/**
- * @see \wcf\page\AbstractPage::$neededPermissions
+ * @inheritDoc
*/
- public $neededPermissions = array('admin.user.canSearchUser');
+ public $neededPermissions = ['admin.user.canSearchUser'];
/**
* IOptionHandler object
- * @var \wcf\system\option\IOptionHandler
+ * @var IOptionHandler
*/
protected $optionHandler = null;
* list of available user option names
* @var array
*/
- public $options = array();
+ public $options = [];
/**
* id of a user search
/**
* list of user ids
- * @var array<integer>
+ * @var integer[]
*/
- public $userIDs = array();
+ public $userIDs = [];
/**
* list of users
- * @var array<\wcf\data\user\User>
+ * @var User[]
*/
- public $users = array();
+ public $users = [];
/**
* page url
public $url = '';
/**
- * @see \wcf\page\SortablePage::$validSortFields
+ * condition builder for user filtering
+ * @var PreparedStatementConditionBuilder
*/
- public $validSortFields = array('userID', 'registrationDate', 'username', 'lastActivityTime', 'profileHits', 'activityPoints', 'likesReceived');
+ public $conditions = null;
/**
- * @see \wcf\page\IPage::readParameters()
+ * @inheritDoc
+ */
+ public $validSortFields = ['userID', 'registrationDate', 'username', 'lastActivityTime', 'profileHits', 'activityPoints', 'likesReceived'];
+
+ /**
+ * @inheritDoc
*/
public function readParameters() {
parent::readParameters();
if (empty($this->userIDs)) {
throw new IllegalLinkException();
}
- $this->conditions->add("user_table.userID IN (?)", array($this->userIDs));
+ $this->conditions->add("user_table.userID IN (?)", [$this->userIDs]);
}
// get user options
}
/**
- * @see \wcf\page\SortablePage::validateSortField()
+ * @inheritDoc
*/
public function validateSortField() {
// add options to valid sort fields
}
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
parent::readData();
// get marked users
$this->markedUsers = WCF::getSession()->getVar('markedUsers');
- if ($this->markedUsers == null || !is_array($this->markedUsers)) $this->markedUsers = array();
+ if ($this->markedUsers == null || !is_array($this->markedUsers)) $this->markedUsers = [];
// get columns heads
$this->readColumnsHeads();
$this->readUsers();
// build page url
- $this->url = LinkHandler::getInstance()->getLink('UserList', array(), 'searchID='.$this->searchID.'&action='.rawurlencode($this->action).'&pageNo='.$this->pageNo.'&sortField='.$this->sortField.'&sortOrder='.$this->sortOrder);
+ $this->url = LinkHandler::getInstance()->getLink('UserList', [], 'searchID='.$this->searchID.'&action='.rawurlencode($this->action).'&pageNo='.$this->pageNo.'&sortField='.$this->sortField.'&sortOrder='.$this->sortOrder);
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'users' => $this->users,
'searchID' => $this->searchID,
'hasMarkedItems' => ClipboardHandler::getInstance()->hasMarkedItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user')),
'columnHeads' => $this->columnHeads,
'columnValues' => $this->columnValues,
'columnStyling' => $this->columnStyling
- ));
+ ]);
}
/**
- * @see \wcf\page\IPage::show()
+ * @inheritDoc
*/
public function show() {
$this->activeMenuItem = 'wcf.acp.menu.link.user.'.($this->searchID ? 'search' : 'list');
}
/**
- * @see \wcf\page\MultipleLinkPage::countItems()
+ * @inheritDoc
*/
public function countItems() {
// call countItems event
*/
protected function readUsers() {
// get user ids
- $userIDs = array();
+ $userIDs = [];
$sql = "SELECT user_table.userID
FROM wcf".WCF_N."_user user_table
".(isset($this->options[$this->sortField]) ? "LEFT JOIN wcf".WCF_N."_user_option_value user_option_value ON (user_option_value.userID = user_table.userID)" : '')."
// get user data
if (!empty($userIDs)) {
- $userToGroups = array();
+ $userToGroups = [];
// get group ids
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("user_table.userID IN (?)", array($userIDs));
+ $conditions->add("user_table.userID IN (?)", [$userIDs]);
$sql = "SELECT userID, groupID
FROM wcf".WCF_N."_user_to_group user_table
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
while ($row = $statement->fetchArray()) {
- $groupIDs = (isset($userToGroups[$row['userID']]) ? $userToGroups[$row['userID']] : array());
+ $groupIDs = (isset($userToGroups[$row['userID']]) ? $userToGroups[$row['userID']] : []);
$row['groupIDs'] = implode(',', $groupIDs);
$accessible = (!empty($groupIDs) ? UserGroup::isAccessibleGroup($groupIDs) : true);
AND userID = ?
AND searchType = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
+ $statement->execute([
$this->searchID,
WCF::getUser()->userID,
'users'
- ));
+ ]);
$search = $statement->fetchArray();
if (!isset($search['searchData'])) {
throw new IllegalLinkException();
* Gets the user options from cache.
*/
protected function readUserOptions() {
- $this->options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
+ $this->options = UserOptionCacheBuilder::getInstance()->getData([], 'options');
foreach ($this->options as &$option) {
$option = new ViewableUserOption($option);
}
/**
- * @see \wcf\page\MultipleLinkPage::initObjectList()
+ * @inheritDoc
*/
- protected function initObjectList() { }
+ protected function initObjectList() {
+ // does nothing
+ }
/**
- * @see \wcf\page\MultipleLinkPage::readObjects()
+ * @inheritDoc
*/
- protected function readObjects() { }
+ protected function readObjects() {
+ // does nothing
+ }
}
* Represents a tree of category nodes.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data.category
*/
class CategoryNodeTree implements \IteratorAggregate {
/**
- * maximum depth considered when building the node tree.
- *
+ * maximum depth considered when building the node tree
* @var integer
*/
protected $maxDepth = -1;
* name of the category node class
* @var string
*/
- protected $nodeClassName = 'wcf\data\category\CategoryNode';
+ protected $nodeClassName = CategoryNode::class;
/**
* id of the parent category
/**
* parent category node
- * @var \wcf\data\category\CategoryNode
+ * @var CategoryNode
*/
protected $parentNode = null;
+ /**
+ * name of the category object type
+ * @var string
+ */
+ protected $objectType = '';
+
/**
* Creates a new instance of CategoryNodeTree.
*
* @param string $objectType
* @param integer $parentCategoryID
* @param boolean $includeDisabledCategories
- * @param array<integer> $excludedCategoryIDs
+ * @param integer[] $excludedCategoryIDs
*/
- public function __construct($objectType, $parentCategoryID = 0, $includeDisabledCategories = false, array $excludedCategoryIDs = array()) {
+ public function __construct($objectType, $parentCategoryID = 0, $includeDisabledCategories = false, array $excludedCategoryIDs = []) {
$this->objectType = $objectType;
$this->parentCategoryID = $parentCategoryID;
$this->includeDisabledCategories = $includeDisabledCategories;
/**
* Builds a certain level of the tree.
*
- * @param \wcf\data\category\CategoryNode $parentNode
- * @param integer $depth
+ * @param CategoryNode $parentNode
+ * @param integer $depth
*/
protected function buildTreeLevel(CategoryNode $parentNode, $depth = 0) {
if ($this->maxDepth != -1 && $depth < 0) {
* Returns the category with the given id.
*
* @param integer $categoryID
- * @return \wcf\data\category\Category
+ * @return Category
*/
protected function getCategory($categoryID) {
return CategoryHandler::getInstance()->getCategory($categoryID);
/**
* Returns the child categories of the given category node.
*
- * @param \wcf\data\category\CategoryNode $parentNode
- * @return array<\wcf\data\category\Category>
+ * @param CategoryNode $parentNode
+ * @return Category[]
*/
protected function getChildCategories(CategoryNode $parentNode) {
return CategoryHandler::getInstance()->getChildCategories($parentNode->categoryID, $parentNode->objectTypeID);
}
/**
- * @see \IteratorAggregate::getIterator()
+ * @inheritDoc
*/
public function getIterator() {
if ($this->parentNode === null) {
* Returns the category node for the category with the given id.
*
* @param integer $categoryID
- * @return \wcf\data\category\CategoryNode
+ * @return CategoryNode
*/
protected function getNode($categoryID) {
if (!$categoryID) {
- $category = new Category(null, array(
+ $category = new Category(null, [
'categoryID' => 0,
'objectTypeID' => CategoryHandler::getInstance()->getObjectTypeByName($this->objectType)->objectTypeID
- ));
+ ]);
}
else {
$category = $this->getCategory($categoryID);
}
// decorate category if necessary
- $decoratorClassName = call_user_func(array($this->nodeClassName, 'getBaseClass'));
+ $decoratorClassName = call_user_func([$this->nodeClassName, 'getBaseClass']);
if ($decoratorClassName != 'wcf\data\category\Category') {
$category = new $decoratorClassName($category);
}
* Returns true if the given category node fulfils all relevant conditions
* to be included in this tree.
*
- * @param \wcf\data\category\CategoryNode $categoryNode
+ * @param CategoryNode $categoryNode
* @return boolean
*/
protected function isIncluded(CategoryNode $categoryNode) {
* Provides an abstract form for moderation queue processing.
*
* @author Alexander Ebert
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage form
* @category Community Framework
*/
abstract class AbstractModerationForm extends AbstractForm {
+ /**
+ * id of the assigned user
+ * @var integer
+ */
+ public $assignedUserID = 0;
+
/**
* data used for moderation queue update
* @var array
*/
- public $data = array();
+ public $data = [];
/**
- * @see \wcf\page\AbstractPage::$loginRequired
+ * @inheritDoc
*/
public $loginRequired = true;
/**
- * @see \wcf\page\AbstractPage::$neededPermissions
+ * @inheritDoc
*/
- public $neededPermissions = array('mod.general.canUseModeration');
+ public $neededPermissions = ['mod.general.canUseModeration'];
/**
* moderation queue object
- * @var \wcf\data\moderation\queue\ViewableModerationQueue
+ * @var ViewableModerationQueue
*/
public $queue = null;
/**
* comment manager object
- * @var \wcf\system\comment\manager\ICommentManager
+ * @var ICommentManager
*/
public $commentManager = null;
/**
* list of comments
- * @var \wcf\data\comment\StructuredCommentList
+ * @var StructuredCommentList
*/
public $commentList = null;
/**
- * @see \wcf\page\IPage::readParameters()
+ * @inheritDoc
*/
public function readParameters() {
parent::readParameters();
}
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
parent::readData();
// update queue visit
if ($this->queue->isNew()) {
- $action = new ModerationQueueAction(array($this->queue->getDecoratedObject()), 'markAsRead', array(
+ $action = new ModerationQueueAction([$this->queue->getDecoratedObject()], 'markAsRead', [
'visitTime' => TIME_NOW
- ));
+ ]);
$action->executeAction();
}
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'assignedUserID' => $this->assignedUserID,
'queue' => $this->queue,
'queueID' => $this->queueID,
'lastCommentTime' => ($this->commentList ? $this->commentList->getMinCommentTime() : 0),
'sidebarCollapsed' => UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'com.woltlab.wcf.ModerationForm'),
'sidebarName' => 'com.woltlab.wcf.ModerationForm'
- ));
+ ]);
}
/**
<?php
namespace wcf\system\captcha;
+use wcf\data\object\type\ObjectType;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
* Handles captchas.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.captcha
* @category Community Framework
*/
class CaptchaHandler extends SingletonFactory {
+ /**
+ * available captcha object types
+ * @var ObjectType[]
+ */
+ protected $objectTypes = [];
+
/**
* Returns the available captcha types for selection.
*
- * @return array<string>
+ * @return string[]
*/
public function getCaptchaSelection() {
$selection = array();
* object type exists.
*
* @param integer $objectTypeID
- * @return \wcf\data\object\type\ObjectType
+ * @return ObjectType|null
*/
public function getObjectType($objectTypeID) {
if (isset($this->objectTypes[$objectTypeID])) {
* object type exists.
*
* @param string $objectType
- * @return \wcf\data\object\type\ObjectType
+ * @return ObjectType|null
*/
public function getObjectTypeByName($objectType) {
return ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.captcha', $objectType);
}
/**
- * @see \wcf\system\SingletonFactory::init()
+ * @inheritDoc
*/
protected function init() {
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.captcha');
<?php
namespace wcf\system\captcha;
+use wcf\data\captcha\question\CaptchaQuestion;
use wcf\system\cache\builder\CaptchaQuestionCacheBuilder;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
* Captcha handler for captcha questions.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.captcha
/**
* captcha question to answer
- * @var \wcf\data\captcha\question\CaptchaQuestion
+ * @var CaptchaQuestion
*/
protected $question = null;
+ /**
+ * list of available captcha questions
+ * @var CaptchaQuestion[]
+ */
+ protected $questions = [];
+
/**
* Creates a new instance of CaptchaQuestionHandler.
*/
}
/**
- * @see \wcf\system\captcha\ICaptchaHandler::isAvailable()
+ * @inheritDoc
*/
public function isAvailable() {
return count($this->questions) > 0;
}
/**
- * @see \wcf\system\captcha\ICaptchaHandler::getFormElement()
+ * @inheritDoc
*/
public function getFormElement() {
if ($this->question === null) {
$this->readCaptchaQuestion();
}
- return WCF::getTPL()->fetch('captchaQuestion', 'wcf', array(
+ return WCF::getTPL()->fetch('captchaQuestion', 'wcf', [
'captchaQuestion' => $this->captchaQuestion,
'captchaQuestionAnswered' => WCF::getSession()->getVar('captchaQuestionSolved_'.$this->captchaQuestion) !== null,
'captchaQuestionObject' => $this->question
- ));
+ ]);
}
/**
- * @see \wcf\system\captcha\ICaptchaHandler::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST['captchaQuestion'])) $this->captchaQuestion = StringUtil::trim($_POST['captchaQuestion']);
}
/**
- * @see \wcf\system\captcha\ICaptchaHandler::reset()
+ * @inheritDoc
*/
public function reset() {
WCF::getSession()->unregister('captchaQuestion_'.$this->captchaQuestion);
}
/**
- * @see \wcf\system\captcha\ICaptchaHandler::validate()
+ * @inheritDoc
*/
public function validate() {
$questionID = WCF::getSession()->getVar('captchaQuestion_'.$this->captchaQuestion);
* Initializes the argument parser.
*/
public function __construct() {
- $this->argv = new ArgvParser(array());
+ $this->argv = new ArgvParser([]);
}
/**
$file = $archive->downloadArchive();
}
catch (SystemException $e) {
- $this->error('notFound', array('file' => $file));
+ $this->error('notFound', ['file' => $file]);
}
}
else {
// probably local path
if (!file_exists($file)) {
- $this->error('notFound', array('file' => $file));
+ $this->error('notFound', ['file' => $file]);
}
$archive = new PackageArchive($file, null);
$errors = PackageInstallationDispatcher::validatePHPRequirements($archive->getPhpRequirements());
if (!empty($errors)) {
// TODO: Nice output
- $this->error('phpRequirements', array('errors' => $errors));
+ $this->error('phpRequirements', ['errors' => $errors]);
}
// try to find existing package
FROM wcf".WCF_N."_package
WHERE package = ?";
$statement = CLIWCF::getDB()->prepareStatement($sql);
- $statement->execute(array($archive->getPackageInfo('name')));
+ $statement->execute([$archive->getPackageInfo('name')]);
$row = $statement->fetchArray();
$package = null;
if ($row !== false) {
// check update or install support
if ($package !== null) {
- CLIWCF::getSession()->checkPermissions(array('admin.configuration.package.canUpdatePackage'));
+ CLIWCF::getSession()->checkPermissions(['admin.configuration.package.canUpdatePackage']);
$archive->setPackage($package);
if (!$archive->isValidUpdate()) {
}
}
else {
- CLIWCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage'));
+ CLIWCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
if (!$archive->isValidInstall()) {
$this->error('noValidInstall');
else if ($archive->isAlreadyInstalled()) {
$this->error('uniqueAlreadyInstalled');
}
- else if ($archive->getPackageInfo('isApplication') && $this->archive->hasUniqueAbbreviation()) {
+ else if ($archive->getPackageInfo('isApplication') && $archive->hasUniqueAbbreviation()) {
$this->error('noUniqueAbbrevation');
}
}
$processNo = PackageInstallationQueue::getNewProcessNo();
// insert queue
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'processNo' => $processNo,
'userID' => CLIWCF::getUser()->userID,
'package' => $archive->getPackageInfo('name'),
'packageID' => ($package !== null) ? $package->packageID : null,
'archive' => $file,
'action' => ($package !== null ? 'update' : 'install')
- ));
+ ]);
// PackageInstallationDispatcher::openQueue()
$parentQueueID = 0;
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID = ?", array(CLIWCF::getUser()->userID));
- $conditions->add("parentQueueID = ?", array($parentQueueID));
- if ($processNo != 0) $conditions->add("processNo = ?", array($processNo));
- $conditions->add("done = ?", array(0));
+ $conditions->add("userID = ?", [CLIWCF::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
$excludingPackages = $packageInstallationDispatcher->getArchive()->getConflictedExcludingPackages();
$excludedPackages = $packageInstallationDispatcher->getArchive()->getConflictedExcludedPackages();
if (!($missingPackages == 0 && count($excludingPackages) == 0 && count($excludedPackages) == 0)) {
- $this->error('missingPackagesOrExclude', array(
+ $this->error('missingPackagesOrExclude', [
'requirements' => $requirements,
'excludingPackages' => $excludingPackages,
'excludedPackages' => $excludedPackages
- ));
+ ]);
return;
}
$node = '';
// initialize progressbar
- $progressbar = new ProgressBar(new ConsoleProgressBar(array(
+ $progressbar = new ProgressBar(new ConsoleProgressBar([
'width' => CLIWCF::getTerminal()->getWidth(),
- 'elements' => array(
+ 'elements' => [
ConsoleProgressBar::ELEMENT_PERCENT,
ConsoleProgressBar::ELEMENT_BAR,
ConsoleProgressBar::ELEMENT_TEXT
- ),
+ ],
'textWidth' => min(floor(CLIWCF::getTerminal()->getWidth() / 2), 50)
- )));
+ ]));
// InstallPackageAction::readParameters()
$finished = false;
$processNo = PackageInstallationQueue::getNewProcessNo();
// create queue
- $queue = PackageInstallationQueueEditor::create(array(
+ $queue = PackageInstallationQueueEditor::create([
'processNo' => $processNo,
'userID' => CLIWCF::getUser()->userID,
'packageName' => $package->getName(),
'packageID' => $package->packageID,
'action' => 'uninstall'
- ));
+ ]);
// initialize uninstallation
$installation = new PackageUninstallationDispatcher($queue);
$installation->nodeBuilder->purgeNodes();
$installation->nodeBuilder->buildNodes();
- CLIWCF::getTPL()->assign(array(
+ CLIWCF::getTPL()->assign([
'queue' => $queue
- ));
+ ]);
$queueID = $installation->nodeBuilder->getQueueByNode($queue->processNo, $installation->nodeBuilder->getNextNode());
$step = 'uninstall';
$progress = 0;
// initialize progressbar
- $progressbar = new ProgressBar(new ConsoleProgressBar(array(
+ $progressbar = new ProgressBar(new ConsoleProgressBar([
'width' => CLIWCF::getTerminal()->getWidth(),
- 'elements' => array(
+ 'elements' => [
ConsoleProgressBar::ELEMENT_PERCENT,
ConsoleProgressBar::ELEMENT_BAR,
ConsoleProgressBar::ELEMENT_TEXT
- ),
+ ],
'textWidth' => min(floor(CLIWCF::getTerminal()->getWidth() / 2), 50)
- )));
+ ]));
// InstallPackageAction::readParameters()
$finished = false;
* @param string $name
* @param array $parameters
*/
- public function error($name, array $parameters = array()) {
+ public function error($name, array $parameters = []) {
Log::error('package.'.$name.':'.JSON::encode($parameters));
if ($parameters) {
$statement->execute(array(
base64_encode(serialize($document)),
$queue->queueID,
- $document->formName
+ $document->formName // TODO: FormDocument::$formName does not exist, FormDocument::getName()?
));
}