2 namespace wcf\system\package\plugin;
3 use wcf\system\exception\SystemException;
7 * Installs, updates and deletes user notification events.
10 * @copyright 2001-2014 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage system.package.plugin
14 * @category Community Framework
16 class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
18 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
20 public $className = 'wcf\data\user\notification\event\UserNotificationEventEditor';
23 * @see \wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
25 public $tableName = 'user_notification_event';
28 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
30 public $tagName = 'event';
33 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
35 protected function handleDelete(array $items) {
36 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
39 $statement = WCF::getDB()->prepareStatement($sql);
40 foreach ($items as $item) {
41 $statement->execute(array(
42 $this->installation->getPackageID(),
43 $item['elements']['name']
49 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
51 protected function prepareImport(array $data) {
53 $sql = "SELECT object_type.objectTypeID
54 FROM wcf".WCF_N."_object_type object_type
55 WHERE object_type.objectType = ?
56 AND object_type.definitionID IN (
58 FROM wcf".WCF_N."_object_type_definition
59 WHERE definitionName = 'com.woltlab.wcf.notification.objectType'
61 $statement = WCF::getDB()->prepareStatement($sql, 1);
62 $statement->execute(array($data['elements']['objecttype']));
63 $row = $statement->fetchArray();
64 if (empty($row['objectTypeID'])) throw new SystemException("unknown notification object type '".$data['elements']['objecttype']."' given");
65 $objectTypeID = $row['objectTypeID'];
68 'eventName' => $data['elements']['name'],
69 'className' => $data['elements']['classname'],
70 'objectTypeID' => $objectTypeID,
71 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''),
72 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''),
73 'preset' => (!empty($data['elements']['preset']) ? 1 : 0)
78 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
80 protected function findExistingItem(array $data) {
82 FROM wcf".WCF_N."_".$this->tableName."
83 WHERE objectTypeID = ?
86 $data['objectTypeID'],
92 'parameters' => $parameters