- private cf's only visible to certain user or groups

- configurable extra tab for the private cf's
- cf's displayed in the list are now configurable like in InfoLog via
  the column-selection
- row color of the list get's now set by category, if cats have colors
  defined (first match for multiple cats)
- fax is now allways direct visible in list and edit
This commit is contained in:
Ralf Becker 2008-01-19 05:41:04 +00:00
parent ced6adf23f
commit 9d15b05a4f
8 changed files with 113 additions and 41 deletions

View File

@ -104,6 +104,7 @@ class contacts_admin_prefs
$file['Custom fields'] = $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'admin.customfields.edit',
'appname' => $appname,
'use_private'=> 1,
));
}
if ($location == 'admin')

View File

@ -251,12 +251,10 @@ class socontacts
// ToDo: it should be the other way arround, the backend should set the grants it uses
$this->somain->grants =& $this->grants;
$this->soextra =& CreateObject('etemplate.so_sql');
$this->soextra->so_sql('phpgwapi',$this->extra_table);
$this->soextra = new so_sql('phpgwapi',$this->extra_table);
$custom =& CreateObject('admin.customfields',$contact_app);
$this->customfields = $custom->get_customfields();
$this->content_types = $custom->get_content_types();
$this->customfields = config::get_customfields('addressbook');
$this->content_types = config::get_content_types('addressbook');
if (!$this->content_types)
{
$this->content_types = $custom->content_types = array('n' => array(
@ -265,7 +263,6 @@ class socontacts
'template' => 'addressbook.edit',
'icon' => 'navbar.png'
)));
$custom->save_repository();
}
}
@ -301,7 +298,10 @@ class socontacts
if (!$ids) return array(); // nothing to do, eg. all these contacts are in ldap
$fields = array();
foreach((array)$this->soextra->search(array($this->extra_id => $ids),false) as $data)
foreach((array)$this->soextra->search(array(
$this->extra_id => $ids,
$this->extra_key => array_keys($this->customfields),
),false) as $data)
{
if ($data) $fields[$data[$this->extra_id]][$data[$this->extra_key]] = $data[$this->extra_value];
}
@ -462,6 +462,7 @@ class socontacts
{
$customfields = $this->soextra->search(array(
$this->extra_id => $contact['id'],
$this->extra_key => array_keys($this->customfields),
),false);
foreach ((array)$customfields as $field)
{

View File

@ -30,6 +30,8 @@ class socontacts_sql extends so_sql
*/
var $extra_table = 'egw_addressbook_extra';
var $extra_join = ' LEFT JOIN egw_addressbook_extra ON egw_addressbook.contact_id=egw_addressbook_extra.contact_id';
var $extra_join_order = ' LEFT JOIN egw_addressbook_extra extra_order ON egw_addressbook.contact_id=extra_order.contact_id';
var $extra_join_filter = ' JOIN egw_addressbook_extra extra_filter ON egw_addressbook.contact_id=extra_filter.contact_id';
var $account_repository = 'sql';
var $contact_repository = 'sql';
var $grants;
@ -240,7 +242,7 @@ class socontacts_sql extends so_sql
function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
{
if ((int) $this->debug >= 4) echo "<p>socontacts_sql::search(".print_r($criteria,true).",".print_r($only_keys,true).",'$order_by','$extra_cols','$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
$owner = isset($filter['owner']) ? $filter['owner'] : (isset($criteria['owner']) ? $criteria['owner'] : null);
// fix cat_id filter to search in comma-separated multiple cats and return subcats
@ -298,6 +300,26 @@ class socontacts_sql extends so_sql
{
$join .= $this->extra_join;
}
// do we order by a cf?
if ($order_by[0] == '#')
{
list($val) = explode("<>''",$order_by);
$order_by = str_replace($val,'extra_order.contact_value',$order_by);
$join .= $this->extra_join_order.' AND extra_order.contact_name='.$this->db->quote(substr($val,1));
}
// do we filter by a cf?
foreach($filter as $name => $val)
{
if ($name[0] == '#')
{
if (!empty($val)) // empty -> dont filter
{
$join .= $this->extra_join_filter.' AND extra_filter.contact_name='.$this->db->quote(substr($name,1)).
' AND extra_filter.contact_value='.$this->db->quote($val);
}
unset($filter[$name]);
}
}
if (isset($filter['list']))
{
$join .= " JOIN $this->ab2list_table ON $this->table_name.contact_id=$this->ab2list_table.contact_id AND list_id=".(int)$filter['list'];

View File

@ -52,7 +52,7 @@ class uicontacts extends bocontacts
*
* @var string
*/
var $tabs = 'general|cats|home|details|links|custom';
var $tabs = 'general|cats|home|details|links|custom|custom_private';
function uicontacts($contact_app='addressbook')
{
@ -265,23 +265,23 @@ class uicontacts extends bocontacts
{
$sel_options['action']['infolog'] = lang('View linked InfoLog entries');
}
//$sel_options['action'] += $this->get_addressbooks(EGW_ACL_ADD);
foreach($this->get_addressbooks(EGW_ACL_ADD) as $uid => $label)
{
$sel_options['action'][$uid] = lang('Move to addressbook:').' '.$label;
}
$sel_options['action'][lang('Move to addressbook:')] = $this->get_addressbooks(EGW_ACL_ADD);
if (($add_lists = $this->get_lists(EGW_ACL_EDIT))) // do we have distribution lists?
{
$lists = array();
foreach ($add_lists as $list_id => $label)
{
$sel_options['action']['to_list_'.$list_id] = lang('Add to distribution list:').' '.$label;
$lists['to_list_'.$list_id] = $label;
}
$sel_options['action'][lang('Add to distribution list:')] = $lists;
unset($lists);
$sel_options['action']['remove_from_list'] = lang('Remove selected contacts from distribution list');
$sel_options['action']['delete_list'] = lang('Delete selected distribution list!');
}
if ($this->prefs['document_dir'])
{
$sel_options['action'] += $this->get_document_actions();
$sel_options['action'][lang('Insert in document').':'] = $this->get_document_actions();
}
if (!array_key_exists('importexport',$GLOBALS['egw_info']['user']['apps'])) unset($sel_options['action']['export']);
@ -821,6 +821,11 @@ class uicontacts extends bocontacts
$order = "org_name<>'' DESC,org_name $sort,n_family $sort,n_given $sort";
break;
default:
if ($query['order'][0] == '#') // we order by a custom field
{
$order = "$query[order]<>'' DESC,$query[order] $sort,org_name $sort,n_family $sort,n_given $sort";
break;
}
$query['order'] = 'n_family';
case 'n_family':
$order = "n_family<>'' DESC,n_family $sort,n_given $sort,org_name $sort";
@ -994,7 +999,7 @@ class uicontacts extends bocontacts
if (!$homeaddress) $rows['no_home'] = true;
}
// disable customfields column, if we have no customefield(s)
if (!$this->customfields || !$this->prefs['no_auto_hide'] && !$customfields) $rows['no_customfields'] = true;
if (!$this->customfields/* || !$this->prefs['no_auto_hide'] && !$customfields*/) $rows['no_customfields'] = true;
$rows['order'] = $order;
$rows['call_popup'] = $this->config['call_popup'];
@ -1355,7 +1360,10 @@ class uicontacts extends bocontacts
}
// disable not needed tabs
$readonlys[$this->tabs]['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
$readonlys[$this->tabs]['custom'] = !$this->customfields;
$readonlys[$this->tabs]['custom'] = !$this->customfields;
$readonlys[$this->tabs]['custom_private'] = !$this->customfields || !$this->config['private_cf_tab'];
if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
// for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl"
if (!$content['owner'] && !$this->is_admin($content))
{
@ -1606,6 +1614,8 @@ $readonlys['button[vcard]'] = true;
// disable not needed tabs
$readonlys[$this->tabs]['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
$readonlys[$this->tabs]['custom'] = !$this->customfields;
$readonlys[$this->tabs]['custom_private'] = !$this->customfields || !$this->config['private_cf_tab'];
if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
// last and next calendar date
list(,$dates) = each($this->read_calendar(array($content['id']),false));
@ -1798,6 +1808,7 @@ $readonlys['button[vcard]'] = true;
copyvalues(form,"tel_home","tel_home2");
copyvalues(form,"tel_work","tel_work2");
copyvalues(form,"tel_cell","tel_cell2");
copyvalues(form,"tel_fax","tel_fax2");
}
}
@ -1807,6 +1818,7 @@ $readonlys['button[vcard]'] = true;
copyvalues(form,"tel_home2","tel_home");
copyvalues(form,"tel_work2","tel_work");
copyvalues(form,"tel_cell2","tel_cell");
copyvalues(form,"tel_fax2","tel_fax");
}
}
@ -1978,7 +1990,7 @@ $readonlys['button[vcard]'] = true;
// As browsers not always return the right mime_type, you could use a negative list instead
//if ($file['mime_type'] == 'Directory' || substr($file['mime_type'],0,6) == 'image/') continue;
$actions['document-'.$file['directory'].'/'.$file['name']] = lang('Insert in document').': '.$file['name'];
$actions['document-'.$file['directory'].'/'.$file['name']] = /*lang('Insert in document').': '.*/$file['name'];
}
}
$GLOBALS['egw']->session->appsession('document_actions','addressbook',$actions);

