IPB and search by forum_id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mystified
    New Member
    • Jun 2007
    • 2

    IPB and search by forum_id

    I have a php mod that I'm using on an Invision Power Board. It's to search for unanswered topics. The problem is that it was designed to search for "all" and I need to be able to filter them by forum_id.

    This is what I had:
    [code=php]
    $this->ipsclass->input['forums'] = '7 9 10 31 19 26 28 13 15 20 48 21 16 52';


    $forums = $this->get_searchable _forums();

    $mid = intval($this->ipsclass->input['mid']);
    [/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    But now it's only searching the first forum and ignoring the rest. How do I get it to include all forums I listed?

    Thanks
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    I'm mystified too.
    I suggest you study how this 'IPB' class works.
    It is impossible to solve without this knowledge and I have never heard of it

    Comment

    • mystified
      New Member
      • Jun 2007
      • 2

      #3
      This is the mod if it helps:
      Code:
      function get_unanswered()
      
      	{
      
      	
      	//-----------------------------------------
      		// Do we have flood control enabled?
      		//-----------------------------------------
      		
      		if ($this->ipsclass->member['g_search_flood'] > 0)
      		{
      			$flood_time = time() - $this->ipsclass->member['g_search_flood'];
      			
      			//-----------------------------------------
      			// Get any old search results..
      			//-----------------------------------------
      			
      			$this->ipsclass->DB->simple_construct( array( 'select' => 'id',
      										  				  'from'   => 'search_results',
      										  				  'where'  => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );
      			$this->ipsclass->DB->simple_exec();
      		
      			if ( $this->ipsclass->DB->get_num_rows() )
      			{
      				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );
      			}
      		}
      		
      		$this->ipsclass->input['forums'] = 'all';
      		
      		$forums = $this->get_searchable_forums();
      		
      		$mid    = intval($this->ipsclass->input['mid']);
      		
      		//-----------------------------------------
      		// Do we have any forums to search in?
      		//-----------------------------------------
      		
      		if ($forums == "")
      		{
      			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
      		}
      		
      
      		//-----------------------------------------
      		// Get the topic ID's to serialize and store into
      		// the database
      		//-----------------------------------------
      		
      		
      		$this->ipsclass->DB->simple_construct( array( 'select' => 'count(*) as count', 'from' => 'topics t', 'where' => "t.approved=1 AND t.forum_id IN($forums) AND t.posts=0" ) );
      		$this->ipsclass->DB->simple_exec();
      		
      		$row = $this->ipsclass->DB->fetch_row();
      	
      		$results = intval($row['count']);
      		
      		//-----------------------------------------
      		// Do we have any results?
      		//-----------------------------------------
      		
      		if ( ! $results )
      		{
      			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
      		}
      		
      		//-----------------------------------------
      		// Cache query
      		//-----------------------------------------
      		
      		
      		
      		$this->ipsclass->DB->simple_construct( array( 'select' => 't.*, t.title as topic_title',
      									  'from'   => 'topics t',
      									  'where'  => "t.approved=1 AND t.forum_id IN($forums) AND t.posts=0",
      									  'order'  => "t.last_post DESC" ) );
      		
      		
      		$query_to_cache = $this->ipsclass->DB->cur_query;
      		$this->ipsclass->DB->flush_query();
      		
      		//-----------------------------------------
      		// If we are still here, store the data into the database...
      		//-----------------------------------------
      		
      		$unique_id = md5(uniqid(microtime(),1));
      		
      		$this->ipsclass->DB->do_insert( 'search_results', array (
      												  'id'          => $unique_id,
      												  'search_date' => time(),
      												  'post_max'    => $results,
      												  'sort_key'    => $this->sort_key,
      												  'sort_order'  => $this->sort_order,
      												  'member_id'   => $this->ipsclass->member['id'],
      												  'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],
      												  'query_cache' => $query_to_cache
      										 )        );
      		
      		$this->ipsclass->boink_it( $this->ipsclass->base_url."act=Search&nav=au&CODE=show&searchid=$unique_id&search_in=topics&result_type=topics" );
      	
      
      	}
      If you look you can see where it is set to search forum = 'all'
      What I am trying to get it to do is search by the unique id of each forum. It was working and then it stopped and I have no idea why. Is there anyway to get it to search all forums instead of just the first one using php code?

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        I don't quite understand your problem and honestly don't have time to wade through lots of code. If you can narrow down and define the problem I will gladly help if I can

        Comment

        Working...