Skip to content

Commit

Permalink
Prevent users without edit_locked permission from unlocking and editi…
Browse files Browse the repository at this point in the history
…ng locked elements [modxcms#14702]

3.x recreated version of modxcms#14739 to ease inclusion in 3.x
  • Loading branch information
Mark-H committed Sep 18, 2019
1 parent c249621 commit eb61559
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 10 additions & 6 deletions core/src/Revolution/Processors/Element/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ abstract class Update extends modObjectUpdateProcessor
/** @var modElement $object */
public $object;

public function beforeSet()
{
// Make sure the element isn't locked
if ($this->object->get('locked') && !$this->modx->hasPermission('edit_locked')) {
return $this->modx->lexicon($this->objectType.'_err_locked');
}
return parent::beforeSet();
}

public function beforeSave()
{
$locked = $this->getProperty('locked');
Expand All @@ -37,7 +46,7 @@ public function beforeSave()
}

/* make sure a name was specified */
$nameField = $this->classKey == modTemplate::class ? 'templatename' : 'name';
$nameField = $this->classKey === modTemplate::class ? 'templatename' : 'name';
$name = $this->getProperty($nameField, '');
if (empty($name)) {
$this->addFieldError($nameField, $this->modx->lexicon($this->objectType . '_err_ns_name'));
Expand All @@ -49,11 +58,6 @@ public function beforeSave()
}
}

/* if element is locked */
if ($this->object->get('locked') && $this->modx->hasPermission('edit_locked') == false) {
$this->addFieldError($nameField, $this->modx->lexicon($this->objectType . '_err_locked'));
}

/* category */
$category = $this->object->get('category');
$this->previousCategory = $category;
Expand Down
4 changes: 0 additions & 4 deletions manager/controllers/default/element/chunk/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ public function process(array $scriptProperties = array()) {
if (empty($this->chunk)) return $this->failure($this->modx->lexicon('chunk_err_nfs',array('id' => $scriptProperties['id'])));
if (!$this->chunk->checkPolicy('view')) return $this->failure($this->modx->lexicon('access_denied'));

if ($this->chunk->get('locked') && !$this->modx->hasPermission('edit_locked')) {
return $this->failure($this->modx->lexicon('chunk_err_locked'));
}

/* grab category for chunk, assign to parser */
$placeholders['chunk'] = $this->chunk;

Expand Down

0 comments on commit eb61559

Please sign in to comment.