diff --git a/e107_core/bbcodes/quote.bb b/e107_core/bbcodes/quote.bb index fa549245e..292dc74ce 100644 --- a/e107_core/bbcodes/quote.bb +++ b/e107_core/bbcodes/quote.bb @@ -2,4 +2,12 @@ $class = e107::getBB()->getClass('quote'); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_parser_functions.php"); +if(deftrue('BOOTSTRAP')) +{ + return '
+

'.$code_text.'

+ '.$parm.' +
'; +} + return "
$parm ".LAN_WROTE." ...
$code_text
"; diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index f291e18fa..fe199f2ca 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -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(); diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 654a55ef8..1803387a5 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -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 "\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."
Return"; + $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; diff --git a/e107_plugins/forum/languages/English/English_front.php b/e107_plugins/forum/languages/English/English_front.php index 045b545c6..9231210f9 100644 --- a/e107_plugins/forum/languages/English/English_front.php +++ b/e107_plugins/forum/languages/English/English_front.php @@ -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 diff --git a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php index fd44973fe..a60d40eff 100644 --- a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php @@ -50,12 +50,13 @@ class plugin_forum_post_shortcodes extends e_shortcode function sc_formstart() { - return "
"; + return ""; } function sc_formend() { - return '
'; + $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); + + + // + + + } + 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); + + + // + + } + 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 = "\n
\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 .= "

