5f5019befda5f459f41626e6152702143949eb31
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\CacheHandler;
4 use wcf\system\WCF;
5
6 /**
7 * This PIP installs, updates or deletes ACP search providers.
8 *
9 * @author Alexander Ebert
10 * @copyright 2001-2012 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 ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
17 /**
18 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
19 */
20 public $className = 'wcf\data\acp\search\provider\ACPSearchProviderEditor';
21
22 /**
23 * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
24 */
25 public $tableName = 'acp_search_provider';
26
27 /**
28 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
29 */
30 public $tagName = 'acpsearchprovider';
31
32 /**
33 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
34 */
35 protected function handleDelete(array $items) {
36 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
37 WHERE providerName = ?
38 AND packageID = ?";
39 $statement = WCF::getDB()->prepareStatement($sql);
40
41 WCF::getDB()->beginTransaction();
42 foreach ($items as $item) {
43 $statement->execute(array(
44 $item['attributes']['name'],
45 $this->installation->getPackageID()
46 ));
47 }
48 WCF::getDB()->commitTransaction();
49 }
50
51 /**
52 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
53 */
54 protected function prepareImport(array $data) {
55 // get show order
56 $showOrder = (isset($data['elements']['showorder'])) ? $data['elements']['showorder'] : null;
57 $showOrder = $this->getShowOrder($showOrder);
58
59 return array(
60 'className' => $data['elements']['classname'],
61 'providerName' => $data['attributes']['name'],
62 'showOrder' => $showOrder
63 );
64 }
65
66 /**
67 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
68 */
69 protected function findExistingItem(array $data) {
70 $sql = "SELECT *
71 FROM wcf".WCF_N."_".$this->tableName."
72 WHERE providerName = ?
73 AND packageID = ?";
74 $parameters = array(
75 $data['providerName'],
76 $this->installation->getPackageID()
77 );
78
79 return array(
80 'sql' => $sql,
81 'parameters' => $parameters
82 );
83 }
84
85 /**
86 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
87 */
88 protected function cleanup() {
89 CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.acpSearchProvider-*.php');
90 }
91
92 /**
93 * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
94 */
95 public function uninstall() {
96 parent::uninstall();
97
98 // clear cache immediately
99 CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.acpSearchProvider-*.php');
100 }
101 }