<?php
namespace wcf\system\package\plugin;
-use wcf\system\cache\CacheHandler;
use wcf\system\WCF;
/**
--- /dev/null
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\WCF;
+
+/**
+ * This PIP installs, updates or deletes user notification object types.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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
+ );
+ }
+}
+?>
--- /dev/null
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\WCF;
+
+/**
+ * This PIP installs, updates or deletes user notification types.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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
+ );
+ }
+}
+?>
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;
public function getPageType() {\r
return $this->pageType;\r
}\r
-}
\ No newline at end of file
+}\r
+?>
\ No newline at end of file