Permalink
Browse files

[#4830] Prevent removal of Content Types that are in use

  • Loading branch information...
Shaun McCormick
Shaun McCormick committed Oct 14, 2011
1 parent 79506e2 commit a61aa2db8b02fcbf99545578561cf65e5c78cc8f
@@ -2,6 +2,7 @@
This file shows the changes in recent releases of MODX. The most current release is usually the
development release, and is only shown to give an idea of what's currently in the pipeline.
- [#4830] Prevent removal of Content Types that are in use
- [#5293] Prevent drag/drop from Resource Group tree to Resource tree in Resource Group page
- [#4433] Validate paths in setup for trailing slash
- [#564], [#4506] Make Workspace path portable by allowing path setting replacements
@@ -15,6 +15,7 @@
$_lang['content_type_err_ns'] = 'Content Type not specified.';
$_lang['content_type_err_ns_name'] = 'Please specify a valid name for the Content Type.';
$_lang['content_type_err_create'] = 'An error occurred while trying to create the Content Type.';
$_lang['content_type_err_in_use'] = 'You cannot remove this Content Type, as it is currently in use by Resources in MODX. Please re-assign the Content Types of those Resources before proceeding.';
$_lang['content_type_err_remove'] = 'An error occurred while trying to remove the Content Type.';
$_lang['content_type_err_save'] = 'An error occurred while trying to save the Content Type.';
$_lang['content_type_new'] = 'New Content Type';
@@ -40,6 +40,10 @@ public function initialize() {
* @return mixed
*/
public function process() {
if ($this->isInUse()) {
return $this->failure($this->modx->lexicon('content_type_err_in_use'));
}
if ($this->contentType->remove() == false) {
return $this->failure($this->modx->lexicon('content_type_err_remove'));
}
@@ -48,6 +52,10 @@ public function process() {
return $this->success('',$this->contentType);
}
public function isInUse() {
return $this->modx->getCount('modResource',array('content_type' => $this->contentType->get('id'))) > 0;
}
/**
* @return void
*/

0 comments on commit a61aa2d

Please sign in to comment.