1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-28 10:20:45 +02:00

Forum: Fix for SEF Url on Redirect to post.

This commit is contained in:
Cameron
2016-03-26 12:29:32 -07:00
parent e4436417f9
commit 74f0e2f3d9

View File

@@ -49,6 +49,7 @@ class e107forum
// var $fieldTypes = array(); // var $fieldTypes = array();
private $userViewed, $permList; private $userViewed, $permList;
public $modArray, $prefs; public $modArray, $prefs;
private $forumData = array();
public function __construct($update= false) public function __construct($update= false)
{ {
@@ -75,7 +76,7 @@ class e107forum
$this->setDefaults(); $this->setDefaults();
} }
$this->getForumData();
// var_dump($this->prefs); // var_dump($this->prefs);
/* /*
@@ -103,6 +104,41 @@ class e107forum
*/ */
} }
/**
* Grab the forum data up front to reduce LEFT JOIN usage. Currently only forum_id and forum_sef but may be expanded as needed.
*/
function getForumData()
{
$data = e107::getDb()->retrieve("SELECT forum_id, forum_sef FROM `#forum`", true); // no ordering for better performance.
$newData = array();
foreach($data as $row)
{
$id = $row['forum_id'];
$newData[$id ] = $row;
}
$this->forumData = $newData;
}
function getForumSef($threadInfo)
{
$forumId = !empty($threadInfo['post_forum']) ? $threadInfo['post_forum'] : $threadInfo['thread_forum_id'];
if(!empty($this->forumData[$forumId]['forum_sef']))
{
$ret = $this->forumData[$forumId]['forum_sef'];
}
else
{
$ret = null;
}
return $ret;
}
/** /**
* @param $user integer userid (if empty "anon" will be used) * @param $user integer userid (if empty "anon" will be used)
* @param $create boolean creates the attachment folder if set to true * @param $create boolean creates the attachment folder if set to true
@@ -949,7 +985,9 @@ class e107forum
$ret = array(); $ret = array();
while($row = $sql->fetch()) while($row = $sql->fetch())
{ {
$row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl');
$row['thread_sef'] = $this->getThreadSef($row); // eHelper::title2sef($row['thread_name'],'dashl');
$ret[] = $row; $ret[] = $row;
} }
} }
@@ -958,7 +996,18 @@ class e107forum
e107::getMessage()->addDebug('Query failed ('.__METHOD__.' ): '.str_replace('#', MPREFIX,$qry)); e107::getMessage()->addDebug('Query failed ('.__METHOD__.' ): '.str_replace('#', MPREFIX,$qry));
} }
if('post' === $start) { return $ret[0]; }
// print_a($ret);
if($start == 'post')
{
$ret[0]['forum_sef']= $this->getForumSef($ret[0]);
$ret[0]['thread_sef'] = $this->getThreadSef($ret[0]);
return $ret[0];
}
return $ret; return $ret;
} }