From 0274351641cf829af33635e56a2c8868bcc4071e Mon Sep 17 00:00:00 2001 From: mcfly Date: Mon, 22 Mar 2010 01:50:04 +0000 Subject: [PATCH] EONE-1 (Bug): More improvements to upgrade process. I think it's all working, but need to clean up the interface. Also added ability to add attachments while editing a post. --- e107_plugins/forum/forum_admin_class.php | 2 +- e107_plugins/forum/forum_post.php | 21 +++++++++++++++--- e107_plugins/forum/forum_post_shortcodes.php | 2 +- e107_plugins/forum/forum_update.php | 23 +++++++++++++++----- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/e107_plugins/forum/forum_admin_class.php b/e107_plugins/forum/forum_admin_class.php index 128111f55..0ca51bb88 100755 --- a/e107_plugins/forum/forum_admin_class.php +++ b/e107_plugins/forum/forum_admin_class.php @@ -641,7 +641,7 @@ class forumAdmin if(!$poll_installed) { - if($fPref['poll'] == 1) + if($fPref->get('poll') == 1) { $fPref['forum_poll'] = e_UC_NOBODY; $fPref->save(false, true); diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index a76b7803a..60c2d409c 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -51,7 +51,7 @@ switch($action) $postInfo = $forum->postGet($id, 'post'); $threadInfo = $postInfo; $forumId = $postInfo['post_forum']; - $forumInfo = $forum->forum_get($forumId); + $forumInfo = $forum->forumGet($forumId); break; default: @@ -246,6 +246,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply'])) //$postInfo['post_entry'] .= $ur['txt']; $_tmp = $ur['type'].'*'.$ur['file']; if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; } + if($ur['fname']) { $_tmp .= '*'.$ur['fname']; } $attachments[] = $_tmp; } $postInfo['post_attachments'] = implode(',', $attachments); @@ -367,6 +368,19 @@ if (isset($_POST['update_thread'])) exit; } + if($uploadResult = process_upload($postInfo['post_id'])) + { + $attachments = explode(',', $postInfo['post_attachments']); + foreach($uploadResult as $ur) + { + $_tmp = $ur['type'].'*'.$ur['file']; + if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; } + if($ur['fname']) { $_tmp .= '*'.$ur['fname']; } + $attachments[] = $_tmp; + } + $postVals['post_attachments'] = implode(',', $attachments); + } + $postVals['post_edit_datestamp'] = time(); $postVals['post_edit_user'] = USERID; $postVals['post_entry'] = $_POST['post']; @@ -552,7 +566,7 @@ function process_upload() $postId = (int)$postId; $ret = array(); -// var_dump($_FILES); + var_dump($_FILES); if (isset($_FILES['file_userfile']['error'])) { @@ -570,6 +584,7 @@ function process_upload() $_att = ''; $_file = ''; $_thumb = ''; + $_fname = ''; $fpath = '{e_PLUGIN}forum/attachments/'; if(strstr($upload['type'], 'image')) { @@ -627,7 +642,7 @@ function process_upload() } if($_txt && $_file) { - $ret[] = array('type' => $_type, 'txt' => $_txt, 'file' => $_file, 'thumb' => $_thumb); + $ret[] = array('type' => $_type, 'txt' => $_txt, 'file' => $_file, 'thumb' => $_thumb, 'fname' => $_fname); } } else diff --git a/e107_plugins/forum/forum_post_shortcodes.php b/e107_plugins/forum/forum_post_shortcodes.php index 65b255136..ebf1684f3 100644 --- a/e107_plugins/forum/forum_post_shortcodes.php +++ b/e107_plugins/forum/forum_post_shortcodes.php @@ -105,7 +105,7 @@ class forum_post_shortcodes { global $forum, $pref, $fileattach, $fileattach_alert; - if ($forum->prefs->get('attach') && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0'))) + if ($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0'))) { if (is_writable(e_PLUGIN.'forum/attachments')) { diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php index e04aae749..c913cb720 100644 --- a/e107_plugins/forum/forum_update.php +++ b/e107_plugins/forum/forum_update.php @@ -789,19 +789,30 @@ function step10() $info['post_entry'] = $post['post_entry']; foreach($attachments as $attachment) { -// var_dump($attachment); $error = ''; if($f->moveAttachment($attachment, $error)) { $_file = split('/', $attachment['name']); - $tmp = split('_', $_file[1], 4); - $newval = $attachment['type'].'*'.$_file[1].'*'.$tmp[3]; - if($attachment['thumb']) + $newval = $attachment['type'].'*'.$_file[1]; + switch($attachment['type']) { - $_file = split('/', $attachment['thumb']); - $newval .= '*'.$_file[1]; + //If file, add real name to entry + case 'file': + $tmp = split('_', $_file[1], 4); + $newval .= '*'.$tmp[3]; + break; + + //If image and it has a thumb, add thumb filename to entry + case 'img': + if($attachment['thumb']) + { + $_file = split('/', $attachment['thumb']); + $newval .= '*'.$_file[1]; + } + break; } $newValues[] = $newval; + echo "Newval = $newval
"; // echo "Removing from post:".htmlentities($attachment['html'])."
"; $info['post_entry'] = str_replace($attachment['html'], '', $info['post_entry']); }