*/
class UserAction extends AbstractDatabaseObjectAction implements IClipboardAction, ISearchAction {
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::$className
+ * @inheritDoc
*/
- public $className = 'wcf\data\user\UserEditor';
+ public $className = UserEditor::class;
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
+ * @inheritDoc
*/
- protected $allowGuestAccess = array('getSearchResultList');
+ protected $allowGuestAccess = ['getSearchResultList'];
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
+ * @inheritDoc
*/
- protected $permissionsCreate = array('admin.user.canAddUser');
+ protected $permissionsCreate = ['admin.user.canAddUser'];
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
+ * @inheritDoc
*/
- protected $permissionsDelete = array('admin.user.canDeleteUser');
+ protected $permissionsDelete = ['admin.user.canDeleteUser'];
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
+ * @inheritDoc
*/
- protected $permissionsUpdate = array('admin.user.canEditUser');
+ protected $permissionsUpdate = ['admin.user.canEditUser'];
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
+ * @inheritDoc
*/
- protected $requireACP = array('create', 'delete', 'disable', 'enable');
+ protected $requireACP = ['create', 'delete', 'disable', 'enable'];
/**
* Validates permissions and parameters.
// validate groups
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("userID IN (?)", array($this->objectIDs));
+ $conditions->add("userID IN (?)", [$this->objectIDs]);
$sql = "SELECT DISTINCT groupID
FROM wcf".WCF_N."_user_to_group
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
- $groupIDs = array();
+ $groupIDs = [];
while ($row = $statement->fetchArray()) {
$groupIDs[] = $row['groupID'];
}
}
/**
- * @see \wcf\data\IDeleteAction::delete()
+ * @inheritDoc
*/
public function delete() {
if (empty($this->objects)) {
}
// delete avatars
- $avatarIDs = array();
+ $avatarIDs = [];
foreach ($this->objects as $user) {
if ($user->avatarID) $avatarIDs[] = $user->avatarID;
}
* Validates the unban action.
*/
public function validateUnban() {
- WCF::getSession()->checkPermissions(array('admin.user.canBanUser'));
+ WCF::getSession()->checkPermissions(['admin.user.canBanUser']);
$this->__validateAccessibleGroups();
}
}
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('userID IN (?)', array($this->objectIDs));
+ $conditionBuilder->add('userID IN (?)', [$this->objectIDs]);
$sql = "UPDATE wcf".WCF_N."_user
SET banned = ?,
".$conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(
- array_merge(array(
+ array_merge([
1,
$this->parameters['banReason'],
$banExpires
- ), $conditionBuilder->getParameters())
+ ], $conditionBuilder->getParameters())
);
$this->unmarkItems();
*/
public function unban() {
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('userID IN (?)', array($this->objectIDs));
+ $conditionBuilder->add('userID IN (?)', [$this->objectIDs]);
$sql = "UPDATE wcf".WCF_N."_user
SET banned = ?,
".$conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(
- array_merge(array(
+ array_merge([
0,
0
- ), $conditionBuilder->getParameters())
+ ], $conditionBuilder->getParameters())
);
}
// insert user groups
$addDefaultGroups = (isset($this->parameters['addDefaultGroups'])) ? $this->parameters['addDefaultGroups'] : true;
- $groupIDs = (isset($this->parameters['groups'])) ? $this->parameters['groups'] : array();
+ $groupIDs = (isset($this->parameters['groups'])) ? $this->parameters['groups'] : [];
$userEditor->addToGroups($groupIDs, false, $addDefaultGroups);
// insert visible languages
if (!isset($this->parameters['languageIDs'])) {
// using the 'languages' key is deprecated since WCF 2.1, please use 'languageIDs' instead
- $this->parameters['languageIDs'] = (!empty($this->parameters['languages'])) ? $this->parameters['languages'] : array();
+ $this->parameters['languageIDs'] = (!empty($this->parameters['languages'])) ? $this->parameters['languages'] : [];
}
$userEditor->addToLanguages($this->parameters['languageIDs'], false);
FROM wcf".WCF_N."_user_notification_event
WHERE preset = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($user->userID, 1));
+ $statement->execute([$user->userID, 1]);
// update user rank
if (MODULE_USER_RANK) {
- $action = new UserProfileAction(array($userEditor), 'updateUserRank');
+ $action = new UserProfileAction([$userEditor], 'updateUserRank');
$action->executeAction();
}
// update user online marking
- $action = new UserProfileAction(array($userEditor), 'updateUserOnlineMarking');
+ $action = new UserProfileAction([$userEditor], 'updateUserOnlineMarking');
$action->executeAction();
}
}
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::update()
+ * @inheritDoc
*/
public function update() {
if (isset($this->parameters['data'])) {
}
}
- $groupIDs = (isset($this->parameters['groups'])) ? $this->parameters['groups'] : array();
- $languageIDs = (isset($this->parameters['languageIDs'])) ? $this->parameters['languageIDs'] : array();
- $removeGroups = (isset($this->parameters['removeGroups'])) ? $this->parameters['removeGroups'] : array();
- $userOptions = (isset($this->parameters['options'])) ? $this->parameters['options'] : array();
+ $groupIDs = (isset($this->parameters['groups'])) ? $this->parameters['groups'] : [];
+ $languageIDs = (isset($this->parameters['languageIDs'])) ? $this->parameters['languageIDs'] : [];
+ $removeGroups = (isset($this->parameters['removeGroups'])) ? $this->parameters['removeGroups'] : [];
+ $userOptions = (isset($this->parameters['options'])) ? $this->parameters['options'] : [];
if (!empty($groupIDs)) {
- $action = new UserAction($this->objects, 'addToGroups', array(
+ $action = new UserAction($this->objects, 'addToGroups', [
'groups' => $groupIDs,
'addDefaultGroups' => false
- ));
+ ]);
$action->executeAction();
}
if (!empty($removeGroups)) {
- $action = new UserAction($this->objects, 'removeFromGroups', array(
+ $action = new UserAction($this->objects, 'removeFromGroups', [
'groups' => $removeGroups
- ));
+ ]);
$action->executeAction();
}
SET username = ?
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($username, $userID));
+ $statement->execute([$username, $userID]);
+ // update comment responses
$sql = "UPDATE wcf".WCF_N."_comment_response
SET username = ?
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($username, $userID));
+ $statement->execute([$username, $userID]);
- // modification log
+ // update media
+ $sql = "UPDATE wcf".WCF_N."_media
+ SET username = ?
+ WHERE userID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$username, $userID]);
+
+ // update modification log
$sql = "UPDATE wcf".WCF_N."_modification_log
SET username = ?
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($username, $userID));
+ $statement->execute([$username, $userID]);
WCF::getDB()->commitTransaction();
}
//reread objects
- $this->objects = array();
+ $this->objects = [];
UserEditor::resetCache();
$this->readObjects();
}
//reread objects
- $this->objects = array();
+ $this->objects = [];
UserEditor::resetCache();
$this->readObjects();
}
/**
- * @see \wcf\data\ISearchAction::validateGetSearchResultList()
+ * @inheritDoc
*/
public function validateGetSearchResultList() {
$this->readBoolean('includeUserGroups', false, 'data');
}
/**
- * @see \wcf\data\ISearchAction::getSearchResultList()
+ * @inheritDoc
*/
public function getSearchResultList() {
$searchString = $this->parameters['data']['searchString'];
- $excludedSearchValues = array();
+ $excludedSearchValues = [];
if (isset($this->parameters['data']['excludedSearchValues'])) {
$excludedSearchValues = $this->parameters['data']['excludedSearchValues'];
}
- $list = array();
+ $list = [];
if ($this->parameters['data']['includeUserGroups']) {
$accessibleGroups = UserGroup::getAccessibleGroups();
if (!in_array($groupName, $excludedSearchValues)) {
$pos = mb_strripos($groupName, $searchString);
if ($pos !== false && $pos == 0) {
- $list[] = array(
+ $list[] = [
'label' => $groupName,
'objectID' => $group->groupID,
'type' => 'group'
- );
+ ];
}
}
}
// find users
$userProfileList = new UserProfileList();
- $userProfileList->getConditionBuilder()->add("username LIKE ?", array($searchString.'%'));
+ $userProfileList->getConditionBuilder()->add("username LIKE ?", [$searchString.'%']);
if (!empty($excludedSearchValues)) {
- $userProfileList->getConditionBuilder()->add("username NOT IN (?)", array($excludedSearchValues));
+ $userProfileList->getConditionBuilder()->add("username NOT IN (?)", [$excludedSearchValues]);
}
$userProfileList->sqlLimit = 10;
$userProfileList->readObjects();
foreach ($userProfileList as $userProfile) {
- $list[] = array(
+ $list[] = [
'icon' => $userProfile->getAvatar()->getImageTag(16),
'label' => $userProfile->username,
'objectID' => $userProfile->userID,
'type' => 'user'
- );
+ ];
}
return $list;
}
/**
- * @see \wcf\data\IClipboardAction::validateUnmarkAll()
+ * @inheritDoc
*/
public function validateUnmarkAll() {
// does nothing
}
/**
- * @see \wcf\data\IClipboardAction::unmarkAll()
+ * @inheritDoc
*/
public function unmarkAll() {
ClipboardHandler::getInstance()->removeItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user'));
/**
* Unmarks users.
*
- * @param array<integer> $userIDs
+ * @param integer[] $userIDs
*/
- protected function unmarkItems(array $userIDs = array()) {
+ protected function unmarkItems(array $userIDs = []) {
if (empty($userIDs)) {
$userIDs = $this->objectIDs;
}
* Validates the enable action.
*/
public function validateEnable() {
- WCF::getSession()->checkPermissions(array('admin.user.canEnableUser'));
+ WCF::getSession()->checkPermissions(['admin.user.canEnableUser']);
$this->__validateAccessibleGroups();
}
public function enable() {
if (empty($this->objects)) $this->readObjects();
- $action = new UserAction($this->objects, 'update', array(
- 'data' => array(
+ $action = new UserAction($this->objects, 'update', [
+ 'data' => [
'activationCode' => 0
- ),
- 'removeGroups' => UserGroup::getGroupIDsByType(array(UserGroup::GUESTS))
- ));
+ ],
+ 'removeGroups' => UserGroup::getGroupIDsByType([UserGroup::GUESTS])
+ ]);
$action->executeAction();
- $action = new UserAction($this->objects, 'addToGroups', array(
- 'groups' => UserGroup::getGroupIDsByType(array(UserGroup::USERS)),
+ $action = new UserAction($this->objects, 'addToGroups', [
+ 'groups' => UserGroup::getGroupIDsByType([UserGroup::USERS]),
'deleteOldGroups' => false,
'addDefaultGroups' => false
- ));
+ ]);
$action->executeAction();
// send e-mail notification
if (empty($this->parameters['skipNotification'])) {
foreach ($this->objects as $user) {
- $mail = new Mail(array($user->username => $user->email), $user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail.subject'), $user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail', array(
+ $mail = new Mail([$user->username => $user->email], $user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail.subject'), $user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail', [
'username' => $user->username
- )));
+ ]));
$mail->send();
}
}
public function disable() {
if (empty($this->objects)) $this->readObjects();
- $action = new UserAction($this->objects, 'update', array(
- 'data' => array(
+ $action = new UserAction($this->objects, 'update', [
+ 'data' => [
'activationCode' => UserRegistrationUtil::getActivationCode()
- ),
- 'removeGroups' => UserGroup::getGroupIDsByType(array(UserGroup::USERS)),
- ));
+ ],
+ 'removeGroups' => UserGroup::getGroupIDsByType([UserGroup::USERS]),
+ ]);
$action->executeAction();
- $action = new UserAction($this->objects, 'addToGroups', array(
- 'groups' => UserGroup::getGroupIDsByType(array(UserGroup::GUESTS)),
+ $action = new UserAction($this->objects, 'addToGroups', [
+ 'groups' => UserGroup::getGroupIDsByType([UserGroup::GUESTS]),
'deleteOldGroups' => false,
'addDefaultGroups' => false
- ));
+ ]);
$action->executeAction();
$this->unmarkItems();
}
/**
- * @see \wcf\data\AbstractDatabaseObjectAction::readObjects()
+ * @inheritDoc
*/
protected function readObjects() {
if (empty($this->objectIDs)) {
}
// get base class
- $baseClass = call_user_func(array($this->className, 'getBaseClass'));
+ $baseClass = call_user_func([$this->className, 'getBaseClass']);
// get objects
$sql = "SELECT user_option_value.*, user_table.*
}
foreach ($this->objects as $userEditor) {
- $userEditor->update(array(
+ $userEditor->update([
'disableSignature' => 1,
'disableSignatureReason' => $this->parameters['disableSignatureReason'],
'disableSignatureExpires' => $disableSignatureExpires
- ));
+ ]);
}
}
* Validates the 'enableSignature' action.
*/
public function validateEnableSignature() {
- WCF::getSession()->checkPermissions(array('admin.user.canDisableSignature'));
+ WCF::getSession()->checkPermissions(['admin.user.canDisableSignature']);
$this->__validateAccessibleGroups();
}
foreach ($this->objects as $userEditor) {
- $userEditor->update(array(
+ $userEditor->update([
'disableSignature' => 0
- ));
+ ]);
}
}
}
foreach ($this->objects as $userEditor) {
- $userEditor->update(array(
+ $userEditor->update([
'disableAvatar' => 1,
'disableAvatarReason' => $this->parameters['disableAvatarReason'],
'disableAvatarExpires' => $disableAvatarExpires
- ));
+ ]);
}
}
* Validates the 'enableAvatar' action.
*/
public function validateEnableAvatar() {
- WCF::getSession()->checkPermissions(array('admin.user.canDisableAvatar'));
+ WCF::getSession()->checkPermissions(['admin.user.canDisableAvatar']);
$this->__validateAccessibleGroups();
}
foreach ($this->objects as $userEditor) {
- $userEditor->update(array(
+ $userEditor->update([
'disableAvatar' => 0
- ));
+ ]);
}
}
/**
* Validates parameters to retrieve the social network privacy settings.
*/
- public function validateGetSocialNetworkPrivacySettings() { /* does nothing */ }
+ public function validateGetSocialNetworkPrivacySettings() {
+ // does nothing
+ }
/**
* Returns the social network privacy settings.
*
- * @return array<string>
+ * @return string[]
*/
public function getSocialNetworkPrivacySettings() {
$settings = @unserialize(WCF::getUser()->socialNetworkPrivacySettings);
if (!is_array($settings)) {
- $settings = array(
+ $settings = [
'facebook' => false,
'google' => false,
'reddit' => false,
'twitter' => false
- );
+ ];
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'settings' => $settings
- ));
+ ]);
- return array(
+ return [
'template' => WCF::getTPL()->fetch('shareButtonsPrivacySettings')
- );
+ ];
}
+ /**
+ * Validates the 'saveSocialNetworkPrivacySettings' action.
+ */
public function validateSaveSocialNetworkPrivacySettings() {
$this->readBoolean('facebook', true);
$this->readBoolean('google', true);
$this->readBoolean('twitter', true);
}
+ /**
+ * Saves the social network privacy settings.
+ *
+ * @return boolean[]
+ */
public function saveSocialNetworkPrivacySettings() {
- $settings = array(
+ $settings = [
'facebook' => $this->parameters['facebook'],
'google' => $this->parameters['google'],
'reddit' => $this->parameters['reddit'],
'twitter' => $this->parameters['twitter']
- );
+ ];
$userEditor = new UserEditor(WCF::getUser());
- $userEditor->update(array(
+ $userEditor->update([
'socialNetworkPrivacySettings' => serialize($settings)
- ));
+ ]);
- return array(
+ return [
'settings' => $settings
- );
+ ];
}
}