2006-11-10 16:35:35 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2016-04-29 12:41:53 +02:00
|
|
|
* EGroupware - addressbook
|
2006-11-10 16:35:35 +01:00
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package addressbook
|
|
|
|
* @subpackage importexport
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Cornelius Weiss <nelius@cwtech.de>
|
|
|
|
* @copyright Cornelius Weiss <nelius@cwtech.de>
|
2010-11-09 18:37:18 +01:00
|
|
|
* @version $Id$
|
2006-11-10 16:35:35 +01:00
|
|
|
*/
|
|
|
|
|
2016-04-29 12:41:53 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
use EGroupware\Api\Acl;
|
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* export plugin of addressbook
|
|
|
|
*/
|
2016-04-29 12:41:53 +02:00
|
|
|
class addressbook_export_contacts_csv implements importexport_iface_export_plugin
|
|
|
|
{
|
2010-11-09 18:37:18 +01:00
|
|
|
/**
|
|
|
|
* Constants used for exploding categories & multi-selectboxes into seperate fields
|
|
|
|
*/
|
|
|
|
const NO_EXPLODE = False;
|
|
|
|
const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field
|
|
|
|
const EACH_CAT = 'each_cat'; // Every category gets its own field
|
|
|
|
const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field
|
|
|
|
|
2013-01-22 22:17:07 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->ui= new addressbook_ui();
|
|
|
|
$this->get_selects();
|
|
|
|
}
|
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* Exports records as defined in $_definition
|
|
|
|
*
|
|
|
|
* @param egw_record $_definition
|
|
|
|
*/
|
2010-03-22 16:11:12 +01:00
|
|
|
public function export( $_stream, importexport_definition $_definition) {
|
2011-05-20 19:18:49 +02:00
|
|
|
|
2007-06-09 17:38:30 +02:00
|
|
|
$options = $_definition->plugin_options;
|
2012-10-16 20:45:13 +02:00
|
|
|
$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
$selection = array();
|
2010-11-19 19:35:37 +01:00
|
|
|
|
2011-08-19 16:27:49 +02:00
|
|
|
// Addressbook defines its own export imits
|
2016-04-29 12:41:53 +02:00
|
|
|
$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
|
|
|
|
$export_limit = Api\Storage\Merge::getExportLimit($app='addressbook');
|
2011-10-05 14:09:00 +02:00
|
|
|
if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
|
2011-09-13 11:05:33 +02:00
|
|
|
if($export_limit == 'no' && !$limit_exception) {
|
2011-05-20 19:18:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-19 19:35:37 +01:00
|
|
|
// Need to switch the app to get the same results
|
|
|
|
$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
|
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
|
|
|
|
|
2013-02-27 16:33:35 +01:00
|
|
|
if ($options['selection'] == 'search') {
|
2008-05-10 14:02:49 +02:00
|
|
|
// uicontacts selection with checkbox 'use_all'
|
2016-04-29 12:41:53 +02:00
|
|
|
$query = Api\Cache::getSession('addressbook', 'index');
|
2006-11-10 16:35:35 +01:00
|
|
|
$query['num_rows'] = -1; // all
|
2012-03-29 14:06:10 +02:00
|
|
|
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
2013-04-25 11:46:46 +02:00
|
|
|
$query['order'] = 'contact_id';
|
2012-04-23 19:52:36 +02:00
|
|
|
if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
|
2016-04-29 12:41:53 +02:00
|
|
|
$readonlys = null;
|
2013-01-22 22:17:07 +01:00
|
|
|
$this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2013-02-27 16:33:35 +01:00
|
|
|
elseif ( $options['selection'] == 'all' ) {
|
2011-03-15 20:51:39 +01:00
|
|
|
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
|
|
|
|
$col_filter['account_id'] = null;
|
|
|
|
}
|
|
|
|
$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
|
2007-06-28 12:07:16 +02:00
|
|
|
//$uicontacts->get_rows($query,$selection,$readonlys,true);
|
2013-01-22 22:17:07 +01:00
|
|
|
}
|
|
|
|
elseif ($options['selection'] == 'filter')
|
|
|
|
{
|
|
|
|
$filter = $_definition->filter;
|
|
|
|
$query = array();
|
|
|
|
|
|
|
|
// Handle ranges
|
|
|
|
foreach($filter as $field => $value)
|
|
|
|
{
|
|
|
|
if($field == 'cat_id')
|
|
|
|
{
|
|
|
|
$query['col_filter'][$field] = implode(',',$value);
|
|
|
|
continue;
|
|
|
|
}
|
2013-01-23 18:46:58 +01:00
|
|
|
|
|
|
|
// Birthdays in addressbook are formatted Y-m-d
|
|
|
|
if($field == 'bday')
|
|
|
|
{
|
|
|
|
if($value['from'])
|
|
|
|
{
|
|
|
|
$query['col_filter'][] = "contact_bday >= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
|
|
|
|
}
|
|
|
|
if($value['to'])
|
|
|
|
{
|
|
|
|
$query['col_filter'][] = "contact_bday <= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-15 18:26:44 +02:00
|
|
|
// Custom fields & listed exceptions are not filtered with contact_ prefix
|
|
|
|
if(strpos($field, '#') !== 0 && !in_array($field, array('tid','owner')))
|
2013-01-22 22:17:07 +01:00
|
|
|
{
|
|
|
|
$field = 'contact_'.$field;
|
|
|
|
}
|
|
|
|
$query['col_filter'][$field] = $value;
|
|
|
|
if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
|
|
|
|
|
|
|
|
// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
|
|
|
|
if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
|
|
|
|
if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
|
|
|
|
unset($query['col_filter'][$field]);
|
|
|
|
}
|
|
|
|
$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-11-10 16:35:35 +01:00
|
|
|
$selection = explode(',',$options['selection']);
|
|
|
|
}
|
2014-07-15 18:26:44 +02:00
|
|
|
if(!is_array($selection))
|
|
|
|
{
|
|
|
|
$selection = array();
|
|
|
|
}
|
2010-11-19 19:35:37 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2016-04-29 12:41:53 +02:00
|
|
|
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
|
2011-09-13 11:05:33 +02:00
|
|
|
$selection = array_slice($selection, 0, $export_limit);
|
2011-05-20 19:18:49 +02:00
|
|
|
}
|
2011-10-05 14:09:00 +02:00
|
|
|
|
2010-11-09 18:37:18 +01:00
|
|
|
if($options['explode_multiselects']) {
|
2016-04-29 12:41:53 +02:00
|
|
|
$customfields = Api\Storage\Customfields::get('addressbook');
|
2010-11-09 18:37:18 +01:00
|
|
|
$additional_fields = array();
|
2016-04-29 12:41:53 +02:00
|
|
|
$cat_obj = new Api\Categories('', 'addressbook');
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach($options['explode_multiselects'] as $field => $explode) {
|
|
|
|
switch($explode['explode']) {
|
|
|
|
case self::MAIN_CATS:
|
2011-03-15 16:37:52 +01:00
|
|
|
$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach($cats as $settings) {
|
|
|
|
$additional_fields[$field][$settings['id']] = array(
|
|
|
|
'count' => 0,
|
|
|
|
'label' => $settings['name'],
|
|
|
|
'subs' => array(),
|
|
|
|
);
|
2010-11-19 19:35:37 +01:00
|
|
|
$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach($subs as $sub) {
|
2010-11-19 19:35:37 +01:00
|
|
|
$name = $sub['name'];
|
|
|
|
$path = $sub;
|
|
|
|
while($path['parent'] != $settings['id']) {
|
|
|
|
$path = $cat_obj->read($path['parent']);
|
|
|
|
$name = $path['name'] . '/' . $name;
|
|
|
|
}
|
|
|
|
$additional_fields[$field][$settings['id']]['subs'][$sub['id']] = $name;
|
2010-11-09 18:37:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case self::EACH_CAT:
|
2011-03-15 17:49:45 +01:00
|
|
|
$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach($cats as $settings) {
|
2010-11-19 19:35:37 +01:00
|
|
|
$name = $settings['name'];
|
|
|
|
$path = $settings;
|
|
|
|
while($path['level'] != 0) {
|
|
|
|
$path = $cat_obj->read($path['parent']);
|
|
|
|
$name = $path['name'] . '/' . $name;
|
|
|
|
}
|
2010-11-09 18:37:18 +01:00
|
|
|
$additional_fields[$field][$settings['id']] = array(
|
|
|
|
'count' => 0,
|
2010-11-19 19:35:37 +01:00
|
|
|
'label' => $name
|
2010-11-09 18:37:18 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case self::EXPLODE:
|
|
|
|
// Only works for custom fields
|
|
|
|
$index = substr($field, 1);
|
|
|
|
foreach($customfields[$index]['values'] as $key => $value) {
|
|
|
|
$additional_fields[$field][$key] = array(
|
|
|
|
'count' => 0,
|
|
|
|
'label' => $customfields[$index]['label'] . ': ' . $value,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-19 19:35:37 +01:00
|
|
|
// Check records to see if additional fields are actually used
|
|
|
|
foreach ($selection as $_contact) {
|
2011-03-21 19:14:25 +01:00
|
|
|
if(is_array($_contact) && array_key_exists('photo', $_contact)) {
|
|
|
|
unset($_contact['photo']);
|
|
|
|
}
|
|
|
|
if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
|
|
|
|
$_contact = $_contact['id'];
|
|
|
|
}
|
2010-11-19 19:35:37 +01:00
|
|
|
if(is_array($_contact) && $_contact['id']) {
|
|
|
|
$contact = new addressbook_egw_record();
|
|
|
|
$contact->set_record($_contact);
|
|
|
|
} else {
|
|
|
|
$contact = new addressbook_egw_record($_contact);
|
|
|
|
}
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach($additional_fields as $field => &$values) {
|
|
|
|
if(!$contact->$field) continue;
|
|
|
|
foreach($values as $value => &$settings) {
|
|
|
|
if(!is_array($contact->$field)) {
|
|
|
|
$contact->$field = explode(',', $contact->$field);
|
|
|
|
}
|
|
|
|
if(is_array($contact->$field) && in_array($value, $contact->$field)) {
|
|
|
|
$settings['count']++;
|
|
|
|
} elseif($contact->$field == $value) {
|
|
|
|
$settings['count']++;
|
2010-11-19 19:35:37 +01:00
|
|
|
} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
|
|
|
|
$settings['count']++;
|
2010-11-09 18:37:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($field);
|
|
|
|
unset($value);
|
|
|
|
unset($settings);
|
|
|
|
|
|
|
|
// Add additional columns
|
|
|
|
foreach($additional_fields as $field => $additional_values) {
|
|
|
|
// Remove original
|
|
|
|
unset($options['mapping'][$field]);
|
|
|
|
// Add exploded
|
|
|
|
$field_count = 0;
|
|
|
|
foreach($additional_values as $value => $settings) {
|
|
|
|
if($settings['count'] > 0) {
|
|
|
|
$field_count += $settings['count'];
|
|
|
|
$options['mapping'][$field.'-'.$value] = $settings['label'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($field_count > 0) {
|
|
|
|
// Set some options for converting
|
|
|
|
$options['explode_multiselects'][$field]['values'] = $additional_values;
|
|
|
|
} else {
|
|
|
|
// Don't need this anymore
|
|
|
|
unset($options['explode_multiselects'][$field]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-08 00:31:08 +02:00
|
|
|
$export_object->set_mapping($options['mapping']);
|
2016-04-29 12:41:53 +02:00
|
|
|
|
2015-03-02 18:18:19 +01:00
|
|
|
// Add in last/next event, if needed
|
|
|
|
if($options['mapping']['last_date'] || $options['mapping']['next_date'])
|
|
|
|
{
|
|
|
|
$contact_ids = array();
|
|
|
|
foreach($selection as $_contact)
|
|
|
|
{
|
|
|
|
if(is_array($_contact) && $_contact['id'])
|
|
|
|
{
|
|
|
|
$contact_ids[] = $_contact['id'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$contact_ids[] = $contact;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$events = $this->ui->read_calendar($contact_ids, false);
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
// $options['selection'] is array of identifiers as this plugin doesn't
|
|
|
|
// support other selectors atm.
|
2010-11-19 19:35:37 +01:00
|
|
|
foreach ($selection as $_contact) {
|
2011-03-14 20:08:20 +01:00
|
|
|
if(is_array($_contact) && array_key_exists('photo', $_contact)) {
|
|
|
|
unset($_contact['photo']);
|
|
|
|
}
|
|
|
|
if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
|
|
|
|
$_contact = $_contact['id'];
|
|
|
|
}
|
2010-11-19 19:35:37 +01:00
|
|
|
if(is_array($_contact) && $_contact['id']) {
|
|
|
|
$contact = new addressbook_egw_record();
|
|
|
|
$contact->set_record($_contact);
|
|
|
|
} else {
|
|
|
|
$contact = new addressbook_egw_record($_contact);
|
|
|
|
}
|
2015-03-02 18:18:19 +01:00
|
|
|
|
|
|
|
if($events && $events[$contact->id])
|
|
|
|
{
|
|
|
|
// NB: last_date and next_date are used instead of last_event & next_event
|
|
|
|
// to avoid automatic conversion - we want to export link title, not date-time
|
|
|
|
$contact->last_date = $events[$contact->id]['last_link']['title'];
|
|
|
|
$contact->next_date = $events[$contact->id]['next_link']['title'];
|
|
|
|
}
|
2010-10-29 01:14:01 +02:00
|
|
|
// Some conversion
|
2010-11-09 18:37:18 +01:00
|
|
|
$this->convert($contact, $options);
|
2010-11-23 00:32:27 +01:00
|
|
|
if($options['convert']) {
|
2013-01-22 22:17:07 +01:00
|
|
|
importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
|
2010-12-10 23:47:44 +01:00
|
|
|
} else {
|
2011-10-05 14:09:00 +02:00
|
|
|
// Implode arrays, so they don't say 'Array'
|
|
|
|
foreach($contact->get_record_array() as $key => $value) {
|
|
|
|
if(is_array($value)) $contact->$key = implode(',', $value);
|
|
|
|
}
|
|
|
|
}
|
2010-12-10 23:47:44 +01:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
$export_object->export_record($contact);
|
|
|
|
unset($contact);
|
2008-05-10 14:02:49 +02:00
|
|
|
}
|
2012-04-18 20:00:21 +02:00
|
|
|
return $export_object;
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* returns translated name of plugin
|
|
|
|
*
|
|
|
|
* @return string name
|
|
|
|
*/
|
|
|
|
public static function get_name() {
|
|
|
|
return lang('Addressbook CSV export');
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* returns translated (user) description of plugin
|
|
|
|
*
|
|
|
|
* @return string descriprion
|
|
|
|
*/
|
|
|
|
public static function get_description() {
|
2010-10-08 01:07:02 +02:00
|
|
|
return lang("Exports contacts from your Addressbook into a CSV File.");
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* retruns file suffix for exported file
|
|
|
|
*
|
|
|
|
* @return string suffix
|
|
|
|
*/
|
|
|
|
public static function get_filesuffix() {
|
|
|
|
return 'csv';
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2010-10-13 00:48:43 +02:00
|
|
|
public static function get_mimetype() {
|
|
|
|
return 'text/csv';
|
|
|
|
}
|
|
|
|
|
2012-10-16 20:45:13 +02:00
|
|
|
/**
|
|
|
|
* Suggest a file name for the downloaded file
|
|
|
|
* No suffix
|
|
|
|
*/
|
|
|
|
public function get_filename()
|
|
|
|
{
|
|
|
|
if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
|
|
|
|
{
|
|
|
|
return $this->export_object->record->get_title();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* return html for options.
|
|
|
|
* this way the plugin has all opertunities for options tab
|
2008-05-10 14:02:49 +02:00
|
|
|
*
|
2006-11-10 16:35:35 +01:00
|
|
|
* @return string html
|
|
|
|
*/
|
2007-06-09 17:38:30 +02:00
|
|
|
public function get_options_etpl() {
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* returns slectors of this plugin via xajax
|
|
|
|
*
|
|
|
|
*/
|
2007-06-09 17:38:30 +02:00
|
|
|
public function get_selectors_etpl() {
|
2011-03-28 23:13:45 +02:00
|
|
|
return array(
|
2013-01-22 22:17:07 +01:00
|
|
|
'name' => 'importexport.export_csv_selectors',
|
2011-03-28 23:13:45 +02:00
|
|
|
);
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2010-10-29 01:14:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert some internal data to something with more meaning
|
2012-03-29 14:06:10 +02:00
|
|
|
*
|
2010-10-29 01:14:01 +02:00
|
|
|
* Dates, times, user IDs, category IDs
|
|
|
|
*/
|
2010-11-09 18:37:18 +01:00
|
|
|
public static function convert(addressbook_egw_record &$record, $options) {
|
2012-03-29 14:06:10 +02:00
|
|
|
|
2010-10-29 01:14:01 +02:00
|
|
|
if ($record->tel_prefer) {
|
|
|
|
$field = $record->tel_prefer;
|
|
|
|
$record->tel_prefer = $record->$field;
|
|
|
|
}
|
2010-11-09 18:37:18 +01:00
|
|
|
|
2013-01-23 18:24:45 +01:00
|
|
|
if(!is_array($options['explode_multiselects']))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
|
|
|
|
if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
|
2010-11-24 12:21:39 +01:00
|
|
|
foreach((array)$explode_settings['values'] as $value => $settings) {
|
2010-11-09 18:37:18 +01:00
|
|
|
$field_name = "$field-$value";
|
|
|
|
$record->$field_name = array();
|
|
|
|
if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
|
|
|
|
if($explode_settings['explode'] != self::MAIN_CATS) {
|
2010-11-23 00:32:27 +01:00
|
|
|
$record->$field_name = $options['convert'] ? lang('Yes') : true;
|
|
|
|
} elseif($options['convert']) {
|
2010-11-09 18:37:18 +01:00
|
|
|
// 3 part assign due to magic get method
|
|
|
|
$record_value = $record->$field_name;
|
|
|
|
$record_value[] = $settings['label'];
|
|
|
|
$record->$field_name = $record_value;
|
2011-03-15 17:49:45 +01:00
|
|
|
} else {
|
|
|
|
$record->$field_name = $value;
|
2010-11-09 18:37:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
|
|
|
|
// 3 part assign due to magic get method
|
|
|
|
$record_value = $record->$field_name;
|
2011-03-16 16:28:42 +01:00
|
|
|
if(!is_array($record_value)) $record_value = array($record_value);
|
2010-11-09 18:37:18 +01:00
|
|
|
foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
|
2010-11-23 00:32:27 +01:00
|
|
|
$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
|
2010-11-09 18:37:18 +01:00
|
|
|
}
|
|
|
|
$record->$field_name = $record_value;
|
|
|
|
}
|
2011-03-17 15:40:48 +01:00
|
|
|
if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
|
2010-11-09 18:37:18 +01:00
|
|
|
}
|
|
|
|
}
|
2010-10-29 01:14:01 +02:00
|
|
|
}
|
2013-01-22 22:17:07 +01:00
|
|
|
|
2013-04-25 11:46:46 +02:00
|
|
|
|
2013-01-22 22:17:07 +01:00
|
|
|
protected function get_selects()
|
|
|
|
{
|
|
|
|
$this->selects = array(
|
|
|
|
'tid' => array('n' => 'Contact')
|
|
|
|
);
|
|
|
|
foreach($this->ui->content_types as $tid => $data)
|
|
|
|
{
|
|
|
|
$this->selects['tid'][$tid] = $data['name'];
|
|
|
|
}
|
|
|
|
}
|
2016-05-04 21:34:30 +02:00
|
|
|
/**
|
|
|
|
* Get the class name for the egw_record to use while exporting
|
|
|
|
*
|
|
|
|
* @return string;
|
|
|
|
*/
|
|
|
|
public static function get_egw_record_class()
|
|
|
|
{
|
|
|
|
return 'addressbook_egw_record';
|
|
|
|
}
|
2013-01-22 22:17:07 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust automatically generated filter fields
|
|
|
|
*/
|
|
|
|
public function get_filter_fields(Array &$filters)
|
2015-03-02 18:18:19 +01:00
|
|
|
{
|
2013-01-22 22:17:07 +01:00
|
|
|
unset($filters['last_event']);
|
|
|
|
unset($filters['next_event']);
|
2013-11-08 00:43:17 +01:00
|
|
|
foreach($filters as $field_name => &$settings)
|
|
|
|
{
|
2015-03-02 18:18:19 +01:00
|
|
|
if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
|
2013-11-08 00:43:17 +01:00
|
|
|
}
|
2013-01-22 22:17:07 +01:00
|
|
|
$filters['owner'] = array(
|
|
|
|
'name' => 'owner',
|
|
|
|
'label' => 'addressbook',
|
|
|
|
'type' => 'select',
|
|
|
|
'rows' => 5,
|
2013-11-08 00:43:17 +01:00
|
|
|
'tags' => true,
|
2016-04-29 12:41:53 +02:00
|
|
|
'values' => $this->ui->get_addressbooks(Acl::READ)
|
2013-01-22 22:17:07 +01:00
|
|
|
);
|
|
|
|
}
|
2007-06-08 00:31:08 +02:00
|
|
|
}
|