Need mod that can search topics/posts in Mod panel..

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Ideas Centre
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by Jessica »

AmigoJack wrote:(Although this somehow goes beyond this topic) Give me a link to your board and a test account, so I have at least the ability to click on the "find member" when composing a PM.
Username: Test
Password: test123
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by AmigoJack »

Open /styles/prosilver/template/overall_header.html and find:

Code: Select all

	function refresh(f,l)
	{
		var urls= 'models.php';
		var param = 'f='+f+'&selected_language='+l;
		var myAjax = new Ajax.Request
		(
			urls, 
			{
				method: 'post', 
				postBody: param,
				onComplete: showResponse
	};
		);
	};
Must be:

Code: Select all

	function refresh(f,l)
	{
		var urls= 'models.php';
		var param = 'f='+f+'&selected_language='+l;
		var myAjax = new Ajax.Request
		(
			urls, 
			{
				method: 'post', 
				postBody: param,
				onComplete: showResponse
			}
		);
	};
(Indention is for reading only, but semicolons within arguments is lethal.

Your site is full of markup errors and my eyes bleed from viewing everything in the "Times" font since I don't have "Cambria" (and everybody else who either uses Windows lower than Vista or another OS at all).
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by Jessica »

thanks, it's fixed, and I'll go deal with the font thing and make sure it doesn't become unappealing to guests
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: Need mod that can search topics/posts in Mod panel..

Post by baller1234 »

amigo, can you still make the modification like i explained? Or is it to much work. I can reward you for it..
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by AmigoJack »

Describe APAP (as precise as possible) what you expected and what is still missing.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: Need mod that can search topics/posts in Mod panel..

Post by baller1234 »

ok.. thanks Amigo!

I need a extra tab in the modpanel to search for posts/topics. ps click on the image for full screen..
Image

So i need a textbox and a submit button on the extra tab page.. So when i search for eg "trailer" in the forum where i clicked Moderator panel i need to get the results like this:
click on the image for full screen..
Image

With the checkbox to move them to a specific forum..
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by AmigoJack »

baller1234 wrote:a extra tab
That makes little sense.
baller1234 wrote:search for posts/topics
So when viewing a forum you want to filter the list of topics to be displayed by keywords for the topic title? Then a textbox in MCP > Main > View forum would be better then.
And when viewing a topic you want to filter the list of posts to be displayed by keywords for the post text and its subject? Then a textbox in MCP > Main > View forum would be better then.

...So two textboxes, just like every forum and topic already has to perform a quick search in the current forum/topic.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: Need mod that can search topics/posts in Mod panel..

Post by baller1234 »

Yes.. View Forum is better indeed..

Just a search form.. (like in viewforum.php)

And that the results are based on keywords in topic title or topic text. And that the results just look like
MCP > Main > View forum with checkboxes so you can bulk move topics that you find to another forum...
Its not really needed for posts in my case.. Topics are more important.

You hit the jackpot! Sorry for being unclear.. before..


btw, This should be a function in standard phpbb already dont you think! Its undo-able for moderators if you need to filter topics that needs to be moved (for any reason) and you have millions of topics...
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by AmigoJack »

Open /includes/mcp/mcp_forum.php and find:

Code: Select all

    $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; 
After, add:

Code: Select all

    /*** 2012-03-04 BEGIN AmigoJack
        Search within the forum by topic title ***/
    $keywords= utf8_normalize_nfc( request_var( 'keywords', '', TRUE ) );
    if( $keywords== $user-> lang['SEARCH_FORUM'] ) $keywords= '';
    $sql_where = '';  // Used with the search only
    $searchurl= $url;  // Excludes keywords and start
    if( $keywords&& request_var( 'search', '' ) ) {
        $user-> add_lang( 'search' );
        $search_forum= array( $forum_id );  // This forum only
        $search_child= FALSE;
        $url.= '&keywords=' . urlencode(htmlspecialchars_decode($keywords));

        // Largely taken from /search.php
        $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));

        $not_in_fid = (sizeof($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : "";

        $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id
            FROM ' . FORUMS_TABLE . ' f
            LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
                AND fa.session_id = '" . $db->sql_escape($user->session_id) . "')
            $not_in_fid
            ORDER BY f.left_id";
        $result = $db->sql_query($sql);

        $right_id = 0;
        $reset_search_forum = true;
        while ($row = $db->sql_fetchrow($result))
        {
            if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
            {
                $ex_fid_ary[] = (int) $row['forum_id'];
                continue;
            }

            if (sizeof($search_forum))
            {
                if ($search_child)
                {
                    if (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id)
                    {
                        $right_id = (int) $row['right_id'];
                    }
                    else if ($row['right_id'] < $right_id)
                    {
                        continue;
                    }
                }

                if (!in_array($row['forum_id'], $search_forum))
                {
                    $ex_fid_ary[] = (int) $row['forum_id'];
                    $reset_search_forum = false;
                }
            }
        }
        $db->sql_freeresult($result);

        // find out in which forums the user is allowed to view approved posts
        if ($auth->acl_get('m_approve'))
        {
            $m_approve_fid_ary = array(-1);
            $m_approve_fid_sql = '';
        }
        else if ($auth->acl_getf_global('m_approve'))
        {
            $m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
            $m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
        }
        else
        {
            $m_approve_fid_ary = array();
            $m_approve_fid_sql = ' AND p.post_approved = 1';
        }

        if ($reset_search_forum)
        {
            $search_forum = array();
        }

        // Select which method we'll use to obtain the post_id or topic_id information
        $search_type = basename($config['search_type']);

        if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
        {
            trigger_error('NO_SUCH_SEARCH_MODULE');
        }

        require("{$phpbb_root_path}includes/search/$search_type.$phpEx");

        // We do some additional checks in the module to ensure it can actually be utilised
        $error = false;
        $search = new $search_type($error);

        if ($error)
        {
            trigger_error($error);
        }

        // let the search module split up the keywords
        if ($keywords)
        {
            $correct_query = $search->split_keywords($keywords, 'all');
            if (!$correct_query || (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id))
            {
                $ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '<br />' : '';
                trigger_error($ignored . sprintf($user->lang['NO_KEYWORDS'], $search->word_length['min'], $search->word_length['max']));
            }
        }

        sort($ex_fid_ary);
        sort($m_approve_fid_ary);


        $forum_topics= $search-> keyword_search
        ( 'topics'
        , 'titleonly'  // Or 'firstpost' for post text also
        , 'all'
        , $sort_by_sql
        , $sort_key
        , $sort_dir
        , $sort_days
        , $ex_fid_ary
        , $m_approve_fid_ary
        , 0
        , array()
        , ''
        , $id_ary
        , $start
        , $topics_per_page
        );


        // For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options.
        if (!sizeof($id_ary))
        {
            trigger_error('NO_SEARCH_RESULTS');
        }

        if (sizeof($id_ary))
        {
            $sql_where .= 'AND '. $db->sql_in_set( 't.topic_id', $id_ary);
            $sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) . ' OR t.forum_id IS NULL)' : '';
            $sql_where .= str_replace(array('p.post_approved', 'p.forum_id'), array('t.topic_approved', 't.forum_id'), $m_approve_fid_sql );
        }
    }
    /*** 2012-03-04 END ***/
