From b3cec8b63656709ffdf7e8cb4e5423bd06d25206 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 12 Oct 2012 04:41:59 +0200 Subject: [PATCH] Added methods to enable/disable styles --- .../lib/data/style/StyleAction.class.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index 48f9d75c27..90555c5c5e 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -35,6 +35,11 @@ class StyleAction extends AbstractDatabaseObjectAction { */ protected $permissionsDelete = array('admin.style.canDeleteStyle'); + /** + * @see wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate + */ + protected $permissionsUpdate = array('admin.style.canEditStyle'); + /** * @see wcf\data\AbstractDatabaseObjectAction::create() */ @@ -423,4 +428,27 @@ class StyleAction extends AbstractDatabaseObjectAction { 'redirectURL' => LinkHandler::getInstance()->getLink('StyleEdit', array('id' => $newStyle->styleID)) ); } + + /** + * Validates parameters to enable/disable styles. + */ + public function validateToggle() { + parent::validateUpdate(); + + foreach ($this->objects as $style) { + if ($style->isDefault) { + throw new UserInputException('objectIDs'); + } + } + } + + /** + * Enables/disables styles. + */ + public function toggle() { + foreach ($this->objects as $style) { + $disabled = ($style->disabled) ? 0 : 1; + $style->update(array('disabled' => $disabled)); + } + } } -- 2.20.1