Merge branch 'main' into develop

pull/85/head
iglocska 2022-01-17 09:25:31 +01:00
commit 9e2c29660d
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 14 additions and 9 deletions

View File

@ -46,10 +46,10 @@ class TagBehavior extends Behavior
$config = $this->getConfig(); $config = $this->getConfig();
$tagsAssoc = $config['tagsAssoc']; $tagsAssoc = $config['tagsAssoc'];
$taggedAssoc = $config['taggedAssoc']; $taggedAssoc = $config['taggedAssoc'];
$table = $this->_table; $table = $this->_table;
$tableAlias = $this->_table->getAlias(); $tableAlias = $this->_table->getAlias();
$assocConditions = ['Tagged.fk_model' => $tableAlias]; $assocConditions = ['Tagged.fk_model' => $tableAlias];
if (!$table->hasAssociation('Tagged')) { if (!$table->hasAssociation('Tagged')) {
@ -114,7 +114,6 @@ class TagBehavior extends Behavior
$property = $this->getConfig('tagsAssoc.propertyName'); $property = $this->getConfig('tagsAssoc.propertyName');
$options['accessibleFields'][$property] = true; $options['accessibleFields'][$property] = true;
$options['associated']['Tags']['accessibleFields']['id'] = true; $options['associated']['Tags']['accessibleFields']['id'] = true;
if (isset($data['tags'])) { if (isset($data['tags'])) {
if (!empty($data['tags'])) { if (!empty($data['tags'])) {
$data[$property] = $this->normalizeTags($data['tags']); $data[$property] = $this->normalizeTags($data['tags']);
@ -131,7 +130,6 @@ class TagBehavior extends Behavior
if (!$tag->isNew()) { if (!$tag->isNew()) {
continue; continue;
} }
$existingTag = $this->getExistingTag($tag->name); $existingTag = $this->getExistingTag($tag->name);
if (!$existingTag) { if (!$existingTag) {
continue; continue;
@ -176,15 +174,14 @@ class TagBehavior extends Behavior
$result[] = array_merge($common, ['id' => $existingTag->id]); $result[] = array_merge($common, ['id' => $existingTag->id]);
continue; continue;
} }
$result[] = array_merge( $result[] = array_merge(
$common, $common,
[ [
'name' => $tagIdentifier, 'name' => $tagIdentifier,
'colour' => '#924da6'
] ]
); );
} }
return $result; return $result;
} }
@ -312,7 +309,7 @@ class TagBehavior extends Behavior
$key = 'Tags.' . $finderField; $key = 'Tags.' . $finderField;
$taggedAlias = 'Tagged'; $taggedAlias = 'Tagged';
$foreignKey = $this->getConfig('tagsAssoc.foreignKey'); $foreignKey = $this->getConfig('tagsAssoc.foreignKey');
if (!empty($filterValue['AND'])) { if (!empty($filterValue['AND'])) {
$subQuery = $this->buildQuerySnippet($filterValue['AND'], $finderField, $OperatorAND); $subQuery = $this->buildQuerySnippet($filterValue['AND'], $finderField, $OperatorAND);
$modelAlias = $this->_table->getAlias(); $modelAlias = $this->_table->getAlias();
@ -352,4 +349,4 @@ class TagBehavior extends Behavior
return $query; return $query;
} }
} }

View File

@ -97,8 +97,16 @@ class UsersController extends AppController
public function edit($id = false) public function edit($id = false)
{ {
$currentUser = $this->ACL->getUser(); $currentUser = $this->ACL->getUser();
if (empty($id) || (empty($currentUser['role']['perm_org_admin']) && empty($currentUser['role']['perm_admin']))) { if (empty($id)) {
$id = $currentUser['id']; $id = $currentUser['id'];
} else {
if ((empty($currentUser['role']['perm_org_admin']) && empty($currentUser['role']['perm_admin']))) {
if ($id !== $currentUser['id']) {
throw new MethodNotAllowedException(__('You are not authorised to edit that user.'));
} else {
$id = $currentUser['id'];
}
}
} }
$params = [ $params = [