1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-25 17:01:43 +02:00

Fixes #1028 - Forum reporting failing. Reporting now uses 'Notify' settings. Jump to Previous and Next forums working again. Jump to other forums working. Header redirection has been minimized for improved performance.

This commit is contained in:
Cameron
2015-05-26 12:00:43 -07:00
parent 3d703ebb76
commit 240d509fd0
6 changed files with 236 additions and 53 deletions

View File

@@ -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 <br />forum id = $forumId <br />";
// 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;
}

View File

@@ -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 = "<div class='alert alert-block alert-success'><h4>".LAN_FORUM_2021 . "</h4><a href='{$url}'>".LAN_FORUM_2022.'</a></div>';
}
else
{
$text = "<div class='alert alert-block alert-error'><h4>".LAN_FORUM_2021 . "</h4><a href='{$url}'>".LAN_FORUM_2022.'</a></div>';
}
$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&amp;id=".$this->data['thread_id']."&amp;post=".$this->data['post_id'];
if(deftrue('BOOTSTRAP')) //v2.x
{
$text = $frm->open('forum-report-thread','post');
$text .= "
<div>
<div class='alert alert-block alert-warning'>
<h4>".LAN_FORUM_2025.': '.$thread_name."</h4>
".LAN_FORUM_2027."<br />".str_replace(array('[', ']'), array('<b>', '</b>'), LAN_FORUM_2028)."
<a class='pull-right btn btn-xs btn-primary e-expandit' href='#post-info'>".LAN_FORUM_2026."</a>
</div>
<div id='post-info' class='e-hideme alert alert-block alert-danger'>
".$tp->toHtml($this->data['post_entry'],true)."
</div>
<div class='form-group' >
<div class='col-md-12'>
".$frm->textarea('report_add','',10,35,array('size'=>'xxlarge'))."
</div>
</div>
<div class='form-group'>
<div class='col-md-12'>
".$frm->button('report_thread',1,'submit',LAN_FORUM_2029)."
</div>
</div>
</div>";
$text .= $frm->close();
}
else //v1.x legacy layout.
{
$text = "<form action='".$actionUrl."' method='post'>
<table class='table' style='width:100%'>
<tr>
<td style='width:50%'>
".LAN_FORUM_2025.': '.$thread_name." <a class='e-expandit' href='#post-info'><span class='smalltext'>".LAN_FORUM_2026."</span></a>
<div id='post-info' class='e-hideme alert alert-block alert-danger'>
".$tp->toHtml($this->data['post_entry'],true)."
</div>
</td>
<td style='text-align:center;width:50%'></td>
</tr>
<tr>
<td>".LAN_FORUM_2027."<br />".str_replace(array('[', ']'), array('<b>', '</b>'), LAN_FORUM_2028)."</td>
</tr>
<tr>
<td style='text-align:center;'><textarea cols='40' rows='10' class='tbox' name='report_add'></textarea></td>
</tr>
<tr>
<td colspan='2' style='text-align:center;'><br /><input class='btn btn-default button' type='submit' name='report_thread' value='".LAN_FORUM_2029."' /></td>
</tr>
</table>
</form>";
}
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 = "<form method='post' action='".e_SELF."'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox'>";
foreach($jumpList as $key => $val)
{
$text .= "\n<option value='".$key."'>".$val."</option>";
$text .= "\n<option value='".e107::url('forum','forum', $val)."'>".$val['forum_name']."</option>";
}
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='".LAN_GO."' /></p></form>";
return $text;

View File

@@ -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 = "<form method='post' action='".e_SELF."'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox'>";
foreach($jumpList as $key => $val)
{
$text .= "\n<option value='".$key."'>".$val."</option>";
$text .= "\n<option value='".e107::url('forum','forum',$val)."'>".$val['forum_name']."</option>";
}
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='".LAN_GO."' /></form>";
return $text;
@@ -876,7 +881,7 @@ function newthreadjump($url)
foreach($jumpList as $key => $val)
{
$text .= '<li><a href="'.$key.'">'.LAN_FORUM_1017.': '.$val.'</a></li>';
$text .= '<li><a href="'.e107::url('forum','forum',$val).'">'.LAN_FORUM_1017.': '.$val['forum_name'].'</a></li>';
}
$text .= '

View File

