From: Alexander Ebert Date: Fri, 12 Oct 2012 02:41:59 +0000 (+0200) Subject: Added methods to enable/disable styles X-Git-Tag: 2.0.0_Beta_1~904 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b3cec8b63656709ffdf7e8cb4e5423bd06d25206;p=GitHub%2FWoltLab%2FWCF.git Added methods to enable/disable styles --- 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)); + } + } }