All three types are either complex objects or have data or implicit properties associated with them which are not alterable through the ACP. For example user-created menu items will be assigned a generic name which cannot be used as a replacement for pre-defined items with a specific name (e.g. highliting the active menu item).
In order to prevent users from accidentially breaking stuff, we disallow deletion. In return all three types support disabling of items, therefore they can be safely turned off which in return results in the same behavior compared to deleting them.
<td class="columnIcon">
<span class="icon icon16 icon-check{if $bbcode->isDisabled}-empty{/if} jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $bbcode->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$bbcode->bbcodeID}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}"></span>
<a href="{link controller='BBCodeEdit' object=$bbcode}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 icon-pencil"></span></a>
- <span class="icon icon16 icon-remove jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$bbcode->bbcodeID}" data-confirm-message="{lang}wcf.acp.bbcode.delete.sure{/lang}"></span>
+ {if $bbcode->canDelete()}
+ <span class="icon icon16 icon-remove jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$bbcode->bbcodeID}" data-confirm-message="{lang}wcf.acp.bbcode.delete.sure{/lang}"></span>
+ {else}
+ <span class="icon icon16 fa-times disabled"></span>
+ {/if}
{event name='rowButtons'}
</td>
<td class="columnIcon">
<span class="icon icon16 icon-check{if $option->isDisabled}-empty{/if} jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $option->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$option->optionID}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}"></span>
<a href="{link controller='UserOptionEdit' id=$option->optionID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 icon-pencil"></span></a>
- <span class="icon icon16 icon-remove jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$option->optionID}" data-confirm-message="{lang}wcf.acp.user.option.delete.sure{/lang}"></span>
+ {if $option->canDelete()}
+ <span class="icon icon16 icon-remove jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$option->optionID}" data-confirm-message="{lang}wcf.acp.user.option.delete.sure{/lang}"></span>
+ {else}
+ <span class="icon icon16 fa-times disabled"></span>
+ {/if}
{event name='rowButtons'}
</td>
return in_array($bbcodeTag, $allowedBBCodeTags);
}
+
+ /**
+ * Returns true if this BBCode can be deleted.
+ *
+ * @return boolean
+ */
+ public function canDelete() {
+ if ($this->originIsSystem) {
+ return false;
+ }
+
+ return true;
+ }
}
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\IToggleAction;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\PermissionDeniedException;
use wcf\system\WCF;
/**
return $bbCode;
}
+ /**
+ * @see \wcf\data\AbstractDatabaseObjectAction::validateDelete()
+ */
+ public function validateDelete() {
+ parent::validateDelete();
+
+ foreach ($this->objects as $bbcode) {
+ if (!$bbcode->canDelete()) {
+ throw new PermissionDeniedException();
+ }
+ }
+ }
+
/**
* @see \wcf\data\IToggleAction::validateToggle()
*/
* @return boolean
*/
public function canDelete() {
- return ($this->isLandingPage ? false : true);
+ if ($this->originIsSystem || $this->isLandingPage) {
+ return false;
+ }
+
+ return true;
}
/**
}
}
+ /**
+ * @see \wcf\data\AbstractDatabaseObjectAction::validateDelete()
+ */
+ public function validateDelete() {
+ parent::validateDelete();
+
+ foreach ($this->objects as $pageMenuItem) {
+ if (!$pageMenuItem->canDelete()) {
+ throw new PermissionDeniedException();
+ }
+ }
+ }
+
/**
* @see \wcf\data\IToggleAction::validateToggle()
*/
return false;
}
+
+ /**
+ * Returns true if this user option can be deleted.
+ *
+ * @return boolean
+ */
+ public function canDelete() {
+ if ($this->originIsSystem) {
+ return false;
+ }
+
+ return true;
+ }
}
namespace wcf\data\user\option;
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\IToggleAction;
+use wcf\system\exception\PermissionDeniedException;
/**
* Executes user option-related actions.
*/
protected $requireACP = array('create', 'delete', 'toggle', 'update');
+ /**
+ * @see \wcf\data\AbstractDatabaseObjectAction::validateDelete()
+ */
+ public function validateDelete() {
+ parent::validateDelete();
+
+ foreach ($this->objects as $userOption) {
+ if (!$userOption->canDelete()) {
+ throw new PermissionDeniedException();
+ }
+ }
+ }
+
/**
* @see \wcf\data\IToggleAction::toggle()
*/
'attributes' => (isset($data['elements']['attributes']) ? $data['elements']['attributes'] : array()),
'className' => (!empty($data['elements']['classname']) ? $data['elements']['classname'] : ''),
'isSourceCode' => (!empty($data['elements']['sourcecode']) ? 1 : 0),
- 'buttonLabel' => (isset($data['elements']['buttonlabel']) ? $data['elements']['buttonlabel'] : '')
+ 'buttonLabel' => (isset($data['elements']['buttonlabel']) ? $data['elements']['buttonlabel'] : ''),
+ 'originIsSystem' => 1
);
if ($data['wysiwygIcon'] && $data['buttonLabel']) {
throw new SystemException("Menu item '".$result['menuItem']."' neither has a link nor a controller given");
}
+ $result['originIsSystem'] = 1;
+
return $result;
}
'isDisabled' => $isDisabled,
'permissions' => $permissions,
'options' => $options,
- 'additionalData' => serialize($additionalData)
+ 'additionalData' => serialize($additionalData),
+ 'originIsSystem' => 1
);
// update option
isSourceCode TINYINT(1) NOT NULL DEFAULT 0,
isDisabled TINYINT(1) NOT NULL DEFAULT 0,
showButton TINYINT(1) NOT NULL DEFAULT 0,
+ originIsSystem TINYINT(1) NOT NULL DEFAULT 0,
UNIQUE KEY bbcodeTag (bbcodeTag)
);
isDisabled TINYINT(1) NOT NULL DEFAULT 0,
className VARCHAR(255) NOT NULL DEFAULT '',
isLandingPage TINYINT(1) NOT NULL DEFAULT 0,
+ originIsSystem TINYINT(1) NOT NULL DEFAULT 0,
UNIQUE KEY (packageID, menuItem)
);
permissions TEXT,
options TEXT,
additionalData MEDIUMTEXT,
+ originIsSystem TINYINT(1) NOT NULL DEFAULT 0,
UNIQUE KEY optionName (optionName, packageID),
KEY categoryName (categoryName)
);