mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
Merge pull request #4894 from rubencm/ticket/15276
[ticket/15276] Use storage in avatars * github.com:phpbb/phpbb: (34 commits) [ticket/15276] Changed annotation [ticket/15276] Remove unused code [ticket/15276] Revert some changes [ticket/15276] Use IniGetWrapper [ticket/15276] Add missing dependency [ticket/15276] Remove unused dependency [ticket/15276] Add missing properties [ticket/15276] Use InitGetWrapper [ticket/15276] Fix comments [ticket/15276] Fix code and add phpdoc [ticket/15276] Use stream_copy_to_stream [ticket/15276] Fix typo [ticket/15276] Use mimetype guesser [ticket/15276] Update file_info to get size of images [ticket/15276] Update [ticket/15276] Remove avatar_path [ticket/15276] Remove avatar_path from acp [ticket/15276] Use finfo to get mimetype [ticket/15276] Update file_info [ticket/15276] Fix code style ...
This commit is contained in:
@@ -2166,7 +2166,9 @@ function phpbb_style_is_active($style_id)
|
||||
*/
|
||||
function avatar_delete($mode, $row, $clean_db = false)
|
||||
{
|
||||
global $phpbb_root_path, $config;
|
||||
global $config, $phpbb_container;
|
||||
|
||||
$storage = $phpbb_container->get('storage.avatar');
|
||||
|
||||
// Check if the users avatar is actually *not* a group avatar
|
||||
if ($mode == 'user')
|
||||
@@ -2183,11 +2185,16 @@ function avatar_delete($mode, $row, $clean_db = false)
|
||||
}
|
||||
$filename = get_avatar_filename($row[$mode . '_avatar']);
|
||||
|
||||
if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename))
|
||||
try
|
||||
{
|
||||
@unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename);
|
||||
$storage->delete($filename);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (\phpbb\storage\exception\exception $e)
|
||||
{
|
||||
// Fail is covered by return statement below
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2507,7 +2514,9 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
||||
*/
|
||||
function group_correct_avatar($group_id, $old_entry)
|
||||
{
|
||||
global $config, $db, $phpbb_root_path;
|
||||
global $config, $db, $phpbb_container;
|
||||
|
||||
$storage = $phpbb_container->get('storage.avatar');
|
||||
|
||||
$group_id = (int) $group_id;
|
||||
$ext = substr(strrchr($old_entry, '.'), 1);
|
||||
@@ -2515,14 +2524,19 @@ function group_correct_avatar($group_id, $old_entry)
|
||||
$new_filename = $config['avatar_salt'] . "_g$group_id.$ext";
|
||||
$new_entry = 'g' . $group_id . '_' . substr(time(), -5) . ".$ext";
|
||||
|
||||
$avatar_path = $phpbb_root_path . $config['avatar_path'];
|
||||
if (@rename($avatar_path . '/'. $old_filename, $avatar_path . '/' . $new_filename))
|
||||
try
|
||||
{
|
||||
$this->storage->rename($old_filename, $new_filename);
|
||||
|
||||
$sql = 'UPDATE ' . GROUPS_TABLE . '
|
||||
SET group_avatar = \'' . $db->sql_escape($new_entry) . "'
|
||||
WHERE group_id = $group_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
catch (\phpbb\storage\exception\exception $e)
|
||||
{
|
||||
// If rename fail, dont execute the query
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user