1e1eb18d85c6d0482fef89ca513e7c76c09f7e13
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\WCF;
4
5 /**
6 * This PIP installs, updates or deletes user notification events.
7 *
8 * @author Marcel Werk
9 * @copyright 2001-2011 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf.notification
12 * @subpackage system.package.plugin
13 * @category Community Framework
14 */
15 class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
16 /**
17 * @see AbstractXMLPackageInstallationPlugin::$className
18 */
19 public $className = 'wcf\data\user\notification\event\UserNotificationEventEditor';
20
21 /**
22 * @see AbstractXMLPackageInstallationPlugin::$tableName
23 */
24 public $tableName = 'user_notification_event';
25
26 /**
27 * @see AbstractXMLPackageInstallationPlugin::$tagName
28 */
29 public $tagName = 'event';
30
31 /**
32 * @see AbstractXMLPackageInstallationPlugin::handleDelete()
33 */
34 protected function handleDelete(array $items) {
35 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
36 WHERE packageID = ?
37 AND eventName = ?";
38 $statement = WCF::getDB()->prepareStatement($sql);
39 foreach ($items as $item) {
40 $statement->execute(array(
41 $this->installation->getPackageID(),
42 $item['elements']['name']
43 ));
44 }
45 }
46
47 /**
48 * @see AbstractXMLPackageInstallationPlugin::prepareImport()
49 */
50 protected function prepareImport(array $data) {
51 $objectTypeID = 0;
52 $defaultNotificationTypeID = 0;
53
54 return array(
55 'eventName' => $data['elements']['name'],
56 'className' => $data['elements']['classname'],
57 'objectTypeID' => $objectTypeID,
58 'defaultNotificationTypeID' => $defaultNotificationTypeID,
59 'languageCategory' => (isset($data['elements']['languagecategory']) ? $data['elements']['languagecategory'] : ''),
60 'requiresConfirmation' => (isset($data['elements']['requiresconfirmation']) ? intval($data['elements']['requiresconfirmation']) : 0),
61 'acceptURL' => (isset($data['elements']['accepturl']) ? $data['elements']['accepturl'] : ''),
62 'declineURL' => (isset($data['elements']['declineurl']) ? $data['elements']['declineurl'] : ''),
63 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''),
64 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : '')
65 );
66 }
67
68 /**
69 * @see AbstractXMLPackageInstallationPlugin::findExistingItem()
70 */
71 protected function findExistingItem(array $data) {
72 $sql = "SELECT *
73 FROM wcf".WCF_N."_".$this->tableName."
74 WHERE packageID = ?
75 AND eventName = ?";
76 $parameters = array(
77 $this->installation->getPackageID(),
78 $data['eventName']
79 );
80
81 return array(
82 'sql' => $sql,
83 'parameters' => $parameters
84 );
85 }
86 }