@@ -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[] = "<a class='btn btn-default btn-sm btn-small' href='" . e107::url('forum','topic', $prev) . "'>&laquo; " . LAN_FORUM_2001 . "</a>";
}
if($next !== false)
{
$options[] = "<a class='btn btn-default btn-sm btn-small' href='" . e107::url('forum','topic', $next) . "'>" . LAN_FORUM_2002 . " &raquo;</a>";
}
$tVars->NEXTPREV = implode(" | ", $options);
/*
$tVars->NEXTPREV = "<a class='btn btn-default btn-sm btn-small' href='" . $e107->url->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>&laquo; " . LAN_FORUM_2001 . "</a>";
$tVars->NEXTPREV .= ' | '; // enabled to make it look better on v1 templates
$tVars->NEXTPREV .= "<a class='btn btn-default btn-sm btn-small' href='" . $e107->url->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>" . LAN_FORUM_2002 . " &raquo;</a>";
*/
if ($forum->prefs->get('track') && USER)
{
@@ -300,12 +321,22 @@ function forumbuttons($thread)
$options[] = " <a href='".$ntUrl."'>".LAN_FORUM_2005."</a>";
}
$options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
$options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
$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[] = "<a href='" . e107::url('forum','topic', $prev) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
}
if($next !== false)
{
$options[] = "<a href='" . e107::url('forum','topic', $next) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
}
$text = '<div class="btn-group">
'.$replyUrl.'
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
@@ -325,7 +356,7 @@ function forumbuttons($thread)
foreach($jumpList as $key=>$val)
{
$text .= '<li><a href ="'.$key.'">'.LAN_FORUM_1017." ".$val.'</a></li>';
$text .= '<li><a href ="'.e107::url('forum','forum',$val).'">'.LAN_FORUM_1017." ".$val['forum_name'].'</a></li>';
}
$text .= '
@@ -528,7 +559,7 @@ function forumjump()
$text = "<form method='post' action='".e_SELF."'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox'>";
foreach ($jumpList as $key => $val)
{
$text .= "\n<option value='" . $key . "'>" . $val . "</option>";
$text .= "\n<option value='" . e107::url('forum','forum',$val) . "'>" . $val['forum_name'] . "</option>";
}
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='" . LAN_GO . "' /></p></form>";
return $text;
@@ -630,7 +661,7 @@ function rpg($user_join, $user_forums)
$bar_image = e_PLUGIN . "forum/images/" . IMODE . "/bar.jpg";
}
$rpg_info .= "<div style='padding:2px; white-space:nowrap'>";
$rpg_info = "<div style='padding:2px; white-space:nowrap'>";
$rpg_info .= "<b>Level = " . $lvl_level . "</b><br />";
$rpg_info .= "HP = " . $lvl_hp . "<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:" . $lvl_hp_percent . "%'><br />";
$rpg_info .= "EXP = " . $lvl_exp . "<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:" . $lvl_exp_percent . "%'><br />";
@@ -768,7 +799,8 @@ class e107ForumThread
$thread->page = $_GET['p'] = $pages;
break;
case 'next': // FIXME - nextprev thread detection not working
/* // Now linked directly - no more redirect.
case 'next':
$next = $forum->threadGetNextPrev('next', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($next)
{
@@ -779,7 +811,7 @@ class e107ForumThread
$this->message = LAN_FORUM_2013;
break;
case 'prev': // FIXME - nextprev thread detection not working
case 'prev':
$prev = $forum->threadGetNextPrev('prev', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($prev)
{
@@ -789,9 +821,10 @@ class e107ForumThread
}
$this->message = LAN_FORUM_2012;
break;
*/
// TODO Move to form_post.php
// Moved to form_post.php
/*
case 'report':
$threadId = (int)$_GET['id'];
$postId = (int)$_GET['post'];
@@ -801,7 +834,7 @@ class e107ForumThread
{
$report_add = $tp->toDB($_POST['report_add']);
if($forum->prefs->get('reported_post_email')) // todo Use e_NOTIFY.
if($forum->prefs->get('reported_post_email'))
{
require_once(e_HANDLER.'mail.php');
$report = LAN_FORUM_2018." ".SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/") . $e107->getFolder('plugins') . "forum/forum_viewtopic.php?" . $this->threadId . ".post\n
@@ -910,7 +943,7 @@ class e107ForumThread
}
exit;
break;
break;*/
}
}

View File

@@ -159,7 +159,7 @@ define("LAN_FORUM_2022", "Click here to return to the forum"); // LAN_429
define("LAN_FORUM_2023", "Report this topic to a moderator"); // LAN_414 (vt)
define("LAN_FORUM_2024", "Reporting post in topic"); // LAN_426
define("LAN_FORUM_2025", "Topic title"); // LAN_415
define("LAN_FORUM_2026", "Click to view post"); // LAN_420
define("LAN_FORUM_2026", "View post"); // LAN_420
define("LAN_FORUM_2027", "The moderator(s) will be made aware of this topic. You may post a message explaining what you found to be objectionable."); // LAN_417
define("LAN_FORUM_2028", "[Do not] use this form to contact the admin for any other reason."); // LAN_418 - [ and ] are replaced by <b> </b>
define("LAN_FORUM_2029", "Send Report"); // LAN_419

View File

@@ -332,7 +332,9 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
global $page;
if (USER) {
return "<a href='".$this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}")."'>".IMAGE_report.'</a> ';
// $actionUrl= $this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}");
$actionUrl = e107::url('forum','post')."?f=report&amp;id=".$this->data['thread_id']."&amp;post=".$this->data['post_id'];
return "<a href='".$actionUrl."'>".IMAGE_report.'</a> ';
}
}
@@ -511,7 +513,9 @@ class plugin_forum_view_shortcodes extends e_shortcode
if (USER) // Report
{
$text .= "<li class='text-right'><a href='".$this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}")."'>".LAN_FORUM_2046." ".$tp->toGlyph('flag')."</a></li>";
$urlReport = e107::url('forum','post')."?f=report&amp;id=".$this->postInfo['post_thread']."&amp;post=".$this->postInfo['post_id'];
// $urlReport = $this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}");
$text .= "<li class='text-right'><a href='".$urlReport."'>".LAN_FORUM_2046." ".$tp->toGlyph('flag')."</a></li>";
}
// Edit