|
44 | 44 | use CommonTreeDropdown; |
45 | 45 | use ITILCategory; |
46 | 46 | use Entity; |
| 47 | +use Profile_User; |
47 | 48 | use User; |
48 | 49 | use Group; |
49 | 50 | use Group_Ticket; |
@@ -250,6 +251,38 @@ public function buildParams($rand = null) { |
250 | 251 |
|
251 | 252 | case User::class: |
252 | 253 | $dparams['right'] = 'all'; |
| 254 | + $currentEntity = Session::getActiveEntity(); |
| 255 | + $ancestorEntities = getAncestorsOf(Entity::getTable(), $currentEntity); |
| 256 | + switch ($decodedValues['entity_restrict']) { |
| 257 | + case self::ENTITY_RESTRICT_FORM: |
| 258 | + $form = new PluginFormcreatorForm(); |
| 259 | + $form->getFromDBByQuestion($this->getQuestion()); |
| 260 | + $currentEntity = $form->fields['entities_id']; |
| 261 | + $ancestorEntities = getAncestorsOf(Entity::getTable(), $currentEntity); |
| 262 | + break; |
| 263 | + |
| 264 | + case self::ENTITY_RESTRICT_BOTH: |
| 265 | + $form = new PluginFormcreatorForm(); |
| 266 | + $form->getFromDBByQuestion($this->getQuestion()); |
| 267 | + $currentEntity = [$currentEntity, $form->fields['entities_id']]; |
| 268 | + $ancestorEntities = array_merge($ancestorEntities, getAncestorsOf(Entity::getTable(), $currentEntity)); |
| 269 | + break; |
| 270 | + } |
| 271 | + $where = ['OR' => []]; |
| 272 | + $where['OR'][] = ['entities_id' => $currentEntity]; |
| 273 | + if (count($ancestorEntities) > 0) { |
| 274 | + $where['OR'][] = [ |
| 275 | + 'entities_id' => $ancestorEntities, |
| 276 | + 'is_recursive' => '1', |
| 277 | + ]; |
| 278 | + } |
| 279 | + $dparams_cond_crit = [ |
| 280 | + 'id' => new QuerySubQuery([ |
| 281 | + 'SELECT' => 'users_id', |
| 282 | + 'FROM' => Profile_User::getTable(), |
| 283 | + 'WHERE' => $where, |
| 284 | + ]) |
| 285 | + ]; |
253 | 286 | break; |
254 | 287 |
|
255 | 288 | case ITILCategory::class: |
|
0 commit comments