mirror of
https://github.com/e107inc/e107.git
synced 2025-07-26 17:30:24 +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:
@@ -1042,6 +1042,40 @@ class e_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Unzip Plugin or Theme zip file and move to plugin or theme folder.
|
||||||
* @param string $localfile - filename located in e_TEMP
|
* @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);
|
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.$post_id);
|
||||||
$attach = e107::unserialize($array['post_attachments']);
|
$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.
|
// Check if file exists. Send file for download if it does, return 404 error code when file does not exist.
|
||||||
if(file_exists($file))
|
if(file_exists($file))
|
||||||
@@ -162,6 +165,7 @@ class e107forum
|
|||||||
if(E107_DEBUG_LEVEL > 0)
|
if(E107_DEBUG_LEVEL > 0)
|
||||||
{
|
{
|
||||||
echo "Couldn't find file: ".$file;
|
echo "Couldn't find file: ".$file;
|
||||||
|
print_a($attach);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +669,15 @@ class e107forum
|
|||||||
$forumInfo['forum_lastpost_user'] = 0;
|
$forumInfo['forum_lastpost_user'] = 0;
|
||||||
$forumInfo['forum_lastpost_user_anon'] = $postInfo['post_user_anon'];
|
$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';
|
$threadInfo['thread_total_replies'] = 'thread_total_replies + 1';
|
||||||
|
|
||||||
$info = array();
|
$info = array();
|
||||||
@@ -675,6 +687,10 @@ class e107forum
|
|||||||
$info['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
|
$info['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
|
||||||
|
|
||||||
$result = $sql->update('forum_thread', $info);
|
$result = $sql->update('forum_thread', $info);
|
||||||
|
|
||||||
|
e107::getMessage()->addDebug("Updating Thread with: ".print_a($info,true));
|
||||||
|
|
||||||
|
|
||||||
e107::getEvent()->trigger('user_forum_topic_updated', $info);
|
e107::getEvent()->trigger('user_forum_topic_updated', $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -219,7 +219,9 @@ class forum_post_handler
|
|||||||
if(E107_DEBUG_LEVEL > 0)
|
if(E107_DEBUG_LEVEL > 0)
|
||||||
{
|
{
|
||||||
require_once(HEADERF);
|
require_once(HEADERF);
|
||||||
|
|
||||||
e107::getRender()->tablerender('Debug', "Redirecting to: <a href='".$url."'>".$url."</a>");
|
e107::getRender()->tablerender('Debug', "Redirecting to: <a href='".$url."'>".$url."</a>");
|
||||||
|
echo e107::getMessage()->render();
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@@ -781,18 +783,11 @@ class forum_post_handler
|
|||||||
{
|
{
|
||||||
foreach($uploadResult as $ur)
|
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'];
|
$type = $ur['type'];
|
||||||
$newValues[$type][] = $ur['file'];
|
$newValues[$type][] = array('file'=>$ur['file'], 'name'=>$ur['fname'], 'size'=>$ur['size']);
|
||||||
// $attachments[] = $_tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
|
$postInfo['post_attachments'] = e107::serialize($newValues);
|
||||||
$postInfo['post_attachments'] = e107::serialize($newValues); //FIXME XXX - broken encoding when saved to DB.
|
|
||||||
}
|
}
|
||||||
// var_dump($uploadResult);
|
// var_dump($uploadResult);
|
||||||
|
|
||||||
@@ -998,7 +993,7 @@ class forum_post_handler
|
|||||||
// $attachments[] = $_tmp;
|
// $attachments[] = $_tmp;
|
||||||
|
|
||||||
$type = $ur['type'];
|
$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'] = e107::serialize($newValues);
|
||||||
// $postVals['post_attachments'] = implode(',', $attachments);
|
// $postVals['post_attachments'] = implode(',', $attachments);
|
||||||
@@ -1051,10 +1046,26 @@ class forum_post_handler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e107::getMessage()->addDebug(print_a($this->data,true));
|
||||||
|
|
||||||
$postVals['post_edit_datestamp'] = time();
|
$postVals['post_edit_datestamp'] = time();
|
||||||
$postVals['post_edit_user'] = USERID;
|
$postVals['post_edit_user'] = USERID;
|
||||||
$postVals['post_entry'] = $_POST['post'];
|
$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);
|
$this->forumObj->postUpdate($this->data['post_id'], $postVals);
|
||||||
|
|
||||||
e107::getCache()->clear('newforumposts');
|
e107::getCache()->clear('newforumposts');
|
||||||
@@ -1100,7 +1111,7 @@ class forum_post_handler
|
|||||||
|
|
||||||
e107::getMessage()->addDebug("Attachment Directory: ".$attachmentDir);
|
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));
|
e107::getMessage()->addDebug("Uploaded Data: ".print_a($uploaded,true));
|
||||||
@@ -1178,7 +1189,7 @@ class forum_post_handler
|
|||||||
}
|
}
|
||||||
if($_txt && $_file)
|
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
|
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_3009", "You are not authorised to edit this forum post."); //LAN_96
|
||||||
define("LAN_FORUM_3010", "Your name"); // LAN_61
|
define("LAN_FORUM_3010", "Your name"); // LAN_61
|
||||||
define("LAN_FORUM_3011", "Subject"); // LAN_62
|
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_3013", "Attach file"); // LAN_416
|
||||||
define("LAN_FORUM_3014", "File to attach"); // LAN_392
|
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>
|
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>
|
||||||
<div id='fiupsection'>
|
<div id='fiupsection'>
|
||||||
<span id='fiupopt'>
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<input class='btn btn-default button' type='button' name='addoption' value=".LAN_FORUM_3020." onclick=\"duplicateHTML('fiupopt','fiupsection')\" />
|
|
||||||
</div>
|
</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')))
|
if( $this->forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
|
||||||
{
|
{
|
||||||
return $fileattach;
|
return $fileattach;
|
||||||
|
@@ -106,11 +106,22 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
$attachArray = e107::unserialize($this->postInfo['post_attachments']);
|
$attachArray = e107::unserialize($this->postInfo['post_attachments']);
|
||||||
//print_a($attachArray);
|
//print_a($attachArray);
|
||||||
|
|
||||||
foreach($attachArray as $type=>$vals)
|
foreach($attachArray as $type=>$vals)
|
||||||
{
|
{
|
||||||
foreach($vals as $key=>$file)
|
foreach($vals as $key=>$file)
|
||||||
|
{
|
||||||
|
if(is_array($file))
|
||||||
|
{
|
||||||
|
|
||||||
|
$name = !empty($file['name']) ? $file['name'] : $file['file'];
|
||||||
|
|
||||||
|
$file = $file['file'];
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
list($date,$user, $name) = explode("_", $file, 3);
|
list($date,$user, $name) = explode("_", $file, 3);
|
||||||
|
}
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
@@ -131,13 +142,20 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
case 'img': //Always use thumb to hide the hash.
|
case 'img': //Always use thumb to hide the hash.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return $baseDir.$file;
|
// return $baseDir.$file;
|
||||||
if(file_exists($baseDir.$file))
|
if(file_exists($baseDir.$file))
|
||||||
{
|
{
|
||||||
$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-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>";
|
$images[] = "<a {$inc} rel='external' href='{$full}' class='forum-attachment-image e-modal' ><img class='thumbnail' src='{$thumb}' alt='' /></a>";
|
||||||
}
|
}
|
||||||
elseif(ADMIN)
|
elseif(ADMIN)
|
||||||
|
Reference in New Issue
Block a user