Make sure you've read this and update your add-ons if neccessary.
http://xenforo.com/community/threads/xenforo-1-0-0.13280/#post-173592
http://xenforo.com/community/threads/xenforo-1-0-0.13280/#post-173592
That is pretty much it, so it is different.It looks the same to me, just without any array keys.
$visitorID = XenForo_Visitor::getUserId();
$conditions = array(
'deleted' => false,
'moderated' => false,
);
$fetchOptions = array(
'join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER,
'readUserId' => $visitorID,
'watchUserId' => $visitorID,
'postCountUserId' => $visitorID,
'order' => 'last_post_date',
'orderDirection' => 'desc',
'limit' => $params['option']['recentthreads_limit'],
);
$threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads($conditions, $fetchOptions);
foreach ($threads AS &$thread)
{
$thread['content_type'] = 'thread';
$thread['content_id'] = $thread['thread_id'];
}
$threads = $this->getModelFromCache('XenForo_Model_Search')->getViewableSearchResults($threads);
An exception occurred: Undefined offset: 0 in /library/XenForo/Model/Search.php on line 235
- XenForo_Application::handlePhpError() in XenForo/Model/Search.php at line 235
- XenForo_Model_Search->groupSearchResultsByType() in XenForo/Model/Search.php at line 295
- XenForo_Model_Search->getViewableSearchResults() in EWRporta/Block/RecentThreads.php at line 31
- EWRporta_Block_RecentThreads->getBypass() in EWRporta/ViewPublic/Portal.php at line 87
- EWRporta_ViewPublic_Portal->getModuleParams() in EWRporta/ViewPublic/Portal.php at line 23
- EWRporta_ViewPublic_Portal->renderHtml() in XenForo/ViewRenderer/Abstract.php at line 222
- XenForo_ViewRenderer_Abstract->renderViewObject() in XenForo/ViewRenderer/HtmlPublic.php at line 67
- XenForo_ViewRenderer_HtmlPublic->renderView() in XenForo/FrontController.php at line 533
- XenForo_FrontController->renderView() in XenForo/FrontController.php at line 156
- XenForo_FrontController->run() in /index.php at line 17
How would I do that?That said, using the search stuff for this really isn't necessary - you can get the permissions with the threads and filter out the results without doing all the search lookups.
$conditions = array(
'deleted' => false,
'moderated' => false,
);
$fetchOptions = array(
'order' => 'last_post_date',
'orderDirection' => 'desc',
'limit' => $options['recentthreads_limit'],
);
$threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads($conditions, $fetchOptions);
$threadIDs = array_keys($threads);
$visitor = XenForo_Visitor::getInstance();
$handler = XenForo_Search_DataHandler_Abstract::create('thread');
$threads = $handler->getDataForResults($threadIDs, $visitor, $threadIDs);
/**
* get the newest threads
*/
protected function getThreads(){
$nodeModel = $this->getModelFromCache('XenForo_Model_Node');
$threadModel = $this->getModelFromCache('XenForo_Model_Thread');
$viewableNodeList = $nodeModel->getViewableNodeList(); // check if this returns pages too, if yes, we need an other way
$condition = array(
'forum_ids' => array_keys($viewableNodeList), // had to overwrite the model to provide this feature
'moderated' => false,
'deleted' => false
);
$fetchOptions = array(
'order' => 'last_post_date',
'orderDirection' => 'desc',
'join' => XenForo_Model_Thread::FETCH_FIRSTPOST,
'limit' => XenForo_Application::get('options')->ragtek_feed_maxThreads
);
return $threadModel->getThreads($condition,$fetchOptions);
}
$conditions = array(
'deleted' => false,
'moderated' => false,
);
$fetchOptions = array(
'order' => 'last_post_date',
'orderDirection' => 'desc',
'limit' => $options['recentthreads_limit'],
);
$threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads($conditions, $fetchOptions);
$threadIDs = array_keys($threads);
$visitor = XenForo_Visitor::getInstance()->toArray();
$handler = XenForo_Search_DataHandler_Abstract::create('XenForo_Search_DataHandler_Thread');
$threads = $handler->getDataForResults($threadIDs, $visitor, $threadIDs);
foreach ($threads AS &$thread)
{
$thread = $this->getModelFromCache('XenForo_Model_Thread')->prepareThread($thread, $thread);
$thread['canInlineMod'] = false;
$thread['showForumLink'] = true;
}
return $threads;
If your quick search input doesn't have the right ID, it won't pop open when you focus it.I don't see how this affects styles...any insight on that, or what would be messed up if my style isn't up-to-date?
It's poppin', so looks like I'm fine.If your quick search input doesn't have the right ID, it won't pop open when you focus it.
$visitor = XenForo_Visitor::getInstance();
$visitorID = $visitor['user_id'];
$conditions = array(
'deleted' => false,
'moderated' => false,
);
$fetchOptions = array(
'join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER,
'permissionCombinationId' => $visitor['permission_combination_id'],
'readUserId' => $visitorID,
'watchUserId' => $visitorID,
'postCountUserId' => $visitorID,
'order' => 'last_post_date',
'orderDirection' => 'desc',
'limit' => $params['option']['recentthreads_limit'],
);
$threadModel = $this->getModelFromCache('XenForo_Model_Thread');
$threads = $threadModel->getThreads($conditions, $fetchOptions);
$threads = $threadModel->unserializePermissionsInList($threads, 'node_permission_cache');
foreach ($threads AS $threadId => $thread)
{
if (!$threadModel->canViewThreadAndContainer($thread, $thread, $null, $thread['permissions']))
{
unset($threads[$threadId]);
}
}
Jaxel, this is derived from the first set of code you provided. Your latest code does some different stuff (in terms of what it fetches and preparation), and I'm not sure if it's intentional.
I also haven't tested it at all - just typed it up in a text editor, so there might be parse errors.
PHP:$visitor = XenForo_Visitor::getInstance(); $visitorID = $visitor['user_id']; $conditions = array( 'deleted' => false, 'moderated' => false, ); $fetchOptions = array( 'join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER, 'permissionCombinationId' => $visitor['permission_combination_id'], 'readUserId' => $visitorID, 'watchUserId' => $visitorID, 'postCountUserId' => $visitorID, 'order' => 'last_post_date', 'orderDirection' => 'desc', 'limit' => $params['option']['recentthreads_limit'], ); $threadModel = $this->getModelFromCache('XenForo_Model_Thread'); $threads = $threadModel->getThreads($conditions, $fetchOptions); $threads = $threadModel->unserializePermissionsInList($threads, 'node_permission_cache'); foreach ($threads AS $threadId => $thread) { if (!$threadModel->canViewThreadAndContainer($thread, $thread, $null, $thread['permissions'])) { unset($threads[$threadId]); } }
All you can do is select more than you need and hope that when you filter them, you have n remaining. Any more than that, you can chop off.With this way it's not possible to get n Elements back.
If you limit 20 and 5 from them are not viable, the user will get only 15 back!
That's why we need an official way in the thread model, to use a list of forumids . (just like in http://xenforo.com/community/threads/backward-compatability-breaks.13290/#post-174050 )
I have sleepless nights because of this because i don't understand itAll you can do is select more than you need and hope that when you filter them, you have n remaining. Any more than that, you can chop off.
(This is the principle behind pretty much every search engine that has to manage diverse data)
There are far more variables involved than just that. What about soft-deleted threads, or threads in the moderation queue, or threads subject to other viewing restrictions?The readable forums are known because of $nodemodell->getViewableNodeList.
I thought the condition part is handling this?There are far more variables involved than just that. What about soft-deleted threads, or threads in the moderation queue,
Is this a better way, as the code ragtek posted?There are far more variables involved than just that. What about soft-deleted threads, or threads in the moderation queue, or threads subject to other viewing restrictions?
protected function _getThreads()
{
$visitor = XenForo_Visitor::getInstance();
$visitorID = $visitor['user_id'];
$conditions = array(
'deleted' => false,
'moderated' => false,
);
$fetchOptions = array(
'join' => XenForo_Model_Thread::FETCH_FORUM |
XenForo_Model_Thread::FETCH_USER |
XenForo_Model_Thread::FETCH_FIRSTPOST,
'permissionCombinationId' => $visitor['permission_combination_id'],
'readUserId' => $visitorID,
'watchUserId' => $visitorID,
'postCountUserId' => $visitorID,
'order' => 'last_post_date',
'orderDirection' => 'desc',
'limit' => XenForo_Application::get('options')->ragtek_feed_maxThreads * 2, // get more as we need because of the cut off, we'll remove them later
);
/** @var $threadModel XenForo_Model_Thread */
$threadModel = $this->getModelFromCache('XenForo_Model_Thread');
$threads = $threadModel->getThreads($conditions, $fetchOptions);
$threads = $threadModel->unserializePermissionsInList($threads, 'node_permission_cache');
foreach ($threads AS $threadId => $thread)
{
if (!$threadModel->canViewThreadAndContainer($thread, $thread, $null, $thread['permissions'])) {
unset($threads[$threadId]);
}
}
// make sure that we only return max. threads
$threads = array_slice($threads, 0,XenForo_Application::get('options')->ragtek_feed_maxThreads);
return $threads;
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.