"; + $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 = " "; - if ($action != 'nt') + + if($this->var['action'] == 'edit') { - $ret .= ($eaction ? "" : ""); + // 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 ""; + } + else // editing a reply. + { + return ""; + } } - else + + if ($this->var['action'] == 'nt') // new thread. { - $ret .= ($eaction ? "" : ""); + $ret .= ""; } + else // new reply or quoted reply. + { + $ret .= ""; + } + 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; //.
".($pref['image_post'] ? "Attach file / image" : "Attach file")."
@@ -152,7 +239,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
- + toAttribute($tooltip)."\" name='file_userfile[]' type='file' size='47' />
@@ -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 = "
"; - 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 "
".e107::getForm()->radio('threadtype',$opts, $thread_sticky)."
"; // return "
post thread as // ".LAN_1." ".LAN_2." ".LAN_3.""; @@ -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; } diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 1bf1b093b..ebd4a5742 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -313,6 +313,7 @@ class plugin_forum_view_shortcodes extends e_shortcode if($this->forum->checkperm($this->postInfo['post_forum'], 'post')) { return " $this->postInfo['post_id']))."'>".IMAGE_quote.' '; + // return " $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id'] ))."'>".IMAGE_quote.' '; } } @@ -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 .= "
  • $this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."
  • "; + $text .= "
  • $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."
  • "; } if($this->forum->checkperm($this->postInfo['post_forum'], 'post')) { - $text .= "
  • $this->postInfo['post_id']))."'>".LAN_FORUM_2041." ".$tp->toGlyph('share-alt')."
  • "; + $text .= "
  • $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id']))."'>".LAN_FORUM_2041." ".$tp->toGlyph('share-alt')."
  • "; + + // $text .= "
  • $this->postInfo['post_id']))."'>".LAN_FORUM_2041." ".$tp->toGlyph('share-alt')."
  • "; } @@ -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 .= "
  • $this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."
  • "; + $text .= "
  • $this->postInfo['post_thread'], 'post'=>$this->postInfo['post_id']))."'>".LAN_EDIT." ".$tp->toGlyph('edit')."
  • "; } // only show delete button when post is not the initial post of the topic diff --git a/e107_plugins/forum/templates/forum_post_template.php b/e107_plugins/forum/templates/forum_post_template.php index 5b7e68ae5..60b4ea61a 100644 --- a/e107_plugins/forum/templates/forum_post_template.php +++ b/e107_plugins/forum/templates/forum_post_template.php @@ -223,35 +223,47 @@ $THREADTOPIC_REPLY = " // New in v2.x - requires a bootstrap theme be loaded. -$FORUMPOST_TEMPLATE['form'] = " + $FORUM_POST_TEMPLATE['form'] = " {FORMSTART}
    {BACKLINK}
    - - - {USERBOX} - {SUBJECTBOX} - - - - - - - -
    {POSTTYPE} - {POSTBOX} - {EMAILNOTIFY} -
    Post Options{POSTOPTIONS}
    +
    + +
    {FORUM_AUTHOR}
    +
    -
    +
    + +
    {FORUM_SUBJECT}
    +
    + +
    + +
    + {POSTBOX} + {EMAILNOTIFY} +
    +
    + +
    + +
    {POSTOPTIONS}
    +
    + +
    {BUTTONS}
    {FORMEND} + + "; -$FORUMPOST_TEMPLATE['reply'] = ""; + + + +$FORUM_POST_TEMPLATE['reply'] = ""; diff --git a/e107_plugins/forum/templates/forum_posted_template.php b/e107_plugins/forum/templates/forum_posted_template.php index e3c1b5502..4763c727d 100644 --- a/e107_plugins/forum/templates/forum_posted_template.php +++ b/e107_plugins/forum/templates/forum_posted_template.php @@ -20,8 +20,8 @@ $FORUMPOLLPOSTED =" ".IMAGE_e." 
    ".LAN_FORUM_3045."
    - ".LAN_FORUM_3046."
    - ".LAN_FORUM_2022."


    + ".LAN_FORUM_3046."
    + ".LAN_FORUM_2022."


    "; @@ -36,8 +36,8 @@ $FORUMTHREADPOSTED = "
    ".LAN_FORUM_3047."
    ".(defined('F_MESSAGE') ? F_MESSAGE.'
    ' : '')." - ".LAN_FORUM_3048."
    - ".LAN_FORUM_2022."


    + ".LAN_FORUM_3048."
    + ".LAN_FORUM_2022."


    "; @@ -53,10 +53,33 @@ $FORUMREPLYPOSTED = "
    ".LAN_FORUM_3049."
    ".(defined('F_MESSAGE') ? F_MESSAGE.'
    ' : '')." - ".LAN_FORUM_3048."
    - ".LAN_FORUM_2022."


    + ".LAN_FORUM_3048."
    + ".LAN_FORUM_2022."


    "; + +//v2.x ------------ Bootstrap --------------------- + + +$FORUM_POSTED_TEMPLATE['poll'] = $FORUMPOLLPOSTED; + +$FORUM_POSTED_TEMPLATE['thread'] = "
    +

    New topic created.

    + ".LAN_FORUM_3048." + ".LAN_FORUM_2022." +
    "; + +$FORUM_POSTED_TEMPLATE['reply'] = "
    +

    New reply created.

    + ".LAN_FORUM_3048." + ".LAN_FORUM_2022." +
    "; + + + + + + ?> \ No newline at end of file diff --git a/e107_plugins/forum/templates/forum_preview_template.php b/e107_plugins/forum/templates/forum_preview_template.php index ae71a0170..b7e5e220f 100644 --- a/e107_plugins/forum/templates/forum_preview_template.php +++ b/e107_plugins/forum/templates/forum_preview_template.php @@ -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 = "
    +$FORUM_PREVIEW = "
    " : " ( ".LAN_FORUM_3011.": ".$tsubject." )")." + ($action != "nt" ? "" : " ( ".LAN_FORUM_3011.": {PREVIEW_SUBJECT} )")." - +
    ".LAN_FORUM_3005. - ($action != "nt" ? "
    ".$poster."
    ".IMAGE_post2." ".$postdate."
    ".$tpost."
    ".IMAGE_post2." {PREVIEW_DATE}
    {PREVIEW_POST}
    "; + + +//v2.x Bootstrap +$FORUM_PREVIEW_TEMPLATE['item'] = "
    +
    {PREVIEW_SUBJECT}
    + {PREVIEW_POST} +
    "; + ?> \ No newline at end of file diff --git a/e107_plugins/forum/url/url.php b/e107_plugins/forum/url/url.php index 3c7baa719..e4a92d5e5 100644 --- a/e107_plugins/forum/url/url.php +++ b/e107_plugins/forum/url/url.php @@ -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': diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index 4c791a0d8..a38879db9 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -632,9 +632,14 @@ class poll
    ".LAN_FORUM_3029." -
    - -
    +
    "; + + + // $text .= ""; + + + $text .= " +
    ".$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
    - "; + "; //FIXME - get this looking good with Bootstrap CSS only. @@ -681,6 +686,8 @@ class poll
    "; + + // $text .= ""; return $text;