[ticket/11031] Update extension group names after converting them

PHPBB3-11031
This commit is contained in:
Joas Schilling 2013-10-25 12:09:09 +02:00
parent 881ad935d5
commit e9f4be9052
2 changed files with 51 additions and 0 deletions

View file

@ -341,6 +341,9 @@ if (!$get_info)
update_folder_pm_count();
', '
update_unread_count();
', (defined('MOD_ATTACHMENT')) ? '
phpbb_attachment_extension_group_name();
' : '
', '
phpbb_convert_authentication(\'start\');
', '

View file

@ -1414,6 +1414,54 @@ function phpbb_attachment_category($cat_id)
return ATTACHMENT_CATEGORY_NONE;
}
/**
* Convert the attachment extension names
* This is only used if the Attachment MOD was installed
*/
function phpbb_attachment_extension_group_name()
{
global $db, $phpbb_root_path, $phpEx;
// Update file extension group names to use language strings.
$sql = 'SELECT lang_dir
FROM ' . LANG_TABLE;
$result = $db->sql_query($sql);
$extension_groups_updated = array();
while ($lang_dir = $db->sql_fetchfield('lang_dir'))
{
$lang_dir = basename($lang_dir);
if (!file_exists($phpbb_root_path . 'language/' . $lang_dir . '/acp/attachments.' . $phpEx))
{
continue;
}
$lang = array();
include($lang_file);
foreach ($lang as $lang_key => $lang_val)
{
if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0)
{
continue;
}
$sql_ary = array(
'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_'
);
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE group_name = '" . $db->sql_escape($lang_val) . "'";
$db->sql_query($sql);
$extension_groups_updated[$lang_key] = true;
}
}
$db->sql_freeresult($result);
}
/**
* Obtain list of forums in which different attachment categories can be used
*/