2 namespace wcf\system\package\plugin;
3 use wcf\data\template\listener\TemplateListenerEditor;
4 use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
8 * Installs, updates and deletes template listeners.
10 * @author Alexander Ebert
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.package.plugin
15 * @category Community Framework
17 class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
21 public $className = TemplateListenerEditor::class;
26 protected function handleDelete(array $items) {
27 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
32 AND templateName = ?";
33 $statement = WCF::getDB()->prepareStatement($sql);
34 foreach ($items as $item) {
36 $this->installation->getPackageID(),
37 $item['elements']['environment'],
38 $item['elements']['eventname'],
39 $item['attributes']['name'],
40 $item['elements']['templatename']
48 protected function prepareImport(array $data) {
49 $niceValue = isset($data['elements']['nice']) ? intval($data['elements']['nice']) : 0;
50 if ($niceValue < -128) {
53 else if ($niceValue > 127) {
58 'environment' => $data['elements']['environment'],
59 'eventName' => $data['elements']['eventname'],
60 'niceValue' => $niceValue,
61 'name' => $data['attributes']['name'],
62 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''),
63 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''),
64 'templateCode' => $data['elements']['templatecode'],
65 'templateName' => $data['elements']['templatename']
72 protected function findExistingItem(array $data) {
74 FROM wcf".WCF_N."_".$this->tableName."
81 $this->installation->getPackageID(),
83 $data['templateName'],
90 'parameters' => $parameters
97 protected function cleanup() {
98 // clear cache immediately
99 TemplateListenerCodeCacheBuilder::getInstance()->reset();