1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

Forum fixes

This commit is contained in:
Cameron
2013-04-19 01:41:38 -07:00
parent 2e82033bb3
commit 631184f6ea
6 changed files with 63 additions and 28 deletions

View File

@@ -60,6 +60,14 @@ $fVars->VIEWTITLE = LAN_56;
$forumId = (int)$_REQUEST['id']; $forumId = (int)$_REQUEST['id'];
if(!$forumId && e_QUERY) // BC Fix for old links.
{
list($id,$from) = explode(".",e_QUERY);
$forumId = intval($id);
$threadFrom = intval($from);
unset($id,$from);
}
if (!$forum->checkPerm($forumId, 'view')) if (!$forum->checkPerm($forumId, 'view'))
{ {
header('Location:'.e107::getUrl()->create('forum/forum/main')); header('Location:'.e107::getUrl()->create('forum/forum/main'));
@@ -670,7 +678,7 @@ function fadminoptions($thread_info)
$text .= '<div class="btn-group"><button class="btn btn-mini dropdown-toggle" data-toggle="dropdown"> $text .= '<div class="btn-group"><button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu left"> <ul class="dropdown-menu pull-right">
'; ';
//FIXME - not fully working. //FIXME - not fully working.

View File

@@ -375,7 +375,9 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
//XXX Show only on the last page?? //XXX Show only on the last page??
if (!vartrue($forum_quickreply)) if (!vartrue($forum_quickreply))
{ {
$ajaxInsert = ($thread->pages == $thread->page) ? 1 : 0; $ajaxInsert = ($thread->pages == $thread->page || $thread->pages == 0) ? 1 : 0;
// echo "AJAX-INSERT=".$ajaxInsert ."(".$thread->pages." vs ".$thread->page.")";
$tVars->QUICKREPLY = " $tVars->QUICKREPLY = "
<form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'> <form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'>
@@ -609,6 +611,15 @@ class e107ForumThread
$this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $forum->prefs->get('postspage')); $this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $forum->prefs->get('postspage'));
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 1); $this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 1);
if(!$this->threadId && e_QUERY) //BC Links fix.
{
list($id,$page) = explode(".",e_QUERY);
$this->threadId = intval($id);
$this->page = intval($page);
}
//If threadId doesn't exist, or not given, redirect to main forum page //If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId)) if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId))
{ {

View File

@@ -27,31 +27,37 @@ if (isset($_GET['author']) && $_GET['author'] != '') {
if (isset($_GET['match']) && $_GET['match']) { if (isset($_GET['match']) && $_GET['match']) {
$search_fields = array('t.thread_name'); $search_fields = array('t.thread_name');
} else { } else {
$search_fields = array('t.thread_name', 't.thread_thread'); $search_fields = array('t.thread_name', 'p.post_entry');
} }
// basic // basic
$return_fields = 'tp.thread_name AS parent_name, t.thread_id, t.thread_name, t.thread_thread, t.thread_forum_id, t.thread_parent, t.thread_datestamp, t.thread_user, u.user_id, u.user_name, f.forum_class, f.forum_id, f.forum_name'; $return_fields = 't.thread_id, t.thread_name, p.post_entry, t.thread_forum_id, t.thread_datestamp, t.thread_user, u.user_id, u.user_name, f.forum_class, f.forum_id, f.forum_name';
$weights = array('1.2', '0.6'); $weights = array('1.2', '0.6');
$no_results = LAN_198; $no_results = LAN_198;
$where = "f.forum_class REGEXP '".e_CLASS_REGEXP."' AND fp.forum_class REGEXP '".e_CLASS_REGEXP."' AND".$advanced_where; $where = "f.forum_class REGEXP '".e_CLASS_REGEXP."' AND fp.forum_class REGEXP '".e_CLASS_REGEXP."' AND".$advanced_where;
$order = array('thread_datestamp' => DESC); $order = array('thread_datestamp' => DESC);
$table = "forum_thread AS t LEFT JOIN #user AS u ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id $table = "forum_thread AS t LEFT JOIN #user AS u ON t.thread_user = u.user_id
LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
LEFT JOIN #forum_thread AS tp ON t.thread_parent = tp.thread_id"; LEFT JOIN #forum_post AS p ON p.post_thread = t.thread_id
";
$ps = $sch -> parsesearch($table, $return_fields, $search_fields, $weights, 'search_forum', $no_results, $where, $order); $ps = $sch -> parsesearch($table, $return_fields, $search_fields, $weights, 'search_forum', $no_results, $where, $order);
$text .= $ps['text']; $text .= $ps['text'];
$results = $ps['results']; $results = $ps['results'];
function search_forum($row) { function search_forum($row)
{
global $con; global $con;
$datestamp = $con -> convert_date($row['thread_datestamp'], "long"); $datestamp = $con -> convert_date($row['thread_datestamp'], "long");
if ($row['thread_parent']) { if ($row['thread_parent'])
{
$title = $row['parent_name']; $title = $row['parent_name'];
} else { }
else
{
$title = $row['thread_name']; $title = $row['thread_name'];
} }
@@ -61,8 +67,9 @@ function search_forum($row) {
$res['pre_title'] = $title ? FOR_SCH_LAN_5.": " : ""; $res['pre_title'] = $title ? FOR_SCH_LAN_5.": " : "";
$res['title'] = $title ? $title : LAN_SEARCH_9; $res['title'] = $title ? $title : LAN_SEARCH_9;
$res['pre_summary'] = "<div class='smalltext' style='padding: 2px 0px'><a href='".e_PLUGIN."forum/forum.php'>".FOR_SCH_LAN_1."</a> -> <a href='".e_PLUGIN."forum/forum_viewforum.php?".$row['forum_id']."'>".$row['forum_name']."</a></div>"; $res['pre_summary'] = "<div class='smalltext' style='padding: 2px 0px'><a href='".e_PLUGIN."forum/forum.php'>".FOR_SCH_LAN_1."</a> -> <a href='".e_PLUGIN."forum/forum_viewforum.php?".$row['forum_id']."'>".$row['forum_name']."</a></div>";
$res['summary'] = $row['thread_thread']; $res['summary'] = $row['post_entry'];
$res['detail'] = LAN_SEARCH_7."<a href='user.php?id.".$row['user_id']."'>".$row['user_name']."</a>".LAN_SEARCH_8.$datestamp; $res['detail'] = LAN_SEARCH_7."<a href='user.php?id.".$row['user_id']."'>".$row['user_name']."</a>".LAN_SEARCH_8.$datestamp;
return $res; return $res;
} }

View File

@@ -158,11 +158,13 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_avatar() function sc_avatar()
{ {
$tp = e107::getParser();
//return e107::getParser()->parseTemplate("{AVATAR=".$this->postInfo['user_image']."}"); //return e107::getParser()->parseTemplate("{AVATAR=".$this->postInfo['user_image']."}");
$height = e107::getPref("im_height");
$width = e107::getPref("im_width");
if ($this->postInfo['post_user']) if ($this->postInfo['post_user'] && $this->postInfo['user_image'])
{ {
if(!$avatar = getcachedvars('forum_avatar_'.$this->postInfo['post_user'])) if(!$avatar = getcachedvars('forum_avatar_'.$this->postInfo['post_user']))
{ {
@@ -173,13 +175,20 @@ class plugin_forum_view_shortcodes extends e_shortcode
} }
else else
{ {
$avatar = ''; $avatar = "<img class='user-avatar' src='".$img."' alt='' />";
} }
cachevars('forum_avatar_'.$this->postInfo['post_user'], $avatar); cachevars('forum_avatar_'.$this->postInfo['post_user'], $avatar);
} }
return $avatar; return $avatar;
} }
return '';
// $img = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height);
// return print_a($img, true);
$img = e_IMAGE."generic/blank_avatar.jpg";
return "<img class='user-avatar' src='".$img."' alt='' width='".$width."' />";
return $text;
} }
@@ -489,24 +498,24 @@ class plugin_forum_view_shortcodes extends e_shortcode
<ul class="dropdown-menu pull-right">'; <ul class="dropdown-menu pull-right">';
$text .= "<li><a href='".e_HTTP."email.php?plugin:forum.".$this->postInfo['post_thread']."'>".FORLAN_101."</a></li>"; $text .= "<li><a href='".e_HTTP."email.php?plugin:forum.".$this->postInfo['post_thread']."'>".FORLAN_101." <i class='icon-envelope'></i></a></li>";
$text .= "<li><a href='".e_HTTP."print.php?plugin:forum.".$this->postInfo['post_thread']."'>Print</a></li>"; $text .= "<li><a href='".e_HTTP."print.php?plugin:forum.".$this->postInfo['post_thread']."'>Print <i class='icon-print'></i></a></li>";
if (USER) // Report if (USER) // Report
{ {
$text .= "<li><a href='".$this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}")."'>Report</a></li>"; $text .= "<li><a href='".$this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}")."'>Report <i class='icon-flag'></i></a></li>";
} }
// Edit // Edit
if ( (USER && $this->postInfo['post_user'] == USERID && $this->thread->threadInfo['thread_active'])) if ( (USER && $this->postInfo['post_user'] == USERID && $this->thread->threadInfo['thread_active']))
{ {
$text .= "<li><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>Edit</a></li>"; $text .= "<li><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>Edit <i class='icon-edit'></i></a></li>";
} }
if($this->forum->checkperm($this->postInfo['post_forum'], 'post')) if($this->forum->checkperm($this->postInfo['post_forum'], 'post'))
{ {
$text .= "<li><a href='".e107::getUrl()->create('forum/thread/quote', array('id' => $this->postInfo['post_id']))."'>Quote</a></li>"; $text .= "<li><a href='".e107::getUrl()->create('forum/thread/quote', array('id' => $this->postInfo['post_id']))."'>Quote <i class='icon-share-alt'></i></a></li>";
} }
@@ -517,14 +526,14 @@ class plugin_forum_view_shortcodes extends e_shortcode
if ((USER && $this->postInfo['post_user'] != USERID && $this->thread->threadInfo['thread_active'])) if ((USER && $this->postInfo['post_user'] != USERID && $this->thread->threadInfo['thread_active']))
{ {
$text .= "<li><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>Edit</a></li>"; $text .= "<li><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>Edit <i class='icon-edit'></i></a></li>";
} }
$text .= "<li><a href='".e_REQUEST_URI."' data-forum-action='deletepost' data-forum-post='".$this->postInfo['post_id']."'>Delete (fixme)</a></li>"; $text .= "<li><a href='".e_REQUEST_URI."' data-forum-action='deletepost' data-forum-post='".$this->postInfo['post_id']."'>Delete (fixme) <i class='icon-trash'></i></a></li>";
if ($type == 'thread') if ($type == 'thread')
{ {
$text .= "<li><a href='" . e107::getUrl()->create('forum/thread/move', array('id' => $this->postInfo['post_id']))."'>Move</a></li>"; $text .= "<li><a href='" . e107::getUrl()->create('forum/thread/move', array('id' => $this->postInfo['post_id']))."'>Move <i class='icon-move'></i></a></a></li>";
} }
else else
{ {

View File

@@ -337,7 +337,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
<div class='row-fluid' > <div class='row-fluid' >
<div class='span2 center'> <div class='span2 center'>
{CUSTOMTITLE} {CUSTOMTITLE}
{AVATAR} {AVATAR}<br />
{USERCOMBO} {USERCOMBO}
</div> </div>

View File

@@ -553,7 +553,7 @@ if ($perform_search)
if ($results > $search_res) if ($results > $search_res)
{ {
$nextprev = ($results > $search_res) ? $tp -> parseTemplate("{NEXTPREV={$parms}}") : ""; $nextprev = ($results > $search_res) ? $tp -> parseTemplate("{NEXTPREV={$parms}}") : "";
$text .= "<div class='nextprev search'>".$nextprev."</div>"; $text .= "<div class='nextprev search form-inline'>".$nextprev."</div>";
} }
if ($results > 0) if ($results > 0)
{ {