7a7ef08147f7f4a6936f81d6649277298dd08c10
[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 types.
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 UserNotificationTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
16 /**
17 * @see AbstractXMLPackageInstallationPlugin::$className
18 */
19 public $className = 'wcf\data\user\notification\type\UserNotificationTypeEditor';
20
21 /**
22 * @see AbstractXMLPackageInstallationPlugin::$tableName
23 */
24 public $tableName = 'user_notification_type';
25
26 /**
27 * @see AbstractXMLPackageInstallationPlugin::$tagName
28 */
29 public $tagName = 'notificationtype';
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 notificationType = ?";
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 return array(
52 'notificationType' => $data['elements']['name'],
53 'className' => $data['elements']['classname'],
54 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''),
55 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : '')
56 );
57 }
58
59 /**
60 * @see AbstractXMLPackageInstallationPlugin::findExistingItem()
61 */
62 protected function findExistingItem(array $data) {
63 $sql = "SELECT *
64 FROM wcf".WCF_N."_".$this->tableName."
65 WHERE packageID = ?
66 AND notificationType = ?";
67 $parameters = array(
68 $this->installation->getPackageID(),
69 $data['notificationType']
70 );
71
72 return array(
73 'sql' => $sql,
74 'parameters' => $parameters
75 );
76 }
77 }
78 ?>