diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 7b7d1d19f..2968384ed 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -1547,14 +1547,14 @@ class e107forum $sql = e107::getDb(); $forumList = implode(',', $this->permList[$type]); $qry = " - SELECT forum_id, forum_name FROM `#forum` - WHERE forum_id IN ({$forumList}) + SELECT forum_id, forum_name, forum_sef FROM `#forum` + WHERE forum_id IN ({$forumList}) AND forum_parent != 0 "; if ($sql->gen($qry)) { - while($row = $sql->fetch(MYSQL_ASSOC)) + while($row = $sql->fetch()) { - $ret[$row['forum_id']] = $row['forum_name']; + $ret[$row['forum_id']] = $row; } } @@ -1626,40 +1626,39 @@ class e107forum function threadGetNextPrev($which, $threadId, $forumId, $lastpost) { -// echo "threadid = $threadId
forum id = $forumId
"; -// return; - $e107 = e107::getInstance(); $sql = e107::getDb(); - $threadId = (int)$threadId; $forumId = (int)$forumId; $lastpost = (int)$lastpost; - if($which == 'next') - { - $dir = '<'; - $sort = 'ASC'; - } - else - { - $dir = '>'; - $sort = 'DESC'; - } + $dir = ($which == 'next') ? '<' : '>'; + $qry = " - SELECT thread_id from `#forum_thread` - WHERE thread_forum_id = $forumId - AND thread_lastpost {$dir} $lastpost + SELECT t.thread_id, t.thread_sef, f.forum_id, f.forum_sef FROM `#forum_thread` AS t + LEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id + WHERE t.thread_forum_id = $forumId + AND t.thread_lastpost {$dir} $lastpost ORDER BY - thread_sticky DESC, - thread_lastpost {$sort} + t.thread_sticky DESC, + t.thread_lastpost ASC LIMIT 1"; + + // e107::getMessage()->addDebug(ucfirst($which)." Thread Qry: ".$qry); + if ($sql->gen($qry)) { $row = $sql->fetch(); - return $row['thread_id']; + // e107::getMessage()->addInfo(ucfirst($which).print_a($row,true)); + return $row; + // return $row['thread_id']; } + else + { + // e107::getMessage()->addDebug(ucfirst($which)." Thread Qry Returned Nothing: ".$qry); + } + return false; } diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 64178d9b3..4756b7596 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -67,7 +67,11 @@ class forum_post_handler $this->checkPerms($this->data['forum_id']); $this->processPosted(); - if($this->action == 'move') + if($this->action == 'report') + { + $this->renderFormReport(); + } + elseif($this->action == 'move') { $this->renderFormMove(); } @@ -96,7 +100,7 @@ class forum_post_handler if (!e_QUERY || empty($_GET['id'])) { $url = e107::url('forum','index',null,'full'); - e107::getRedirect()->go($url); + $this->redirect($url); // header('Location:'.e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0')); exit; } @@ -129,7 +133,9 @@ class forum_post_handler case 'edit': case 'move': - case 'quote': + case "quote": + case "report": + $postInfo = $this->forumObj->postGet($this->post, 'post'); $forumInfo = $this->forumObj->forumGet($postInfo['post_forum']); $data = array_merge($postInfo ,$forumInfo); @@ -140,7 +146,7 @@ class forum_post_handler default: $url = e107::url('forum','index',null,'full'); - e107::getRedirect()->go($url); + $this->redirect($url); // header("Location:".e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0')); exit; } @@ -188,7 +194,10 @@ class forum_post_handler $this->submitPoll(); } - + if(!empty($_POST['report_thread'])) + { + $this->submitReport(); + } } @@ -222,6 +231,51 @@ class forum_post_handler } + /** + * Report a topic post. + */ + private function submitReport() + { + $tp = e107::getParser(); + $sql = e107::getDb(); + + $report_add = $tp->toDB($_POST['report_add']); + + $insert = array( + 'gen_id' => 0, + 'gen_type' => 'reported_post', + 'gen_datestamp' => time(), + 'gen_user_id' => USERID, + 'gen_ip' => $tp->toDB($this->data['thread_name']), + 'gen_intdata' => intval($this->data['thread_id']), + 'gen_chardata' => $report_add, + ); + + // $url = e107::getUrl()->create('forum/thread/post', array('id' => $postId, 'name' => $postInfo['thread_name'], 'thread' => $threadId)); // both post info and thread info contain thread name + + $url = e107::url('forum','topic', $this->data); + $result = $sql->insert('generic', $insert); + + if($result) + { + $text = "

".LAN_FORUM_2021 . "

".LAN_FORUM_2022.'
'; + } + else + { + $text = "

".LAN_FORUM_2021 . "

".LAN_FORUM_2022.'
'; + } + + $link = "{e_PLUGIN}forum/forum_admin.php?mode=post&action=list&id=".intval($result); + + $report = LAN_FORUM_2018." ".SITENAME." : ".$link . "\n + ".LAN_FORUM_2019.": ".USERNAME. "\n" . $report_add; + $subject = LAN_FORUM_2020." ". SITENAME; + e107::getNotify()->send('forum_post_rep', $subject, $report); + e107::getRender()->tablerender(LAN_FORUM_2023, $text, array('forum_viewtopic', 'report')); + } + + + function setPageTitle($data) { @@ -235,6 +289,8 @@ class forum_post_handler } + + function checkPerms($forumId) { $mes = e107::getMessage(); @@ -445,6 +501,92 @@ class forum_post_handler } + function renderFormReport() + { + if(!empty($_POST['report_thread'])) + { + return false; + } + + $tp = e107::getParser(); + $frm = e107::getForm(); + + $thread_name = e107::getParser()->toHTML($this->data['thread_name'], true, 'no_hook, emotes_off'); + // define('e_PAGETITLE', LAN_FORUM_1001.' / '.LAN_FORUM_2024.': '.$thread_name); + // $url = e107::getUrl()->create('forum/thread/post', array('id' => $postId, 'name' => $postInfo['thread_name'], 'thread' => $threadId)); + // $actionUrl = e107::getUrl()->create('forum/thread/report', "id={$threadId}&post={$postId}"); + + $actionUrl = e107::url('forum','post')."?f=report&id=".$this->data['thread_id']."&post=".$this->data['post_id']; + + + if(deftrue('BOOTSTRAP')) //v2.x + { + $text = $frm->open('forum-report-thread','post'); + $text .= " +
+
+

".LAN_FORUM_2025.': '.$thread_name."

+ ".LAN_FORUM_2027."
".str_replace(array('[', ']'), array('', ''), LAN_FORUM_2028)." + ".LAN_FORUM_2026." +
+
+ ".$tp->toHtml($this->data['post_entry'],true)." +
+
+
+ ".$frm->textarea('report_add','',10,35,array('size'=>'xxlarge'))." +
+
+
+
+ ".$frm->button('report_thread',1,'submit',LAN_FORUM_2029)." +
+
+ +
"; + + $text .= $frm->close(); + } + else //v1.x legacy layout. + { + $text = "
+ + + + + + + + + + + + + + +
+ ".LAN_FORUM_2025.': '.$thread_name." ".LAN_FORUM_2026." +
+ ".$tp->toHtml($this->data['post_entry'],true)." +
+
".LAN_FORUM_2027."
".str_replace(array('[', ']'), array('', ''), LAN_FORUM_2028)."

+
"; + + + + } + + + e107::getRender()->tablerender(LAN_FORUM_2023, $text, array('forum_viewtopic', 'report2')); + + + + + } + + + + /** * @param $text */ @@ -723,7 +865,7 @@ class forum_post_handler if ($this->forumObj->prefs->get('redirect')) { - e107::getRedirect()->go($threadLink); + $this->redirect($threadLink); // header('location:'.e107::getUrl()->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true))); exit; } @@ -846,7 +988,7 @@ class forum_post_handler $url = e107::url('forum','topic',$this->data); - e107::getRedirect()->go($url); + $this->redirect($url); exit; // $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)); @@ -1600,7 +1742,7 @@ function forumjump() $text = "

".LAN_FORUM_1017.":

"; return $text; diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php index 6485e484d..e551ed590 100644 --- a/e107_plugins/forum/forum_viewforum.php +++ b/e107_plugins/forum/forum_viewforum.php @@ -46,7 +46,10 @@ if (!e_QUERY && empty($_GET)) if(!empty($_GET['sef'])) { - $_REQUEST['id'] = $sql->retrieve('forum', 'forum_id', "forum_sef= '".$tp->toDB($_GET['sef'])."' LIMIT 1"); + if($newID = $sql->retrieve('forum', 'forum_id', "forum_sef= '".$tp->toDB($_GET['sef'])."' LIMIT 1")) + { + $_REQUEST['id'] = $newID; + } } require_once(e_PLUGIN.'forum/forum_class.php'); @@ -70,7 +73,7 @@ $fVars->VIEWTITLE = LAN_FORUM_1005; $forumId = (int)$_REQUEST['id']; -if(!$forumId && e_QUERY) // BC Fix for old links. +if(!$forumId && e_QUERY) // BC Fix for old links. { list($id,$from) = explode(".",e_QUERY); $forumId = intval($id); @@ -86,6 +89,8 @@ if (!$forum->checkPerm($forumId, 'view')) if(E107_DEBUG_LEVEL > 0) { + print_a($_REQUEST); + print_a($_GET); echo __FILE__ .' Line: '.__LINE__; echo " forumId: ".$forumId; exit; @@ -722,7 +727,7 @@ function forumjump() $text = "

".LAN_FORUM_1017.":

"; return $text; @@ -876,7 +881,7 @@ function newthreadjump($url) foreach($jumpList as $key => $val) { - $text .= '
  • '.LAN_FORUM_1017.': '.$val.'
  • '; + $text .= '
  • '.LAN_FORUM_1017.': '.$val['forum_name'].'
  • '; } $text .= ' diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index c9fafff6b..43fd8f05e 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -204,6 +204,7 @@ if(is_array($FORUM_VIEWTOPIC_TEMPLATE) && deftrue('BOOTSTRAP',false)) $FORUMREPLYSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['replies']; } +//TODO Clean up this mess!! // get info for main thread ------------------------------------------------------------------------------------------------------------------------------------------------------------------- $tVars = new e_vars; @@ -212,9 +213,29 @@ $forum->set_crumb(true, '', $tVars); // Set $BREADCRUMB (and BACKLINK) //$tVars->BACKLINK = $tVars->BREADCRUMB; //$tVars->FORUM_CRUMB = $crumbs['forum_crumb']; $tVars->THREADNAME = $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off'); + + + $prev = $forum->threadGetNextPrev('prev', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']); + $next = $forum->threadGetNextPrev('next', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']); + + $options = array(); + + if($prev !== false) + { + $options[] = "« " . LAN_FORUM_2001 . ""; + } + if($next !== false) + { + $options[] = "" . LAN_FORUM_2002 . " »"; + } + + $tVars->NEXTPREV = implode(" | ", $options); + +/* $tVars->NEXTPREV = " $thread->threadId)) . "'>« " . LAN_FORUM_2001 . ""; $tVars->NEXTPREV .= ' | '; // enabled to make it look better on v1 templates $tVars->NEXTPREV .= " $thread->threadId)) . "'>" . LAN_FORUM_2002 . " »"; +*/ if ($forum->prefs->get('track') && USER) { @@ -300,12 +321,22 @@ function forumbuttons($thread) $options[] = " ".LAN_FORUM_2005.""; } - $options[] = " $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001.""; - $options[] = " $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002.""; +// $options[] = " $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001.""; +// $options[] = " $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002.""; + + $prev = $forum->threadGetNextPrev('prev', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']); + $next = $forum->threadGetNextPrev('next', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']); + + if($prev !== false) + { + $options[] = "".LAN_FORUM_1017." ".LAN_FORUM_2001.""; + } + if($next !== false) + { + $options[] = "".LAN_FORUM_1017." ".LAN_FORUM_2002.""; + } + - - - $text = '
    '.$replyUrl.'