From: Marcel Werk Date: Thu, 14 Jul 2011 20:11:45 +0000 (+0200) Subject: - PIPs for the user notification package X-Git-Tag: 2.0.0_Beta_1~2038 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=034529824a531a38f395f3ee0b74b3f4a08f0e61;p=GitHub%2FWoltLab%2FWCF.git - PIPs for the user notification package --- diff --git a/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php b/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php index 8b8de31735..f4bfd52919 100644 --- a/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php +++ b/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php @@ -1,6 +1,5 @@ + * @package com.woltlab.wcf.notification + * @subpackage system.package.plugin + * @category Community Framework + */ +class UserNotificationObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin { + /** + * @see AbstractXMLPackageInstallationPlugin::$className + */ + public $className = 'wcf\data\user\notification\object\type\UserNotificationObjectTypeEditor'; + + /** + * @see AbstractXMLPackageInstallationPlugin::$tableName + */ + public $tableName = 'user_notification_object_type'; + + /** + * @see AbstractXMLPackageInstallationPlugin::$tagName + */ + public $tagName = 'objecttype'; + + /** + * @see AbstractXMLPackageInstallationPlugin::handleDelete() + */ + protected function handleDelete(array $items) { + $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName." + WHERE packageID = ? + AND objectType = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + foreach ($items as $item) { + $statement->execute(array( + $this->installation->getPackageID(), + $item['elements']['name'] + )); + } + } + + /** + * @see AbstractXMLPackageInstallationPlugin::prepareImport() + */ + protected function prepareImport(array $data) { + return array( + 'objectType' => $data['elements']['name'], + 'className' => $data['elements']['classname'], + 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''), + 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : '') + ); + } + + /** + * @see AbstractXMLPackageInstallationPlugin::findExistingItem() + */ + protected function findExistingItem(array $data) { + $sql = "SELECT * + FROM wcf".WCF_N."_".$this->tableName." + WHERE packageID = ? + AND objectType = ?"; + $parameters = array( + $this->installation->getPackageID(), + $data['objectType'] + ); + + return array( + 'sql' => $sql, + 'parameters' => $parameters + ); + } +} +?> diff --git a/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationTypePackageInstallationPlugin.class.php b/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationTypePackageInstallationPlugin.class.php new file mode 100644 index 0000000000..7a7ef08147 --- /dev/null +++ b/com.woltlab.wcf.notification/files/lib/system/package/plugin/UserNotificationTypePackageInstallationPlugin.class.php @@ -0,0 +1,78 @@ + + * @package com.woltlab.wcf.notification + * @subpackage system.package.plugin + * @category Community Framework + */ +class UserNotificationTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin { + /** + * @see AbstractXMLPackageInstallationPlugin::$className + */ + public $className = 'wcf\data\user\notification\type\UserNotificationTypeEditor'; + + /** + * @see AbstractXMLPackageInstallationPlugin::$tableName + */ + public $tableName = 'user_notification_type'; + + /** + * @see AbstractXMLPackageInstallationPlugin::$tagName + */ + public $tagName = 'notificationtype'; + + /** + * @see AbstractXMLPackageInstallationPlugin::handleDelete() + */ + protected function handleDelete(array $items) { + $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName." + WHERE packageID = ? + AND notificationType = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + foreach ($items as $item) { + $statement->execute(array( + $this->installation->getPackageID(), + $item['elements']['name'] + )); + } + } + + /** + * @see AbstractXMLPackageInstallationPlugin::prepareImport() + */ + protected function prepareImport(array $data) { + return array( + 'notificationType' => $data['elements']['name'], + 'className' => $data['elements']['classname'], + 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''), + 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : '') + ); + } + + /** + * @see AbstractXMLPackageInstallationPlugin::findExistingItem() + */ + protected function findExistingItem(array $data) { + $sql = "SELECT * + FROM wcf".WCF_N."_".$this->tableName." + WHERE packageID = ? + AND notificationType = ?"; + $parameters = array( + $this->installation->getPackageID(), + $data['notificationType'] + ); + + return array( + 'sql' => $sql, + 'parameters' => $parameters + ); + } +} +?> diff --git a/com.woltlab.wcf.notification/install.sql b/com.woltlab.wcf.notification/install.sql index e0fe14d0cc..5857f676ad 100644 --- a/com.woltlab.wcf.notification/install.sql +++ b/com.woltlab.wcf.notification/install.sql @@ -69,7 +69,8 @@ CREATE TABLE wcf1_user_notification_type ( notificationType VARCHAR(255) NOT NULL, className VARCHAR(255) NOT NULL, permissions TEXT, - options TEXT + options TEXT, + UNIQUE KEY packageID (packageID, notificationType) ); ALTER TABLE wcf1_user_notification ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index 4d0433d38f..d5d8a261a7 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -94,4 +94,5 @@ class Request { public function getPageType() { return $this->pageType; } -} \ No newline at end of file +} +?> \ No newline at end of file