Hi,
I checked the search.php file and I can't seem to understand the code enough to create my custom search.
What I'm trying to do is, basically, there is an action called "getnew" or "getdaily", I want to make my own called "newaction" for example that will show posts from specific forums only.
Thanks in advance.
I managed to fix this by myself, I wasn't adding 's between the forum IDs which was the problem.
Sounds interesting - this is something I wanted to do myself - any chance of sharing that edit?
Sure. I think a plugin could be made for this one as well.
elseif($mybb->input['action'] == "custom")
{
if($mybb->input['days'] < 1)
{
$days = 1;
}
else
{
$days = intval($mybb->input['days']);
}
$datecut = TIME_NOW-(86400*$days);
$where_sql = "t.lastpost >='".$datecut."'";
$where_sql .= "AND t.fid IN ('1','2','3','4')";
$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$where_sql .= " AND t.fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
}
$permsql = "";
$onlyusfids = array();
// Check group permissions if we can't view threads not started by us
$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)
{
if($forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$where_sql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
}
$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => TIME_NOW,
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),
"keywords" => ''
);
$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
Replace custom with the action you want it to be called and '1', '2', etc with the IDs of the forum(s). This will show all the posts/threads made in the specific forums today! (like view today's posts, but only for specific forums).