Skip to content

Commit

Permalink
Fix CC-481
Browse files Browse the repository at this point in the history
  • Loading branch information
aembler committed Nov 2, 2023
1 parent db69407 commit 0f05642
Showing 1 changed file with 22 additions and 7 deletions.
Expand Up @@ -31,10 +31,11 @@ public function add()
$vs = \Core::make('helper/validation/strings');

$name = $sec->sanitizeString($this->request->request->get('name'));
$handle = $sec->sanitizeString($this->request->request->get('handle'));
$handle = $this->request->request->get('handle');
$plural_handle = $this->request->request->get('plural_handle');

if (!$vs->handle($handle)) {
$this->error->add(t('You must create a handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
$this->error->add(t('You must create a valid handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
} else {
$entity = Express::getObjectByHandle($handle);
if (is_object($entity)) {
Expand All @@ -44,15 +45,19 @@ public function add()
}
}

if (!$vs->handle($plural_handle)) {
$this->error->add(t('You must create a valid plural handle for your data object. It may contain only lowercase letters and underscores.'), 'plural_handle');
}

if (!$name) {
$this->error->add(t('You must give your data object a name.'), 'name');
}

if (!$this->error->has()) {
$entity = new Entity();
$entity->setName($this->request->request->get('name'));
$entity->setHandle($this->request->request->get('handle'));
$entity->setPluralHandle($this->request->request->get('plural_handle'));
$entity->setHandle($handle);
$entity->setPluralHandle($plural_handle);
$entity->setLabelMask($this->request->request->get('label_mask'));
$entity->setDescription($this->request->request->get('description'));
$entity->setIsPublished(false);
Expand Down Expand Up @@ -330,10 +335,11 @@ public function update($id = null)
$vs = \Core::make('helper/validation/strings');

$name = $sec->sanitizeString($this->request->request->get('name'));
$handle = $sec->sanitizeString($this->request->request->get('handle'));
$handle = $this->request->request->get('handle');
$plural_handle = $this->request->request->get('plural_handle');

if (!$vs->handle($handle)) {
$this->error->add(t('You must create a handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
$this->error->add(t('You must create a valid handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
} else {
$exist = Express::getObjectByHandle($handle);
if (is_object($exist) && $exist->getID() != $id) {
Expand All @@ -343,6 +349,15 @@ public function update($id = null)
}
}

if (!$vs->handle($plural_handle)) {
$this->error->add(
t(
'You must create a valid plural handle for your data object. It may contain only lowercase letters and underscores.'
),
'plural_handle'
);
}

if (!$name) {
$this->error->add(t('You must give your data object a name.'), 'name');
}
Expand Down Expand Up @@ -379,7 +394,7 @@ public function update($id = null)
*/
$entity->setName($name);
$entity->setHandle($handle);
$entity->setPluralHandle($this->request->request->get('plural_handle'));
$entity->setPluralHandle($plural_handle);
$entity->setLabelMask($this->request->request->get('label_mask'));
$entity->setDescription($this->request->request->get('description'));
$entity->setDefaultViewForm($viewForm);
Expand Down

0 comments on commit 0f05642

Please sign in to comment.