File diff suppressed because one or more lines are too long

View File

@ -48,6 +48,15 @@
</td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Use_an_extra_tab_for_private_custom_fields?}</td>
<td>
<select name="newsettings[private_cf_tab]">
<option value="">{lang_No}</option>
<option value="True"{selected_private_cf_tab_True}>{lang_Yes}</option>
</select>
</td>
</tr>
<tr class="row_on">
<td>&nbsp;<b>{lang_Security}</b>: {lang_How_many_contacts_should_non-admins_be_able_to_export_(empty_=_no_limit)}:</td>
<td><input name="newsettings[contact_export_limit]" value="{value_contact_export_limit}" size="5"></td>
</tr>

View File

@ -326,7 +326,7 @@
</rows>
</grid>
</template>
<template id="addressbook.edit.custom" template="" lang="" group="0" version="1.4.001">
<template id="addressbook.edit.custom" template="" lang="" group="0" version="1.5.001">
<grid width="100%" height="258" class="row_on" spacing="0" padding="0" overflow="auto">
<columns>
<column/>
@ -336,7 +336,22 @@
<description value="Custom fields"/>
</row>
<row height="100%">
<customfields/>
<customfields options=",$cont[no_private_cfs]"/>
</row>
</rows>
</grid>
</template>
<template id="addressbook.edit.custom_private" template="" lang="" group="0" version="1.5.001">
<grid width="100%" height="258" class="row_on" spacing="0" padding="0" overflow="auto">
<columns>
<column/>
</columns>
<rows>
<row class="th" height="20">
<description value="Custom fields"/>
</row>
<row height="100%">
<customfields options=",1"/>
</row>
</rows>
</grid>
@ -371,7 +386,7 @@
</row>
<row>
<description value="fax" options=",,,tel_fax"/>
<textbox size="30" id="tel_fax"/>
<textbox size="30" id="tel_fax2"/>
<radio options="tel_fax,&amp;hearts;" id="tel_prefer" statustext="select phone number as prefered way of contact"/>
</row>
<row>
@ -428,7 +443,7 @@
</rows>
</grid>
</template>
<template id="addressbook.edit" template="" lang="" group="0" version="1.3.004">
<template id="addressbook.edit" template="" lang="" group="0" version="1.5.002">
<grid>
<columns>
<column width="450"/>
@ -467,6 +482,7 @@
<tab label="Details" statustext="Categories, Notes, ..."/>
<tab label="Links" statustext="Links"/>
<tab label="Extra" statustext="Custom fields"/>
<tab label="Extra private" statustext="Private custom fields"/>
</tabs>
<tabpanels>
<template id="addressbook.edit.general"/>
@ -475,6 +491,7 @@
<template id="addressbook.edit.details"/>
<template id="addressbook.edit.links"/>
<template id="addressbook.edit.custom"/>
<template id="addressbook.edit.custom_private"/>
</tabpanels>
</tabbox>
<vbox>
@ -507,6 +524,12 @@
<textbox id="tel_home" size="24" maxlength="40" class="telNumbers"/>
<radio options="tel_home,&amp;hearts;" id="tel_prefer" statustext="select phone number as prefered way of contact"/>
</row>
<row>
<description/>
<description value="Fax"/>
<textbox id="tel_fax" size="24" maxlength="40" class="telNumbers"/>
<radio options="tel_fax,&amp;hearts;" id="tel_prefer" statustext="select phone number as prefered way of contact"/>
</row>
<row>
<description/>
<description/>

