use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
+use wcf\data\TDatabaseObjectToggle;
use wcf\system\condition\ConditionHandler;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
* @method AdEditor getSingleObject()
*/
class AdAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction {
+ use TDatabaseObjectToggle;
+
/**
* @inheritDoc
*/
return parent::delete();
}
- /**
- * @inheritDoc
- */
- public function toggle() {
- foreach ($this->getObjects() as $ad) {
- $ad->update([
- 'isDisabled' => $ad->isDisabled ? 0 : 1
- ]);
- }
- }
-
- /**
- * @inheritDoc
- */
- public function validateToggle() {
- parent::validateUpdate();
- }
-
/**
* @inheritDoc
*/
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
use wcf\data\IToggleContainerAction;
+use wcf\data\TDatabaseObjectToggle;
use wcf\system\category\CategoryHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\PermissionDeniedException;
* @method CategoryEditor getSingleObject()
*/
class CategoryAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction, IToggleContainerAction {
+ use TDatabaseObjectToggle;
+
/**
* categorized object type
* @var \wcf\data\object\type\ObjectType
return $returnValue;
}
- /**
- * @inheritDoc
- */
- public function toggle() {
- foreach ($this->getObjects() as $categoryEditor) {
- $categoryEditor->update([
- 'isDisabled' => 1 - $categoryEditor->isDisabled
- ]);
- }
- }
-
/**
* @inheritDoc
*/
}
}
- /**
- * @inheritDoc
- */
- public function validateToggle() {
- $this->validateUpdate();
- }
-
/**
* @inheritDoc
*/
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
+use wcf\data\TDatabaseObjectToggle;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
* @method ContactRecipientEditor getSingleObject()
*/
class ContactRecipientAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction {
+ use TDatabaseObjectToggle;
+
/**
* @inheritDoc
*/
}
}
- /**
- * @inheritDoc
- */
- public function toggle() {
- foreach ($this->getObjects() as $object) {
- $object->update([
- 'isDisabled' => $object->isDisabled ? 0 : 1
- ]);
- }
- }
-
/**
* @inheritDoc
*/
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
+use wcf\data\TDatabaseObjectToggle;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
* @method MenuItemEditor getSingleObject()
*/
class MenuItemAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction {
+ use TDatabaseObjectToggle;
+
/**
* @inheritDoc
*/
}
}
- /**
- * @inheritDoc
- */
- public function toggle() {
- foreach ($this->getObjects() as $object) {
- $object->update(['isDisabled' => $object->isDisabled ? 0 : 1]);
- }
- }
-
/**
* @inheritDoc
*/
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
+use wcf\data\TDatabaseObjectToggle;
use wcf\system\condition\ConditionHandler;
use wcf\system\exception\UserInputException;
use wcf\system\user\storage\UserStorageHandler;
* @method NoticeEditor getSingleObject()
*/
class NoticeAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction {
+ use TDatabaseObjectToggle;
+
/**
* @inheritDoc
*/
];
}
- /**
- * @inheritDoc
- */
- public function toggle() {
- foreach ($this->getObjects() as $notice) {
- $notice->update([
- 'isDisabled' => $notice->isDisabled ? 0 : 1
- ]);
- }
- }
-
/**
* Validates the 'dismiss' action.
*/
$this->getSingleObject();
}
- /**
- * @inheritDoc
- */
- public function validateToggle() {
- parent::validateUpdate();
- }
-
/**
* @inheritDoc
*/
use wcf\data\ISearchAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
+use wcf\data\TDatabaseObjectToggle;
use wcf\system\comment\CommentHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\PermissionDeniedException;
* @method PageEditor getSingleObject()
*/
class PageAction extends AbstractDatabaseObjectAction implements ISearchAction, ISortableAction, IToggleAction {
+ use TDatabaseObjectToggle;
+
/**
* @inheritDoc
*/
}
}
- /**
- * @inheritDoc
- */
- public function toggle() {
- foreach ($this->getObjects() as $object) {
- $object->update(['isDisabled' => $object->isDisabled ? 0 : 1]);
- }
- }
-
/**
* @inheritDoc
*/
<?php
namespace wcf\data\trophy;
+use wcf\data\TDatabaseObjectToggle;
use wcf\data\user\trophy\UserTrophyAction;
use wcf\data\user\trophy\UserTrophyList;
use wcf\data\user\UserAction;
* @method TrophyEditor getSingleObject()
*/
class TrophyAction extends AbstractDatabaseObjectAction implements IToggleAction, IUploadAction, ISortableAction {
+ use TDatabaseObjectToggle;
+
/**
* @inheritDoc
*/
$trophy->update(['isDisabled' => $trophy->isDisabled ? 0 : 1]);
if (!$trophy->isDisabled) {
-
$disabledTrophyIDs[] = $trophy->trophyID;
}
else {
UserStorageHandler::getInstance()->resetAll('specialTrophies');
}
- /**
- * @inheritDoc
- */
- public function validateToggle() {
- WCF::getSession()->checkPermissions(['admin.trophy.canManageTrophy']);
-
- // read objects
- if (empty($this->objects)) {
- $this->readObjects();
-
- if (empty($this->objects)) {
- throw new UserInputException('objectIDs');
- }
- }
- }
-
/**
* @inheritDoc
*/