diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-08-27 10:27:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 10:27:34 +0200 |
commit | af41d5ab5d2bd3ba64d052c997bc6afa6966a63c (patch) | |
tree | 8fad2829c55f94022e359fa8914e11f80a2afc2a /application/config/ConfigPlugin.php | |
parent | b8e3630f2ecd142d397b1b062a346a667bb78595 (diff) | |
parent | 0c6fdbe12bbbb336348666b14b82096f24d5858b (diff) | |
download | Shaarli-af41d5ab5d2bd3ba64d052c997bc6afa6966a63c.tar.gz Shaarli-af41d5ab5d2bd3ba64d052c997bc6afa6966a63c.tar.zst Shaarli-af41d5ab5d2bd3ba64d052c997bc6afa6966a63c.zip |
Merge pull request #1511 from ArthurHoaro/wip-slim-routing
Diffstat (limited to 'application/config/ConfigPlugin.php')
-rw-r--r-- | application/config/ConfigPlugin.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/application/config/ConfigPlugin.php b/application/config/ConfigPlugin.php index dbb24937..ea8dfbda 100644 --- a/application/config/ConfigPlugin.php +++ b/application/config/ConfigPlugin.php | |||
@@ -1,6 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Shaarli\Config\Exception\PluginConfigOrderException; | 3 | use Shaarli\Config\Exception\PluginConfigOrderException; |
4 | use Shaarli\Plugin\PluginManager; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * Plugin configuration helper functions. | 7 | * Plugin configuration helper functions. |
@@ -19,6 +20,20 @@ use Shaarli\Config\Exception\PluginConfigOrderException; | |||
19 | */ | 20 | */ |
20 | function save_plugin_config($formData) | 21 | function save_plugin_config($formData) |
21 | { | 22 | { |
23 | // We can only save existing plugins | ||
24 | $directories = str_replace( | ||
25 | PluginManager::$PLUGINS_PATH . '/', | ||
26 | '', | ||
27 | glob(PluginManager::$PLUGINS_PATH . '/*') | ||
28 | ); | ||
29 | $formData = array_filter( | ||
30 | $formData, | ||
31 | function ($value, string $key) use ($directories) { | ||
32 | return startsWith($key, 'order') || in_array($key, $directories); | ||
33 | }, | ||
34 | ARRAY_FILTER_USE_BOTH | ||
35 | ); | ||
36 | |||
22 | // Make sure there are no duplicates in orders. | 37 | // Make sure there are no duplicates in orders. |
23 | if (!validate_plugin_order($formData)) { | 38 | if (!validate_plugin_order($formData)) { |
24 | throw new PluginConfigOrderException(); | 39 | throw new PluginConfigOrderException(); |
@@ -69,7 +84,7 @@ function validate_plugin_order($formData) | |||
69 | $orders = array(); | 84 | $orders = array(); |
70 | foreach ($formData as $key => $value) { | 85 | foreach ($formData as $key => $value) { |
71 | // No duplicate order allowed. | 86 | // No duplicate order allowed. |
72 | if (in_array($value, $orders)) { | 87 | if (in_array($value, $orders, true)) { |
73 | return false; | 88 | return false; |
74 | } | 89 | } |
75 | 90 | ||