diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index c9c7f8df14..20b8f2d9e0 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -987,6 +987,20 @@ window.egw_LAB.wait(function() { Api\Json\Response::get()->data($contact); } + /** + * Disable / clear advanced search + * + * Advanced search is stored server side in session no matter what the nextmatch + * sends, so we have to clear it here. + */ + public static function ajax_clear_advanced_search() + { + $query = Api\Cache::getSession('addressbook', 'index'); + unset($query['advanced_search']); + Api\Cache::setSession('addressbook','index',$query); + Api\Cache::setSession('addressbook', 'advanced_search', false); + } + /** * apply an action to multiple contacts * @@ -1363,7 +1377,8 @@ window.egw_LAB.wait(function() { { unset($store_query[$key]); } - $old_state = Api\Cache::setSession('addressbook', $what, $store_query); + $old_state = $store_query; + Api\Cache::setSession('addressbook', $what, $store_query); } else { @@ -1384,7 +1399,7 @@ window.egw_LAB.wait(function() { //unset($query['advanced_search']); if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; } - elseif(!$query['search'] && $old_state['advanced_search']) // eg. paging in an advanced search + elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search { $query['advanced_search'] = $old_state['advanced_search']; } diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 73300647c0..2f83899977 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -850,7 +850,29 @@ app.classes.addressbook = AppJS.extend( egw.open('',this.appname,'list',{'favorite': safe_name},this.appname); return false; } - return this._super.apply(this, arguments); + else if (jQuery.isEmptyObject(state)) + { + // Regular handling first to clear everything but advanced search + this._super.apply(this, arguments); + + // Clear advanced search, which is in session and etemplate + egw.json('addressbook.addressbook_ui.ajax_clear_advanced_search',[], function() { + framework.setWebsiteTitle('addressbook',''); + var index = etemplate2.getById('addressbook-index'); + if(index && index.widgetContainer) + { + var nm = index.widgetContainer.getWidgetById('nm'); + if(nm) + { + nm.applyFilters({ + advanced_search: false + }); + } + } + },this).sendRequest(true); + return false; + } + return }, /**