1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

Fixes #717 - Forum Post rewrite. new bootstrap templates added as well as new shortcodes. (attachments not functioning at this moment)

This commit is contained in:
Cameron
2015-04-18 15:09:10 -07:00
parent 654fd32677
commit 8890c523f0
11 changed files with 1065 additions and 96 deletions

View File

@@ -2,4 +2,12 @@
$class = e107::getBB()->getClass('quote');
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_parser_functions.php");
if(deftrue('BOOTSTRAP'))
{
return '<blockquote>
<p>'.$code_text.'</p>
<small><cite title="'.$parm.'">'.$parm.'</cite></small>
</blockquote>';
}
return "<div class='indent {$class}'><em>$parm ".LAN_WROTE."</em> ...<br />$code_text</div>";

View File

@@ -585,6 +585,27 @@ class e107forum
return false;
}
function isDuplicatePost($postInfo)
{
$sql = e107::getDb();
$tp = e107::getParser();
$post = $tp->toDB($postInfo['post_entry']);
if($sql->select('forum_post', 'post_id', "post_forum = ".intval($postInfo['post_forum'])." AND post_entry='".$post."' AND post_user = ".USERID." LIMIT 1"))
{
return true;
}
return false;
}
/*
* Add a post to the db.
*
@@ -594,14 +615,24 @@ class e107forum
function postAdd($postInfo, $updateThread = true, $updateForum = true)
{
// var_dump($postInfo);
//Future option, will just set to true here
if($this->isDuplicatePost($postInfo)==true)
{
return -1;
}
$addUserPostCount = true;
$result = false;
$e107 = e107::getInstance();
$sql = e107::getDb();
$info = array();
$tp = e107::getParser();
// $info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$postInfo['post_entry'] = $tp->toDB($postInfo['post_entry']);
$info['data'] = $postInfo;
$postId = $sql->insert('forum_post', $info);
e107::getEvent()->trigger('user_forum_post_created', $info);
@@ -747,7 +778,12 @@ class e107forum
$info['data'] = $threadInfo;
// $info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
$info['WHERE'] = 'thread_id = '.(int)$threadId;
e107::getDb()->update('forum_thread', $info);
if(e107::getDb()->update('forum_thread', $info)===false)
{
e107::getMessage()->addDebug("Thread Update Failed: ".print_a($info,true));
}
e107::getEvent()->trigger('user_forum_topic_updated', $info);
}
@@ -759,7 +795,12 @@ class e107forum
$info['data'] = $postInfo;
// $info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$info['WHERE'] = 'post_id = '.(int)$postId;
e107::getDb()->update('forum_post', $info);
if(e107::getDb()->update('forum_post', $info)===false)
{
e107::getMessage()->addDebug("Post Update Failed: ".print_a($info,true));
}
e107::getEvent()->trigger('user_forum_post_updated', $info);
}
@@ -805,6 +846,10 @@ class e107forum
return $tmp;
}
}
else
{
e107::getMessage()->addDebug('Query failed ('.__METHOD__.' ): '.$qry);
}
return false;
}
@@ -818,7 +863,7 @@ class e107forum
if('post' === $start)
{
$qry = '
SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, t.thread_id, p.* FROM `#forum_post` AS p
SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, t.thread_user, t.thread_id, p.* FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE p.post_id = '.$id;
@@ -849,6 +894,11 @@ class e107forum
$ret[] = $row;
}
}
else
{
e107::getMessage()->addDebug("Query Failed: ".$qry);
}
if('post' === $start) { return $ret[0]; }
return $ret;
}
@@ -1806,7 +1856,9 @@ class e107forum
// New v2.x Bootstrap Standardized Breadcrumb.
// New v2.x Bootstrap Standardized Breadcrumb.
// return print_a($forumInfo);
$breadcrumb = array();

View File

@@ -11,7 +11,8 @@
*/
require_once('../../class2.php');
define('NAVIGATION_ACTIVE','forum');
define('NAVIGATION_ACTIVE','forum'); // ??
$e107 = e107::getInstance();
$tp = e107::getParser();
$ns = e107::getRender();
@@ -23,25 +24,721 @@ if (!$e107->isInstalled('forum'))
exit;
}
// include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_post.php');
e107::lan('forum','English_front');
if (isset($_POST['fjsubmit']))
class forum_post_handler
{
header('Location:'.e107::getUrl()->create('forum/forum/view', array('id'=>(int) $_POST['forumjump']), '', 'full=1&encode=0'));
exit;
private $forumObj;
private $action;
private $id;
private $data;
function __construct()
{
$this->checkForumJump();
require_once(e_PLUGIN.'forum/forum_class.php'); // includes LAN file.
$forum = new e107forum();
$this->forumObj = $forum;
$this->action = trim($_GET['f']); // action: rp|quote|nt|edit etc.
$this->id = (int) $_GET['id']; // forum thread/topic id.
$this->post = (int) $_GET['post']; // post ID if needed.
define('MODERATOR', USER && $this->forumObj->isModerator(USERID));
$this->checkPerms($this->id);
$this->data = $this->processGet();
$this->processPosted();
$this->renderForm();
}
function checkForumJump()
{
if(isset($_POST['fjsubmit']))
{
header('Location:'.e107::getUrl()->create('forum/forum/view', array('id'=>(int) $_POST['forumjump']), '', 'full=1&encode=0'));
exit;
}
if (!e_QUERY || empty($_GET['id']))
{
header('Location:'.e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
}
}
/**
* Handle all _GET request actions.
*/
function processGet()
{
switch($this->action)
{
case 'rp':
$thread = $this->forumObj->threadGet($this->id, false);
$extra = $this->forumObj->forumGet($thread['thread_forum_id']);
$data = array_merge($thread,$extra);
$data['action'] = $this->action;
$this->setPageTitle($data);
return $data;
break;
case 'nt':
$forumInfo = $this->forumObj->forumGet($this->id);
$forumInfo['action'] = $this->action;
$this->setPageTitle($forumInfo);
return $forumInfo;
break;
case 'edit':
case 'quote':
$postInfo = $this->forumObj->postGet($this->post, 'post');
$forumInfo = $this->forumObj->forumGet($postInfo['post_forum']);
$data = array_merge($postInfo ,$forumInfo);
$data['action'] = $this->action;
$this->setPageTitle($data);
return $data;
break;
default:
header("Location:".e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
}
}
/**
* Handle all _POST actions.
*/
function processPosted()
{
if(!empty($_POST['action'])) // override from 'quote' mode to 'rp' mode.
{
$this->action = $_POST['action'];
}
if(isset($_POST['newthread']) || isset($_POST['reply']))
{
$this->insertPost();
}
if(isset($_POST['update_thread']))
{
$this->updateThread();
}
if(isset($_POST['update_reply']))
{
$this->updateReply();
}
if(!empty($_POST['fpreview']))
{
$this->renderPreview();
}
if (isset($_POST['submitpoll']))
{
$this->submitPoll();
}
}
/**
* @param $url
*/
private function redirect($url)
{
e107::getRedirect()->go($url);
}
/**
*
*/
function submitPoll()
{
require_once(e_PLUGIN.'poll/poll_class.php');
$poll = new poll;
require_once(HEADERF);
$template = $this->getTemplate('posted');
echo $template['poll'];
require_once(FOOTERF);
exit;
}
function setPageTitle($data)
{
$tp = e107::getParser();
$data['forum_name'] = $tp->toHTML($data['forum_name'], true);
define('e_PAGETITLE', ($this->action == 'rp' ? LAN_FORUM_3003.": ".$data['thread_name'] : LAN_FORUM_1018).' / '.$data['forum_name'].' / '.LAN_FORUM_1001);
}
function checkPerms($forumId)
{
$mes = e107::getMessage();
$ns = e107::getRender();
if (!$this->forumObj->checkPerm($forumId, 'post')) // check user has permission to post to this thread.
{
require_once(HEADERF);
$mes->addError(LAN_FORUM_3001);
// $mes->addDebug("action: ".$this->action);
// $mes->addDebug("id: ".$this->id);
// $mes->addDebug(print_a($threadInfo, true));
$ns->tablerender(LAN_FORUM_1001, $mes->render());
require_once(FOOTERF);
exit;
}
$data = $this->forumObj->threadGet($this->id, false);
if ($this->action != 'nt' && !$data['thread_active'] && !MODERATOR) // check the thread is active.
{
require_once(HEADERF);
$mes->addError(LAN_FORUM_3002);
$ns->tablerender(LAN_FORUM_1001, $mes->render());
require_once(FOOTERF);
exit;
}
}
/**
* @return string
*/
function getTemplate($type = 'post')
{
global $FORUMPOST;
$FORUM_POST_TEMPLATE = array();
$FORUM_POSTED_TEMPLATE = array();
$FORUMREPLYPOSTED = '';
$FORUMTHREADPOSTED = '';
$FORUMPOLLPOSTED = '';
$file = "forum_".$type."_template.php";
if (empty($FORUMPOST) && empty($FORUMREPLYPOSTED) && empty($FORUMTHREADPOSTED))
{
if (is_readable(THEME.$file))
{
include_once(THEME.$file);
}
else
{
include_once(e_PLUGIN.'forum/templates/'.$file);
}
}
if($type == 'post')
{
return (deftrue('BOOTSTRAP')) ? $FORUM_POST_TEMPLATE : array('form'=>$FORUMPOST);
}
else
{
if (deftrue('BOOTSTRAP')) //v2.x
{
return $FORUM_POSTED_TEMPLATE;
}
else //v1.x
{
return array(
"reply" => $FORUMREPLYPOSTED,
"thread" => $FORUMTHREADPOSTED,
"poll" => $FORUMPOLLPOSTED
);
}
}
}
function renderForm()
{
$data = $this->data;
$template = $this->getTemplate();
$sc = e107::getScBatch('post', 'forum')->setScVar('forum', $this->forumObj)->setScVar('threadInfo', vartrue($data))->setVars($data);
$text = e107::getParser()->parseTemplate($template['form'], true, $sc);
$this->render($text);
if(empty($data))
{
e107::getMessage()->addError("No Data supplied");
}
if(E107_DEBUG_LEVEL > 0)
{
e107::getMessage()->addInfo(print_a($data,true));
echo e107::getMessage()->render();
}
require_once(FOOTERF);
exit;
}
/**
* @param $text
*/
function render($text)
{
$ns = e107::getRender();
if ($this->forumObj->prefs->get('enclose'))
{
$ns->tablerender($this->forumObj->prefs->get('title'), $text);
}
else
{
echo $text;
}
}
/**
*
*/
function renderPreview()
{
global $FORUM_PREVIEW; // BC v1.x
$tp = e107::getParser();
$ns = e107::getRender();
process_upload();
require_once(HEADERF);
if (USER)
{
$poster = USERNAME;
}
else
{
$poster = ($_POST['anonname']) ? $_POST['anonname'] : LAN_ANONYMOUS;
}
$postdate = e107::getDate()->convert_date(time(), "forum");
$tsubject = $tp->post_toHTML($_POST['subject'], true);
$tpost = $tp->post_toHTML($_POST['post'], true);
if ($_POST['poll_title'] != '' && check_class($this->forumObj->prefs->get('poll')))
{
require_once(e_PLUGIN."poll/poll_class.php");
$poll = new poll;
$poll_text = $poll->render_poll($_POST, 'forum', 'notvoted', true);
}
else
{
$poll_text = false;
}
if (empty($FORUM_PREVIEW))
{
if(deftrue('BOOTSTRAP')) //v2.x
{
$FORUM_PREVIEW = e107::getTemplate('forum','forum_preview', 'item');
}
else //1.x
{
if (file_exists(THEME."forum_preview_template.php"))
{
require_once(THEME."forum_preview_template.php");
}
else
{
require_once(e_PLUGIN."forum/templates/forum_preview_template.php");
}
}
}
$shortcodes = array('PREVIEW_DATE'=>$postdate, 'PREVIEW_SUBJECT'=>$tsubject, 'PREVIEW_POST'=>$tpost);
$text = $tp->simpleParse($FORUM_PREVIEW,$shortcodes);
if ($poll_text)
{
$ns->tablerender($_POST['poll_title'], $poll_text);
}
$ns->tablerender(LAN_FORUM_3005, $text);
if ($this->action == 'edit')
{
if ($_POST['subject'])
{
$action = 'edit';
}
else
{
$action = 'rp';
}
$eaction = true;
}
else if($this->action == 'quote')
{
$action = 'rp';
$eaction = false;
}
}
/**
* Insert a new thread or a reply/quoted reply.
*/
function insertPost()
{
$postInfo = array();
$threadInfo = array();
$threadOptions = array();
$fp = new floodprotect;
if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '')
{
message_handler('ALERT', 5);
}
else
{
if ($fp->flood('forum_thread', 'thread_datestamp') == false && !ADMIN)
{
echo "<script type='text/javascript'>document.location.href='".e_BASE."index.php'</script>\n";
exit;
}
$hasPoll = ($this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '');
if (USER)
{
$postInfo['post_user'] = USERID;
$threadInfo['thread_lastuser'] = USERID;
$threadInfo['thread_user'] = USERID;
$threadInfo['thread_lastuser_anon'] = '';
}
else
{
$postInfo['post_user_anon'] = $_POST['anonname'];
$threadInfo['thread_lastuser_anon'] = $_POST['anonname'];
$threadInfo['thread_user_anon'] = $_POST['anonname'];
}
$time = time();
$postInfo['post_entry'] = $_POST['post'];
$postInfo['post_forum'] = $this->id;
$postInfo['post_datestamp'] = $time;
$postInfo['post_ip'] = e107::getIPHandler()->getIP(FALSE);
$threadInfo['thread_lastpost'] = $time;
if(isset($_POST['no_emote']))
{
$postInfo['post_options'] = serialize(array('no_emote' => 1));
}
//If we've successfully uploaded something, we'll have to edit the post_entry and post_attachments
$newValues = array();
if($uploadResult = process_upload($newPostId))
{
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;
}
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
$postInfo['post_attachments'] = e107::serialize($newValues); //FIXME XXX - broken encoding when saved to DB.
}
// var_dump($uploadResult);
switch($this->action)
{
// Reply only. Add the post, update thread record with latest post info.
// Update forum with latest post info
case 'rp':
$postInfo['post_thread'] = $this->id;
$newPostId = $this->forumObj->postAdd($postInfo);
break;
// New thread started. Add the thread info (with lastest post info), add the post.
// Update forum with latest post info
case 'nt':
$threadInfo['thread_sticky'] = (MODERATOR ? (int)$_POST['threadtype'] : 0);
$threadInfo['thread_name'] = $_POST['subject'];
$threadInfo['thread_forum_id'] = $this->id;
$threadInfo['thread_active'] = 1;
$threadInfo['thread_datestamp'] = $time;
if($hasPoll)
{
$threadOptions['poll'] = '1';
}
if(is_array($threadOptions) && count($threadOptions))
{
$threadInfo['thread_options'] = serialize($threadOptions);
}
else
{
$threadInfo['thread_options'] = '';
}
if($postResult = $this->forumObj->threadAdd($threadInfo, $postInfo))
{
$newPostId = $postResult['postid'];
$newThreadId = $postResult['threadid'];
if($_POST['email_notify'])
{
$this->forumObj->track('add', USERID, $newThreadId);
}
}
break;
}
if($postResult === -1 || $newPostId === -1) //Duplicate post
{
require_once(HEADERF);
$message = LAN_FORUM_3006."<br ><a class='btn btn-default' href='".$_SERVER['HTTP_REFERER']."'>Return</a>";
$text = e107::getMessage()->addError($message)->render();
e107::getRender()->tablerender(LAN_PLUGIN_FORUM_NAME, $text); // change to forum-title pref.
require_once(FOOTERF);
exit;
}
$threadId = ($this->action == 'nt' ? $newThreadId : $this->id);
//If a poll was submitted, let's add it to the poll db
if ($this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '')
{
require_once(e_PLUGIN.'poll/poll_class.php');
$_POST['iid'] = $threadId;
$poll = new poll;
$poll->submit_poll(2);
}
e107::getCache()->clear('newforumposts');
$postInfo = $this->forumObj->postGet($newPostId, 'post');
$forumInfo = $this->forumObj->forumGet($postInfo['post_forum']);
$threadLink = e107::getUrl()->create('forum/thread/last', $postInfo);
$forumLink = e107::getUrl()->create('forum/forum/view', $forumInfo);
if ($this->forumObj->prefs->get('redirect'))
{
header('location:'.e107::getUrl()->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true)));
exit;
}
else
{
require_once(HEADERF);
$template = $this->getTemplate('posted');
$SHORTCODES = array(
'THREADLINK' => $threadLink,
'FORUMLINK' => $forumLink
);
$txt = (isset($_POST['newthread']) ? $template['thread'] : $template['reply']);
$txt = e107::getParser()->parseTemplate($txt,true, $SHORTCODES);
e107::getRender()->tablerender('Forums', e107::getMessage()->render().$txt);
require_once(FOOTERF);
exit;
}
}
}
function updateThread()
{
$mes = e107::getMessage();
if (empty($_POST['subject']) || empty($_POST['post']))
{
$mes->addError(LAN_FORUM_3007);
return;
}
else
{
if (!$this->isAuthor())
{
$mes->addError(LAN_FORUM_3009);
return;
}
$postVals = array();
$threadVals = array();
if($uploadResult = process_upload($this->data['post_id']))
{
$attachments = explode(',', $this->data['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'];
$threadVals['thread_name'] = $_POST['subject'];
$this->forumObj->threadUpdate($this->data['post_thread'], $threadVals);
$this->forumObj->postUpdate($this->data['post_id'], $postVals);
e107::getCache()->clear('newforumposts');
$url = e107::getUrl()->create('forum/thread/post', array('name'=>$threadVals['thread_name'], 'id' => $this->data['post_id'], 'thread' => $this->data['post_thread']), array('encode'=>false));
header('location:'.$url);
exit;
}
}
/**
* @param $id of the post
*/
function updateReply()
{
$mes = e107::getMessage();
$ns = e107::getRender();
if (empty($_POST['post']))
{
$mes->addError(LAN_FORUM_3007);
return;
}
if ($this->isAuthor()==false)
{
$mes->addError(LAN_FORUM_3009);
return;
}
$postVals['post_edit_datestamp'] = time();
$postVals['post_edit_user'] = USERID;
$postVals['post_entry'] = $_POST['post'];
$this->forumObj->postUpdate($this->data['post_id'], $postVals);
e107::getCache()->clear('newforumposts');
$url = e107::getUrl()->create('forum/thread/post', "id={$this->data['post_id']}", 'encode=0&full=1'); // XXX what data is available, find thread name
header('location:'.$url);
exit;
}
function isAuthor()
{
return ((USERID === (int)$this->data['post_user']) || MODERATOR);
}
}
require_once(HEADERF);
new forum_post_handler;
exit;
require_once(e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum();
if (!e_QUERY || !isset($_GET['id']))
$action = trim($_GET['f']); //
$id = (int)$_GET['id']; // topic / thread.
$post = (int) $_GET['post']; // individual post.
if(!empty($_POST['action']))
{
header('Location:'.e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
$action = $_POST['action'];
}
$action = trim($_GET['f']);
$id = (int)$_GET['id'];
switch($action)
{
@@ -58,7 +755,7 @@ switch($action)
case 'quote':
case 'edit':
$postInfo = $forum->postGet($id, 'post');
$postInfo = $forum->postGet($post, 'post');
$threadInfo = $postInfo;
$forumId = $postInfo['post_forum'];
$forumInfo = $forum->forumGet($forumId);
@@ -75,10 +772,15 @@ if (!$forum->checkPerm($forumId, 'post'))
{
require_once(HEADERF);
$mes->addError(LAN_FORUM_3001);
//$mes->addDebug("action: ".$action);
// $mes->addDebug("id: ".$id);
// $mes->addDebug(print_a($threadInfo, true));
$ns->tablerender(LAN_FORUM_1001, $mes->render());
require_once(FOOTERF);
exit;
}
define('MODERATOR', USER && $forum->isModerator(USERID));
require_once(e_HANDLER.'ren_help.php'); // FIXME deprecated
@@ -138,7 +840,7 @@ if (isset($_POST['submitpoll']))
exit;
}
if (isset($_POST['fpreview']))
/*if (isset($_POST['fpreview']))
{
process_upload();
require_once(HEADERF);
@@ -202,7 +904,7 @@ if (isset($_POST['fpreview']))
$action = 'reply';
$eaction = false;
}
}
}*/
if (isset($_POST['newthread']) || isset($_POST['reply']))
{
@@ -311,6 +1013,9 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
}
// print_a($threadInfo);
// print_a($postInfo);
// print_a('action: '.$action);
// print_a("newId:".$newPostId);
// print_a($_POST);
// exit;
if($postResult === -1) //Duplicate post
@@ -334,8 +1039,12 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
}
e107::getCache()->clear('newforumposts');
$postInfo = $forum->postGet($newPostId, 'post');
$forumInfo = $forum->forumGet($postInfo['post_forum']);
$threadLink = e107::getUrl()->create('forum/thread/last', $postInfo);
$forumLink = e107::getUrl()->create('forum/forum/view', $forumInfo);
@@ -456,6 +1165,8 @@ if (vartrue($error))
$ns->tablerender(EMESSLAN_TITLE_ERROR, $error); // LAN?
}
if ($action == 'edit' || $action == 'quote')
{
if ($action == 'edit')
@@ -480,19 +1191,21 @@ if ($action == 'edit' || $action == 'quote')
if ($action == 'quote')
{
//remote [hide] bbcode, or else it doesn't hide stuff too well :)
$post = preg_replace('#\[hide].*?\[/hide]#s', '', $post);
/* $post = preg_replace('#\[hide].*?\[/hide]#s', '', $post);
$quoteName = ($postInfo['user_name'] ? $postInfo['user_name'] : $postInfo['post_user_anon']);
$post = "[quote={$quoteName}]\n".$post."\n[/quote]\n";
$post = "[quote={$quoteName}]\n".$post."\n[/quote]\n";*/
// $eaction = true;
$action = 'reply';
// $action = 'reply';
}
else
{
$eaction = true;
if($postInfo['post_datestamp'] != $postInfo['thread_datestamp'])
{
$action = 'reply';
$action = 'rp';
}
else
{
@@ -502,6 +1215,14 @@ if ($action == 'edit' || $action == 'quote')
}
}
$postInfo['action'] = $action;
$sc->setVars($postInfo); // send data to shortcodes - remove globals!
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Load forumpost template
@@ -563,6 +1284,7 @@ function forumjump()
function process_upload()
{
return;
global $forumInfo, $thread_info, $admin_log, $forum;
$postId = (int)$postId;

View File

@@ -189,7 +189,7 @@ define("LAN_FORUM_3002", "This topic is locked."); // LAN_397
define("LAN_FORUM_3003", "Replying to"); // LAN_02 (p)
// define("LAN_FORUM_3004", "Anonymous"); // LAN_311
define("LAN_FORUM_3005", "Preview"); // LAN_323
// define("LAN_FORUM_3006", "Duplicate post"); // LAN_FORUM_2
define("LAN_FORUM_3006", "Duplicate post"); // LAN_FORUM_2
define("LAN_FORUM_3007", "You left required field(s) blank"); // LAN_27
define("LAN_FORUM_3008", "Unauthorised"); // LAN_95
define("LAN_FORUM_3009", "You are not authorised to edit this forum post."); //LAN_96

View File

@@ -50,12 +50,13 @@ class plugin_forum_post_shortcodes extends e_shortcode
function sc_formstart()
{
return "<form enctype='multipart/form-data' method='post' action='".e_REQUEST_URL."' id='dataform'>";
return "<form class='form-horizontal' enctype='multipart/form-data' method='post' action='".e_REQUEST_URL."' id='dataform'>";
}
function sc_formend()
{
return '</form>';
$frm = e107::getForm();
return $frm->hidden('action',$this->var['action']).$frm->close();
}
function sc_forumjump()
@@ -69,54 +70,138 @@ class plugin_forum_post_shortcodes extends e_shortcode
return (USER == false ? $userbox : '');
}
function sc_forum_author()
{
$opts = array('size' => 'xlarge');
$tp = e107::getParser();
if(USER == false)
{
$val = $tp->post_toForm($_POST['anonname']);
}
else
{
$val = USERNAME;
$opts['disabled'] = true;
}
return e107::getForm()->text('anonname',$val, 20, $opts);
// <input class='tbox form-control' type='text' name='anonname' size='71' value='".vartrue($anonname)."' maxlength='20' style='width:95%' />
}
function sc_subjectbox()
{
global $subjectbox, $action;
return ($action == 'nt' ? $subjectbox : '');
}
function sc_forum_subject()
{
$opts = array('size' => 'xlarge');
if($this->var['action'] =='rp' || $this->var['action'] =='quote')
{
$_POST['subject'] = "Re: ". $this->var['thread_name'];
$opts['disabled'] = 1;
}
elseif($this->var['action'] == 'edit')
{
$_POST['subject'] = $this->var['thread_name'];
}
else
{
$opts['required'] = 1;
}
// elseif($this->var['action'] == 'edit')
// {
// $_POST['subject'] = $this->varp;
// }
$tp = e107::getParser();
return e107::getForm()->text('subject',$tp->post_toForm($_POST['subject']), 100, $opts);
// <input class='tbox form-control' type='text' name='subject' size='71' value='".vartrue($subject)."' maxlength='100' style='width:95%' />
}
function sc_posttype()
{
global $action;
return ($action == 'nt' ? LAN_FORUM_2015 : LAN_FORUM_2006);
return ($this->var['action'] == 'nt' ? LAN_FORUM_2015 : LAN_FORUM_2006);
}
function sc_postbox()
{
global $post;
return e107::getForm()->bbarea('post',$post,'forum');
/*
$rows = (e107::wysiwyg()==true) ? 15 : 10;
$ret = "<textarea class='e-wysiwyg tbox form-control' id='post' name='post' cols='70' rows='{$rows}' style='width:95%' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$post</textarea>\n<br />\n";
// if(!e_WYSIWYG)
$tp = e107::getParser();
if(!empty($_POST['post']))
{
// $ret .= display_help('helpb', 'forum');
$text = $tp->post_toForm($_POST['post']);
}
return $ret;
*/
elseif($this->var['action'] == 'quote')
{
$post = preg_replace('#\[hide].*?\[/hide]#s', '', trim($this->var['post_entry']));
$quoteName = ($this->var['user_name'] ? $this->var['user_name'] : $this->var['post_user_anon']);
$text = $tp->toText("[quote={$quoteName}]\n".$post."\n[/quote]\n",true);
$text .= "<br /><br />";
$this->var['action'] = 'rp';
}
elseif($this->var['action'] == 'edit')
{
$text = $tp->toForm($this->var['post_entry']);
}
else
{
$text = '';
}
return e107::getForm()->bbarea('post',$text,'forum');
}
function sc_buttons()
{
global $action, $eaction;
$ret = "<input class='btn btn-default button' type='submit' name='fpreview' value='".LAN_FORUM_3005."' /> ";
if ($action != 'nt')
if($this->var['action'] == 'edit')
{
$ret .= ($eaction ? "<input class='btn btn-primary button' type='submit' name='update_reply' value='".LAN_FORUM_3024."' />" : "<input class='btn btn-primary button' type='submit' name='reply' value='".LAN_FORUM_2006."' />");
// This user created the thread and is editing the original post.
if($this->var['thread_datestamp'] == $this->var['post_datestamp'] && $this->var['thread_user'] == $this->var['post_user'])
{
return "<input class='btn btn-primary button' type='submit' name='update_thread' value='".LAN_FORUM_3023."' />";
}
else // editing a reply.
{
return "<input class='btn btn-primary button' type='submit' name='update_reply' value='".LAN_FORUM_3024."' />";
}
}
else
if ($this->var['action'] == 'nt') // new thread.
{
$ret .= ($eaction ? "<input class='btn btn-primary button' type='submit' name='update_thread' value='".LAN_FORUM_3023."' />" : "<input class='btn btn-primary button' type='submit' name='newthread' value='".LAN_FORUM_2005."' />");
$ret .= "<input class='btn btn-primary button' type='submit' name='newthread' value='".LAN_FORUM_2005."' />";
}
else // new reply or quoted reply.
{
$ret .= "<input class='btn btn-primary button' type='submit' name='reply' value='".LAN_FORUM_2006."' />";
}
return $ret;
}
function sc_fileattach()
{
global $forum, $fileattach, $fileattach_alert;
if ($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
$uploadClass = e107::pref('core','upload_class');
if ($forum->prefs->get('attach') && (check_class($uploadClass) || getperms('0')))
{
if (is_writable(e_PLUGIN.'forum/attachments'))
{
@@ -141,6 +226,8 @@ class plugin_forum_post_shortcodes extends e_shortcode
function sc_forumattachment()
{
$pref = e107::getPref();
$tp = e107::getParser();
global $forum;
//. <div>".($pref['image_post'] ? "Attach file / image" : "Attach file")."</div>
@@ -152,7 +239,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
<div>
<div id='fiupsection'>
<span id='fiupopt'>
<input class='tbox e-tip' title=\"".$tooltip."\" name='file_userfile[]' type='file' size='47' />
<input class='tbox e-tip' title=\"".$tp->toAttribute($tooltip)."\" name='file_userfile[]' type='file' size='47' />
</span>
</div>
<input class='btn btn-default button' type='button' name='addoption' value=".LAN_FORUM_3020." onclick=\"duplicateHTML('fiupopt','fiupsection')\" />
@@ -160,19 +247,64 @@ class plugin_forum_post_shortcodes extends e_shortcode
";
if ($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;
}
}
function sc_postoptions_label()
{
$type = $this->sc_postthreadas();
$poll = $this->sc_poll('front');
$attach = $this->sc_forumattachment();
if(empty($type) && empty($poll) && empty($attach))
{
return '';
}
return "Options"; //TODO LAN.
}
function sc_postoptions($parm='')
{
$type = $this->sc_postthreadas();
$poll = $this->sc_poll('front');
$attach = $this->sc_forumattachment();
$tabs = array();
if(!empty($type))
{
$tabs['type'] = array('caption'=>LAN_FORUM_3025, 'text'=>$type);
}
if(!empty($poll))
{
$tabs['poll'] = array('caption'=>LAN_FORUM_1016, 'text'=>$poll);
}
if(!empty($attach))
{
$tabs['attach'] = array('caption'=>LAN_FORUM_3012, 'text'=>$attach);
}
if(!empty($tabs))
{
return e107::getForm()->tabs($tabs);
}
else
{
return false;
}
/*
$text = "
<ul class='nav nav-tabs'>
<li class='active'><a href='#type' data-toggle='tab'>".LAN_FORUM_3025."</a></li>";
@@ -213,7 +345,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
</div>";
return $text;
return $text;*/
@@ -222,9 +354,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
function sc_poll($parm='')
{
global $forum, $action;
if(is_readable(e_PLUGIN."poll/poll_class.php"))
if(is_readable(e_PLUGIN."poll/poll_class.php"))
{
require_once(e_PLUGIN."poll/poll_class.php");
$pollo = new poll;
@@ -234,7 +364,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
}
if ($action == 'nt' && check_class($forum->prefs->get('poll')) && strpos(e_QUERY, 'edit') === false)
if ($this->var['action'] == 'nt' && check_class($this->forum->prefs->get('poll')) && strpos(e_QUERY, 'edit') === false)
{
if($parm == 'front')
{
@@ -252,15 +382,14 @@ class plugin_forum_post_shortcodes extends e_shortcode
function sc_postthreadas()
{
global $action, $threadInfo;
if (MODERATOR && $action == "nt")
if (MODERATOR && $this->var['action'] == "nt")
{
$thread_sticky = (isset($_POST['threadtype']) ? $_POST['threadtype'] : vartrue($threadInfo['thread_sticky'],0)); // no reference of 'head' $threadInfo['head']['thread_sticky']
$thread_sticky = (isset($_POST['threadtype']) ? $_POST['threadtype'] : vartrue($this->var['thread_sticky'],0)); // no reference of 'head' $threadInfo['head']['thread_sticky']
$opts = array(0 => LAN_FORUM_3038, 1 => LAN_FORUM_1011, 2 => LAN_FORUM_1013);
return e107::getForm()->radio('threadtype',$opts, $thread_sticky);
return "<div class='checkbox'>".e107::getForm()->radio('threadtype',$opts, $thread_sticky)."</div>";
// return "<br /><span class='defaulttext'>post thread as
// <input name='threadtype' type='radio' value='0' ".(!$thread_sticky ? "checked='checked' " : "")." />".LAN_1."&nbsp;<input name='threadtype' type='radio' value='1' ".($thread_sticky == 1 ? "checked='checked' " : "")." />".LAN_2."&nbsp;<input name='threadtype' type='radio' value='2' ".($thread_sticky == 2 ? "checked='checked' " : "")." />".LAN_3."</span>";
@@ -270,10 +399,15 @@ class plugin_forum_post_shortcodes extends e_shortcode
function sc_backlink()
{
global $forum, $threadInfo, $eaction, $action;
global $forum, $threadInfo, $eaction, $action,$forumInfo;
$forumInfo = $this->var;
// return print_a($forumInfo,true);
$_tmp = new e_vars();
// no reference of 'head' $threadInfo['head']['thread_name']
$forum->set_crumb(true, ($action == 'nt' ? ($eaction ? LAN_FORUM_3023 : LAN_FORUM_1018) : ($eaction ? LAN_FORUM_3024 : $threadInfo['thread_name'])), $_tmp);
$eaction = ($this->var['action'] == 'edit');
$this->forum->set_crumb(true, ($this->var['action'] == 'nt' ? ($eaction ? LAN_FORUM_3023 : LAN_FORUM_1018) : ($eaction ? LAN_FORUM_3024 : $this->var['thread_name'])), $_tmp);
return $_tmp->BREADCRUMB;
}

View File

@@ -313,6 +313,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
if($this->forum->checkperm($this->postInfo['post_forum'], 'post'))
{
return "<a href='".$this->e107->url->create('forum/thread/quote', array('id' => $this->postInfo['post_id']))."'>".IMAGE_quote.'</a> ';
// return "<a href='".$this->e107->url->create('forum/thread/quote', array('id' => $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id'] ))."'>".IMAGE_quote.'</a> ';
}
}
@@ -493,13 +494,15 @@ class plugin_forum_view_shortcodes extends e_shortcode
// Edit
if ( (USER && $this->postInfo['post_user'] == USERID && $this->thread->threadInfo['thread_active']))
{
$text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."</a></li>";
$text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."</a></li>";
}
if($this->forum->checkperm($this->postInfo['post_forum'], 'post'))
{
$text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/quote', array('id' => $this->postInfo['post_id']))."'>".LAN_FORUM_2041." ".$tp->toGlyph('share-alt')."</a></li>";
$text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/quote', array('id' => $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id']))."'>".LAN_FORUM_2041." ".$tp->toGlyph('share-alt')."</a></li>";
// $text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/quote', array('id' => $this->postInfo['post_id']))."'>".LAN_FORUM_2041." ".$tp->toGlyph('share-alt')."</a></li>";
}
@@ -510,7 +513,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
if ((USER && $this->postInfo['post_user'] != USERID && $this->thread->threadInfo['thread_active']))
{
$text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."</a></li>";
$text .= "<li class='text-right'><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."</a></li>";
}
// only show delete button when post is not the initial post of the topic

View File

@@ -223,35 +223,47 @@ $THREADTOPIC_REPLY = "
// New in v2.x - requires a bootstrap theme be loaded.
$FORUMPOST_TEMPLATE['form'] = "
$FORUM_POST_TEMPLATE['form'] = "
{FORMSTART}
<div class='row-fluid'>
<div>{BACKLINK}</div>
</div>
<table class='table'>
<tr>
{USERBOX}
{SUBJECTBOX}
<tr>
<td style='width:20%'>{POSTTYPE} </td>
<td style='width:80%'>
{POSTBOX}
{EMAILNOTIFY}
</td>
</tr>
<td style='width:20%'>Post Options</td>
<td style='width:80%'>{POSTOPTIONS}</td>
</tr>
</table>
<div class='form-group'>
<label for='name' class='col-sm-3 control-label'>".LAN_FORUM_3010."</label>
<div class='col-sm-9'>{FORUM_AUTHOR}</div>
</div>
<div class='text-center'>
<div class='form-group'>
<label for='subject' class='col-sm-3 control-label'>".LAN_FORUM_3011."</label>
<div class='col-sm-9'>{FORUM_SUBJECT}</div>
</div>
<div class='form-group'>
<label class='col-sm-3 control-label'>{POSTTYPE}</label>
<div class='col-sm-9'>
{POSTBOX}
{EMAILNOTIFY}
</div>
</div>
<div class='form-group'>
<label class='col-sm-3 control-label'>{POSTOPTIONS_LABEL}</label>
<div class='col-sm-9'>{POSTOPTIONS}</div>
</div>
<div class='form-group text-center'>
{BUTTONS}
</div>
{FORMEND}
";
$FORUMPOST_TEMPLATE['reply'] = "";
$FORUM_POST_TEMPLATE['reply'] = "";

View File

@@ -20,8 +20,8 @@ $FORUMPOLLPOSTED ="
<td style='text-align:right; vertical-align:middle; width:20%' class='forumheader2'>".IMAGE_e."&nbsp;</td>
<td style='vertical-align:middle; width:80%' class='forumheader2'>
<br />".LAN_FORUM_3045."<br />
<span class='defaulttext'><a class='forumlink' href='{$threadLink}'>".LAN_FORUM_3046."</a><br />
<a class='forumlink' href='{$forumLink}'>".LAN_FORUM_2022."</a></span><br /><br />
<span class='defaulttext'><a class='forumlink' href='{THREADLINK}'>".LAN_FORUM_3046."</a><br />
<a class='forumlink' href='{FORUMLINK}'>".LAN_FORUM_2022."</a></span><br /><br />
</td>
</tr>
</table>";
@@ -36,8 +36,8 @@ $FORUMTHREADPOSTED = "
<td style='vertical-align:middle; width:80%' class='forumheader2'>
<br />".LAN_FORUM_3047."<br />
".(defined('F_MESSAGE') ? F_MESSAGE.'<br />' : '')."
<span class='defaulttext'><a href='{$threadLink}'>".LAN_FORUM_3048."</a><br />
<a href='{$forumLink}'>".LAN_FORUM_2022."</a></span><br /><br />
<span class='defaulttext'><a href='{THREADLINK}'>".LAN_FORUM_3048."</a><br />
<a href='{FORUMLINK}'>".LAN_FORUM_2022."</a></span><br /><br />
</td>
</tr>
</table>";
@@ -53,10 +53,33 @@ $FORUMREPLYPOSTED = "
<td style='vertical-align:middle; width:80%' class='forumheader2'>
<br />".LAN_FORUM_3049."<br />
".(defined('F_MESSAGE') ? F_MESSAGE.'<br />' : '')."
<span class='defaulttext'><a href='{$threadLink}'>".LAN_FORUM_3048."</a><br />
<a href='{$forumLink}'>".LAN_FORUM_2022."</a></span><br /><br />
<span class='defaulttext'><a href='{THREADLINK}'>".LAN_FORUM_3048."</a><br />
<a href='{FORUMLINK}'>".LAN_FORUM_2022."</a></span><br /><br />
</td>
</tr>
</table>";
//v2.x ------------ Bootstrap ---------------------
$FORUM_POSTED_TEMPLATE['poll'] = $FORUMPOLLPOSTED;
$FORUM_POSTED_TEMPLATE['thread'] = "<div class='alert alert-success'>
<h4>New topic created.</h4>
<a class='btn btn-primary' href='{THREADLINK}'>".LAN_FORUM_3048."</a>
<a class='btn btn-primary' href='{FORUMLINK}'>".LAN_FORUM_2022."</a>
</div>";
$FORUM_POSTED_TEMPLATE['reply'] = "<div class='alert alert-success'>
<h4>New reply created.</h4>
<a class='btn btn-primary' href='{THREADLINK}'>".LAN_FORUM_3048."</a>
<a class='btn btn-primary' href='{FORUMLINK}'>".LAN_FORUM_2022."</a>
</div>";
?>

View File

@@ -9,18 +9,26 @@
*/
if (!defined('e107_INIT')) { exit; }
if(!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%;margin-left:auto;margin-right:auto"); }
if(!defined("USER_WIDTH") && !deftrue('BOOTSTRAP')){ define("USER_WIDTH","width:95%;margin-left:auto;margin-right:auto"); }
$FORUM_PREVIEW = "<div style='text-align:center'>
$FORUM_PREVIEW = "<div>
<table style='".USER_WIDTH."' class='fborder table'>
<tr>
<td colspan='2' class='fcaption' style='vertical-align:top'>".LAN_FORUM_3005.
($action != "nt" ? "</td>" : " ( ".LAN_FORUM_3011.": ".$tsubject." )</td>")."
($action != "nt" ? "</td>" : " ( ".LAN_FORUM_3011.": {PREVIEW_SUBJECT} )</td>")."
<tr>
<td class='forumheader3' style='width:20%; vertical-align:top'><b>".$poster."</b></td>
<td class='forumheader3' style='width:80%'><div class='smallblacktext' style='text-align:right'>".IMAGE_post2." ".$postdate."</div>".$tpost."</td>
<td class='forumheader3' style='width:80%'><div class='smallblacktext' style='text-align:right'>".IMAGE_post2." {PREVIEW_DATE}</div>{PREVIEW_POST}</td>
</tr>
</table>
</div>";
//v2.x Bootstrap
$FORUM_PREVIEW_TEMPLATE['item'] = "<div class='alert alert-warning alert-block'>
<div><b>{PREVIEW_SUBJECT}</b></div>
{PREVIEW_POST}
</div>";
?>

View File

@@ -108,7 +108,7 @@ class plugin_forum_url extends eUrlConfig
break;
case 'edit':
return $base."forum_post.php?f=edit{$amp}id={$params['id']}";
return $base."forum_post.php?f=edit{$amp}id={$params['id']}{$amp}post={$params['post']}";
break;
case 'move':
@@ -120,7 +120,7 @@ class plugin_forum_url extends eUrlConfig
break;
case 'quote':
return $base."forum_post.php?f=quote{$amp}id={$params['id']}";
return $base."forum_post.php?f=quote{$amp}id={$params['id']}{$amp}post={$params['post']}";
break;
case 'next':

View File

@@ -632,9 +632,14 @@ class poll
<div class='alert alert-info'>
<small >".LAN_FORUM_3029."</small>
</div>
<form>
</div>";
// $text .= "<form>";
$text .= "
<div class='form-group'>
<label for='poll_title'>Poll question</label>
".$frm->text('poll_title', $tp->post_toForm(vartrue($_POST['poll_title'])), '200', array('placeholder' => LAN_FORUM_3030, 'id' => 'poll_title'))."
@@ -665,7 +670,7 @@ class poll
<input class='btn btn-default' type='button' id='addoption' name='addoption' value='".LAN_FORUM_3032."' />
</div>
</form>";
";
//FIXME - get this looking good with Bootstrap CSS only.
@@ -681,6 +686,8 @@ class poll
</div>
</div>
";
// $text .= "</form>";
return $text;