-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacymailing.script.php
125 lines (102 loc) · 3.38 KB
/
acymailing.script.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* Acymailing - Privacy plugin
*
* @version ___VERSION___
* @package Joomla
* @subpackage plg_privacy_acymailing
*
* @author Ruud van Lent <info@onlinecommunityhub.nl>
* @copyright Copyright (C) 2022 - ___CURRENTYEAR___ OnlineCommunityHub (J.L.R. van Lent Holding B.V.). All rights reserved.
* @license GNU/GPL version 3 or later
* @link https://onlinecommunityhub.nl
*/
// No direct access
defined('_JEXEC') or die;
use ___NAMESPACE_HELPER___\OchInstallerScriptHelper;
// Include the helper functions only once, because autoloading doesn't work on fresh install (autoload not registered)
JLoader::register('___NAMESPACE_HELPER___\OchInstallerScriptHelper', __DIR__ . '/src/Helper/OchInstallerScriptHelper.php');
/**
* Script file to clean up left-overs from previous versions
* Called from upgrade routine
*
* @since 0.2.1
*/
class PlgPrivacyKunenaInstallerScript
{
/**
* @var string
*/
protected $installedVersion;
/**
* @var array
*/
protected $maintenanceVariables;
/**
* @var array
*/
protected $preflightVariables;
/**
* Method to run before the install routine.
*
* @param string $type The action being performed
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void|boolean
*/
public function preflight($type, $parent)
{
// Check for minimum required Joomla! version
if (!OchInstallerScriptHelper::checkMinimumJoomlaVersion($type, $parent)) {
// We are not on minimum Joomla! version: get out of here...
return false;
}
$type = strtolower($type);
if ($type == 'update') {
$this->installedVersion = OchInstallerScriptHelper::getInstalledVersion('plugin', 'kunena', 'privacy');
// Load all maintenance variables
$this->setPreFlightMaintenanceVariables();
// Do preflight maintenance
OchInstallerScriptHelper::doMaintenance($this->preflightVariables, $this->installedVersion);
}
}
/**
* Code to execute on plugin update, used for cleaning left-overs from previous versions
*
* @param object $adapter Adapter instance
*
* @return void
*/
public function update($adapter)
{
$newVersion = $adapter->manifest->version;
// Load all maintenance variables
$this->setMaintenanceVariables();
// Rename all configured files
OchInstallerScriptHelper::doMaintenance($this->maintenanceVariables, $this->installedVersion);
}
/**
* Set the maintenance variables
*
* @return void
*/
public function setMaintenanceVariables()
{
$this->maintenanceVariables['rename_files'] = [];
$this->maintenanceVariables['delete_files'] = [];
$this->maintenanceVariables['remove_directories'] = [];
$this->maintenanceVariables['installation_messages'] = [];
$this->maintenanceVariables['component_warnings'] = [];
$this->maintenanceVariables['update_sites'] = [];
}
/**
* Set the maintenance variables
*
* @return void
*/
public function setPreFlightMaintenanceVariables()
{
$this->preflightVariables['remove_directories'] = [];
$this->preflightVariables['remove_files'] = [];
}
}