e64cf587f06c2729248d94259f9c7bcdfa546b7d
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\builder\ACPSearchProviderCacheBuilder;
4 use wcf\system\WCF;
5
6 /**
7 * Installs, updates and deletes ACP search providers.
8 *
9 * @author Alexander Ebert
10 * @copyright 2001-2015 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\AbstractXMLPackageInstallationPlugin::handleDelete()
24 */
25 protected function handleDelete(array $items) {
26 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
27 WHERE providerName = ?
28 AND packageID = ?";
29 $statement = WCF::getDB()->prepareStatement($sql);
30
31 WCF::getDB()->beginTransaction();
32 foreach ($items as $item) {
33 $statement->execute([
34 $item['attributes']['name'],
35 $this->installation->getPackageID()
36 ]);
37 }
38 WCF::getDB()->commitTransaction();
39 }
40
41 /**
42 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
43 */
44 protected function prepareImport(array $data) {
45 // get show order
46 $showOrder = (isset($data['elements']['showorder'])) ? $data['elements']['showorder'] : null;
47 $showOrder = $this->getShowOrder($showOrder);
48
49 return [
50 'className' => $data['elements']['classname'],
51 'providerName' => $data['attributes']['name'],
52 'showOrder' => $showOrder
53 ];
54 }
55
56 /**
57 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
58 */
59 protected function findExistingItem(array $data) {
60 $sql = "SELECT *
61 FROM wcf".WCF_N."_".$this->tableName."
62 WHERE providerName = ?
63 AND packageID = ?";
64 $parameters = [
65 $data['providerName'],
66 $this->installation->getPackageID()
67 ];
68
69 return [
70 'sql' => $sql,
71 'parameters' => $parameters
72 ];
73 }
74
75 /**
76 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
77 */
78 protected function cleanup() {
79 ACPSearchProviderCacheBuilder::getInstance()->reset();
80 }
81
82 /**
83 * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename()
84 * @since 2.2
85 */
86 public static function getDefaultFilename() {
87 return 'acpSearchProvider.xml';
88 }
89 }