Find:

Code: Select all

        'S_MCP_ACTION'            => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''), 
After, add:

Code: Select all

        /*** 2012-03-04 BEGIN AmigoJack
            Search within the forum by topic title ***/
        'S_MCP_SEARCHACTION'            => $searchurl . "&i=$id&forum_action=$action&mode=$mode",
        /*** 2012-03-04 END ***/ 
Find:

Code: Select all

    else
    {
        $read_tracking_join = $read_tracking_select = '';
    } 
After, add:

Code: Select all

    /*** 2012-03-04 BEGIN AmigoJack
        Search within the forum by topic title ***/
    if( $keywords&& request_var( 'search', '' ) ) {
        $sql = "SELECT t.topic_id
            FROM " . TOPICS_TABLE . " t
            WHERE t.forum_id IN($forum_id, 0)
                " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
                $sql_where
                $limit_time_sql
            ORDER BY t.topic_type DESC, $sort_order_sql";
        $result = $db->sql_query($sql);
    } else {
    /*** 2012-03-04 END ***/ 
Find:

Code: Select all

    $topic_list = $topic_tracking_info = array(); 
Before, add:

Code: Select all

    /*** 2012-03-04 BEGIN AmigoJack
        Search within the forum by topic title ***/
    }
    /*** 2012-03-04 END ***/ 
Open /includes/mcp/mcp_main.php and find:

Code: Select all

        $quickmod = ($mode == 'quickmod') ? true : false; 