View File

@ -14,7 +14,7 @@
</hbox>
<styles>.rightPadAdd { width: 30px; }</styles>
</template>
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.5.001">
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.5.002">
<grid width="100%">
<columns>
<column/>
@ -53,7 +53,7 @@
<row>
<nextmatch-sortheader id="org_name" label="Organisation" span="all"/>
</row>
<row disabled="!@order=/^(org_name|n_fileas|adr_one_postalcode|contact_modified|contact_created)$/">
<row disabled="!@order=/^(org_name|n_fileas|adr_one_postalcode|contact_modified|contact_created|#)/">
<nextmatch-sortheader id="n_family" label="Name"/>
<nextmatch-sortheader id="n_given" label="Firstname" class="leftPad5"/>
</row>
@ -74,25 +74,14 @@
<nextmatch-header id="tel_work" label="Business phone"/>
<nextmatch-header label="Mobile phone" id="tel_cell"/>
<nextmatch-header id="tel_home" label="Home phone"/>
<description value="Fax"/>
</vbox>
<vbox options="0,0">
<nextmatch-header id="url" label="Url"/>
<nextmatch-header label="Business email" id="email"/>
<nextmatch-header id="email_home" label="Home email"/>
</vbox>
<vbox options="0,0">
<nextmatch-header id="customfields" options="Custom fields"/>
<grid spacing="0" padding="0">
<columns>
<column/>
</columns>
<rows>
<row>
<description no_lang="1" id="customfields[$row][label]"/>
</row>
</rows>
</grid>
</vbox>
<nextmatch-customfields id="customfields"/>
<vbox options="0,0">
<nextmatch-header label="Last date" id="calendar"/>
<nextmatch-header label="Next date" id="calendar"/>
@ -106,7 +95,7 @@
<button image="check" label="Check all" id="check_all" statustext="Check all" onclick="toggle_all(this.form,form::name('checked[]')); return false;" needed="1" align="right"/>
</hbox>
</row>
<row class="row" valign="top">
<row class="$row_cont[cat_id]" valign="top">
<image label="$row_cont[type_label]" src="${row}[type]" align="center" no_lang="1"/>
<vbox options="0,0" id="${row}[id]">
<description id="${row}[line1]" no_lang="1"/>
@ -143,6 +132,7 @@
<description no_lang="1" id="${row}[tel_work]" class="telNumbers" options=",$row_cont[tel_work_link],,,calling,$cont[call_popup]"/>
<description id="${row}[tel_cell]" no_lang="1" class="telNumbers" options=",$row_cont[tel_cell_link],,,calling,$cont[call_popup]"/>
<description id="${row}[tel_home]" no_lang="1" class="telNumbers" options=",$row_cont[tel_home_link],,,calling,$cont[call_popup]"/>
<description id="${row}[tel_fax]" no_lang="1"/>
<description id="${row}[tel_prefered]" no_lang="1" options=",$row_cont[tel_prefered_link],,,calling,$cont[call_popup]"/>
</vbox>
<vbox options="0,0">