mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
Fixes #1433 - Forum Attachments/Image data would become corrupted while editing.
This commit is contained in:
@@ -743,7 +743,12 @@ class e107forum
|
|||||||
{
|
{
|
||||||
e107::getEvent()->trigger('user_forum_topic_created', $info);
|
e107::getEvent()->trigger('user_forum_topic_created', $info);
|
||||||
$postInfo['post_thread'] = $newThreadId;
|
$postInfo['post_thread'] = $newThreadId;
|
||||||
$newPostId = $this->postAdd($postInfo, false);
|
|
||||||
|
if(!$newPostId = $this->postAdd($postInfo, false))
|
||||||
|
{
|
||||||
|
e107::getMessage()->addDebug("There was a problem: ".print_a($postInfo,true));
|
||||||
|
}
|
||||||
|
|
||||||
$this->threadMarkAsRead($newThreadId);
|
$this->threadMarkAsRead($newThreadId);
|
||||||
$threadInfo['thread_sef'] = $this->getThreadsef($threadInfo);
|
$threadInfo['thread_sef'] = $this->getThreadsef($threadInfo);
|
||||||
|
|
||||||
@@ -931,7 +936,7 @@ class e107forum
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e107::getMessage()->addDebug("Query Failed: ".$qry);
|
e107::getMessage()->addDebug('Query failed ('.__METHOD__.' ): '.str_replace('#', MPREFIX,$qry));
|
||||||
|
|
||||||
}
|
}
|
||||||
if('post' === $start) { return $ret[0]; }
|
if('post' === $start) { return $ret[0]; }
|
||||||
|
@@ -988,15 +988,20 @@ class forum_post_handler
|
|||||||
|
|
||||||
if($uploadResult = $this->processAttachments())
|
if($uploadResult = $this->processAttachments())
|
||||||
{
|
{
|
||||||
$attachments = explode(',', $this->data['post_attachments']);
|
// $attachments = explode(',', $this->data['post_attachments']);
|
||||||
|
$newValues = e107::unserialize($this->data['post_attachments']);
|
||||||
foreach($uploadResult as $ur)
|
foreach($uploadResult as $ur)
|
||||||
{
|
{
|
||||||
$_tmp = $ur['type'].'*'.$ur['file'];
|
// $_tmp = $ur['type'].'*'.$ur['file'];
|
||||||
if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
|
// if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
|
||||||
if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
||||||
$attachments[] = $_tmp;
|
// $attachments[] = $_tmp;
|
||||||
|
|
||||||
|
$type = $ur['type'];
|
||||||
|
$newValues[$type][] = $ur['file'];
|
||||||
}
|
}
|
||||||
$postVals['post_attachments'] = implode(',', $attachments);
|
$postVals['post_attachments'] = e107::serialize($newValues);
|
||||||
|
// $postVals['post_attachments'] = implode(',', $attachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
$postVals['post_edit_datestamp'] = time();
|
$postVals['post_edit_datestamp'] = time();
|
||||||
@@ -1074,23 +1079,33 @@ class forum_post_handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function processAttachments()
|
function processAttachments()
|
||||||
{
|
{
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
|
e107::getMessage()->addDebug("Processing Attachments");
|
||||||
|
|
||||||
|
|
||||||
if (isset($_FILES['file_userfile']['error']))
|
if (isset($_FILES['file_userfile']['error']))
|
||||||
{
|
{
|
||||||
require_once(e_HANDLER.'upload_handler.php');
|
|
||||||
|
e107::getMessage()->addDebug("Attachment Detected");
|
||||||
|
|
||||||
// retrieve and create attachment directory if needed
|
// retrieve and create attachment directory if needed
|
||||||
$attachmentDir = $this->forumObj->getAttachmentPath(USERID, true);
|
$attachmentDir = $this->forumObj->getAttachmentPath(USERID, true);
|
||||||
|
|
||||||
if($uploaded = process_uploaded_files($attachmentDir, 'attachment', ''))
|
e107::getMessage()->addDebug("Attachment Directory: ".$attachmentDir);
|
||||||
|
|
||||||
|
if($uploaded = e107::getFile()->getUploaded($attachmentDir, 'attachment', ''))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
e107::getMessage()->addDebug("Uploaded Data: ".print_a($uploaded,true));
|
||||||
|
|
||||||
|
|
||||||
foreach($uploaded as $upload)
|
foreach($uploaded as $upload)
|
||||||
{
|
{
|
||||||
//print_a($upload); exit;
|
//print_a($upload); exit;
|
||||||
@@ -1176,6 +1191,11 @@ class forum_post_handler
|
|||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// e107::getMessage()->addError('There was a problem with the attachment.');
|
||||||
|
// e107::getMessage()->addDebug(print_a($_FILES['file_userfile'],true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* no file uploaded at all, proceed with creating the topic or reply
|
/* no file uploaded at all, proceed with creating the topic or reply
|
||||||
// TODO don't call process_upload() when no attachments are uploaded.. (check user input first, then call if needed)
|
// TODO don't call process_upload() when no attachments are uploaded.. (check user input first, then call if needed)
|
||||||
|
@@ -137,8 +137,8 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
|||||||
$thumb = $tp->thumbUrl($baseDir.$file,'x=1',true);
|
$thumb = $tp->thumbUrl($baseDir.$file,'x=1',true);
|
||||||
$full = $tp->thumbUrl($baseDir.$file,'w=1000&x=1', true);
|
$full = $tp->thumbUrl($baseDir.$file,'w=1000&x=1', true);
|
||||||
|
|
||||||
$inc = (vartrue($parm['modal'])) ? "data-toggle='modal' data-target='#".$parm['modal']."' " : "";
|
$inc = (vartrue($parm['modal'])) ? "data-modal-caption=\"".$file."\" data-target='#uiModal' " : "";
|
||||||
$images[] = "<a {$inc} rel='external' href='{$full}' class='forum-attachment-image' ><img class='thumbnail' src='{$thumb}' alt='' /></a>";
|
$images[] = "<a {$inc} rel='external' href='{$full}' class='forum-attachment-image e-modal' ><img class='thumbnail' src='{$thumb}' alt='' /></a>";
|
||||||
}
|
}
|
||||||
elseif(ADMIN)
|
elseif(ADMIN)
|
||||||
{
|
{
|
||||||
|
@@ -363,7 +363,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
|
|||||||
<div class='col-xs-12 col-md-9 span9 forum-thread-text '>
|
<div class='col-xs-12 col-md-9 span9 forum-thread-text '>
|
||||||
{POLL}
|
{POLL}
|
||||||
{THREAD_TEXT}
|
{THREAD_TEXT}
|
||||||
{ATTACHMENTS}
|
{ATTACHMENTS: modal=1}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user