| @@ -1,80 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -use AcyMailing\Classes\PluginClass; | |
| 4 | - | |
| 5 | -global $acymPlugins; | |
| 6 | -global $acymAddonsForSettings; | |
| 7 | - | |
| 8 | -function acym_trigger($method, $args = [], $plugin = null, $callbackOnePlugin = null) | |
| 9 | -{ | |
| 10 | - if (!in_array(acym_getPrefix().'acym_configuration', acym_getTableList())) { | |
| 11 | - return null; | |
| 12 | - } | |
| 13 | - | |
| 14 | - if (in_array($method, ['replaceContent', 'replaceUserInformation']) && !empty($args[0]->language)) { | |
| 15 | - $previousLanguage = acym_setLanguage($args[0]->language); | |
| 16 | - acym_loadLanguage($args[0]->language); | |
| 17 | - } | |
| 18 | - | |
| 19 | - global $acymPlugins; | |
| 20 | - global $acymAddonsForSettings; | |
| 21 | - if (empty($acymPlugins)) acym_loadPlugins(); | |
| 22 | - | |
| 23 | - $result = []; | |
| 24 | - $listAddons = $acymPlugins; | |
| 25 | - if ($method === 'onAcymAddSettings') { | |
| 26 | - $listAddons = $acymAddonsForSettings; | |
| 27 | - } | |
| 28 | - | |
| 29 | - foreach ($listAddons as $class => $onePlugin) { | |
| 30 | - if (is_callable($callbackOnePlugin)) $callbackOnePlugin($onePlugin); | |
| 31 | - if (!method_exists($onePlugin, $method)) continue; | |
| 32 | - if (!empty($plugin) && $class != $plugin) continue; | |
| 33 | - | |
| 34 | - try { | |
| 35 | - $value = call_user_func_array([$onePlugin, $method], $args); | |
| 36 | - if (isset($value)) $result[] = $value; | |
| 37 | - if (!empty($onePlugin->errors)) { | |
| 38 | - $onePlugin->errorCallback(); | |
| 39 | - } | |
| 40 | - } catch (Exception $e) { | |
| 41 | - acym_logError('An error occurred when triggering the method '.$method.': '.$e->getMessage()); | |
| 42 | - } | |
| 43 | - } | |
| 44 | - | |
| 45 | - if (!empty($previousLanguage)) { | |
| 46 | - acym_setLanguage($previousLanguage); | |
| 47 | - acym_loadLanguage($previousLanguage); | |
| 48 | - } | |
| 49 | - | |
| 50 | - return $result; | |
| 51 | -} | |
| 52 | - | |
| 53 | -function acym_checkPluginsVersion(): bool | |
| 54 | -{ | |
| 55 | - $pluginClass = new PluginClass(); | |
| 56 | - $pluginsInstalled = $pluginClass->getMatchingElements(); | |
| 57 | - $pluginsInstalled = $pluginsInstalled['elements']; | |
| 58 | - | |
| 59 | - if (empty($pluginsInstalled)) { | |
| 60 | - return true; | |
| 61 | - } | |
| 62 | - | |
| 63 | - $response = acym_fileGetContent(ACYM_UPDATEME_API_URL.'public/addons'); | |
| 64 | - $pluginsAvailable = @json_decode($response, true); | |
| 65 | - if (empty($pluginsAvailable)) { | |
| 66 | - return true; | |
| 67 | - } | |
| 68 | - | |
| 69 | - foreach ($pluginsInstalled as $key => $pluginInstalled) { | |
| 70 | - foreach ($pluginsAvailable as $pluginAvailable) { | |
| 71 | - if ($pluginAvailable['file_name'] === $pluginInstalled->folder_name && !version_compare($pluginInstalled->version, $pluginAvailable['version'], '>=')) { | |
| 72 | - $pluginInstalled->uptodate = 0; | |
| 73 | - $pluginInstalled->latest_version = $pluginAvailable['version']; | |
| 74 | - $pluginClass->save($pluginInstalled); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - } | |
| 78 | - | |
| 79 | - return true; | |
| 80 | -} | |