ce1197f72c301a00bb7a37bfc9c4707aa5428eb2
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
4 use wcf\system\WCF;
5
6 /**
7 * Installs, updates and deletes template listeners.
8 *
9 * @author Alexander Ebert
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
15 */
16 class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
17 /**
18 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
19 */
20 public $className = 'wcf\data\template\listener\TemplateListenerEditor';
21
22 /**
23 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
24 */
25 protected function handleDelete(array $items) {
26 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
27 WHERE packageID = ?
28 AND environment = ?
29 AND eventName = ?
30 AND name = ?
31 AND templateName = ?";
32 $statement = WCF::getDB()->prepareStatement($sql);
33 foreach ($items as $item) {
34 $statement->execute(array(
35 $this->installation->getPackageID(),
36 $item['elements']['environment'],
37 $item['elements']['eventname'],
38 $item['attributes']['name'],
39 $item['elements']['templatename']
40 ));
41 }
42 }
43
44 /**
45 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
46 */
47 protected function prepareImport(array $data) {
48 return array(
49 'environment' => $data['elements']['environment'],
50 'eventName' => $data['elements']['eventname'],
51 'name' => $data['attributes']['name'],
52 'templateCode' => $data['elements']['templatecode'],
53 'templateName' => $data['elements']['templatename']
54 );
55 }
56
57 /**
58 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
59 */
60 protected function findExistingItem(array $data) {
61 $sql = "SELECT *
62 FROM wcf".WCF_N."_".$this->tableName."
63 WHERE packageID = ?
64 AND name = ?
65 AND templateName = ?
66 AND eventName = ?
67 AND environment = ?";
68 $parameters = array(
69 $this->installation->getPackageID(),
70 $data['name'],
71 $data['templateName'],
72 $data['eventName'],
73 $data['environment']
74 );
75
76 return array(
77 'sql' => $sql,
78 'parameters' => $parameters
79 );
80 }
81
82 /**
83 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
84 */
85 protected function cleanup() {
86 // clear cache immediately
87 TemplateListenerCodeCacheBuilder::getInstance()->reset();
88 }
89 }