1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Merge pull request #1583 from waskosky/master

New method to post forum attachment related data directly
This commit is contained in:
Cameron
2016-04-24 17:35:54 -07:00

View File

@@ -796,6 +796,13 @@ class forum_post_handler
$postInfo['post_attachments'] = e107::serialize($newValues);
}
//Allows directly overriding the method of adding files (or other data) as attachments
if($attachmentsPosted = $this->processAttachmentsPosted())
{
$postInfo['post_attachments'] = $attachmentsPosted;
}
// var_dump($uploadResult);
switch($this->action)
@@ -1005,7 +1012,13 @@ class forum_post_handler
$postVals['post_attachments'] = e107::serialize($newValues);
// $postVals['post_attachments'] = implode(',', $attachments);
}
//Allows directly overriding the method of adding files (or other data) as attachments
if($attachmentsPosted = $this->processAttachmentsPosted($this->data['post_attachments']))
{
$postVals['post_attachments'] = $attachmentsPosted;
}
$postVals['post_edit_datestamp'] = time();
$postVals['post_edit_user'] = USERID;
$postVals['post_entry'] = $_POST['post'];
@@ -1071,7 +1084,12 @@ class forum_post_handler
$postVals['post_attachments'] = e107::serialize($newValues);
}
//Allows directly overriding the method of adding files (or other data) as attachments
if($attachmentsPosted = $this->processAttachmentsPosted($this->data['post_attachments']))
{
$postVals['post_attachments'] = $attachmentsPosted;
}
$this->forumObj->postUpdate($this->data['post_id'], $postVals);
@@ -1223,6 +1241,31 @@ class forum_post_handler
}
*/
}
//Allows directly overriding the method of adding files (or other data) as attachments
function processAttachmentsPosted($existingValues = '')
{
if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json']))
{
$postedAttachments = json_decode($_POST['post_attachments_json'], true);
$attachmentsJsonErrors = json_last_error();
if($attachmentsJsonErrors === JSON_ERROR_NONE)
{
if($existingValues)
{
$existingValues = e107::unserialize($existingValues);
return e107::serialize(array_merge_recursive($existingValues,$postedAttachments));
}
else
{
return e107::serialize($postedAttachments);
}
}
}
return false;
}
}