diff options
author | OpenShift guest <dachebodt@gmail.com> | 2013-03-25 18:21:48 -0400 |
---|---|---|
committer | OpenShift guest <dachebodt@gmail.com> | 2013-03-25 18:21:48 -0400 |
commit | 323a494cd16bd202d89260f756519c2d76f2f9fe (patch) | |
tree | 4ddea81864669bb970fbe10c8f313f2c55332c58 /phpBB/includes/functions_admin.php | |
parent | 8b464e87f0a41422dddaa647ac42ab9c7950bb4b (diff) | |
download | forums-323a494cd16bd202d89260f756519c2d76f2f9fe.tar forums-323a494cd16bd202d89260f756519c2d76f2f9fe.tar.gz forums-323a494cd16bd202d89260f756519c2d76f2f9fe.tar.bz2 forums-323a494cd16bd202d89260f756519c2d76f2f9fe.tar.xz forums-323a494cd16bd202d89260f756519c2d76f2f9fe.zip |
[ticket/11458] Search for permission language files in extensions
Extensions that add new permission masks only need to add a permission file in
the language folder of the extension. The file must start with 'permissions_'
eg 'permissions_blog.php'. The permission language file will be automatically
included when viewing/setting permissions.
PHPBB3-11458
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r-- | phpBB/includes/functions_admin.php | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d273b9fb3a..5d71f55d1a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3040,38 +3040,25 @@ function tidy_database() */ function add_permission_language() { - global $user, $phpEx; + global $user, $phpEx, $phpbb_extension_manager; // First of all, our own file. We need to include it as the first file because it presets all relevant variables. $user->add_lang('acp/permissions_phpbb'); - $files_to_add = array(); + // add permission language files from extensions + $finder = $phpbb_extension_manager->get_finder(); - // Now search in acp and mods folder for permissions_ files. - foreach (array('acp/', 'mods/') as $path) - { - $dh = @opendir($user->lang_path . $user->lang_name . '/' . $path); - - if ($dh) - { - while (($file = readdir($dh)) !== false) - { - if ($file !== 'permissions_phpbb.' . $phpEx && strpos($file, 'permissions_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) - { - $files_to_add[] = $path . substr($file, 0, -(strlen($phpEx) + 1)); - } - } - closedir($dh); - } - } + $lang_files = $finder + ->prefix('permissions_') + ->suffix(".$phpEx") + ->extension_directory('/language/' . $user->lang_name) + ->core_path('language/' . $user->lang_name . '/mods') + ->find(); - if (!sizeof($files_to_add)) + foreach ($lang_files as $lang_file => $ext_name) { - return false; + $user->add_lang_ext($ext_name, $lang_file); } - - $user->add_lang($files_to_add); - return true; } /** |