2018-12-14 20:25:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
App::uses('AppModel', 'Model');
|
|
|
|
|
|
|
|
class TagCollection extends AppModel
|
|
|
|
{
|
|
|
|
public $useTable = 'tag_collections';
|
|
|
|
|
|
|
|
public $displayField = 'name';
|
|
|
|
|
|
|
|
public $actsAs = array(
|
|
|
|
'Trim',
|
|
|
|
'SysLogLogable.SysLogLogable' => array(
|
|
|
|
'roleModel' => 'Role',
|
|
|
|
'roleKey' => 'role_id',
|
|
|
|
'change' => 'full'
|
2018-12-20 21:48:04 +01:00
|
|
|
),
|
|
|
|
'Containable'
|
|
|
|
);
|
|
|
|
|
|
|
|
public $hasMany = array(
|
|
|
|
'TagCollectionElement' => array(
|
|
|
|
'dependent' => true
|
|
|
|
)
|
2018-12-14 20:25:38 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
public $whitelistedItems = false;
|
|
|
|
|
|
|
|
public $validate = array(
|
|
|
|
'name' => array(
|
|
|
|
'valueNotEmpty' => array(
|
|
|
|
'rule' => array('valueNotEmpty'),
|
|
|
|
),
|
|
|
|
'unique' => array(
|
|
|
|
'rule' => 'isUnique',
|
|
|
|
'message' => 'A similar name already exists.',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
2018-12-20 21:48:04 +01:00
|
|
|
|
|
|
|
public function beforeValidate($options = array())
|
|
|
|
{
|
|
|
|
parent::beforeValidate();
|
|
|
|
// generate UUID if it doesn't exist
|
|
|
|
if (empty($this->data['TagCollection']['uuid'])) {
|
|
|
|
$this->data['TagCollection']['uuid'] = CakeText::uuid();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-14 20:25:38 +01:00
|
|
|
}
|