| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - iCalendar Parser * 4 * http://www.egroupware.org * 5 * Written by Lars Kneschke <lkneschke@egroupware.org> * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License. * 10 \**************************************************************************/ 11 12 /* $Id: class.vcalinfolog.inc.php 22339 2006-08-24 09:48:38Z lkneschke $ */ 13 14 require_once EGW_SERVER_ROOT.'/infolog/inc/class.boinfolog.inc.php'; 15 require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar.php'; 16 17 class vcalinfolog extends boinfolog 18 { 19 var $status2vtodo = array( 20 'offer' => 'NEEDS-ACTION', 21 'not-started' => 'NEEDS-ACTION', 22 'ongoing' => 'IN-PROCESS', 23 'done' => 'COMPLETED', 24 'cancelled' => 'CANCELLED', 25 'billed' => 'DONE', 26 'call' => 'NEEDS-ACTION', 27 'will-call' => 'IN-PROCESS', 28 ); 29 var $vtodo2status = array( 30 'NEEDS-ACTION' => 'not-started', 31 'IN-PROCESS' => 'ongoing', 32 'COMPLETED' => 'done', 33 'CANCELLED' => 'cancelled', 34 ); 35 var $egw_priority2vcal_priority = array( 36 0 => 3, 37 1 => 2, 38 2 => 1, 39 3 => 1, 40 41 ); 42 var $vcal_priority2egw_priority = array( 43 1 => 2, 44 2 => 1, 45 3 => 0, 46 ); 47 function exportVTODO($_taskID, $_version) 48 { 49 $taskData = $this->read($_taskID); 50 51 $taskData = $GLOBALS['egw']->translation->convert($taskData,$GLOBALS['egw']->translation->charset(),'UTF-8'); 52 53 //_debug_array($taskData); 54 55 $taskGUID = $GLOBALS['phpgw']->common->generate_uid('infolog_task',$_taskID); 56 #print "<br>"; 57 #print $GLOBALS['phpgw']->contenthistory->getTSforAction($eventGUID,'add'); 58 #print "<br>"; 59 60 $vcal = &new Horde_iCalendar; 61 $vcal->setAttribute('VERSION',$_version); 62 $vcal->setAttribute('METHOD','PUBLISH'); 63 64 $vevent = Horde_iCalendar::newComponent('VTODO',$vcal); 65 66 $options = array(); 67 68 $vevent->setAttribute('SUMMARY',$taskData['info_subject']); 69 $vevent->setAttribute('DESCRIPTION',$taskData['info_des']); 70 $vevent->setAttribute('LOCATION',$taskData['info_location']); 71 if($taskData['info_startdate']) 72 $vevent->setAttribute('DTSTART',$taskData['info_startdate']); 73 if($taskData['info_enddate']) 74 $vevent->setAttribute('DUE',$taskData['info_enddate']); 75 if($taskData['info_datecompleted']) 76 $vevent->setAttribute('COMPLETED',$taskData['info_datecompleted']); 77 $vevent->setAttribute('DTSTAMP',time()); 78 $vevent->setAttribute('CREATED',$GLOBALS['phpgw']->contenthistory->getTSforAction($eventGUID,'add')); 79 $vevent->setAttribute('LAST-MODIFIED',$GLOBALS['phpgw']->contenthistory->getTSforAction($eventGUID,'modify')); 80 $vevent->setAttribute('UID',$taskGUID); 81 $vevent->setAttribute('CLASS',$taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE'); 82 $vevent->setAttribute('STATUS',isset($this->status2vtodo[$taskData['info_status']]) ? 83 $this->status2vtodo[$taskData['info_status']] : 'NEEDS-ACTION'); 84 $vevent->setAttribute('PRIORITY',$this->egw_priority2vcal_priority[$taskData['info_priority']]); 85 86 #$vevent->setAttribute('TRANSP','OPAQUE'); 87 # status 88 # ATTENDEE 89 90 $options = array('CHARSET' => 'UTF-8','ENCODING' => 'QUOTED-PRINTABLE'); 91 $vevent->setParameter('SUMMARY', $options); 92 $vevent->setParameter('DESCRIPTION', $options); 93 94 $vcal->addComponent($vevent); 95 96 #print "<pre>"; 97 #print $vcal->exportvCalendar(); 98 #print "</pre>"; 99 100 return $vcal->exportvCalendar(); 101 } 102 103 function importVTODO(&$_vcalData, $_taskID=-1) 104 { 105 if(!$taskData = $this->vtodotoegw($_vcalData)) { 106 return false; 107 } 108 109 if($_taskID>0) 110 $taskData['info_id'] = $_taskID; 111 112 #_debug_array($taskData);exit; 113 return $this->write($taskData); 114 } 115 116 function searchVTODO($_vcalData) { 117 if(!$egwData = $this->vtodotoegw($_vcalData)) { 118 return false; 119 } 120 121 $filter = array('col_filter' => $egwData); 122 if($foundItems = $this->search($filter)) { 123 if(count($foundItems) > 0) { 124 #error_log(__LINE__); 125 #error_log(print_r($foundItems, true)); 126 $itemIDs = array_keys($foundItems); 127 #error_log($itemIDs[0]); 128 return $itemIDs[0]; 129 } 130 } 131 132 return false; 133 } 134 function vtodotoegw($_vcalData) { 135 $vcal = &new Horde_iCalendar; 136 if(!$vcal->parsevCalendar($_vcalData)) 137 { 138 return FALSE; 139 } 140 141 $components = $vcal->getComponents(); 142 143 if(count($components) > 0) 144 { 145 $component = $components[0]; 146 if(is_a($component, 'Horde_iCalendar_vtodo')) 147 { 148 if($_taskID>0) 149 $taskData['info_id'] = $_taskID; 150 151 foreach($component->_attributes as $attributes) 152 { 153 #print $attributes['name'].' - '.$attributes['value'].'<br>'; 154 switch($attributes['name']) 155 { 156 case 'CLASS': 157 $taskData['info_access'] = strtolower($attributes['value']); 158 break; 159 case 'DESCRIPTION': 160 $taskData['info_des'] = $attributes['value']; 161 break; 162 case 'LOCATION': 163 $taskData['info_location'] = $attributes['value']; 164 break; 165 case 'DUE': 166 $taskData['info_enddate'] = $attributes['value']; 167 break; 168 case 'COMPLETED': 169 $taskData['info_datecompleted'] = $attributes['value']; 170 break; 171 case 'DTSTART': 172 $taskData['info_startdate'] = $attributes['value']; 173 break; 174 case 'PRIORITY': 175 if (1 <= $attributes['value'] && $attributes['value'] <= 3) 176 { 177 $taskData['info_priority'] = $this->vcal_priority2egw_priority[$attributes['value']]; 178 } 179 else 180 { 181 $taskData['info_priority'] = 1; // default = normal 182 } 183 break; 184 case 'STATUS': 185 $taskData['info_status'] = isset($this->vtodo2status[strtoupper($attributes['value'])]) ? 186 $this->vtodo2status[strtoupper($attributes['value'])] : 'ongoing'; 187 break; 188 case 'SUMMARY': 189 $taskData['info_subject'] = $attributes['value']; 190 break; 191 } 192 } 193 return $taskData; 194 } 195 } 196 return FALSE; 197 } 198 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |