Making search results saveable in 7.0.4

Hello, Everyone,

 

I have recently tried to modify the original BoonEx script to make it possible to save search options in the profile search after you press "Search" button. I've also been trying to make search parameters from different search blocks to stack. I.e. each time the "Search" button on the new search block is pressed, new filter conditions are added. Unfortunately, by so far, to modify the filter options, grouped in one searck block, one should press "Search" button namely in that particular block. Pressing "Search" button in the other ones will not apply the parameter change.

Please correct my modifications if there is some security risk or could be any performance issue, as I am not great in php.

1. In search.php

After

        'photos_only' => isset($_GET['photos_only']) ? $_GET['photos_only'] : ''

        );

Add
//////BEGIN ext search
        foreach($_GET as $_GET_key => $_GET_value) 
        {
          if (is_array($_GET[$_GET_key]))
            $_GET[$_GET_key] = array_unique($_GET[$_GET_key]);
        } 
    
        $aDefaultParams = array_merge($_GET, $aDefaultParams); 
//////END ext search

2. In inc/classes/BxDolProfileFields
After
        $iFormCounter = 1;
Add
//////BEGIN ext search
        $jpatch_get_orig = serialize($_GET);
//////END ext search
After
        foreach ($this->aBlocks as $iBlockId => $aBlock) {
Add
//////BEGIN ext search
 
            $jpatch_get_next = unserialize($jpatch_get_orig);
//////END ext search

After
            foreach ($aBlock['Items'] as $iItemId => $aItem) {
Add
//////BEGIN ext search
 
                if (isset($jpatch_get_next[$aItem['Name']]))
                    unset($jpatch_get_next[$aItem['Name']]);
//////END ext search

Find
                        if (is_array($aFormInput['value'])) {
                            $aFormInput['value'] = $aFormInput['value'][0];
                        }    
Replace with
//////BEGIN ext search
 
                        //if (is_array($aFormInput['value'])) {
                        //    $aFormInput['value'] = $aFormInput['value'][0];
                        //} 
//////END ext search

Before
            // create submit button
Add
//////BEGIN ext search
 
            if (isset($jpatch_get_next["submit"]))
                unset($jpatch_get_next["submit"]);
            if (isset($jpatch_get_next["csrf_token"]))
                unset($jpatch_get_next["csrf_token"]);
            if (isset($jpatch_get_next["search_mode"]))
                unset($jpatch_get_next["search_mode"]);
            $jpatch_raw = urldecode(http_build_query($jpatch_get_next));
            $jpatch_search = '/[&]?([^&]*)\=([^&]*)/';
            $jpatch_replace = '<input type="hidden" name="$1" value="$2" />'."\n";
            
            $jpatch_hidden = preg_replace($jpatch_search, $jpatch_replace, $jpatch_raw);
            $aInputs[] = array(
                'type' => 'custom',
                'content' => $jpatch_hidden,
            );
//////END ext search

This however will add an extra empty row in each search block, but this, I think, is a little cost.
Besides, if you wish to be able to exclude select box from search (i.e., blank field in a selectbox, which means get all results, independant from particular selectbox values), you could do the following.
In inc/classes/BxDolProfileFields
After
                        $aFormInput['values'] = $this->convertValues4Input($aItem['Values'], $aItem['UseLKey']);
Add
//////BEGIN ext search exclude select
 
                        if (($aFormInput['type'] == 'select_box') || ($aFormInput['type'] == 'select'))
                            $aFormInput['values'] = array("" => "") + $aFormInput['values'];
//////END ext search exclude select
After
$aFormInput['type'] = 'select';
                               $aFormInput['values'] = array(
Add
                               '' => '', // ext search exclude select

Hope didn't miss something. Please try!
Best regards,
Yury
Quote · 8 Aug 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.