WoltLab/WCF — Issue #456: AbstractPage::$permissions
Author: Gravatronics
Created: 2012-02-27 14:20:19+00:00
State: open

**Suggestion**: Add a `$permissions`-property to the `AbstractPage` which stores permission values for the current user and is automatically assigned to the template.

**Use case**: Especially with the introduction of the ACL system checking permissions is more complex, especially in templates. Furthermore, static permission checks in templates like

```tpl
{if $__wcf->session->getPermission('admin.content.label.group.canAddLabelGroup')}
// do something
{/if}
```

don't allow plugins to alter them by adding an additional permission that is needed or a new permission that is sufficient to display something.

**Implementation**: The template code above would now be:

```tpl
{if $permissions['canAddLabelGroup']}
// do something
{/if}
```

while the class (in an own method?) sets that permission as:

```php
permissions['canAddLabelGroup'] = WCF::getSession()->getPermission('admin.content.label.group.canAddLabelGroup');
```

A plugin could then use an event listener and easily change that value (this case might not be the best example, but in other situations it might be handy):

```php
permissions['canAddLabelGroup'] = $eventObj->permissions['canAddLabelGroup'] || $someOtherNewPermissionValue;
```

If you think that's something that could be added, I could make a pull request with the implementation.