Merge pull request #3553 from oliverrahner/patch-1

Enable `$user:local_name$` placeholder in restrictions
This commit is contained in:
Johannes Meyer 2019-06-04 07:33:51 +02:00 committed by GitHub
commit 09090bcf9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -214,6 +214,16 @@ results of this query instead:
|
+--- 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>

View File

@ -252,6 +252,10 @@ class User
*/
public function setRestrictions(array $restrictions)
{
foreach ($restrictions as $name => $restriction) {
$restrictions[$name] = str_replace('$user:local_name$', $this->getLocalUsername(), $restriction);
}
$this->restrictions = $restrictions;
return $this;
}