diff options
author | Andrew Dolgov <[email protected]> | 2023-10-27 22:07:28 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2023-10-27 22:07:28 +0300 |
commit | 5920ac814c0a72b8c348650b09597ed8793a54c9 (patch) | |
tree | a52a8f755ea033a6c96f8a1c1633d81b68ab5c45 /classes/Pref_Prefs.php | |
parent | 8c9c69921f8552e49291df9e2503709aaa564270 (diff) |
replace some dirname horrors with a separate unit-tested method
Diffstat (limited to 'classes/Pref_Prefs.php')
-rw-r--r-- | classes/Pref_Prefs.php | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php index da0ee54f7..5aa2382dd 100644 --- a/classes/Pref_Prefs.php +++ b/classes/Pref_Prefs.php @@ -1061,7 +1061,7 @@ class Pref_Prefs extends Handler_Protected { * @return array<int, array{'plugin': string, 'rv': array{'stdout': false|string, 'stderr': false|string, 'git_status': int, 'need_update': bool}|null}> */ static function _get_updated_plugins(): array { - $root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/ + $root_dir = Config::get_self_dir(); $plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir"); $rv = []; @@ -1185,7 +1185,7 @@ class Pref_Prefs extends Handler_Protected { $plugin_name = basename(clean($_REQUEST['plugin'])); $status = 0; - $plugin_dir = dirname(dirname(__DIR__)) . "/plugins.local/$plugin_name"; + $plugin_dir = Config::get_self_dir() . "/plugins.local/$plugin_name"; if (is_dir($plugin_dir)) { $status = $this->_recursive_rmdir($plugin_dir); @@ -1199,7 +1199,7 @@ class Pref_Prefs extends Handler_Protected { if ($_SESSION["access_level"] >= UserHelper::ACCESS_LEVEL_ADMIN && Config::get(Config::ENABLE_PLUGIN_INSTALLER)) { $plugin_name = basename(clean($_REQUEST['plugin'])); $all_plugins = $this->_get_available_plugins(); - $plugin_dir = dirname(dirname(__DIR__)) . "/plugins.local"; + $plugin_dir = Config::get_self_dir() . "/plugins.local"; $work_dir = "$plugin_dir/plugin-installer"; @@ -1306,7 +1306,7 @@ class Pref_Prefs extends Handler_Protected { function checkForPluginUpdates(): void { if ($_SESSION["access_level"] >= UserHelper::ACCESS_LEVEL_ADMIN && Config::get(Config::CHECK_FOR_UPDATES) && Config::get(Config::CHECK_FOR_PLUGIN_UPDATES)) { $plugin_name = $_REQUEST["name"] ?? ""; - $root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/ + $root_dir = Config::get_self_dir(); $rv = empty($plugin_name) ? self::_get_updated_plugins() : [ ["plugin" => $plugin_name, "rv" => self::_plugin_needs_update($root_dir, $plugin_name)], @@ -1324,8 +1324,7 @@ class Pref_Prefs extends Handler_Protected { $plugins = array_filter($plugins, 'strlen'); } - # we're in classes/pref/ - $root_dir = dirname(dirname(__DIR__)); + $root_dir = Config::get_self_dir(); $rv = []; |