1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

Forum plugin - now also displays file attachment when image attachment is also present

This commit is contained in:
Moc
2014-08-04 17:54:34 +02:00
parent c15c22ad7d
commit d6afec8de9
2 changed files with 11 additions and 15 deletions

View File

@@ -977,8 +977,9 @@ class e107forum
} }
} }
} }
// check if there are images to be deleted // check if there are images to be deleted
elseif(is_array($imgs)) if(is_array($imgs))
{ {
// loop through each image and delete it // loop through each image and delete it
foreach ($imgs as $img) foreach ($imgs as $img)
@@ -993,12 +994,7 @@ class e107forum
} }
} }
} }
// Apparently there are attachments other than 'files' or 'images' present. Add warning to log and proceed.
else
{
$log->addError("Unknown attachments detected in post (id: ".$id.")");
}
// At this point we assume that all attachments have been deleted from the post. The log file may prove otherwise (see above). // At this point we assume that all attachments have been deleted from the post. The log file may prove otherwise (see above).
$log->toFile('forum_delete_attachments', 'Forum plugin - Delete attachments', TRUE); $log->toFile('forum_delete_attachments', 'Forum plugin - Delete attachments', TRUE);

View File

@@ -99,22 +99,22 @@ class plugin_forum_view_shortcodes extends e_shortcode
$baseDir = $this->forum->getAttachmentPath($this->postInfo['post_user']); $baseDir = $this->forum->getAttachmentPath($this->postInfo['post_user']);
$images = array(); $images = array();
$attachArray = e107::unserialize($this->postInfo['post_attachments']);
$attachArray = e107::unserialize($this->postInfo['post_attachments']);
//print_a($attachArray);
foreach($attachArray as $type=>$vals) foreach($attachArray as $type=>$vals)
{ {
foreach($vals as $key=>$file) foreach($vals as $key=>$file)
{ {
list($date,$user,$tmp,$name) = explode("_", $file, 4); // FIXME $name is empty when there are just 3 parts to the filename (e.g. 1407153763_1_abbas.zip) list($date,$user, $name) = explode("_", $file, 3);
switch($type) switch($type)
{ {
case 'file': case 'file':
$url = e_SELF."?id=".$this->postInfo['post_id']."&dl=".$key; $url = e_SELF."?id=".$this->postInfo['post_id']."&dl=".$key;
$txt .= IMAGE_attachment." <a href='".$url."'>{$name}</a><br />"; $txt = IMAGE_attachment." <a href='".$url."'>{$name}</a><br />";
break; break;
case 'img': //Always use thumb to hide the hash. case 'img': //Always use thumb to hide the hash.
@@ -142,9 +142,9 @@ class plugin_forum_view_shortcodes extends e_shortcode
} }
if(count($images) ) if(count($images))
{ {
return (deftrue('BOOTSTRAP')) ? "<ul class='thumbnails'><li>".implode("</li><li>",$images)."</li></ul>" : implode("<br />",$images); return (deftrue('BOOTSTRAP')) ? "<ul class='thumbnails'><li>".implode("</li><li>",$images)."</li></ul>".vartrue($txt) : implode("<br />",$images).vartrue($txt);
} }