Results 1 to 8 of 8

Thread: How not to make Search remember?

  1. #1
    madhrishi is offline Senior Member
    Join Date
    Feb 2009
    Posts
    99

    Default How not to make Search remember?

    Hi

    Basic & Advanced Search, remembers the previous query and even on logging out and logging in again with a fresh loading of the page, search still remembers the last selected fields and displays records accordingly.... it is a pain to deselect the search criteria every time for a new search...

    how to make search not remember the previously run query?

    Thanks!

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: How not to make Search remember?

    Hi madhrishi

    There is a possible and probably upgrade safe solution.
    But you will need to create a custom view.list.php for all modules you don't want to remember the search.

    You need to implement the function listViewPrepare on view.list.php as a copy of the original one and remove all lines regarding storeQuery.

    Kind regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    madhrishi is offline Senior Member
    Join Date
    Feb 2009
    Posts
    99

    Default Re: How not to make Search remember?

    Thank you Andopes, i shall try this one...

  4. #4
    madhrishi is offline Senior Member
    Join Date
    Feb 2009
    Posts
    99

    Default Re: How not to make Search remember?

    hmm i see this is not a simple one

    Can you please give me a more detailed version of how to do this... i wish to modify only 'contacts' module... firstly, i dont find any view.list.php in module/contacts....

    should i create a view.list.php?? where?

    i see one global view.list.php @ include/MVC/view/views ... with following content

    Code:
    	function listViewPrepare(){
            $module = $GLOBALS['module'];
            $metadataFile = null;
            $foundViewDefs = false;
            if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
                $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
                $foundViewDefs = true;
            }else{
                if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
                    require_once('custom/modules/'.$module.'/metadata/metafiles.php');
                    if(!empty($metafiles[$module]['listviewdefs'])){
                        $metadataFile = $metafiles[$module]['listviewdefs'];
                        $foundViewDefs = true;
                    }
                }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
                    require_once('modules/'.$module.'/metadata/metafiles.php');
                    if(!empty($metafiles[$module]['listviewdefs'])){
                        $metadataFile = $metafiles[$module]['listviewdefs'];
                        $foundViewDefs = true;
                    }
                }
            }
            if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
                    $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
            }
            require_once($metadataFile);
            $this->listViewDefs = $listViewDefs;
    
    
    
    
    
            if(!empty($this->bean->object_name) && isset($_REQUEST[$module.'2_'.strtoupper($this->bean->object_name).'_offset'])) {//if you click the pagination button, it will poplate the search criteria here
                if(!empty($_REQUEST['current_query_by_page'])) {//The code support multi browser tabs pagination
                    $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'request_data', 'current_query_by_page',$module.'2_'.strtoupper($this->bean->object_name).'_ORDER_BY' );
                    if(isset($_REQUEST['lvso'])){
                    	$blockVariables[] = 'lvso';
                    }
                    $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page']));
                    foreach($current_query_by_page as $search_key=>$search_value) {
                        if($search_key != $module.'2_'.strtoupper($this->bean->object_name).'_offset' && !in_array($search_key, $blockVariables)) {
                            $_REQUEST[$search_key] = $search_value;
                        }
                    }
                }
            }
            
            if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
                if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
                    $this->saved_search = loadBean('SavedSearch');
                    $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
                    $this->saved_search->populateRequest();
                }
                elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
                    $_SESSION['LastSavedView'][$_REQUEST['module']] = '';
                    unset($_REQUEST['saved_search_select']);
                    unset($_REQUEST['saved_search_select_name']);
                }
            }
            $this->storeQuery = new StoreQuery();
            if(!isset($_REQUEST['query'])){
                $this->storeQuery->loadQuery($this->module);
                $this->storeQuery->populateRequest();
            }else{
                $this->storeQuery->saveFromRequest($this->module);
            }
            
            $this->seed = $this->bean;
            
            $displayColumns = array();
            if(!empty($_REQUEST['displayColumns'])) {
                foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
                    if(!empty($this->listViewDefs[$module][$col])) 
                        $displayColumns[$col] = $this->listViewDefs[$module][$col];
                }    
            }
            else {
                foreach($this->listViewDefs[$module] as $col => $this->params) {
                    if(!empty($this->params['default']) && $this->params['default'])
                        $displayColumns[$col] = $this->params;
                }
            } 
            $this->params = array('massupdate' => true);
            if(!empty($_REQUEST['orderBy'])) {
                $this->params['orderBy'] = $_REQUEST['orderBy'];
                $this->params['overrideOrder'] = true;
                if(!empty($_REQUEST['sortOrder'])) $this->params['sortOrder'] = $_REQUEST['sortOrder'];
            }
            $this->lv->displayColumns = $displayColumns;
    
            $this->seed = $this->seed;
            $this->module = $module;
            
            $this->prepareSearchForm();
            
            if(isset($this->options['show_title']) && $this->options['show_title']) {
                $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
                echo "\n<p>\n";
                echo get_module_title($moduleName, $GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true); 
                echo "\n</p>\n";
            }
     	}

  5. #5
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: How not to make Search remember?

    The class should looks like that, but I DID NOT TRIED IT BEFORE. So make the necessary changes to get it working.

    PHP Code:
    <?php
    require_once('include/MVC/View/views/view.list.php');

    class 
    ContactsViewList extends ViewList {
         function 
    listViewPrepare() {
            
    $module $GLOBALS['module'];
            
    $metadataFile null;
            
    $foundViewDefs false;
            if(
    file_exists('custom/modules/' $module'/metadata/listviewdefs.php')){
                
    $metadataFile 'custom/modules/' $module '/metadata/listviewdefs.php';
                
    $foundViewDefs true;
            }else{
                if(
    file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
                    require_once(
    'custom/modules/'.$module.'/metadata/metafiles.php');
                    if(!empty(
    $metafiles[$module]['listviewdefs'])){
                        
    $metadataFile $metafiles[$module]['listviewdefs'];
                        
    $foundViewDefs true;
                    }
                }elseif(
    file_exists('modules/'.$module.'/metadata/metafiles.php')){
                    require_once(
    'modules/'.$module.'/metadata/metafiles.php');
                    if(!empty(
    $metafiles[$module]['listviewdefs'])){
                        
    $metadataFile $metafiles[$module]['listviewdefs'];
                        
    $foundViewDefs true;
                    }
                }
            }
            if(!
    $foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
                    
    $metadataFile 'modules/'.$module.'/metadata/listviewdefs.php';
            }
            require_once(
    $metadataFile);
            
    $this->listViewDefs $listViewDefs;

            
    $this->seed $this->bean;
            
            
    $displayColumns = array();
            if(!empty(
    $_REQUEST['displayColumns'])) {
                foreach(
    explode('|'$_REQUEST['displayColumns']) as $num => $col) {
                    if(!empty(
    $this->listViewDefs[$module][$col])) 
                        
    $displayColumns[$col] = $this->listViewDefs[$module][$col];
                }    
            }
            else {
                foreach(
    $this->listViewDefs[$module] as $col => $this->params) {
                    if(!empty(
    $this->params['default']) && $this->params['default'])
                        
    $displayColumns[$col] = $this->params;
                }
            } 
            
    $this->params = array('massupdate' => true);
            if(!empty(
    $_REQUEST['orderBy'])) {
                
    $this->params['orderBy'] = $_REQUEST['orderBy'];
                
    $this->params['overrideOrder'] = true;
                if(!empty(
    $_REQUEST['sortOrder'])) $this->params['sortOrder'] = $_REQUEST['sortOrder'];
            }
            
    $this->lv->displayColumns $displayColumns;

            
    $this->seed $this->seed;
            
    $this->module $module;
            
            
    $this->prepareSearchForm();
            
            if(isset(
    $this->options['show_title']) && $this->options['show_title']) {
                
    $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
                echo 
    "\n<p>\n";
                echo 
    get_module_title($moduleName$GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true); 
                echo 
    "\n</p>\n";
            }
         }
    }
    ?>
    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  6. #6
    dekleinemedia is offline A Prolific Poster
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    241

    Default Re: How not to make Search remember?

    Quote Originally Posted by andopes View Post
    The class should looks like that, but I DID NOT TRIED IT BEFORE. So make the necessary changes to get it working.

    PHP Code:
    <?php
    require_once('include/MVC/View/views/view.list.php');

    class 
    ContactsViewList extends ViewList {
         function 
    listViewPrepare() {
            
    $module $GLOBALS['module'];
            
    $metadataFile null;
            
    $foundViewDefs false;
            if(
    file_exists('custom/modules/' $module'/metadata/listviewdefs.php')){
                
    $metadataFile 'custom/modules/' $module '/metadata/listviewdefs.php';
                
    $foundViewDefs true;
            }else{
                if(
    file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
                    require_once(
    'custom/modules/'.$module.'/metadata/metafiles.php');
                    if(!empty(
    $metafiles[$module]['listviewdefs'])){
                        
    $metadataFile $metafiles[$module]['listviewdefs'];
                        
    $foundViewDefs true;
                    }
                }elseif(
    file_exists('modules/'.$module.'/metadata/metafiles.php')){
                    require_once(
    'modules/'.$module.'/metadata/metafiles.php');
                    if(!empty(
    $metafiles[$module]['listviewdefs'])){
                        
    $metadataFile $metafiles[$module]['listviewdefs'];
                        
    $foundViewDefs true;
                    }
                }
            }
            if(!
    $foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
                    
    $metadataFile 'modules/'.$module.'/metadata/listviewdefs.php';
            }
            require_once(
    $metadataFile);
            
    $this->listViewDefs $listViewDefs;

            
    $this->seed $this->bean;
            
            
    $displayColumns = array();
            if(!empty(
    $_REQUEST['displayColumns'])) {
                foreach(
    explode('|'$_REQUEST['displayColumns']) as $num => $col) {
                    if(!empty(
    $this->listViewDefs[$module][$col])) 
                        
    $displayColumns[$col] = $this->listViewDefs[$module][$col];
                }    
            }
            else {
                foreach(
    $this->listViewDefs[$module] as $col => $this->params) {
                    if(!empty(
    $this->params['default']) && $this->params['default'])
                        
    $displayColumns[$col] = $this->params;
                }
            } 
            
    $this->params = array('massupdate' => true);
            if(!empty(
    $_REQUEST['orderBy'])) {
                
    $this->params['orderBy'] = $_REQUEST['orderBy'];
                
    $this->params['overrideOrder'] = true;
                if(!empty(
    $_REQUEST['sortOrder'])) $this->params['sortOrder'] = $_REQUEST['sortOrder'];
            }
            
    $this->lv->displayColumns $displayColumns;

            
    $this->seed $this->seed;
            
    $this->module $module;
            
            
    $this->prepareSearchForm();
            
            if(isset(
    $this->options['show_title']) && $this->options['show_title']) {
                
    $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
                echo 
    "\n<p>\n";
                echo 
    get_module_title($moduleName$GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true); 
                echo 
    "\n</p>\n";
            }
         }
    }
    ?>
    Cheers
    Thanks André, this works fine for me!
    Kind regards,

    De Kleine Media


    SugarCRM CE v.5.2.0h
    Windows platform
    MySQL v.5.1
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

  7. #7
    NicolasFoucher is offline Sugar Community Member
    Join Date
    Jul 2007
    Location
    Paris - France
    Posts
    11

    Default Re: How not to make Search remember?

    Quote Originally Posted by madhrishi View Post
    how to make search not remember the previously run query?
    Hello

    You can add this option in your config_override.php file:

    Code:
    $sugar_config['save_query'] = 'no';
    Nicolas
    CARRENET - SugarCRM Gold Partner
    67 rue Desnouettes - 75015 Paris - France
    >>> Suivez notre actualité sur Twitter ! http://twitter.com/carrenet

  8. #8
    dekleinemedia is offline A Prolific Poster
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    241

    Default Re: How not to make Search remember?

    Quote Originally Posted by NicolasFoucher View Post
    Hello

    You can add this option in your config_override.php file:

    Code:
    $sugar_config['save_query'] = 'no';
    Hi Nicolas,

    Is that a upgrade safe solution? If so that would be great
    Kind regards,

    De Kleine Media


    SugarCRM CE v.5.2.0h
    Windows platform
    MySQL v.5.1
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 2009-10-06, 08:57 AM
  2. Remember Me (Saved Login's) for SugarOS?
    By sagetree124 in forum General Discussion
    Replies: 3
    Last Post: 2009-06-03, 11:36 AM
  3. Remember me button for SugarCRM
    By illumini in forum General Discussion
    Replies: 0
    Last Post: 2008-08-14, 01:12 AM
  4. Please make your bug search more usable
    By maschek in forum Site feedback
    Replies: 3
    Last Post: 2008-08-07, 10:04 AM
  5. Remember the last action performed after timing out
    By alex1000 in forum Feature Requests
    Replies: 4
    Last Post: 2005-04-05, 01:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •