PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Classes / ConfigurationClass.php

ConfigurationClass.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at back/Classes/ConfigurationClass.php

108 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Classes;
4
5 use AcyMailing\Controllers\ConfigurationController;
6 use AcyMailing\Core\AcymClass;
7
8 class ConfigurationClass extends AcymClass
9 {
10 private $values = [];
11
12 public function __construct()
13 {
14 parent::__construct();
15
16 $this->table = 'configuration';
17 $this->pkey = 'name';
18 }
19
20 public function load()
21 {
22 $this->values = acym_loadObjectList('SELECT * FROM #__acym_configuration', 'name');
23 }
24
25 public function get($namekey, $default = '')
26 {
27 if (isset($this->values[$namekey])) {
28 return $this->values[$namekey]->value;
29 }
30
31 return $default;
32 }
33
34 public function save($newConfig, $escape = true)
35 {
36 $oldFollowupPriority = $this->get('followup_max_priority', 0);
37
38 $query = 'REPLACE INTO #__acym_configuration (`name`, `value`) VALUES ';
39
40 $previousCronSecurity = $this->get('cron_security', 0);
41 $previousCronSecurityKey = $this->get('cron_key');
42 $params = [];
43 foreach ($newConfig as $name => $value) {
44 if (strpos($name, 'password') !== false && !empty($value) && trim($value, '*') == '') {
45 continue;
46 }
47 if (strpos($name, 'key') !== false && !empty($value) && strpos($value, '**********') !== false) {
48 continue;
49 }
50
51 if ($name === 'multilingual' && $value === '1') {
52 $remindme = json_decode($this->get('remindme', '[]'), true);
53 if (!in_array('multilingual', $remindme)) {
54 $remindme[] = 'multilingual';
55 $this->save(['remindme' => json_encode($remindme)]);
56 }
57 }
58
59 if (is_array($value)) {
60 $value = implode(',', $value);
61 }
62
63 if (empty($this->values[$name])) {
64 $this->values[$name] = new \stdClass();
65 }
66 $this->values[$name]->value = $value;
67
68 if ($escape) {
69 $params[] = '('.acym_escapeDB(strip_tags($name)).','.acym_escapeDB(strip_tags($value)).')';
70 } else {
71 $params[] = '('.acym_escapeDB($name).','.acym_escapeDB($value).')';
72 }
73 }
74
75 $activeCron = $this->get('active_cron', 0);
76 $newCronSecurity = $this->get('cron_security', 0);
77 $newCronSecurityKey = $this->get('cron_key');
78 if (!empty($activeCron) && !empty($newCronSecurity) && (empty($previousCronSecurity) || $previousCronSecurityKey !== $newCronSecurityKey)) {
79 $configurationController = new ConfigurationController();
80 if ($configurationController->modifyCron('deactivateCron') !== false) {
81 $configurationController->modifyCron('activateCron');
82 }
83 }
84
85 if (empty($params)) {
86 return true;
87 }
88
89 $query .= implode(',', $params);
90
91 try {
92 $status = acym_query($query);
93 } catch (\Exception $e) {
94 $status = false;
95 }
96 if ($status === false) {
97 acym_display(isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200).'...', 'error');
98 }
99
100 $newFollowupPriority = $this->get('followup_max_priority', 0);
101
102 $mailClass = new MailClass();
103 $mailClass->updateFollowupPriority($oldFollowupPriority, $newFollowupPriority);
104
105 return $status;
106 }
107 }
108