mirror of
https://github.com/e107inc/e107.git
synced 2025-04-21 21:21:54 +02:00
Forum now allows for multiple attachments in a single user selection. For update thread/count should now working with PDO.
This commit is contained in:
parent
d7818345ce
commit
bf2db49dd1
@ -1040,8 +1040,42 @@ class e_file
|
||||
return process_uploaded_files($uploaddir, $fileinfo, $options);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Quickly scan and return a list of files in a directory.
|
||||
* @param $dir
|
||||
* @return array
|
||||
*/
|
||||
public function scandir($dir, $extensions=null)
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$ext = str_replace(",","|",$extensions);
|
||||
|
||||
$tmp = scandir($dir);
|
||||
foreach($tmp as $v)
|
||||
{
|
||||
if($v == '.' || $v == '..')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!empty($ext) && !preg_match("/\.(".$ext.")$/i", $v))
|
||||
{
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$list[] = $v;
|
||||
}
|
||||
|
||||
return $list ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Unzip Plugin or Theme zip file and move to plugin or theme folder.
|
||||
* @param string $localfile - filename located in e_TEMP
|
||||
|
@ -150,7 +150,10 @@ class e107forum
|
||||
|
||||
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.$post_id);
|
||||
$attach = e107::unserialize($array['post_attachments']);
|
||||
$file = $this->getAttachmentPath($array['post_user']).varset($attach['file'][$file_id]);
|
||||
|
||||
$filename = is_array($attach['file'][$file_id]) ? $attach['file'][$file_id]['file'] : $attach['file'][$file_id];
|
||||
|
||||
$file = $this->getAttachmentPath($array['post_user']).varset($filename);
|
||||
|
||||
// Check if file exists. Send file for download if it does, return 404 error code when file does not exist.
|
||||
if(file_exists($file))
|
||||
@ -162,6 +165,7 @@ class e107forum
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
echo "Couldn't find file: ".$file;
|
||||
print_a($attach);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -665,7 +669,15 @@ class e107forum
|
||||
$forumInfo['forum_lastpost_user'] = 0;
|
||||
$forumInfo['forum_lastpost_user_anon'] = $postInfo['post_user_anon'];
|
||||
}
|
||||
$threadInfo['thread_lastpost'] = $postInfo['post_datestamp'];
|
||||
|
||||
$threadInfo['thread_lastpost'] = !empty($postInfo['post_edit_datestamp']) ? $postInfo['post_edit_datestamp'] : $postInfo['post_datestamp'];
|
||||
|
||||
if(!empty($postInfo['post_edit_user']))
|
||||
{
|
||||
$threadInfo['thread_lastuser'] = $postInfo['post_edit_user'];
|
||||
}
|
||||
|
||||
|
||||
$threadInfo['thread_total_replies'] = 'thread_total_replies + 1';
|
||||
|
||||
$info = array();
|
||||
@ -675,6 +687,10 @@ class e107forum
|
||||
$info['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
|
||||
|
||||
$result = $sql->update('forum_thread', $info);
|
||||
|
||||
e107::getMessage()->addDebug("Updating Thread with: ".print_a($info,true));
|
||||
|
||||
|
||||
e107::getEvent()->trigger('user_forum_topic_updated', $info);
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,9 @@ class forum_post_handler
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
require_once(HEADERF);
|
||||
|
||||
e107::getRender()->tablerender('Debug', "Redirecting to: <a href='".$url."'>".$url."</a>");
|
||||
echo e107::getMessage()->render();
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
|
||||
@ -781,18 +783,11 @@ class forum_post_handler
|
||||
{
|
||||
foreach($uploadResult as $ur)
|
||||
{
|
||||
//$postInfo['post_entry'] .= $ur['txt'];
|
||||
// $_tmp = $ur['type'].'*'.$ur['file'];
|
||||
// if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
|
||||
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
||||
|
||||
$type = $ur['type'];
|
||||
$newValues[$type][] = $ur['file'];
|
||||
// $attachments[] = $_tmp;
|
||||
$newValues[$type][] = array('file'=>$ur['file'], 'name'=>$ur['fname'], 'size'=>$ur['size']);
|
||||
}
|
||||
|
||||
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
|
||||
$postInfo['post_attachments'] = e107::serialize($newValues); //FIXME XXX - broken encoding when saved to DB.
|
||||
$postInfo['post_attachments'] = e107::serialize($newValues);
|
||||
}
|
||||
// var_dump($uploadResult);
|
||||
|
||||
@ -998,7 +993,7 @@ class forum_post_handler
|
||||
// $attachments[] = $_tmp;
|
||||
|
||||
$type = $ur['type'];
|
||||
$newValues[$type][] = $ur['file'];
|
||||
$newValues[$type][] = array('file'=>$ur['file'], 'name'=>$ur['fname'], 'size'=>$ur['size']);
|
||||
}
|
||||
$postVals['post_attachments'] = e107::serialize($newValues);
|
||||
// $postVals['post_attachments'] = implode(',', $attachments);
|
||||
@ -1051,10 +1046,26 @@ class forum_post_handler
|
||||
return;
|
||||
}
|
||||
|
||||
e107::getMessage()->addDebug(print_a($this->data,true));
|
||||
|
||||
$postVals['post_edit_datestamp'] = time();
|
||||
$postVals['post_edit_user'] = USERID;
|
||||
$postVals['post_entry'] = $_POST['post'];
|
||||
|
||||
if($uploadResult = $this->processAttachments())
|
||||
{
|
||||
$newValues = e107::unserialize($this->data['post_attachments']);
|
||||
|
||||
foreach($uploadResult as $ur)
|
||||
{
|
||||
$type = $ur['type'];
|
||||
$newValues[$type][] = array('file'=>$ur['file'], 'name'=>$ur['fname'], 'size'=>$ur['size']);
|
||||
}
|
||||
|
||||
$postVals['post_attachments'] = e107::serialize($newValues);
|
||||
}
|
||||
|
||||
|
||||
$this->forumObj->postUpdate($this->data['post_id'], $postVals);
|
||||
|
||||
e107::getCache()->clear('newforumposts');
|
||||
@ -1100,7 +1111,7 @@ class forum_post_handler
|
||||
|
||||
e107::getMessage()->addDebug("Attachment Directory: ".$attachmentDir);
|
||||
|
||||
if($uploaded = e107::getFile()->getUploaded($attachmentDir, 'attachment', ''))
|
||||
if($uploaded = e107::getFile()->getUploaded($attachmentDir, 'attachment', array( 'max_file_count' => 5)))
|
||||
{
|
||||
|
||||
e107::getMessage()->addDebug("Uploaded Data: ".print_a($uploaded,true));
|
||||
@ -1178,7 +1189,7 @@ class forum_post_handler
|
||||
}
|
||||
if($_txt && $_file)
|
||||
{
|
||||
$ret[] = array('type' => $_type, 'txt' => $_txt, 'file' => $_file, 'thumb' => $_thumb, 'fname' => $_fname);
|
||||
$ret[] = array('type' => $_type, 'txt' => $_txt, 'file' => $_file, 'thumb' => $_thumb, 'fname' => $upload['origname'], 'size'=>$upload['size']);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -197,7 +197,7 @@ define("LAN_FORUM_3008", "Unauthorised"); // LAN_95
|
||||
define("LAN_FORUM_3009", "You are not authorised to edit this forum post."); //LAN_96
|
||||
define("LAN_FORUM_3010", "Your name"); // LAN_61
|
||||
define("LAN_FORUM_3011", "Subject"); // LAN_62
|
||||
define("LAN_FORUM_3012", "Attach file / image"); // LAN_390
|
||||
define("LAN_FORUM_3012", "Attach file(s) / image(s)"); // LAN_390
|
||||
define("LAN_FORUM_3013", "Attach file"); // LAN_416
|
||||
define("LAN_FORUM_3014", "File to attach"); // LAN_392
|
||||
define("LAN_FORUM_3015", "[Please note]"); // LAN_393 1st half - [ and ] are replaced by <b> </b>
|
||||
|
@ -256,14 +256,14 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
<div>
|
||||
<div id='fiupsection'>
|
||||
<span id='fiupopt'>
|
||||
<input class='tbox e-tip' title=\"".$tp->toAttribute($tooltip)."\" name='file_userfile[]' type='file' size='47' />
|
||||
<input class='tbox e-tip' title=\"".$tp->toAttribute($tooltip)."\" name='file_userfile[]' type='file' size='47' multiple='multiple' />
|
||||
</span>
|
||||
</div>
|
||||
<input class='btn btn-default button' type='button' name='addoption' value=".LAN_FORUM_3020." onclick=\"duplicateHTML('fiupopt','fiupsection')\" />
|
||||
|
||||
</div>
|
||||
|
||||
";
|
||||
|
||||
//<input class='btn btn-default button' type='button' name='addoption' value=".LAN_FORUM_3020." />
|
||||
if( $this->forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
|
||||
{
|
||||
return $fileattach;
|
||||
|
@ -105,12 +105,23 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
$txt = '';
|
||||
|
||||
$attachArray = e107::unserialize($this->postInfo['post_attachments']);
|
||||
//print_a($attachArray);
|
||||
//print_a($attachArray);
|
||||
|
||||
foreach($attachArray as $type=>$vals)
|
||||
{
|
||||
foreach($vals as $key=>$file)
|
||||
{
|
||||
list($date,$user, $name) = explode("_", $file, 3);
|
||||
if(is_array($file))
|
||||
{
|
||||
|
||||
$name = !empty($file['name']) ? $file['name'] : $file['file'];
|
||||
|
||||
$file = $file['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
list($date,$user, $name) = explode("_", $file, 3);
|
||||
}
|
||||
|
||||
switch($type)
|
||||
{
|
||||
@ -130,14 +141,21 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
break;
|
||||
|
||||
case 'img': //Always use thumb to hide the hash.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// return $baseDir.$file;
|
||||
if(file_exists($baseDir.$file))
|
||||
{
|
||||
$thumb = $tp->thumbUrl($baseDir.$file,'x=1',true);
|
||||
$full = $tp->thumbUrl($baseDir.$file,'w=1000&x=1', true);
|
||||
|
||||
$inc = (vartrue($parm['modal'])) ? "data-modal-caption=\"".$file."\" data-target='#uiModal' " : "";
|
||||
|
||||
//TODO Use jQuery zoom instead.
|
||||
|
||||
$caption = $name;
|
||||
|
||||
$inc = (vartrue($parm['modal'])) ? "data-modal-caption=\"".$caption."\" data-target='#uiModal' " : "";
|
||||
$images[] = "<a {$inc} rel='external' href='{$full}' class='forum-attachment-image e-modal' ><img class='thumbnail' src='{$thumb}' alt='' /></a>";
|
||||
}
|
||||
elseif(ADMIN)
|
||||
|
Loading…
x
Reference in New Issue
Block a user