2015-01-10, 10:51 AM
Hi,
i create simple plugin to show latest user thread in his profile (tabs)
in portal php is ready-made solution, I use it in my plugin
but
get_unviewable_forums not work, guest can see thread from forums when thay don't have permissions
get_inactive_forums(); is OK
i create simple plugin to show latest user thread in his profile (tabs)
in portal php is ready-made solution, I use it in my plugin
function ostatnie_tematy()
{
global $mybb, $db, $templates, $theme, $ostatnie_tematy, $memprofile, $parser, $forum_cache;
$altbg = alt_trow();
$ostatnie_tematy_row = "";
$memprofileuid = $memprofile['uid'];
// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
$unviewwhere = " AND fid NOT IN ($unviewable)";
$tunviewwhere = " AND t.fid NOT IN ($unviewable)";
}
else
{
$unviewwhere = '';
}
// get inactive forums
$inactive = get_inactive_forums();
if($inactive)
{
$inactivewhere = " AND fid NOT IN ($inactive)";
$tinactivewhere = " AND t.fid NOT IN ($inactive)";
}
else
{
$inactivewhere = '';
}
/*
$excludeforums = '';
if(!empty($mybb->settings['portal_excludediscussion']))
{
$excludeforums = "AND t.fid NOT IN ({$mybb->settings['portal_excludediscussion']})";
}
*/
$query = $db->query("
SELECT t.tid, t.fid, t.uid, t.subject, t.replies, t.views, t.dateline, t.firstpost, p.pid, p.message
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."posts p ON (t.firstpost=p.pid)
WHERE 1=1 AND t.uid={$memprofileuid} {$excludeforums}{$tunviewwhere}{$tinactivewhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.dateline DESC
LIMIT 0, 5
");
while($thread = $db->fetch_array($query))
{
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['dateline'] = my_date('relative', $thread['dateline']);
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$parser_options = array("allow_html" => 0, "allow_mycode" => 1, "allow_smilies" => 1, "allow_imgcode" => 1, "allow_videocode" => 1, "filter_badwords" => 1);
$thread['message'] = $parser->parse_message($thread['message'], $parser_options);
eval("\$ostatnie_tematy_row .= \"".$templates->get("ostatnie_tematy_row")."\";");
$altbg = alt_trow();
}
// if(!$ostatnie_tematy_row)
// {
// eval("\$ostatnie_tematy_row = \"".$templates->get("ostatnie_tematy_row_empty")."\";");
// }
eval("\$ostatnie_tematy = \"".$templates->get("ostatnie_tematy")."\";");
return $ostatnie_tematy;
}
but
get_unviewable_forums not work, guest can see thread from forums when thay don't have permissions
get_inactive_forums(); is OK