2006-11-10 16:35:35 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* eGroupWare
|
|
|
|
*
|
|
|
|
* @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>
|
2007-06-08 00:31:08 +02:00
|
|
|
* @version $Id: $
|
2006-11-10 16:35:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* export plugin of addressbook
|
|
|
|
*/
|
2010-03-22 16:11:12 +01:00
|
|
|
class addressbook_export_contacts_csv implements importexport_iface_export_plugin {
|
2008-05-10 14:02:49 +02:00
|
|
|
|
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) {
|
2007-06-09 17:38:30 +02:00
|
|
|
$options = $_definition->plugin_options;
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2008-05-10 14:11:02 +02:00
|
|
|
$uicontacts = new addressbook_ui();
|
2006-11-10 16:35:35 +01:00
|
|
|
$selection = array();
|
2007-06-28 12:07:16 +02:00
|
|
|
if ($options['selection'] == 'use_all') {
|
2008-05-10 14:02:49 +02:00
|
|
|
// uicontacts selection with checkbox 'use_all'
|
2006-11-10 16:35:35 +01:00
|
|
|
$query = $GLOBALS['egw']->session->appsession('index','addressbook');
|
|
|
|
$query['num_rows'] = -1; // all
|
|
|
|
$uicontacts->get_rows($query,$selection,$readonlys,true); // true = only return the id's
|
|
|
|
}
|
2007-06-28 12:07:16 +02:00
|
|
|
elseif ( $options['selection'] == 'all_contacts' ) {
|
2008-05-10 14:02:49 +02:00
|
|
|
$selection = ExecMethod('addressbook.addressbook_bo.search',array());
|
2007-06-28 12:07:16 +02:00
|
|
|
//$uicontacts->get_rows($query,$selection,$readonlys,true);
|
|
|
|
} else {
|
2006-11-10 16:35:35 +01:00
|
|
|
$selection = explode(',',$options['selection']);
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2010-03-22 16:11:12 +01:00
|
|
|
$export_object = new importexport_export_csv($_stream, (array)$options);
|
2007-06-08 00:31:08 +02:00
|
|
|
$export_object->set_mapping($options['mapping']);
|
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.
|
|
|
|
foreach ($selection as $identifier) {
|
2010-03-22 16:11:12 +01:00
|
|
|
$contact = new addressbook_egw_record($identifier);
|
2006-11-10 16:35:35 +01:00
|
|
|
$export_object->export_record($contact);
|
|
|
|
unset($contact);
|
2008-05-10 14:02:49 +02:00
|
|
|
}
|
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';
|
|
|
|
}
|
|
|
|
|
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
|
|
|
return 'addressbook.export_csv_options';
|
|
|
|
}
|
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() {
|
2010-03-22 16:11:12 +01:00
|
|
|
return 'addressbook.export_csv_selectors';
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2007-06-08 00:31:08 +02:00
|
|
|
}
|