### 2.2.0 Alpha 1 (XXXX-YY-ZZ)
* `permissions` and `options` support for event listeners.
+* `permissions` and `options` support for template listeners.
* `wcf\data\TDatabaseObjectOptions` and `wcf\data\TDatabaseObjectPermissions` for database object-bound options and permissions validation.
* `wcf\system\cache\builder\EventListenerCacheBuilder` returns `wcf\data\event\listener\EventListener` objects instead of data arrays.
$data[$templateListener->templateName] = array();
}
- $data[$templateListener->templateName][$templateListener->eventName][] = $templateListener->templateCode;
+ $templateCode = $templateListener->templateCode;
+ // wrap template listener code in if condition for options
+ // and permissions check
+ if ($templateListener->options || $templateListener->permissions) {
+ $templateCode = '{if ';
+
+ $options = $permissions = [ ];
+ if ($templateListener->options) {
+ $options = explode(',', strtoupper($templateListener->options));
+
+ array_walk($options, function(&$value, $key) {
+ $value = "('".$value."'|defined && '".$value."'|constant)";
+ });
+
+ $templateCode .= '('.implode(' || ', $options).')';
+ }
+ if ($templateListener->permissions) {
+ $permissions = explode(',', $templateListener->permissions);
+
+ array_walk($permissions, function(&$value, $key) {
+ $value = "\$__wcf->session->getPermission('".$value."')";
+ });
+
+ if (!empty($options)) {
+ $templateCode .= " && ";
+ }
+
+ $templateCode .= '('.implode(' || ', $permissions).')';
+ }
+
+ $templateCode .= '}'.$templateListener->templateCode.'{/if}';
+ }
+
+ $data[$templateListener->templateName][$templateListener->eventName][] = $templateCode;
}
return $data;
'eventName' => $data['elements']['eventname'],
'niceValue' => $niceValue,
'name' => $data['attributes']['name'],
+ 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''),
+ 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''),
'templateCode' => $data['elements']['templatecode'],
'templateName' => $data['elements']['templatename']
);
eventName VARCHAR(50) NOT NULL DEFAULT '',
templateCode TEXT NOT NULL,
niceValue TINYINT(3) NOT NULL DEFAULT 0,
+ permissions TEXT,
+ options TEXT,
+
KEY templateName (environment, templateName)
);