# R32509 - in /trunk/calendar: inc/ setup/

**URL:** <https://help.egroupware.org/t/r32509-in-trunk-calendar-inc-setup/41705>\
**Category:** eGW-svn\
**Created:** [October 12, 2010, 10:45pm UTC](https://help.egroupware.org/t/r32509-in-trunk-calendar-inc-setup/41705 "2010-10-12T22:45:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathangray](https://help.egroupware.org/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nathangray](https://help.egroupware.org/u/nathangray)\
**Post date:** [October 12, 2010, 10:45pm UTC](https://help.egroupware.org/t/r32509-in-trunk-calendar-inc-setup/41705/1 "2010-10-12T22:45:02Z")

</div>

Author: nathangray  
New Revision: 32509

URL: [http://www.egroupware.org/viewvc/egroupware?rev=32509&view=rev](http://www.egroupware.org/viewvc/egroupware?rev=32509&view=rev)  
Log:  
Add exporting iCal and CSV via importexport

Added:  
trunk/calendar/inc/class.calendar\_egw\_record.inc.php  
- copied, changed from r32506, trunk/addressbook/inc/class.addressbook\_egw\_record.inc.php  
trunk/calendar/inc/class.calendar\_export\_csv.inc.php  
- copied, changed from r32506, trunk/addressbook/inc/class.addressbook\_export\_contacts\_csv.inc.php  
trunk/calendar/inc/class.calendar\_wizard\_export\_csv.inc.php  
- copied, changed from r32506, trunk/addressbook/inc/class.addressbook\_wizard\_export\_contacts\_csv.inc.php  
Modified:  
trunk/calendar/setup/etemplates.inc.php

# Copied: trunk/calendar/inc/class.calendar\_egw\_record.inc.php (from r32506, trunk/addressbook/inc/class.addressbook\_egw\_record.inc.php) URL: [http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar\_egw\_record.inc.php?p2=trunk/calendar/inc/class.calendar\_egw\_record.inc.php&p1=trunk/addressbook/inc/class.addressbook\_egw\_record.inc.php&r1=32506&r2=32509&rev=32509&view=diff](http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar_egw_record.inc.php?p2=trunk/calendar/inc/class.calendar_egw_record.inc.php&p1=trunk/addressbook/inc/class.addressbook_egw_record.inc.php&r1=32506&r2=32509&rev=32509&view=diff)

— trunk/addressbook/inc/class.addressbook\_egw\_record.inc.php (original)  
+++ trunk/calendar/inc/class.calendar\_egw\_record.inc.php Wed Oct 13 00:45:02 2010  
@@ -1,28 +1,26 @@

 \<?php /\*\* - \* eGroupWare - Addressbook - importexport + \* eGroupWare - Calendar - importexport \* \* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - \* @package addressbook + \* @package calendar \* @subpackage importexport \* @link http://www.egroupware.org - \* @author Cornelius Weiss - \* @copyright Cornelius Weiss - \* @version $Id: class.egw\_addressbook\_record.inc.php 22827 2006-11-10 15:35:35Z nelius\_weiss $ + \* @author Nathan Gray + \* @copyright Nathan Gray + \* @version $Id$ \*/ /\*\* - \* class addressbook\_egw\_record + \* class calendar\_egw\_record \* compability layer for iface\_egw\_record needet for importexport \*/ -class addressbook\_egw\_record implements importexport\_iface\_egw\_record +class calendar\_egw\_record implements importexport\_iface\_egw\_record { private $identifier = ''; - private $contact = array(); - private $bocontacts; - - + private $record = array(); + private static $bo; /\*\* \* constructor @@ -32,8 +30,12 @@ \*/ public function \_\_construct( $\_identifier='' ){ $this-\>identifier = $\_identifier; - $this-\>bocontacts = new addressbook\_bo(); - $this-\>contact = $this-\>bocontacts-\>read($this-\>identifier); + if(!is\_object($this-\>bo)) { + $this-\>bo = new calendar\_bo(); + } + if($this-\>identifier) { + $this-\>record = $this-\>bo-\>read($this-\>identifier); + } } /\*\* @@ -64,7 +66,7 @@ \* @return array complete record as associative array \*/ public function get\_record\_array() { - return $this-\>contact; + return $this-\>record; } /\*\* @@ -73,10 +75,10 @@ \*@return string tiltle \*/ public function get\_title() { - if (empty($this-\>contact)) { + if (empty($this-\>record)) { $this-\>get\_record(); } - return $this-\>contact['fn']; + return $this-\>record['title']; } /\*\* @@ -86,7 +88,7 @@ \* @return void \*/ public function set\_record(array $\_record){ - $this-\>contact = $\_record; + $this-\>record = $\_record; } /\*\* @@ -141,8 +143,7 @@ \* \*/ public function \_\_destruct() { - unset ($this-\>bocontacts); } -} // end of egw\_addressbook\_record +} // end of calendar\_egw\_record ?\>
# Copied: trunk/calendar/inc/class.calendar\_export\_csv.inc.php (from r32506, trunk/addressbook/inc/class.addressbook\_export\_contacts\_csv.inc.php) URL: [http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar\_export\_csv.inc.php?p2=trunk/calendar/inc/class.calendar\_export\_csv.inc.php&p1=trunk/addressbook/inc/class.addressbook\_export\_contacts\_csv.inc.php&r1=32506&r2=32509&rev=32509&view=diff](http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar_export_csv.inc.php?p2=trunk/calendar/inc/class.calendar_export_csv.inc.php&p1=trunk/addressbook/inc/class.addressbook_export_contacts_csv.inc.php&r1=32506&r2=32509&rev=32509&view=diff)

— trunk/addressbook/inc/class.addressbook\_export\_contacts\_csv.inc.php (original)  
+++ trunk/calendar/inc/class.calendar\_export\_csv.inc.php Wed Oct 13 00:45:02 2010  
@@ -3,18 +3,18 @@

- eGroupWare
- 
- @license [http://opensource.org/licenses/gpl-license.php](http://opensource.org/licenses/gpl-license.php) GPL - GNU General Public License

- 
  - @package addressbook

- 
  - @package calendar
  - @subpackage importexport
  - @link [http://www.egroupware.org](http://www.egroupware.org)

- 
  - @author Cornelius Weiss [nelius@cwtech.de](mailto:nelius@cwtech.de)

- 
  - @copyright Cornelius Weiss [nelius@cwtech.de](mailto:nelius@cwtech.de)

- 
  - @version $Id: $

- 
  - @author Nathan Gray

- 
  - @copyright Nathan Gray

- 
  - @version $Id$  
\*/

/\*\*

- 
  - export plugin of addressbook

- 
  - export CSV plugin of calendar  
\*/  
-class addressbook\_export\_contacts\_csv implements importexport\_iface\_export\_plugin {  
+class calendar\_export\_csv implements importexport\_iface\_export\_plugin {

- 
- 

```
  $uicontacts = new addressbook_ui();

```

- 

```
  $selection = array();

```

- 

```
  if ($options['selection'] == 'use_all') {

```

- 

```
  	// uicontacts selection with checkbox 'use_all'

```

- 

```
  	$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

```

- 

```
  }

```

- 

```
  elseif ( $options['selection'] == 'all_contacts' ) {

```

- 

```
  	$selection = ExecMethod('addressbook.addressbook_bo.search',array());

```

- 

```
  	//$uicontacts->get_rows($query,$selection,$readonlys,true);

```

- 

```
  } else {

```

- 

```
  	$selection = explode(',',$options['selection']);

```

- 

```
  }

```

- 

```
  $this->bo = new calendar_bo();

```

- 

```
  $events =& $this->bo->search(array(

```

- 

```
  	'start' => $options['selection']['start'],

```

- 

```
  	'end' => $options['selection']['end'],

```

- 

```
  	'categories'	=> $options['categories'] ? $options['categories'] : $options['selection']['categories'],

```

- 

```
  	'enum_recuring' => false,

```

- 

```
  	'daywise' => false,

```

- 

```
  	'owner' => $options['owner'],

```

- 

```
  	'date_format' => $options['date_format'],

```

- 

```
  ));

  $export_object = new importexport_export_csv($_stream, (array)$options);
  $export_object->set_mapping($options['mapping']);

  // $options['selection'] is array of identifiers as this plugin doesn't
  // support other selectors atm.

```

- 

```
  foreach ($selection as $identifier) {

```

- 

```
  	$contact = new addressbook_egw_record($identifier);

```

- 

```
  	$export_object->export_record($contact);

```

- 

```
  	unset($contact);

```

- 

```
  $record = new calendar_egw_record();

```

- 

```
  foreach ($events as $event) {

```

- 

```
  	$record->set_record($event);

```

- 

```
  	$export_object->export_record($record);
  }

```

- 

```
  unset($record);

```

}

/\*\*  
@@ -57,7 +53,7 @@

  - @return string name  
\*/  
public static function get\_name() {

- 

```
  return lang('Addressbook CSV export');

```

- 

```
  return lang('Calendar CSV export');

```

}

/\*\*  
@@ -66,7 +62,7 @@

  - @return string descriprion  
\*/  
public static function get\_description() {

- 

```
  return lang("Exports contacts from your Addressbook into a CSV File.");

```

- 

```
  return lang("Exports events from your Calendar into a CSV File.");

```

}

/\*\*  
@@ -78,21 +74,28 @@  
return ‘csv’;  
}

- /\*\*
- 
  - return html for options.

- 
  - this way the plugin has all opertunities for options tab

- 
  - 

- 
  - @return string html

- \*/
- public function get\_options\_etpl() {
- 

```
  return 'addressbook.export_csv_options';

```

- public static function get\_mimetype() {

- 

```
  return 'text/csv';

```

}

/\*\*

- 
  - returns slectors of this plugin via xajax

- 
  - return html for options.

- 
  - 

- \*/
- public function get\_options\_etpl() {
- }
- 
- /\*\*
- 
  - returns selectors of this plugin
  - 

\*/  
public function get\_selectors\_etpl() {

- 

```
  return 'addressbook.export_csv_selectors';

```

- 

```
  return array(

```

- 

```
  	'name' => 'calendar.export_csv_select',

```

- 

```
  	'content'	=> array(

```

- 

```
  		'start' => time(),

```

- 

```
  		'end' => time()

```

- 

```
  	)

```

- 

```
  );

```

}  
}

# Copied: trunk/calendar/inc/class.calendar\_wizard\_export\_csv.inc.php (from r32506, trunk/addressbook/inc/class.addressbook\_wizard\_export\_contacts\_csv.inc.php) URL: [http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar\_wizard\_export\_csv.inc.php?p2=trunk/calendar/inc/class.calendar\_wizard\_export\_csv.inc.php&p1=trunk/addressbook/inc/class.addressbook\_wizard\_export\_contacts\_csv.inc.php&r1=32506&r2=32509&rev=32509&view=diff](http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar_wizard_export_csv.inc.php?p2=trunk/calendar/inc/class.calendar_wizard_export_csv.inc.php&p1=trunk/addressbook/inc/class.addressbook_wizard_export_contacts_csv.inc.php&r1=32506&r2=32509&rev=32509&view=diff)

— trunk/addressbook/inc/class.addressbook\_wizard\_export\_contacts\_csv.inc.php (original)  
+++ trunk/calendar/inc/class.calendar\_wizard\_export\_csv.inc.php Wed Oct 13 00:45:02 2010  
@@ -3,22 +3,25 @@

- eGroupWare - Wizard for Adressbook CSV export
- 
- @license [http://opensource.org/licenses/gpl-license.php](http://opensource.org/licenses/gpl-license.php) GPL - GNU General Public License

- 
  - @package addressbook

- 
  - @package calendar
  - @link [http://www.egroupware.org](http://www.egroupware.org)
  - @author Nathan Gray

- 
  - @version $Id: $

- 
  - @version $Id$  
\*/

-class addressbook\_wizard\_export\_contacts\_csv extends importexport\_wizard\_basic\_export\_csv  
+class calendar\_wizard\_export\_csv extends importexport\_wizard\_basic\_export\_csv  
{  
public function \_\_construct() {  
parent::\_\_construct();  
// Field mapping

- 

```
  $bocontacts = new addressbook_bo();

```

- 

```
  $this->export_fields = $bocontacts->contact_fields;

```

- 

```
  foreach($bocontacts->customfields as $name => $data) {

```

- 

```
  $bo = new calendar_tracking();

```

- 

```
  $this->export_fields = $bo->field2label;

```

- 

```
  $custom = config::get_customfields('calendar', true);

```

- 

```
  foreach($custom as $name => $data) {
  	$this->export_fields['#'.$name] = $data['label'];
  }

```

- 

```
  unset($this->export_fields['jpegphoto']); // can't cvs export that

```

- }
- 
- 

}

# Modified: trunk/calendar/setup/etemplates.inc.php URL: [http://www.egroupware.org/viewvc/egroupware/trunk/calendar/setup/etemplates.inc.php?rev=32509&r1=32508&r2=32509&view=diff](http://www.egroupware.org/viewvc/egroupware/trunk/calendar/setup/etemplates.inc.php?rev=32509&r1=32508&r2=32509&view=diff)

— trunk/calendar/setup/etemplates.inc.php (original)  
+++ trunk/calendar/setup/etemplates.inc.php Wed Oct 13 00:45:02 2010  
@@ -2,7 +2,7 @@  
/\*\*  
\* eGroupWare - eTemplates for Application calendar  
\* [http://www.egroupware.org](http://www.egroupware.org)

- 
  - generated by soetemplate::dump4setup() 2010-10-07 08:23

- 
  - generated by soetemplate::dump4setup() 2010-10-12 16:44
  - 
  - @license [http://opensource.org/licenses/gpl-license.php](http://opensource.org/licenses/gpl-license.php) GPL - GNU General Public License
  - @package calendar  
@@ -45,6 +45,8 @@

$templ\_data[] = array(‘name’ =\> ‘calendar.export’,‘template’ =\> ‘’,‘lang’ =\> ‘’,‘group’ =\> ‘0’,‘version’ =\> ‘1.0.1.001’,‘data’ =\> ‘a:1:{i:0;a:6:{s:4:“type”;s:4:“grid”;s:4:“data”;a:8:{i:0;a:2:{s:2:“h5”;s:2:",1";s:2:“h1”;s:6:",!@msg";}i:1;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“span”;s:11:“all,message”;s:4:“name”;s:3:“msg”;}s:1:“B”;a:1:{s:4:“type”;s:5:“label”;}}i:2;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“size”;s:8:",start";s:5:“label”;s:5:“Start”;}s:1:“B”;a:3:{s:4:“type”;s:4:“date”;s:4:“name”;s:5:“start”;s:4:“help”;s:23:“Startdate of the export”;}}i:3;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“size”;s:6:",end";s:5:“label”;s:3:“End”;}s:1:“B”;a:3:{s:4:“type”;s:4:“date”;s:4:“name”;s:3:“end”;s:4:“help”;s:21:“Enddate of the export”;}}i:4;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“size”;s:7:",file";s:5:“label”;s:8:“Filename”;}s:1:“B”;a:3:{s:4:“type”;s:4:“text”;s:4:“name”;s:4:“file”;s:4:“help”;s:24:“Filename of the download”;}}i:5;a:2:{s:1:“A”;a:3:{s:4:“type”;  
s:5:“label”;s:4:“size”;s:10:",version";s:5:“label”;s:7:“Version”;}s:1:“B”;a:2:{s:4:“type”;s:6:“select”;s:4:“name”;s:7:“version”;}}i:6;a:2:{s:1:“A”;a:1:{s:4:“type”;s:5:“label”;}s:1:“B”;a:3:{s:4:“type”;s:6:“button”;s:5:“label”;s:8:“Download”;s:4:“name”;s:8:“download”;}}i:7;a:2:{s:1:“A”;a:2:{s:4:“type”;s:5:“label”;s:4:“span”;s:3:“all”;}s:1:“B”;a:1:{s:4:“type”;s:5:“label”;}}}s:4:“rows”;i:7;s:4:“cols”;i:2;s:5:“align”;s:6:“center”;s:7:“options”;a:0:{}}}’,‘size’ =\> ‘’,‘style’ =\> ‘’,‘modified’ =\> ‘1130738737’,);

+$templ\_data[] = array(‘name’ =\> ‘calendar.export\_csv\_select’,‘template’ =\> ‘’,‘lang’ =\> ‘’,‘group’ =\> ‘0’,‘version’ =\> ‘1.9.001’,‘data’ =\> ‘a:1:{i:0;a:6:{s:4:“type”;s:4:“grid”;s:4:“data”;a:5:{i:0;a:1:{s:2:“h1”;s:6:",!@msg";}i:1;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“span”;s:11:“all,message”;s:4:“name”;s:3:“msg”;}s:1:“B”;a:1:{s:4:“type”;s:5:“label”;}}i:2;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“size”;s:8:",start";s:5:“label”;s:5:“Start”;}s:1:“B”;a:3:{s:4:“type”;s:4:“date”;s:4:“name”;s:16:“selection[start]”;s:4:“help”;s:23:“Startdate of the export”;}}i:3;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“size”;s:6:",end";s:5:“label”;s:3:“End”;}s:1:“B”;a:3:{s:4:“type”;s:4:“date”;s:4:“name”;s:14:“selection[end]”;s:4:“help”;s:21:“Enddate of the export”;}}i:4;a:2:{s:1:“A”;a:2:{s:4:“type”;s:5:“label”;s:4:“span”;s:3:“all”;}s:1:“B”;a:1:{s:4:“type”;s:5:“label”;}}}s:4:“rows”;i:4;s:4:“cols”;i:2;s:5:“align”;s:6:“center”;s:7:“options”;a:0:{}}}’,‘size’ =\> ‘’,‘style’ =\> ‘’,‘modif  
ied’ =\> ‘1286919523’,);  
+  
$templ\_data[] = array(‘name’ =\> ‘calendar.freetimesearch’,‘template’ =\> ‘’,‘lang’ =\> ‘’,‘group’ =\> ‘0’,‘version’ =\> ‘1.3.001’,‘data’ =\> ‘a:1:{i:0;a:4:{s:4:“type”;s:4:“grid”;s:4:“data”;a:7:{i:0;a:0:{}i:1;a:2:{s:1:“A”;a:3:{s:4:“type”;s:5:“label”;s:4:“span”;s:9:",size120b";s:5:“label”;s:15:“Freetime Search”;}s:1:“B”;a:4:{s:4:“type”;s:5:“label”;s:4:“span”;s:10:",redItalic";s:7:“no\_lang”;s:1:“1”;s:4:“name”;s:3:“msg”;}}i:2;a:2:{s:1:“A”;a:2:{s:4:“type”;s:5:“label”;s:5:“label”;s:17:“Startdate / -time”;}s:1:“B”;a:3:{s:4:“type”;s:9:“date-time”;s:4:“name”;s:5:“start”;s:4:“help”;s:33:“Startdate and -time of the search”;}}i:3;a:2:{s:1:“A”;a:2:{s:4:“type”;s:5:“label”;s:5:“label”;s:8:“Duration”;}s:1:“B”;a:4:{s:4:“type”;s:4:“hbox”;s:4:“size”;s:1:“2”;i:1;a:6:{s:4:“type”;s:6:“select”;s:7:“no\_lang”;s:1:“1”;s:4:“name”;s:8:“duration”;s:4:“help”;s:23:“Duration of the meeting”;s:8:“onchange”;s:92:“set\_style\_by\_class(‘table’,‘end\_hide’,‘visibility’,this.value == ‘’ ? ‘visible’ : ‘hidden  
’);”;s:4:“size”;s:12:“Use end date”;}i:2;a:4:{s:4:“type”;s:9:“date-time”;s:4:“name”;s:3:“end”;s:4:“help”;s:57:“Enddate / -time of the meeting, eg. for more then one day”;s:4:“span”;s:9:",end\_hide";}}}i:4;a:2:{s:1:“A”;a:2:{s:4:“type”;s:5:“label”;s:5:“label”;s:9:“Timeframe”;}s:1:“B”;a:7:{s:4:“type”;s:4:“hbox”;s:4:“size”;s:1:“5”;i:1;a:3:{s:4:“type”;s:13:“date-houronly”;s:4:“name”;s:10:“start\_time”;s:4:“help”;s:19:“Timeframe to search”;}i:2;a:2:{s:4:“type”;s:5:“label”;s:5:“label”;s:3:“til”;}i:3;a:3:{s:4:“type”;s:13:“date-houronly”;s:4:“name”;s:8:“end\_time”;s:4:“help”;s:19:“Timeframe to search”;}i:4;a:2:{s:4:“type”;s:5:“label”;s:5:“label”;s:8:“Weekdays”;}i:5;a:4:{s:4:“type”;s:10:“select-dow”;s:4:“size”;s:1:“3”;s:4:“name”;s:8:“weekdays”;s:4:“help”;s:25:“Weekdays to use in search”;}}}i:5;a:2:{s:1:“A”;a:4:{s:4:“type”;s:6:“button”;s:5:“label”;s:10:“New search”;s:4:“name”;s:6:“search”;s:4:“help”;s:36:“new search with the above parameters”;}s:1:“B”;a:4:{s:4:“type”;s:4:“hbox”;s:4:“size”  
;s:1:“2”;i:1;a:4:{s:4:“type”;s:6:“select”;s:7:“no\_lang”;s:1:“1”;s:4:“name”;s:13:“search\_window”;s:4:“help”;s:34:“how far to search (from startdate)”;}i:2;a:5:{s:4:“type”;s:6:“button”;s:4:“name”;s:6:“cancel”;s:5:“label”;s:6:“Cancel”;s:4:“help”;s:16:“Close the window”;s:7:“onclick”;s:15:“window.close();”;}}}i:6;a:2:{s:1:“A”;a:4:{s:4:“type”;s:8:“template”;s:4:“size”;s:8:“freetime”;s:4:“span”;s:3:“all”;s:4:“name”;s:4:“rows”;}s:1:“B”;a:1:{s:4:“type”;s:5:“label”;}}}s:4:“rows”;i:6;s:4:“cols”;i:2;}}’,‘size’ =\> ‘’,‘style’ =\> ‘.size120b { text-size: 120%; font-weight: bold; }  
.redItalic { color: red; font-style: italic; }  
.end\_hide { visibility: hidden; }’,‘modified’ =\> ‘1149297367’,);

* * *

Beautiful is writing same markup. Internet Explorer 9 supports  
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.  
Spend less time writing and rewriting code and more time creating great  
experiences on the web. Be a part of the beta today.  
[http://p.sf.net/sfu/beautyoftheweb](http://p.sf.net/sfu/beautyoftheweb)

* * *

eGroupWare-cvs mailing list  
[eGroupWare-cvs@lists.sourceforge.net](mailto:eGroupWare-cvs@lists.sourceforge.net)  
[https://lists.sourceforge.net/lists/listinfo/egroupware-cvs](https://lists.sourceforge.net/lists/listinfo/egroupware-cvs)