After, add:

Code: Select all

        /*** 2013-07-08 BEGIN AmigoJack
            http://www.phpbb.com/community/viewtopic.php?t=2151774 ***/
        if( request_var( 'search', '' ) ) $action= '';
        /*** 2013-07-08 END ***/ 
Open /styles/prosilver/template/mcp_forums.html and find:

Code: Select all

<h2><a href="{U_VIEW_FORUM}">{L_FORUM}: {FORUM_NAME}</a></h2>
After, add:

Code: Select all

		<div class="search-box">
			<form method="post" id="forum-search" action="{S_MCP_SEARCHACTION}">
			<fieldset>
				<input class="inputbox search tiny" type="text" name="keywords" id="search_keywords" size="20" value="{L_SEARCH_FORUM}" onclick="if (this.value == '{LA_SEARCH_FORUM}') this.value = '';" onblur="if (this.value == '') this.value = '{LA_SEARCH_FORUM}';" />
				<input class="button2" type="submit" name="search" value="{L_SEARCH}" />
			</fieldset>
			</form>
		</div>
Roughly tested: it filters the topic list to those where my keywords are found in the title. Going beyond page 1 also works, aswell as submitting a new search while search results are already shown. If you also want to search within the text of the topic's first post, search for 'titleonly' in my code and replace it according to the comment.
Last edited by AmigoJack on Mon Jul 08, 2013 6:47 am, edited 3 times in total.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: Need mod that can search topics/posts in Mod panel..

Post by baller1234 »

DUDE I love you :-D

You made my life and my mods life so much easier!! You should release this as a official mod for sure!!
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: Need mod that can search topics/posts in Mod panel..

Post by baller1234 »

Just one qstion. When i move topics that are on 1 page in mcp it auto redirects to the mcp.. But when there are no topics anymore (from search results) i get the standard error that nothing is found.. I can only go back if enter the forum again. (mcp link)

Also sometimes it goes back and i see the pagination but there are no topics anymore.. Something to do with refreshing the list?
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by AmigoJack »

baller1234 wrote:when there are no topics anymore (from search results) i get the standard error that nothing is found
That's to have a distinction wheather a forum has no topics or the search didn't match any topics (along with other possible error messages a search can give you).
baller1234 wrote:sometimes it goes back
"it"? Do you click on a link or do you navigate one step back in your browser, looking at (the old state of) the previous site?
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
theallzaz
Registered User
Posts: 84
Joined: Tue Apr 16, 2013 2:41 pm

Re: Need mod that can search topics/posts in Mod panel..

Post by theallzaz »

AmigoJack wrote:Open /includes/mcp/mcp_forum.php
Roughly tested: it filters the topic list to those where my keywords are found in the title. Going beyond page 1 also works, aswell as submitting a new search while search results are already shown. If you also want to search within the text of the topic's first post, search for 'titleonly' in my code and replace it according to the comment.
The filter is working, but when searching, phpBB shows me this Debug error:

[phpBB Debug] PHP Notice: in file [ROOT]/includes/mcp/mcp_forum.php on line 202: Undefined variable: search_terms
[phpBB Debug] PHP Warning: in file [ROOT]/includes/search/fulltext_native.php on line 82: Missing argument 2 for fulltext_native::split_keywords(), called in [ROOT]/includes/mcp/mcp_forum.php on line 202 and defined
[phpBB Debug] PHP Notice: in file [ROOT]/includes/search/fulltext_native.php on line 192: Undefined variable: terms

Im missing something or its a bug?

My version is 3.0.11
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: Need mod that can search topics/posts in Mod panel..

Post by baller1234 »

its not working with new version of phpbb.. Lets hope amigo reads this.
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Need mod that can search topics/posts in Mod panel..

Post by AmigoJack »

theallzaz wrote:Debug error
Updated my post: open /includes/mcp/mcp_forum.php and find:

Code: Select all

$correct_query = $search->split_keywords($keywords, $search_terms); 
Replace with:

Code: Select all

$correct_query = $search->split_keywords($keywords, 'all'); 
Also notice this new line:

Code: Select all

if( $keywords== $user-> lang['SEARCH_FORUM'] ) $keywords= '';
baller1234 wrote:its not working with new version
Works with 3.0.11. Your loose description doesn't help. What are you doing, what do you expect, what happens instead?
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Locked

Return to “[3.0.x] MOD Requests”