From 60a8c15563b386f5f4c122a6fc84f4af950293d2 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sat, 22 Mar 2014 22:36:31 +0100 Subject: [PATCH] Fixed preset issue --- ...onEventPackageInstallationPlugin.class.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php index 06551cdf2c..8021f5bbdf 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php @@ -29,6 +29,12 @@ class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageI */ public $tagName = 'event'; + /** + * preset event ids + * @var array + */ + protected $presetEventIDs = array(); + /** * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete() */ @@ -74,6 +80,37 @@ class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageI ); } + /** + * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::import() + */ + protected function import(array $row, array $data) { + $result = parent::import($row, $data); + + if (empty($row)) { + $this->presetEventIDs[] = $result->eventID; + } + + return $result; + } + + /** + * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup() + */ + protected function cleanup() { + if (empty($this->presetEventIDs)) return; + + $sql = "INSERT IGNORE INTO wcf".WCF_N."_user_notification_event_to_user + (userID, eventID) + SELECT userID, ? + FROM wcf".WCF_N."_user"; + $statement = WCF::getDB()->prepareStatement($sql); + WCF::getDB()->beginTransaction(); + foreach ($this->presetEventIDs as $eventID) { + $statement->execute(array($eventID)); + } + WCF::getDB()->commitTransaction(); + } + /** * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem() */ -- 2.20.1