mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 17:19:06 +01:00
improved advanced search:
- fixed not working paging (lost advanced search) - uses now a named window and gives it focus - disabled for org-views - can be unset via clicking on the addressbook icon (index.php) - last search can always be restored from session
This commit is contained in:
parent
ba311860b0
commit
25055b8603
@ -54,7 +54,7 @@ class contacts_admin_prefs
|
|||||||
array(
|
array(
|
||||||
'text' => '<a class="textSidebox" href="'.$GLOBALS['egw']->link('/index.php',array(
|
'text' => '<a class="textSidebox" href="'.$GLOBALS['egw']->link('/index.php',array(
|
||||||
'menuaction' => 'addressbook.uicontacts.search',)).
|
'menuaction' => 'addressbook.uicontacts.search',)).
|
||||||
'" onclick="window.open(this.href,\'_blank\',\'dependent=yes,width=850,height=480,scrollbars=yes,status=yes\');
|
'" onclick="window.open(this.href,\'advanced_search\',\'dependent=yes,width=850,height=480,scrollbars=yes,status=yes\');
|
||||||
return false;">'.lang('Advanced search').'</a>',
|
return false;">'.lang('Advanced search').'</a>',
|
||||||
'no_lang' => true,
|
'no_lang' => true,
|
||||||
'link' => false
|
'link' => false
|
||||||
|
@ -489,6 +489,28 @@ class uicontacts extends bocontacts
|
|||||||
*/
|
*/
|
||||||
function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
|
function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
|
||||||
{
|
{
|
||||||
|
$old_state = $GLOBALS['egw']->session->appsession('index','addressbook');
|
||||||
|
if (isset($this->org_views[(string) $query['org_view']])) // we have an org view, reset the advanced search
|
||||||
|
{
|
||||||
|
if (is_array($query['search'])) unset($query['search']);
|
||||||
|
unset($query['advanced_search']);
|
||||||
|
}
|
||||||
|
elseif (is_array($query['search'])) // new advanced search, store it in the session
|
||||||
|
{
|
||||||
|
$query['advanced_search'] = array_intersect_key($query['search'],array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select'))));
|
||||||
|
foreach ($query['advanced_search'] as $key => $value)
|
||||||
|
{
|
||||||
|
if(!$value) unset($query['advanced_search'][$key]);
|
||||||
|
}
|
||||||
|
$query['start'] = 0;
|
||||||
|
$query['search'] = '';
|
||||||
|
// store the advanced search in the session to call it again
|
||||||
|
$GLOBALS['egw']->session->appsession('advanced_search','addressbook',$query['advanced_search']);
|
||||||
|
}
|
||||||
|
elseif(!$query['search'] && $old_state['advanced_search']) // eg. paging in an advanced search
|
||||||
|
{
|
||||||
|
$query['advanced_search'] = $old_state['advanced_search'];
|
||||||
|
}
|
||||||
if (($do_email=$query['do_email']) && $GLOBALS['egw_info']['etemplate']['loop'] && is_object($GLOBALS['egw']->js))
|
if (($do_email=$query['do_email']) && $GLOBALS['egw_info']['etemplate']['loop'] && is_object($GLOBALS['egw']->js))
|
||||||
{ // remove previous addEmail() calls, otherwise they will be run again
|
{ // remove previous addEmail() calls, otherwise they will be run again
|
||||||
$GLOBALS['egw']->js->body['onLoad'] = preg_replace('/addEmail\([^)]+\);/','',$GLOBALS['egw']->js->body['onLoad']);
|
$GLOBALS['egw']->js->body['onLoad'] = preg_replace('/addEmail\([^)]+\);/','',$GLOBALS['egw']->js->body['onLoad']);
|
||||||
@ -496,7 +518,6 @@ class uicontacts extends bocontacts
|
|||||||
//echo "<p>uicontacts::get_rows(".print_r($query,true).")</p>\n";
|
//echo "<p>uicontacts::get_rows(".print_r($query,true).")</p>\n";
|
||||||
if (!$id_only)
|
if (!$id_only)
|
||||||
{
|
{
|
||||||
$old_state = $GLOBALS['egw']->session->appsession('index','addressbook');
|
|
||||||
// check if accounts are stored in ldap, which does NOT yet support the org-views
|
// check if accounts are stored in ldap, which does NOT yet support the org-views
|
||||||
if ($this->so_accounts && $query['filter'] === '0' && $query['org_view'])
|
if ($this->so_accounts && $query['filter'] === '0' && $query['org_view'])
|
||||||
{
|
{
|
||||||
@ -513,7 +534,6 @@ class uicontacts extends bocontacts
|
|||||||
{
|
{
|
||||||
$query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one organisation
|
$query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one organisation
|
||||||
}
|
}
|
||||||
unset($old_state);
|
|
||||||
$GLOBALS['egw']->session->appsession($do_email ? 'email' : 'index','addressbook',$query);
|
$GLOBALS['egw']->session->appsession($do_email ? 'email' : 'index','addressbook',$query);
|
||||||
// save the state of the index in the user prefs
|
// save the state of the index in the user prefs
|
||||||
$state = serialize(array(
|
$state = serialize(array(
|
||||||
@ -531,6 +551,8 @@ class uicontacts extends bocontacts
|
|||||||
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($old_state);
|
||||||
|
|
||||||
if ((string)$query['cat_id'] != '')
|
if ((string)$query['cat_id'] != '')
|
||||||
{
|
{
|
||||||
$query['col_filter']['cat_id'] = $query['cat_id'] ? $query['cat_id'] : null;
|
$query['col_filter']['cat_id'] = $query['cat_id'] ? $query['cat_id'] : null;
|
||||||
@ -596,25 +618,17 @@ class uicontacts extends bocontacts
|
|||||||
}
|
}
|
||||||
$wildcard = '%';
|
$wildcard = '%';
|
||||||
$op = 'OR';
|
$op = 'OR';
|
||||||
if (is_array($query['search'])) // Advanced Search
|
if ($query['advanced_search'])
|
||||||
{
|
{
|
||||||
$op = $query['search']['operator'];
|
$op = $query['advanced_search']['operator'];
|
||||||
$wildcard = $query['search']['meth_select'];
|
unset($query['advanced_search']['operator']);
|
||||||
$advanced_search = $query['search'];
|
$wildcard = $query['advanced_search']['meth_select'];
|
||||||
$query['search'] = array_intersect_key($query['search'],array_flip($this->get_contact_columns()));
|
unset($query['advanced_search']['meth_select']);
|
||||||
foreach ($query['search'] as $key => $value) {
|
|
||||||
if(!$value) unset($query['search'][$key]);
|
|
||||||
}
|
|
||||||
if (empty($query['search'])) {
|
|
||||||
$query['search'] = '';
|
|
||||||
unset($advanced_search);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$rows = parent::search($query['search'],$id_only ? array('id','org_name','n_family','n_given','n_fileas') : false,
|
$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],
|
||||||
|
$id_only ? array('id','org_name','n_family','n_given','n_fileas') : false,
|
||||||
$order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']);
|
$order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']);
|
||||||
if( is_array($advanced_search) ) {
|
|
||||||
$query['search'] = '';
|
|
||||||
}
|
|
||||||
// do we need the custom fields
|
// do we need the custom fields
|
||||||
if (!$id_only && $this->prefs['custom_colum'] != 'never' && $rows && $this->customfields)
|
if (!$id_only && $this->prefs['custom_colum'] != 'never' && $rows && $this->customfields)
|
||||||
{
|
{
|
||||||
@ -749,6 +763,10 @@ class uicontacts extends bocontacts
|
|||||||
{
|
{
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$query['org_view_label'];
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$query['org_view_label'];
|
||||||
}
|
}
|
||||||
|
if($query['advanced_search'])
|
||||||
|
{
|
||||||
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Advanced search');
|
||||||
|
}
|
||||||
if ($query['cat_id'])
|
if ($query['cat_id'])
|
||||||
{
|
{
|
||||||
if (!is_object($GLOBALS['egw']->categories))
|
if (!is_object($GLOBALS['egw']->categories))
|
||||||
@ -766,9 +784,6 @@ class uicontacts extends bocontacts
|
|||||||
{
|
{
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang("Search for '%1'",$query['search']);
|
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang("Search for '%1'",$query['search']);
|
||||||
}
|
}
|
||||||
if(is_array($advanced_search)) {
|
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang("Advanced search");
|
|
||||||
}
|
|
||||||
return $this->total;
|
return $this->total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1295,10 +1310,12 @@ $readonlys['button[vcard]'] = true;
|
|||||||
}
|
}
|
||||||
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
|
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
|
||||||
$GLOBALS['egw_info']['flags']['java_script'] .= $this->js();
|
$GLOBALS['egw_info']['flags']['java_script'] .= $this->js();
|
||||||
|
$GLOBALS['egw_info']['flags']['java_script'] .= "<script>window.focus()</script>";
|
||||||
$GLOBALS['egw_info']['etemplate']['advanced_search'] = true;
|
$GLOBALS['egw_info']['etemplate']['advanced_search'] = true;
|
||||||
|
|
||||||
// initialize etemplate arrays
|
// initialize etemplate arrays
|
||||||
$content = $sel_options = $readonlys = $preserv = array();
|
$sel_options = $readonlys = $preserv = array();
|
||||||
|
$content = $GLOBALS['egw']->session->appsession('advanced_search','addressbook');
|
||||||
|
|
||||||
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
|
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
|
||||||
$sel_options['tz'] = $tz + array('' => lang('doesn\'t matter'));
|
$sel_options['tz'] = $tz + array('' => lang('doesn\'t matter'));
|
||||||
@ -1315,11 +1332,6 @@ $readonlys['button[vcard]'] = true;
|
|||||||
'%' => lang('contains'),
|
'%' => lang('contains'),
|
||||||
false => lang('exact'),
|
false => lang('exact'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$index_nm = $GLOBALS['egw']->session->appsession($do_email ? 'email' : 'index','addressbook');
|
|
||||||
if (array_key_exists('meth_select',$index_nm['search'])) {
|
|
||||||
$content = $index_nm['search'];
|
|
||||||
}
|
|
||||||
// configure edit template as search dialog
|
// configure edit template as search dialog
|
||||||
$readonlys['change_photo'] = true;
|
$readonlys['change_photo'] = true;
|
||||||
$readonlys['fileas_type'] = true;
|
$readonlys['fileas_type'] = true;
|
||||||
@ -1328,6 +1340,7 @@ $readonlys['button[vcard]'] = true;
|
|||||||
$readonlys['personal|organisation|home|details|links']['links'] = true;
|
$readonlys['personal|organisation|home|details|links']['links'] = true;
|
||||||
$content['hidebuttons'] = true;
|
$content['hidebuttons'] = true;
|
||||||
$content['no_tid'] = true;
|
$content['no_tid'] = true;
|
||||||
|
$content['disable_change_org'] = true;
|
||||||
|
|
||||||
$this->tmpl->read('addressbook.search');
|
$this->tmpl->read('addressbook.search');
|
||||||
return $this->tmpl->exec('addressbook.uicontacts.search',$content,$sel_options,$readonlys,$preserv,2);
|
return $this->tmpl->exec('addressbook.uicontacts.search',$content,$sel_options,$readonlys,$preserv,2);
|
||||||
|
@ -19,6 +19,11 @@
|
|||||||
));
|
));
|
||||||
include('../header.inc.php');
|
include('../header.inc.php');
|
||||||
|
|
||||||
ExecMethod('addressbook.uicontacts.index');
|
// check if we have an advanced search and reset it in case
|
||||||
|
$old_state = $GLOBALS['egw']->session->appsession('index','addressbook');
|
||||||
$GLOBALS['egw']->common->egw_footer();
|
if ($old_state['advanced_search'])
|
||||||
|
{
|
||||||
|
unset($old_state['advanced_search']);
|
||||||
|
$GLOBALS['egw']->session->appsession('index','addressbook',$old_state);
|
||||||
|
}
|
||||||
|
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uicontacts.index');
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
<row>
|
<row>
|
||||||
<image src="private.png"/>
|
<image src="private.png"/>
|
||||||
<description value="Addressbook" options=",,,owner"/>
|
<description value="Addressbook" options=",,,owner"/>
|
||||||
<menulist span=",owner">
|
<menulist class="owner">
|
||||||
<menupopup id="owner" statustext="Addressbook the contact should be saved to" no_lang="1"/>
|
<menupopup id="owner" statustext="Addressbook the contact should be saved to" no_lang="1"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
</row>
|
</row>
|
||||||
@ -83,7 +83,7 @@
|
|||||||
<row>
|
<row>
|
||||||
<description/>
|
<description/>
|
||||||
<description options=",,,role" value="Role"/>
|
<description options=",,,role" value="Role"/>
|
||||||
<hbox orient=",0,0">
|
<hbox options="0,0">
|
||||||
<textbox id="role" size="25" maxlength="64"/>
|
<textbox id="role" size="25" maxlength="64"/>
|
||||||
<textbox size="8" maxlength="64" label="Room" align="right" id="room"/>
|
<textbox size="8" maxlength="64" label="Room" align="right" id="room"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
@ -128,7 +128,7 @@
|
|||||||
<row>
|
<row>
|
||||||
<description/>
|
<description/>
|
||||||
<description value="country" options=",,,adr_one_countryname"/>
|
<description value="country" options=",,,adr_one_countryname"/>
|
||||||
<menulist span=",fullWidth">
|
<menulist class="fullWidth">
|
||||||
<menupopup type="select-country" options="Select one,1" id="adr_one_countryname"/>
|
<menupopup type="select-country" options="Select one,1" id="adr_one_countryname"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
<description/>
|
<description/>
|
||||||
@ -177,14 +177,14 @@
|
|||||||
<row>
|
<row>
|
||||||
<description/>
|
<description/>
|
||||||
<description value="country" options=",,,adr_two_countryname"/>
|
<description value="country" options=",,,adr_two_countryname"/>
|
||||||
<menulist span=",fullWidth">
|
<menulist class="fullWidth">
|
||||||
<menupopup type="select-country" options="Select one,1" id="adr_two_countryname"/>
|
<menupopup type="select-country" options="Select one,1" id="adr_two_countryname"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
</row>
|
</row>
|
||||||
<row height="30">
|
<row height="30">
|
||||||
<image src="gear"/>
|
<image src="gear"/>
|
||||||
<description options=",,,bday" value="Birthday"/>
|
<description options=",,,bday" value="Birthday"/>
|
||||||
<hbox id="bday" orient=",0,0">
|
<hbox id="bday" options="0,0">
|
||||||
<date options="Y-m-d" id="bday"/>
|
<date options="Y-m-d" id="bday"/>
|
||||||
<menulist>
|
<menulist>
|
||||||
<menupopup id="tz" no_lang="1" label="Timezone" align="right"/>
|
<menupopup id="tz" no_lang="1" label="Timezone" align="right"/>
|
||||||
@ -340,7 +340,7 @@
|
|||||||
<description/>
|
<description/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<menulist span=",fileas">
|
<menulist class="fileas">
|
||||||
<menupopup data="" rows="1" cols="3" id="fileas_type" no_lang="1"/>
|
<menupopup data="" rows="1" cols="3" id="fileas_type" no_lang="1"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
<grid>
|
<grid>
|
||||||
@ -350,7 +350,7 @@
|
|||||||
</columns>
|
</columns>
|
||||||
<rows>
|
<rows>
|
||||||
<row disabled="@no_tid">
|
<row disabled="@no_tid">
|
||||||
<menulist span=",leftPad5">
|
<menulist class="leftPad5">
|
||||||
<menupopup no_lang="1" id="tid" onchange="1" label="Type"/>
|
<menupopup no_lang="1" id="tid" onchange="1" label="Type"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
<html class="space" needed="1" label=" " no_lang="1" id="typegfx" readonly="true"/>
|
<html class="space" needed="1" label=" " no_lang="1" id="typegfx" readonly="true"/>
|
||||||
@ -449,8 +449,8 @@
|
|||||||
</vbox>
|
</vbox>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<hbox orient=",0,0">
|
<hbox options="0,0">
|
||||||
<menulist span=",leftPad5">
|
<menulist class="leftPad5">
|
||||||
<menupopup type="select-account" id="creator" readonly="true" label="Created"/>
|
<menupopup type="select-account" id="creator" readonly="true" label="Created"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
<date-time id="created" class="leftPad5" readonly="true"/>
|
<date-time id="created" class="leftPad5" readonly="true"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user