chg: [internal] Faster validating SG

pull/7824/head
Jakub Onderka 2021-10-10 11:58:37 +02:00
parent a7ea4bbc4d
commit 3af50e0770
1 changed files with 1 additions and 8 deletions

View File

@ -69,10 +69,8 @@ class SharingGroup extends AppModel
'access' => array()
);
public function beforeValidate($options = array())
{
parent::beforeValidate();
if (empty($this->data['SharingGroup']['uuid'])) {
$this->data['SharingGroup']['uuid'] = CakeText::uuid();
} else {
@ -86,12 +84,7 @@ class SharingGroup extends AppModel
$this->data['SharingGroup']['active'] = 0;
}
$this->data['SharingGroup']['modified'] = $date;
$sameNameSG = $this->find('first', array(
'conditions' => array('SharingGroup.name' => $this->data['SharingGroup']['name']),
'recursive' => -1,
'fields' => array('SharingGroup.name')
));
if (!empty($sameNameSG) && !isset($this->data['SharingGroup']['id'])) {
if (!isset($this->data['SharingGroup']['id']) && $this->hasAny(['SharingGroup.name' => $this->data['SharingGroup']['name']])) {
$this->data['SharingGroup']['name'] = $this->data['SharingGroup']['name'] . '_' . mt_rand(0, 9999);
}
return true;