diff options
| author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2016-03-25 11:48:29 +0100 | 
|---|---|---|
| committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2016-03-25 11:48:29 +0100 | 
| commit | 7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55 (patch) | |
| tree | 19de4f59168c5d5045aba760784dad9cbe0836e5 /phpBB/includes | |
| parent | 6774c5077ddf82eb2f31e92d327ce6905b73c3df (diff) | |
| parent | 3d7d0c40b8e7f1897fc4a323d4edee6db2a7f452 (diff) | |
| download | forums-7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55.tar forums-7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55.tar.gz forums-7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55.tar.bz2 forums-7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55.tar.xz forums-7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55.zip | |
Merge pull request #4190 from marc1706/ticket/14437
[ticket/14437] Correctly assume index from attachment display order
* marc1706/ticket/14437:
  [ticket/14437] Make sure attachments array is properly ordered before processing
  [ticket/14437] Preserve attachment ID order by ordering by attach_id
  [ticket/14437] Sort attachments after assigning inline attachments
  [ticket/14437] Correctly assume index from attachment display order
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/functions_content.php | 30 | 
1 files changed, 15 insertions, 15 deletions
| diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 36d7dfc03c..e05fcb0586 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1036,17 +1036,8 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  		unset($new_attachment_data);  	} -	// Sort correctly -	if ($config['display_order']) -	{ -		// Ascending sort -		krsort($attachments); -	} -	else -	{ -		// Descending sort -		ksort($attachments); -	} +	// Make sure attachments are properly ordered +	ksort($attachments);  	foreach ($attachments as $attachment)  	{ @@ -1285,8 +1276,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  	$attachments = $compiled_attachments;  	unset($compiled_attachments); -	$tpl_size = sizeof($attachments); -  	$unset_tpl = array();  	preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $message, $matches, PREG_PATTERN_ORDER); @@ -1294,8 +1283,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  	$replace = array();  	foreach ($matches[0] as $num => $capture)  	{ -		// Flip index if we are displaying the reverse way -		$index = ($config['display_order']) ? ($tpl_size-($matches[1][$num] + 1)) : $matches[1][$num]; +		$index = $matches[1][$num];  		$replace['from'][] = $matches[0][$num];  		$replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]); @@ -1310,6 +1298,18 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  	$unset_tpl = array_unique($unset_tpl); +	// Sort correctly +	if ($config['display_order']) +	{ +		// Ascending sort +		krsort($attachments); +	} +	else +	{ +		// Descending sort +		ksort($attachments); +	} +  	// Needed to let not display the inlined attachments at the end of the post again  	foreach ($unset_tpl as $index)  	{ | 
