From: Marcel Werk Date: Sat, 22 Mar 2014 21:36:31 +0000 (+0100) Subject: Fixed preset issue X-Git-Tag: 2.0.5~24 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=60a8c15563b386f5f4c122a6fc84f4af950293d2;p=GitHub%2FWoltLab%2FWCF.git Fixed preset issue --- 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() */