<eventlistener>
<eventclassname>wcf\page\AbstractPage</eventclassname>
<eventname>readParameters</eventname>
+ <environment>admin</environment>
<inherit>1</inherit>
<listenerclassname>wcf\system\event\listener\SessionAccessLogListener</listenerclassname>
</eventlistener>
<eventlistener>
<eventclassname>wcf\form\AbstractForm</eventclassname>
<eventname>readParameters</eventname>
+ <environment>admin</environment>
<inherit>1</inherit>
<listenerclassname>wcf\system\event\listener\SessionAccessLogListener</listenerclassname>
</eventlistener>
<eventlistener>
<eventclassname>wcf\action\AbstractAction</eventclassname>
<eventname>readParameters</eventname>
+ <environment>admin</environment>
<inherit>1</inherit>
<listenerclassname>wcf\system\event\listener\SessionAccessLogListener</listenerclassname>
</eventlistener>
while ($row = $statement->fetchArray()) {
// distinguish between inherited actions and non-inherited actions
if (!$row['inherit']) {
- $data['actions'][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;
+ $data['actions'][$row['environment']][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;
}
else {
- if (!isset($data['inheritedActions'][$row['eventClassName']])) $data['inheritedActions'][$row['eventClassName']] = array();
- $data['inheritedActions'][$row['eventClassName']][$row['eventName']][] = $row;
+ if (!isset($data['inheritedActions'][$row['environment']][$row['eventClassName']])) $data['inheritedActions'][$row['environment']][$row['eventClassName']] = array();
+ $data['inheritedActions'][$row['environment']][$row['eventClassName']][$row['eventName']][] = $row;
}
}
// sort data by nice value and class name
- foreach ($data['actions'] as $key => $listeners) {
- uasort($data['actions'][$key], array(__CLASS__, 'sortListeners'));
+ foreach ($data['actions'] as &$listenerMap) {
+ foreach ($listenerMap as &$listeners) {
+ uasort($listeners, array(__CLASS__, 'sortListeners'));
+ }
}
- foreach ($data['inheritedActions'] as $class => $listeners) {
- foreach ($listeners as $key => $val) {
- uasort($data['inheritedActions'][$class][$key], array(__CLASS__, 'sortListeners'));
+ foreach ($data['inheritedActions'] as &$listenerMap) {
+ foreach ($listenerMap as &$listeners) {
+ foreach ($listeners as &$val) {
+ uasort($val, array(__CLASS__, 'sortListeners'));
+ }
}
}
* Loads all registered actions of the active package.
*/
protected function loadActions() {
+ $environment = (class_exists('wcf\system\WCFACP', false) ? 'admin' : 'user');
$cacheName = 'eventListener-'.PACKAGE_ID;
CacheHandler::getInstance()->addResource(
$cacheName,
);
$cache = CacheHandler::getInstance()->get($cacheName);
- if (isset($cache['actions'])) {
- $this->actions = $cache['actions'];
+ if (isset($cache['actions'][$environment])) {
+ $this->actions = $cache['actions'][$environment];
}
- if (isset($cache['inheritedActions'])) {
- $this->inheritedActions = $cache['inheritedActions'];
+ if (isset($cache['inheritedActions'][$environment])) {
+ $this->inheritedActions = $cache['inheritedActions'][$environment];
}
unset($cache);
protected function handleDelete(array $items) {
$sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
WHERE packageID = ?
+ AND environment = ?
AND eventClassName = ?
AND eventName = ?,
AND inherit = ?
foreach ($items as $item) {
$statement->execute(array(
$this->installation->getPackageID(),
+ (isset($item['elements']['environment']) ? $item['elements']['environment'] : 'user'),
$item['elements']['eventclassname'],
$item['elements']['eventname'],
$item['elements']['inherit'],
else if ($nice > 127) $nice = 127;
return array(
+ 'environment' => (isset($data['elements']['environment']) ? $data['elements']['environment'] : 'user'),
'eventClassName' => $data['elements']['eventclassname'],
'eventName' => $data['elements']['eventname'],
'inherit' => (isset($data['elements']['inherit'])) ? intval($data['elements']['inherit']) : 0,
protected function findExistingItem(array $data) {
$sql = "SELECT *
FROM wcf".WCF_N."_".$this->tableName."
- WHERE eventClassName = ?
+ WHERE packageID = ?
+ AND environment = ?
+ AND eventClassName = ?
AND eventName = ?
- AND listenerClassName = ?
- AND packageID = ?";
+ AND listenerClassName = ?";
$parameters = array(
+ $this->installation->getPackageID(),
+ $data['environment'],
$data['eventClassName'],
$data['eventName'],
- $data['listenerClassName'],
- $this->installation->getPackageID()
+ $data['listenerClassName']
);
return array(
CREATE TABLE wcf1_event_listener (
listenerID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
packageID INT(10) NOT NULL,
+ environment ENUM('user', 'admin') NOT NULL DEFAULT 'user',
eventClassName VARCHAR(80) NOT NULL DEFAULT '',
eventName VARCHAR(50) NOT NULL DEFAULT '',
listenerClassName VARCHAR(200) NOT NULL DEFAULT '',
inherit TINYINT(1) NOT NULL DEFAULT 0,
niceValue TINYINT(3) NOT NULL DEFAULT 0,
- UNIQUE KEY packageID (packageID, eventClassName, eventName, listenerClassName)
+ UNIQUE KEY packageID (packageID, environment, eventClassName, eventName, listenerClassName)
);
DROP TABLE IF EXISTS wcf1_language;