chg: [addTag] functions changed to also work with uuids, rather than just local IDs

- as reported by @0x3c7
pull/9454/head
iglocska 2023-12-19 12:25:17 +01:00
parent 9fe416bb63
commit 8b4bb3b34a
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 16 additions and 3 deletions

View File

@ -2671,12 +2671,15 @@ class AttributesController extends AppController
$fails = 0;
$this->Taxonomy = ClassRegistry::init('Taxonomy');
foreach ($idList as $id) {
$conditions = $this->__idToConditions($id);
$conditions['Attribute.deleted'] = 0;
$attribute = $this->Attribute->fetchAttributeSimple($this->Auth->user(), [
'conditions' => array('Attribute.id' => $id, 'Attribute.deleted' => 0),
'conditions' => $conditions,
]);
if (empty($attribute)) {
throw new NotFoundException(__('Invalid attribute'));
}
$id = $attribute['Attribute']['id'];
if (!$this->__canModifyTag($attribute, $local)) {
$fails++;
continue;

View File

@ -3792,11 +3792,21 @@ class EventsController extends AppController
if ($id === false) {
$id = $this->request->data['event'];
}
$this->Event->recursive = -1;
$event = $this->Event->read(array(), $id);
$conditions = ['Event.id' => $id];
if (Validation::uuid($id)) {
$conditions = ['Event.uuid' => $id];
}
$event = $this->Event->find(
'first',
[
'recursive' => -1,
'conditions' => $conditions
]
);
if (empty($event)) {
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => 'Invalid event.')), 'status'=>200, 'type' => 'json'));
}
$id = $event['Event']['id'];
$local = !empty($this->params['named']['local']);
if (!$this->request->is('post')) {
$this->set('local', $local);