* Addressbook: Add site configuration to always load certain custom fields, allows for single customfields in custom list templates

This commit is contained in:
nathangray 2019-10-07 14:16:04 -06:00
parent c51108b71b
commit 183955c97c
4 changed files with 20 additions and 4 deletions

View File

@ -564,9 +564,13 @@ class addressbook_hooks
'copy_fields' => $copy_fields, 'copy_fields' => $copy_fields,
'fileas' => $bocontacts->fileas_options(), 'fileas' => $bocontacts->fileas_options(),
'contact_repository' => $repositories, 'contact_repository' => $repositories,
'geolocation_url' => $geoLocation 'geolocation_url' => $geoLocation,
) )
); );
foreach(Api\Storage\Customfields::get('addressbook') as $tid => $data)
{
$ret['sel_options']['index_load_cfs'][$tid] = $data['name'];
}
if (empty($config['geolocation_url'])) $ret ['geolocation_url'] = $geoLocation[0]['value']; if (empty($config['geolocation_url'])) $ret ['geolocation_url'] = $geoLocation[0]['value'];
return $ret; return $ret;

View File

@ -1713,7 +1713,7 @@ class addressbook_ui extends addressbook_bo
$ids = $calendar_participants = array(); $ids = $calendar_participants = array();
if (!$id_only && $rows) if (!$id_only && $rows)
{ {
$show_custom_fields = (in_array('customfields',$columselection)) && $this->customfields; $show_custom_fields = (in_array('customfields',$columselection) || $this->config['index_load_cfs']) && $this->customfields;
$show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar',$columselection); $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar',$columselection);
$show_distributionlist = in_array('distrib_lists',$columselection) || count($available_distib_lists); $show_distributionlist = in_array('distrib_lists',$columselection) || count($available_distib_lists);
if ($show_calendar || $show_custom_fields || $show_distributionlist) if ($show_calendar || $show_custom_fields || $show_distributionlist)
@ -1725,10 +1725,15 @@ class addressbook_ui extends addressbook_bo
} }
if ($show_custom_fields) if ($show_custom_fields)
{ {
foreach($columselection as $col) $selected_cfs = array();
if(in_array('customfields',$columselection))
{ {
if ($col[0] == '#') $selected_cfs[] = substr($col,1); foreach($columselection as $col)
{
if ($col[0] == '#') $selected_cfs[] = substr($col,1);
}
} }
$selected_cfs = array_unique(array_merge($selected_cfs, (array)$this->config['index_load_cfs']));
$customfields = $this->read_customfields($ids,$selected_cfs); $customfields = $this->read_customfields($ids,$selected_cfs);
} }
if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants);

View File

@ -48,6 +48,10 @@
<row> <row>
<description value="General" span="all" class="subHeader"/> <description value="General" span="all" class="subHeader"/>
</row> </row>
<row>
<description value="Load custom fields in index, even if custom field column is off (eg. to display them in a specific index column)"/>
<listbox id="newsettings[index_load_cfs]" rows="6" options=",,,,,,1"/>
</row>
<row> <row>
<description value="Use a category tree?"/> <description value="Use a category tree?"/>
<select id="newsettings[cat_tab]"> <select id="newsettings[cat_tab]">

View File

@ -16,6 +16,7 @@
<column width="180"/> <column width="180"/>
<column width="180"/> <column width="180"/>
<column width="40"/> <column width="40"/>
<column width="60"/>
<column width="80" disabled="@no_customfields"/> <column width="80" disabled="@no_customfields"/>
<column width="60%" minWidth="100"/> <column width="60%" minWidth="100"/>
<column width="80" disabled="@no_distribution_list"/> <column width="80" disabled="@no_distribution_list"/>
@ -82,6 +83,7 @@
<nextmatch-header label="Home email" id="email_home"/> <nextmatch-header label="Home email" id="email_home"/>
</vbox> </vbox>
<nextmatch-header label="Room" id="room"/> <nextmatch-header label="Room" id="room"/>
<nextmatch-header label="INdustry" id="#kgb_industry"/>
<nextmatch-customfields id="customfields"/> <nextmatch-customfields id="customfields"/>
<nextmatch-header label="Note" id="note"/> <nextmatch-header label="Note" id="note"/>
<nextmatch-header label="Distribution lists" id="distribution_list"/> <nextmatch-header label="Distribution lists" id="distribution_list"/>
@ -150,6 +152,7 @@
<url-email id="${row}[email_home]" readonly="true" class="fixedHeight"/> <url-email id="${row}[email_home]" readonly="true" class="fixedHeight"/>
</vbox> </vbox>
<description id="${row}[room]"/> <description id="${row}[room]"/>
<customfields id="$row" readonly="true" fields="kgb_industry" field-list="kgb_industry"/>
<customfields-list id="$row" class="customfields"/> <customfields-list id="$row" class="customfields"/>
<textbox multiline="true" id="${row}[note]" no_lang="1" readonly="true"/> <textbox multiline="true" id="${row}[note]" no_lang="1" readonly="true"/>
<description id="${row}[distrib_lists]"/> <description id="${row}[distrib_lists]"/>