<?xml version="1.0" encoding="UTF-8"?>
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/eventListener.xsd">
<import>
- <eventlistener>
+ <eventlistener name="sessionPageAccessLog">
<eventclassname><![CDATA[wcf\page\AbstractPage]]></eventclassname>
<eventname>readParameters</eventname>
<environment>admin</environment>
<inherit>1</inherit>
<listenerclassname><![CDATA[wcf\system\event\listener\SessionAccessLogListener]]></listenerclassname>
</eventlistener>
- <eventlistener>
+ <eventlistener name="sessionFormAccessLog">
<eventclassname><![CDATA[wcf\form\AbstractForm]]></eventclassname>
<eventname>readParameters</eventname>
<environment>admin</environment>
<inherit>1</inherit>
<listenerclassname><![CDATA[wcf\system\event\listener\SessionAccessLogListener]]></listenerclassname>
</eventlistener>
- <eventlistener>
+ <eventlistener name="sessionActionAccessLog">
<eventclassname><![CDATA[wcf\action\AbstractAction]]></eventclassname>
<eventname>readParameters</eventname>
<environment>admin</environment>
</import>
<delete>
+ <!-- event listeners with names now -->
+ <eventlistener>
+ <eventclassname><![CDATA[wcf\page\AbstractPage]]></eventclassname>
+ <eventname>readParameters</eventname>
+ <environment>admin</environment>
+ <inherit>1</inherit>
+ <listenerclassname><![CDATA[wcf\system\event\listener\SessionAccessLogListener]]></listenerclassname>
+ </eventlistener>
+ <eventlistener>
+ <eventclassname><![CDATA[wcf\form\AbstractForm]]></eventclassname>
+ <eventname>readParameters</eventname>
+ <environment>admin</environment>
+ <inherit>1</inherit>
+ <listenerclassname><![CDATA[wcf\system\event\listener\SessionAccessLogListener]]></listenerclassname>
+ </eventlistener>
+ <eventlistener>
+ <eventclassname><![CDATA[wcf\action\AbstractAction]]></eventclassname>
+ <eventname>readParameters</eventname>
+ <environment>admin</environment>
+ <inherit>1</inherit>
+ <listenerclassname><![CDATA[wcf\system\event\listener\SessionAccessLogListener]]></listenerclassname>
+ </eventlistener>
+ <!-- /event listeners with names now -->
+
<eventlistener>
<eventclassname><![CDATA[wcf\system\bbcode\PreParser]]></eventclassname>
<eventname>beforeParsing</eventname>
<?php
namespace wcf\system\package\plugin;
+use wcf\data\event\listener\EventListener;
+use wcf\data\event\listener\EventListenerEditor;
use wcf\system\cache\builder\EventListenerCacheBuilder;
use wcf\system\WCF;
AND eventName = ?
AND inherit = ?
AND listenerClassName = ?";
+ $legacyStatement = WCF::getDB()->prepareStatement($sql);
+
+ $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
+ WHERE packageID = ?
+ AND listenerName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
+
foreach ($items as $item) {
- $statement->execute(array(
- $this->installation->getPackageID(),
- (isset($item['elements']['environment']) ? $item['elements']['environment'] : 'user'),
- $item['elements']['eventclassname'],
- $item['elements']['eventname'],
- (isset($item['elements']['inherit'])) ? $item['elements']['inherit'] : 0,
- $item['elements']['listenerclassname']
- ));
+ if (!isset($item['attributes']['name'])) {
+ $legacyStatement->execute(array(
+ $this->installation->getPackageID(),
+ (isset($item['elements']['environment']) ? $item['elements']['environment'] : 'user'),
+ $item['elements']['eventclassname'],
+ $item['elements']['eventname'],
+ (isset($item['elements']['inherit'])) ? $item['elements']['inherit'] : 0,
+ $item['elements']['listenerclassname']
+ ));
+ }
+ else {
+ $statement->execute(array(
+ $this->installation->getPackageID(),
+ $item['attributes']['name']
+ ));
+ }
}
}
'eventName' => $data['elements']['eventname'],
'inherit' => (isset($data['elements']['inherit'])) ? intval($data['elements']['inherit']) : 0,
'listenerClassName' => $data['elements']['listenerclassname'],
+ 'listenerName' => (isset($data['attributes']['name']) ? $data['attributes']['name'] : ''),
'niceValue' => $nice,
'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''),
'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '')
);
}
+ /**
+ * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::import()
+ */
+ protected function import(array $row, array $data) {
+ // if an event listener is updated without a name given, keep the
+ // old automatically assigned name
+ if (!empty($row) && !$data['listenerName']) {
+ unset($data['listenerName']);
+ }
+
+ $eventListener = parent::import($row, $data);
+
+ // update event listener name
+ if (!$eventListener->listenerName) {
+ $eventListenerEditor = new EventListenerEditor($eventListener);
+ $eventListenerEditor->update(array(
+ 'listenerName' => EventListener::AUTOMATIC_NAME_PREFIX.$eventListener->listenerID
+ ));
+
+ $eventListener = new EventListener($eventListener->listenerID);
+ }
+
+ return $eventListener;
+ }
+
/**
* @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
*/
protected function findExistingItem(array $data) {
- $sql = "SELECT *
- FROM wcf".WCF_N."_".$this->tableName."
- WHERE packageID = ?
- AND environment = ?
- AND eventClassName = ?
- AND eventName = ?
- AND listenerClassName = ?";
- $parameters = array(
- $this->installation->getPackageID(),
- $data['environment'],
- $data['eventClassName'],
- $data['eventName'],
- $data['listenerClassName']
- );
+ if (!$data['listenerName']) {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_".$this->tableName."
+ WHERE packageID = ?
+ AND environment = ?
+ AND eventClassName = ?
+ AND eventName = ?
+ AND listenerClassName = ?";
+ $parameters = array(
+ $this->installation->getPackageID(),
+ $data['environment'],
+ $data['eventClassName'],
+ $data['eventName'],
+ $data['listenerClassName']
+ );
+ }
+ else {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_".$this->tableName."
+ WHERE packageID = ?
+ AND listenerName = ?";
+ $parameters = array(
+ $this->installation->getPackageID(),
+ $data['listenerName']
+ );
+ }
return array(
'sql' => $sql,
listenerID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
packageID INT(10) NOT NULL,
environment ENUM('user', 'admin') NOT NULL DEFAULT 'user',
+ listenerName VARCHAR(255) NOT NULL,
eventClassName VARCHAR(80) NOT NULL DEFAULT '',
eventName VARCHAR(50) NOT NULL DEFAULT '',
listenerClassName VARCHAR(200) NOT NULL DEFAULT '',
permissions TEXT,
options TEXT,
+ UNIQUE KEY listenerName (listenerName, packageID),
UNIQUE KEY packageID (packageID, environment, eventClassName, eventName, listenerClassName)
);