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