[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare - ICal Calendar * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * Created by Mark Peters <skeeter@phpgroupware.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, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | if (isset($GLOBALS['phpgw_info']['flags']['included_classes']['calendar_']) && |
---|
| 15 | $GLOBALS['phpgw_info']['flags']['included_classes']['calendar_'] == True) |
---|
| 16 | { |
---|
| 17 | return; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | $GLOBALS['phpgw_info']['flags']['included_classes']['calendar_'] = True; |
---|
| 21 | |
---|
| 22 | class calendar_ extends calendar__ |
---|
| 23 | { |
---|
| 24 | function open($calendar='',$user='',$passwd='',$options='') |
---|
| 25 | { |
---|
| 26 | if($user=='') |
---|
| 27 | { |
---|
| 28 | $user = $GLOBALS['phpgw_info']['user']['account_lid']; |
---|
| 29 | } |
---|
| 30 | elseif(is_int($user)) |
---|
| 31 | { |
---|
| 32 | $this->user = $GLOBALS['phpgw']->accounts->id2name($user); |
---|
| 33 | } |
---|
| 34 | elseif(is_string($user)) |
---|
| 35 | { |
---|
| 36 | $this->user = $user; |
---|
| 37 | } |
---|
| 38 | if($options != '') |
---|
| 39 | { |
---|
| 40 | $this->stream = mcal_open('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd,$options); |
---|
| 41 | } |
---|
| 42 | else |
---|
| 43 | { |
---|
| 44 | $this->stream = mcal_open('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | function popen($calendar='',$user='',$passwd='',$options='') |
---|
| 49 | { |
---|
| 50 | if($user=='') |
---|
| 51 | { |
---|
| 52 | $this->user = $GLOBALS['phpgw_info']['user']['account_lid']; |
---|
| 53 | } |
---|
| 54 | elseif(is_int($user)) |
---|
| 55 | { |
---|
| 56 | $this->user = $GLOBALS['phpgw']->accounts->id2name($user); |
---|
| 57 | } |
---|
| 58 | elseif(is_string($user)) |
---|
| 59 | { |
---|
| 60 | $this->user = $user; |
---|
| 61 | } |
---|
| 62 | if($options != '') |
---|
| 63 | { |
---|
| 64 | $this->stream = mcal_popen('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd,$options); |
---|
| 65 | } |
---|
| 66 | else |
---|
| 67 | { |
---|
| 68 | $this->stream = mcal_popen('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd); |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | function reopen($calendar,$options='') |
---|
| 73 | { |
---|
| 74 | if($options != '') |
---|
| 75 | { |
---|
| 76 | $this->stream = mcal_reopen($calendar,$options); |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | $this->stream = mcal_reopen($calendar); |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | function close($options='') |
---|
| 85 | { |
---|
| 86 | if($options != '') |
---|
| 87 | { |
---|
| 88 | return mcal_close($this->stream,$options); |
---|
| 89 | } |
---|
| 90 | else |
---|
| 91 | { |
---|
| 92 | return mcal_close($this->stream); |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | function create_calendar($calendar) |
---|
| 97 | { |
---|
| 98 | return mcal_create_calendar($this->stream,$calendar); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | function rename_calendar($old_name,$new_name) |
---|
| 102 | { |
---|
| 103 | return mcal_rename_calendar($this->stream,$old_name,$new_name); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | function delete_calendar($calendar) |
---|
| 107 | { |
---|
| 108 | return mcal_delete_calendar($this->stream,$calendar); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | function fetch_event($event_id,$options='') |
---|
| 112 | { |
---|
| 113 | if(!isset($this->stream)) |
---|
| 114 | { |
---|
| 115 | return False; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | $this->event = CreateObject('calendar.calendar_item'); |
---|
| 119 | |
---|
| 120 | if($options != '') |
---|
| 121 | { |
---|
| 122 | $this->event = mcal_fetch_event($this->stream,$event_id,$options); |
---|
| 123 | } |
---|
| 124 | else |
---|
| 125 | { |
---|
| 126 | $this->event = mcal_fetch_event($this->stream,$event_id); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | // Need to load the $this->event variable with the $event structure from |
---|
| 130 | // the mcal_fetch_event() call |
---|
| 131 | // Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference |
---|
| 132 | // This only needs legacy support |
---|
| 133 | |
---|
| 134 | return $this->event; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | function list_events($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='') |
---|
| 138 | { |
---|
| 139 | if($endYear != '' && $endMonth != '' && $endDay != '') |
---|
| 140 | { |
---|
| 141 | $events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay,$endYear,$endMonth,$endYear); |
---|
| 142 | } |
---|
| 143 | else |
---|
| 144 | { |
---|
| 145 | $events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | return $events; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | function append_event() |
---|
| 152 | { |
---|
| 153 | return mcal_append_event($this->stream); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | function store_event() |
---|
| 157 | { |
---|
| 158 | return mcal_store_event($this->stream); |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | function delete_event($event_id) |
---|
| 162 | { |
---|
| 163 | return mcal_delete_event($this->stream,$event_id); |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | function snooze($event_id) |
---|
| 167 | { |
---|
| 168 | return mcal_snooze($this->stream,$event_id); |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') |
---|
| 172 | { |
---|
| 173 | if($end_day == '') |
---|
| 174 | { |
---|
| 175 | if($end_month == '') |
---|
| 176 | { |
---|
| 177 | if($end_year == '') |
---|
| 178 | { |
---|
| 179 | if($begin_day == '') |
---|
| 180 | { |
---|
| 181 | if($begin_month == '') |
---|
| 182 | { |
---|
| 183 | if($begin_year == '') |
---|
| 184 | { |
---|
| 185 | return mcal_list_alarms($this->stream); |
---|
| 186 | } |
---|
| 187 | else |
---|
| 188 | { |
---|
| 189 | return mcal_list_alarms($this->stream,$begin_year); |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | else |
---|
| 193 | { |
---|
| 194 | return mcal_list_alarms($this->stream,$begin_year,$begin_month); |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | else |
---|
| 198 | { |
---|
| 199 | return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day); |
---|
| 200 | } |
---|
| 201 | } |
---|
| 202 | else |
---|
| 203 | { |
---|
| 204 | return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year); |
---|
| 205 | } |
---|
| 206 | } |
---|
| 207 | else |
---|
| 208 | { |
---|
| 209 | return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month); |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | else |
---|
| 213 | { |
---|
| 214 | return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month,$end_day); |
---|
| 215 | } |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | function event_init() |
---|
| 219 | { |
---|
| 220 | $this->event = CreateObject('calendar.calendar_item'); |
---|
| 221 | return mcal_event_init($this->stream); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | function set_category($category='') |
---|
| 225 | { |
---|
| 226 | calendar__::set_category($category); |
---|
| 227 | return mcal_event_set_category($this->stream,$category); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | function set_title($title='') |
---|
| 231 | { |
---|
| 232 | calendar__::set_title($title); |
---|
| 233 | return mcal_event_set_title($this->stream,$title); |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | function set_description($description='') |
---|
| 237 | { |
---|
| 238 | calendar__::set_description($description); |
---|
| 239 | return mcal_event_set_description($this->stream,$description); |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | function set_ex_participants($ex_participants='') |
---|
| 243 | { |
---|
| 244 | calendar__::set_ex_participants($ex_participants); |
---|
| 245 | return mcal_event_set_ex_participants($this->stream,$ex_participants); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0) |
---|
| 249 | { |
---|
| 250 | calendar__::set_start($year,$month,$day,$hour,$min,$sec); |
---|
| 251 | return mcal_event_set_start($this->stream,$year,$month,$day,$hour,$min,$sec); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0) |
---|
| 255 | { |
---|
| 256 | calendar__::set_end($year,$month,$day,$hour,$min,$sec); |
---|
| 257 | return mcal_event_set_end($this->stream,$year,$month,$day,$hour,$min,$sec); |
---|
| 258 | } |
---|
| 259 | |
---|
| 260 | function set_alarm($alarm) |
---|
| 261 | { |
---|
| 262 | calendar__::set_alarm($alarm); |
---|
| 263 | return mcal_event_set_alarm ($this->stream,$alarm); |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | function set_class($class) |
---|
| 267 | { |
---|
| 268 | calendar__::set_class($class); |
---|
| 269 | return mcal_event_set_class($this->stream,$class); |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | // The function definition doesn't look correct... |
---|
| 273 | // Need more information for this function |
---|
| 274 | function next_recurrence($weekstart,$next) |
---|
| 275 | { |
---|
| 276 | return mcal_next_recurrence($this->stream,$weekstart,$next); |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | function set_recur_none() |
---|
| 280 | { |
---|
| 281 | calendar__::set_recur_none(); |
---|
| 282 | return mcal_event_set_recur_none($this->stream); |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | function set_recur_daily($year,$month,$day,$interval) |
---|
| 286 | { |
---|
| 287 | calendar__::set_recur_daily($year,$month,$day,$interval); |
---|
| 288 | return mcal_event_set_recur_daily($this->stream,$year,$month,$day,$interval); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | function set_recur_weekly($year,$month,$day,$interval,$weekdays) |
---|
| 292 | { |
---|
| 293 | calendar__::set_recur_weekly($year,$month,$day,$interval,$weekdays); |
---|
| 294 | return mcal_event_set_recur_weekly($this->stream,$year,$month,$day,$interval,$weekdays); |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | function set_recur_monthly_mday($year,$month,$day,$interval) |
---|
| 298 | { |
---|
| 299 | calendar__::set_recur_monthly_mday($year,$month,$day,$interval); |
---|
| 300 | return mcal_event_set_recur_monthly_mday($this->stream,$year,$month,$day,$interval); |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | function set_recur_monthly_wday($year,$month,$day,$interval) |
---|
| 304 | { |
---|
| 305 | calendar__::set_recur_monthly_wday($year,$month,$day,$interval); |
---|
| 306 | return mcal_event_set_recur_monthly_wday($this->stream,$year,$month,$day,$interval); |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | function set_recur_yearly($year,$month,$day,$interval) |
---|
| 310 | { |
---|
| 311 | calendar__::set_recur_yearly($year,$month,$day,$interval); |
---|
| 312 | return mcal_event_set_recur_yearly($this->stream,$year,$month,$day,$interval); |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | function fetch_current_stream_event() |
---|
| 316 | { |
---|
| 317 | $this->event = mcal_fetch_current_stream_event($this->stream); |
---|
| 318 | return $this->event; |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | function add_attribute($attribute,$value) |
---|
| 322 | { |
---|
| 323 | calendar__::add_attribute($attribute,$value); |
---|
| 324 | return mcal_event_add_attribute($this->stream,$attribute,$value); |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | function expunge() |
---|
| 328 | { |
---|
| 329 | return mcal_expunge($this->stream); |
---|
| 330 | } |
---|
| 331 | |
---|
| 332 | /**************** Local functions for ICAL based Calendar *****************/ |
---|
| 333 | |
---|
| 334 | function set_status($id,$owner,$status) |
---|
| 335 | { |
---|
| 336 | $status_code_short = Array( |
---|
| 337 | REJECTED => 'R', |
---|
| 338 | NO_RESPONSE => 'U', |
---|
| 339 | TENTATIVE => 'T', |
---|
| 340 | ACCEPTED => 'A' |
---|
| 341 | ); |
---|
| 342 | $this->add_attribute('status['.$owner.']',$status_code_short[$status]); |
---|
| 343 | // $this->stream->query("UPDATE calendar_entry_user SET cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND cal_login=".$owner,__LINE__,__FILE__); |
---|
| 344 | return True; |
---|
| 345 | } |
---|
| 346 | } |
---|