mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Merge pull request #3553 from oliverrahner/patch-1
Enable `$user:local_name$` placeholder in restrictions
This commit is contained in:
commit
09090bcf9f
@ -214,6 +214,16 @@ results of this query instead:
|
|||||||
|
|
|
|
||||||
+--- service_handled = 0
|
+--- service_handled = 0
|
||||||
|
|
||||||
|
#### Username placeholder <a id="username-placeholder"></a>
|
||||||
|
|
||||||
|
The string `$user:local_name$` is replaced by the local username (without the domain part) of the logged on user while evaluating restrictions.
|
||||||
|
This can come in handy if you have some kind of attribute on host or service level defining which user is responsible for a certain host or service.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```
|
||||||
|
monitoring/filter/objects = (_responsible=$user:local_name$|_deputy=$user:local_name$)
|
||||||
|
```
|
||||||
|
|
||||||
#### Stacking Filters <a id="stacking-filters"></a>
|
#### Stacking Filters <a id="stacking-filters"></a>
|
||||||
|
|
||||||
|
@ -252,6 +252,10 @@ class User
|
|||||||
*/
|
*/
|
||||||
public function setRestrictions(array $restrictions)
|
public function setRestrictions(array $restrictions)
|
||||||
{
|
{
|
||||||
|
foreach ($restrictions as $name => $restriction) {
|
||||||
|
$restrictions[$name] = str_replace('$user:local_name$', $this->getLocalUsername(), $restriction);
|
||||||
|
}
|
||||||
|
|
||||||
$this->restrictions = $restrictions;
|
$this->restrictions = $restrictions;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user