2020-07-13 11:14:56 +02:00
|
|
|
<?php
|
|
|
|
App::uses('AppModel', 'Model');
|
2022-11-17 15:33:52 +01:00
|
|
|
|
2020-07-13 11:14:56 +02:00
|
|
|
class GalaxyClusterBlocklist extends AppModel
|
|
|
|
{
|
|
|
|
public $useTable = 'galaxy_cluster_blocklists';
|
|
|
|
|
|
|
|
public $recursive = -1;
|
|
|
|
|
|
|
|
public $actsAs = array(
|
2021-01-22 13:01:23 +01:00
|
|
|
'AuditLog',
|
2020-07-31 15:07:24 +02:00
|
|
|
'SysLogLogable.SysLogLogable' => array( // TODO Audit, logable
|
|
|
|
'userModel' => 'User',
|
|
|
|
'userKey' => 'user_id',
|
|
|
|
'change' => 'full'
|
|
|
|
),
|
|
|
|
'Containable',
|
2020-07-13 11:14:56 +02:00
|
|
|
);
|
|
|
|
|
2020-09-22 14:02:44 +02:00
|
|
|
public $blocklistFields = array('cluster_uuid', 'comment', 'cluster_info', 'cluster_orgc');
|
2020-09-22 14:42:44 +02:00
|
|
|
public $blocklistTarget = 'cluster';
|
2020-07-13 11:14:56 +02:00
|
|
|
|
|
|
|
public $validate = array(
|
2020-07-31 15:07:24 +02:00
|
|
|
'cluster_uuid' => array(
|
|
|
|
'unique' => array(
|
2022-11-17 15:33:52 +01:00
|
|
|
'rule' => 'isUnique',
|
|
|
|
'message' => 'Galaxy Cluster already blocklisted.'
|
2020-07-31 15:07:24 +02:00
|
|
|
),
|
|
|
|
'uuid' => array(
|
2022-11-17 15:33:52 +01:00
|
|
|
'rule' => array('uuid'),
|
|
|
|
'message' => 'Please provide a valid UUID'
|
2020-07-31 15:07:24 +02:00
|
|
|
),
|
|
|
|
)
|
2020-07-13 11:14:56 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
public function beforeValidate($options = array())
|
|
|
|
{
|
|
|
|
parent::beforeValidate();
|
|
|
|
if (empty($this->data['GalaxyClusterBlocklist']['id'])) {
|
2022-11-17 15:33:52 +01:00
|
|
|
$this->data['GalaxyClusterBlocklist']['date_created'] = date('Y-m-d H:i:s');
|
2020-07-13 11:14:56 +02:00
|
|
|
}
|
|
|
|
if (empty($this->data['GalaxyClusterBlocklist']['comment'])) {
|
|
|
|
$this->data['GalaxyClusterBlocklist']['comment'] = '';
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2020-07-13 16:48:14 +02:00
|
|
|
|
2022-11-17 15:33:52 +01:00
|
|
|
/**
|
|
|
|
* @param string $clusterUUID
|
|
|
|
* @return bool
|
|
|
|
*/
|
2020-07-13 16:48:14 +02:00
|
|
|
public function checkIfBlocked($clusterUUID)
|
|
|
|
{
|
2022-11-17 15:33:52 +01:00
|
|
|
return $this->hasAny([
|
|
|
|
'cluster_uuid' => $clusterUUID,
|
|
|
|
]);
|
2020-07-13 16:48:14 +02:00
|
|
|
}
|
2020-07-13 11:14:56 +02:00
|
|
|
}
|