mirror of
https://github.com/e107inc/e107.git
synced 2025-08-19 21:02:09 +02:00
Forum upgrade fixes. Forum-attachments now converted in batches.
This commit is contained in:
@@ -147,6 +147,32 @@ class e107forum
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
function getAttachmentPath($user=0)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
$baseDir = e_MEDIA.'plugins/forum/attachments/';
|
||||
$baseDir .= ($user) ? "user_". $tp->leadingZeros($user, 6) : "anon";
|
||||
$baseDir .= "/";
|
||||
|
||||
return $baseDir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function sendFile($data)
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$fid = intval($data['dl']);
|
||||
|
||||
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.intval($data['id']));
|
||||
$attach = e107::getArrayStorage()->read($array['post_attachments']);
|
||||
$file = $this->getAttachmentPath($array['post_user']).varset($attach['file'][$fid]);
|
||||
|
||||
e107::getFile()->send($file);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle the Ajax quick-reply.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,9 @@ if (!e_QUERY)
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// include_lan(e_PLUGIN . 'forum/languages/'.e_LANGUAGE.'/lan_forum_viewtopic.php');
|
||||
include_once (e_PLUGIN . 'forum/forum_class.php');
|
||||
|
||||
@@ -43,6 +46,15 @@ include_once (e_PLUGIN . 'forum/forum_class.php');
|
||||
$forum = new e107forum();
|
||||
$thread = new e107ForumThread();
|
||||
|
||||
if(vartrue($_GET['id']) && isset($_GET['dl']))
|
||||
{
|
||||
$forum->sendFile($_GET);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST && varset($_POST['action']) == 'quickreply')
|
||||
{
|
||||
$forum->ajaxQuickReply();
|
||||
|
||||
@@ -70,36 +70,61 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
$ret = '<pre>'.print_r($info, true).'</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function sc_attachments()
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
if($this->postInfo['post_attachments'])
|
||||
{
|
||||
$baseDir = e_MEDIA_ABS.'files/plugins/forum/attachments/';
|
||||
$attachments = explode(',', $this->postInfo['post_attachments']);
|
||||
$txt = '';
|
||||
foreach($attachments as $a)
|
||||
{
|
||||
$info = explode('*', $a);
|
||||
switch($info[0])
|
||||
{
|
||||
case 'file':
|
||||
$txt .= IMAGE_attachment." <a href='{$baseDir}{$info[1]}'>{$info[2]}</a><br />";
|
||||
break;
|
||||
$baseDir = $this->forum->getAttachmentPath($this->postInfo['post_user']);
|
||||
|
||||
case 'img':
|
||||
//if image has a thumb, show it and link to main
|
||||
if(isset($info[2]))
|
||||
$images = array();
|
||||
|
||||
$attachArray = e107::getArrayStorage()->read($this->postInfo['post_attachments']);
|
||||
|
||||
foreach($attachArray as $type=>$vals)
|
||||
{
|
||||
foreach($vals as $key=>$file)
|
||||
{
|
||||
list($date,$user,$tmp,$name) = explode("_",$file,4);
|
||||
|
||||
switch($type)
|
||||
{
|
||||
$txt .= "<a href='{$baseDir}{$info[1]}'><img src='{$baseDir}thumb/{$info[2]}' alt='' /></a><br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
$txt .= "<img src='{$baseDir}{$info[1]}' alt='' /><br />";
|
||||
}
|
||||
}
|
||||
case 'file':
|
||||
|
||||
$url = e_SELF."?id=".$this->postInfo['post_id']."&dl=".$key;
|
||||
$txt .= IMAGE_attachment." <a href='".$url."'>{$name}</a><br />";
|
||||
|
||||
break;
|
||||
|
||||
case 'img': //Always use thumb to hide the hash.
|
||||
|
||||
$thumb = $tp->thumbUrl($baseDir.$file,'x=1',true);
|
||||
$full = $tp->thumbUrl($baseDir.$file,'w=1000&x=1', true);
|
||||
|
||||
$inc = (vartrue($parm['modal'])) ? "data-toggle='modal' data-target='#".$parm['modal']."' " : "";
|
||||
$images[] = "<a {$inc} rel='external' href='{$full}'><img class='thumbnail' src='{$thumb}' alt='' /></a>";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(count($images) )
|
||||
{
|
||||
return (deftrue('e_BOOTSTRAP')) ? "<ul class='thumbnails'><li>".implode("</li><li>",$images)."</li></ul>" : implode("<br />",$images);
|
||||
}
|
||||
|
||||
|
||||
return $txt;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -339,14 +339,12 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
|
||||
{CUSTOMTITLE}
|
||||
{AVATAR}
|
||||
{USERCOMBO}
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class='span9 '>
|
||||
{POLL}
|
||||
{POST}
|
||||
|
||||
{ATTACHMENTS}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -356,7 +354,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
|
||||
|
||||
</div>
|
||||
<div class='span9 finfobar' >
|
||||
<small>{ATTACHMENTS} {SIGNATURE=clean}</small>
|
||||
<small> {SIGNATURE=clean}</small>
|
||||
</div>
|
||||
|
||||
<div class='span3'>
|
||||
|
||||
Reference in New Issue
Block a user