Changeset 5132 for trunk/calendar/inc/class.boicalendar.inc.php
- Timestamp:
- 11/03/11 13:21:19 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/calendar/inc/class.boicalendar.inc.php
r3736 r5132 1 1 <?php 2 /**************************************************************************\ 3 * eGroupWare - iCalendar Parser * 4 * http://www.egroupware.org * 5 * Written 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 define('FOLD_LENGTH',75); 15 16 define('VEVENT',1); 17 define('VTODO',2); 18 19 define('NONE',0); 20 define('CHAIR',1); 21 define('REQ_PARTICIPANT',2); 22 define('OPT_PARTICIPANT',3); 23 define('NON_PARTICIPANT',4); 24 25 define('INDIVIDUAL',1); 26 define('GROUP',2); 27 define('RESOURCE',4); 28 define('ROOM',8); 29 define('UNKNOWN',16); 30 31 define('NEEDS_ACTION',0); 32 define('ACCEPTED',1); 33 define('DECLINED',2); 34 define('TENTATIVE',3); 35 define('DELEGATED',4); 36 define('COMPLETED',5); 37 define('IN_PROCESS',6); 38 39 /* 40 * Class 41 */ 42 define('_PRIVATE',0); 43 define('_PUBLIC',1); 44 define('_CONFIDENTIAL',3); 45 46 /* 47 * Transparency 48 */ 49 define('TRANSPARENT',0); 50 define('OPAQUE',1); 51 52 /* 53 * Frequency 54 */ 55 define('SECONDLY',1); 56 define('MINUTELY',2); 57 define('HOURLY',3); 58 define('DAILY',4); 59 define('WEEKLY',5); 60 define('MONTHLY',6); 61 define('YEARLY',7); 62 63 define('FREE',0); 64 define('BUSY',1); 65 define('BUSY_UNAVAILABLE',2); 66 define('BUSY_TENTATIVE',3); 67 68 define('THISANDPRIOR',0); 69 define('THISANDFUTURE',1); 70 71 define('START',0); 72 define('END',1); 73 74 define('_8BIT',0); 75 define('_BASE64',1); 76 77 define('OTHER',99); 78 79 class boicalendar 80 { 81 var $public_functions = array( 2 3 /**************************************************************************\ 4 * eGroupWare - iCalendar Parser * 5 * http://www.egroupware.org * 6 * Written by Mark Peters <skeeter@phpgroupware.org> * 7 * -------------------------------------------- * 8 * This program is free software; you can redistribute it and/or modify it * 9 * under the terms of the GNU General Public License as published by the * 10 * Free Software Foundation; either version 2 of the License, or (at your * 11 * option) any later version. * 12 \**************************************************************************/ 13 14 define('FOLD_LENGTH', 75); 15 16 define('VEVENT', 1); 17 define('VTODO', 2); 18 19 define('NONE', 0); 20 define('CHAIR', 1); 21 define('REQ_PARTICIPANT', 2); 22 define('OPT_PARTICIPANT', 3); 23 define('NON_PARTICIPANT', 4); 24 25 define('INDIVIDUAL', 1); 26 define('GROUP', 2); 27 define('RESOURCE', 4); 28 define('ROOM', 8); 29 define('UNKNOWN', 16); 30 31 define('NEEDS_ACTION', 0); 32 define('ACCEPTED', 1); 33 define('DECLINED', 2); 34 define('TENTATIVE', 3); 35 define('DELEGATED', 4); 36 define('COMPLETED', 5); 37 define('IN_PROCESS', 6); 38 39 /* 40 * Class 41 */ 42 define('_PRIVATE', 0); 43 define('_PUBLIC', 1); 44 define('_CONFIDENTIAL', 3); 45 46 /* 47 * Transparency 48 */ 49 define('TRANSPARENT', 0); 50 define('OPAQUE', 1); 51 52 /* 53 * Frequency 54 */ 55 define('SECONDLY', 1); 56 define('MINUTELY', 2); 57 define('HOURLY', 3); 58 define('DAILY', 4); 59 define('WEEKLY', 5); 60 define('MONTHLY', 6); 61 define('YEARLY', 7); 62 63 define('FREE', 0); 64 define('BUSY', 1); 65 define('BUSY_UNAVAILABLE', 2); 66 define('BUSY_TENTATIVE', 3); 67 68 define('THISANDPRIOR', 0); 69 define('THISANDFUTURE', 1); 70 71 define('START', 0); 72 define('END', 1); 73 74 define('_8BIT', 0); 75 define('_BASE64', 1); 76 77 define('OTHER', 99); 78 79 class boicalendar { 80 var $public_functions = array ( 82 81 'import' => True, 83 82 'export' => True, … … 87 86 var $ical; 88 87 var $line = 0; 89 var $event = Array();90 var $todo = Array();91 var $journal = Array();92 var $freebusy = Array();93 var $timezone = Array();94 var $property = Array();95 var $parameter = Array();88 var $event = Array (); 89 var $todo = Array (); 90 var $journal = Array (); 91 var $freebusy = Array (); 92 var $timezone = Array (); 93 var $property = Array (); 94 var $parameter = Array (); 96 95 var $debug_str = False; 97 96 var $api = True; … … 102 101 */ 103 102 104 function boicalendar() 105 { 106 $this->property = Array( 107 'action' => Array( 103 function boicalendar() { 104 $this->property = Array ( 105 'action' => Array ( 108 106 'type' => 'text', 109 107 'to_text' => True, 110 'valarm' => Array(108 'valarm' => Array ( 111 109 'state' => 'required', 112 110 'multiples' => False 113 111 ) 114 112 ), 115 'attach' => Array(113 'attach' => Array ( 116 114 'type' => 'uri', 117 115 'to_text' => True, 118 'vevent' => Array(119 'state' => 'optional', 120 'multiples' => True 121 ), 122 'vtodo' => Array(123 'state' => 'optional', 124 'multiples' => True 125 ), 126 'vjournal' => Array(127 'state' => 'optional', 128 'multiples' => True 129 ), 130 'valarm' => Array(131 'state' => 'optional', 132 'multiples' => True 133 ) 134 ), 135 'attendee' => Array(116 'vevent' => Array ( 117 'state' => 'optional', 118 'multiples' => True 119 ), 120 'vtodo' => Array ( 121 'state' => 'optional', 122 'multiples' => True 123 ), 124 'vjournal' => Array ( 125 'state' => 'optional', 126 'multiples' => True 127 ), 128 'valarm' => Array ( 129 'state' => 'optional', 130 'multiples' => True 131 ) 132 ), 133 'attendee' => Array ( 136 134 'type' => 'cal-address', 137 135 'to_text' => False, 138 'vevent' => Array(139 'state' => 'optional', 140 'multiples' => True 141 ), 142 'vtodo' => Array(143 'state' => 'optional', 144 'multiples' => True 145 ), 146 'vjournal' => Array(147 'state' => 'optional', 148 'multiples' => True 149 ), 150 'valarm' => Array(151 'state' => 'optional', 152 'multiples' => True 153 ), 154 'vfreebusy' => Array(155 'state' => 'optional', 156 'multiples' => True 157 ) 158 ), 159 'categories' => Array(136 'vevent' => Array ( 137 'state' => 'optional', 138 'multiples' => True 139 ), 140 'vtodo' => Array ( 141 'state' => 'optional', 142 'multiples' => True 143 ), 144 'vjournal' => Array ( 145 'state' => 'optional', 146 'multiples' => True 147 ), 148 'valarm' => Array ( 149 'state' => 'optional', 150 'multiples' => True 151 ), 152 'vfreebusy' => Array ( 153 'state' => 'optional', 154 'multiples' => True 155 ) 156 ), 157 'categories' => Array ( 160 158 'type' => 'text', 161 159 'to_text' => True, 162 'vevent' => Array(163 'state' => 'optional', 164 'multiples' => True 165 ), 166 'vtodo' => Array(167 'state' => 'optional', 168 'multiples' => False 169 ), 170 'vjournal' => Array(171 'state' => 'optional', 172 'multiples' => True 173 ) 174 ), 175 'class' => Array(160 'vevent' => Array ( 161 'state' => 'optional', 162 'multiples' => True 163 ), 164 'vtodo' => Array ( 165 'state' => 'optional', 166 'multiples' => False 167 ), 168 'vjournal' => Array ( 169 'state' => 'optional', 170 'multiples' => True 171 ) 172 ), 173 'class' => Array ( 176 174 'type' => 'text', 177 175 'to_text' => True, 178 'vevent' => Array(179 'state' => 'optional', 180 'multiples' => False 181 ), 182 'vtodo' => Array(183 'state' => 'optional', 184 'multiples' => False 185 ), 186 'vjournal' => Array(187 'state' => 'optional', 188 'multiples' => False 189 ) 190 ), 191 'comment' => Array(176 'vevent' => Array ( 177 'state' => 'optional', 178 'multiples' => False 179 ), 180 'vtodo' => Array ( 181 'state' => 'optional', 182 'multiples' => False 183 ), 184 'vjournal' => Array ( 185 'state' => 'optional', 186 'multiples' => False 187 ) 188 ), 189 'comment' => Array ( 192 190 'type' => 'text', 193 191 'to_text' => True, 194 'daylight' => Array(195 'state' => 'optional', 196 'multiples' => True 197 ), 198 'standard' => Array(199 'state' => 'optional', 200 'multiples' => True 201 ), 202 'valarm' => Array(203 'state' => 'optional', 204 'multiples' => True 205 ), 206 'vevent' => Array(207 'state' => 'optional', 208 'multiples' => True 209 ), 210 'vfreebusy' => Array(211 'state' => 'optional', 212 'multiples' => True 213 ), 214 'vjournal' => Array(215 'state' => 'optional', 216 'multiples' => True 217 ), 218 'vtodo' => Array(219 'state' => 'optional', 220 'multiples' => True 221 ) 222 ), 223 'completed' => Array(192 'daylight' => Array ( 193 'state' => 'optional', 194 'multiples' => True 195 ), 196 'standard' => Array ( 197 'state' => 'optional', 198 'multiples' => True 199 ), 200 'valarm' => Array ( 201 'state' => 'optional', 202 'multiples' => True 203 ), 204 'vevent' => Array ( 205 'state' => 'optional', 206 'multiples' => True 207 ), 208 'vfreebusy' => Array ( 209 'state' => 'optional', 210 'multiples' => True 211 ), 212 'vjournal' => Array ( 213 'state' => 'optional', 214 'multiples' => True 215 ), 216 'vtodo' => Array ( 217 'state' => 'optional', 218 'multiples' => True 219 ) 220 ), 221 'completed' => Array ( 224 222 'type' => 'date-time', 225 223 'to_text' => False, 226 'vtodo' => Array(227 'state' => 'optional', 228 'multiples' => False 229 ) 230 ), 231 'contact' => Array(224 'vtodo' => Array ( 225 'state' => 'optional', 226 'multiples' => False 227 ) 228 ), 229 'contact' => Array ( 232 230 'type' => 'text', 233 231 'to_text' => True, 234 'vevent' => Array(235 'state' => 'optional', 236 'multiples' => True 237 ), 238 'vfreebusy' => Array(239 'state' => 'optional', 240 'multiples' => False 241 ), 242 'vjournal' => Array(243 'state' => 'optional', 244 'multiples' => True 245 ) 246 ), 247 'created' => Array(232 'vevent' => Array ( 233 'state' => 'optional', 234 'multiples' => True 235 ), 236 'vfreebusy' => Array ( 237 'state' => 'optional', 238 'multiples' => False 239 ), 240 'vjournal' => Array ( 241 'state' => 'optional', 242 'multiples' => True 243 ) 244 ), 245 'created' => Array ( 248 246 'type' => 'date-time', 249 247 'to_text' => False, 250 'vevent' => Array(251 'state' => 'optional', 252 'multiples' => False 253 ), 254 'vtodo' => Array(255 'state' => 'optional', 256 'multiples' => False 257 ), 258 'vjournal' => Array(259 'state' => 'optional', 260 'multiples' => False 261 ) 262 ), 263 'description' => Array(248 'vevent' => Array ( 249 'state' => 'optional', 250 'multiples' => False 251 ), 252 'vtodo' => Array ( 253 'state' => 'optional', 254 'multiples' => False 255 ), 256 'vjournal' => Array ( 257 'state' => 'optional', 258 'multiples' => False 259 ) 260 ), 261 'description' => Array ( 264 262 'type' => 'text', 265 263 'to_text' => True, 266 'vevent' => Array(267 'state' => 'optional', 268 'multiples' => False 269 ), 270 'vtodo' => Array(271 'state' => 'optional', 272 'multiples' => False 273 ), 274 'vjournal' => Array(275 'state' => 'optional', 276 'multiples' => True 277 ), 278 'valarm' => Array(279 'state' => 'optional', 280 'multiples' => False 281 ) 282 ), 283 'dtend' => Array(264 'vevent' => Array ( 265 'state' => 'optional', 266 'multiples' => False 267 ), 268 'vtodo' => Array ( 269 'state' => 'optional', 270 'multiples' => False 271 ), 272 'vjournal' => Array ( 273 'state' => 'optional', 274 'multiples' => True 275 ), 276 'valarm' => Array ( 277 'state' => 'optional', 278 'multiples' => False 279 ) 280 ), 281 'dtend' => Array ( 284 282 'type' => 'date-time', 285 283 'to_text' => False, 286 'vevent' => Array(287 'state' => 'optional', 288 'multiples' => False 289 ), 290 'vfreebusy' => Array(291 'state' => 'optional', 292 'multiples' => False 293 ) 294 ), 295 'dtstamp' => Array(284 'vevent' => Array ( 285 'state' => 'optional', 286 'multiples' => False 287 ), 288 'vfreebusy' => Array ( 289 'state' => 'optional', 290 'multiples' => False 291 ) 292 ), 293 'dtstamp' => Array ( 296 294 'type' => 'date-time', 297 295 'to_text' => False, 298 'vevent' => Array(299 'state' => 'optional', 300 'multiples' => False 301 ), 302 'vtodo' => Array(303 'state' => 'optional', 304 'multiples' => False 305 ), 306 'vjournal' => Array(307 'state' => 'optional', 308 'multiples' => True 309 ), 310 'vfreebusy' => Array(311 'state' => 'optional', 312 'multiples' => False 313 ) 314 ), 315 'dtstart' => Array(296 'vevent' => Array ( 297 'state' => 'optional', 298 'multiples' => False 299 ), 300 'vtodo' => Array ( 301 'state' => 'optional', 302 'multiples' => False 303 ), 304 'vjournal' => Array ( 305 'state' => 'optional', 306 'multiples' => True 307 ), 308 'vfreebusy' => Array ( 309 'state' => 'optional', 310 'multiples' => False 311 ) 312 ), 313 'dtstart' => Array ( 316 314 'type' => 'date-time', 317 315 'to_text' => False, 318 'daylight' => Array(316 'daylight' => Array ( 319 317 'state' => 'required', 320 318 'multiples' => False 321 319 ), 322 'standard' => Array(320 'standard' => Array ( 323 321 'state' => 'required', 324 322 'multiples' => False 325 323 ), 326 'vevent' => Array(327 'state' => 'optional', 328 'multiples' => False 329 ), 330 'vfreebusy' => Array(331 'state' => 'optional', 332 'multiples' => False 333 ), 334 'vjournal' => Array(335 'state' => 'optional', 336 'multiples' => False 337 ), 338 'vtodo' => Array(339 'state' => 'optional', 340 'multiples' => False 341 ) 342 ), 343 'due' => Array(324 'vevent' => Array ( 325 'state' => 'optional', 326 'multiples' => False 327 ), 328 'vfreebusy' => Array ( 329 'state' => 'optional', 330 'multiples' => False 331 ), 332 'vjournal' => Array ( 333 'state' => 'optional', 334 'multiples' => False 335 ), 336 'vtodo' => Array ( 337 'state' => 'optional', 338 'multiples' => False 339 ) 340 ), 341 'due' => Array ( 344 342 'type' => 'date-time', 345 343 'to_text' => False, 346 'vtodo' => Array(347 'state' => 'optional', 348 'multiples' => False 349 ) 350 ), 351 'duration' => Array(344 'vtodo' => Array ( 345 'state' => 'optional', 346 'multiples' => False 347 ) 348 ), 349 'duration' => Array ( 352 350 'type' => 'duration', 353 351 'to_text' => False, 354 'valarm' => Array(355 'state' => 'optional', 356 'multiples' => False 357 ), 358 'vevent' => Array(359 'state' => 'optional', 360 'multiples' => False 361 ), 362 'vfreebusy' => Array(363 'state' => 'optional', 364 'multiples' => False 365 ), 366 'vtodo' => Array(367 'state' => 'optional', 368 'multiples' => False 369 ) 370 ), 371 'exdate' => Array(352 'valarm' => Array ( 353 'state' => 'optional', 354 'multiples' => False 355 ), 356 'vevent' => Array ( 357 'state' => 'optional', 358 'multiples' => False 359 ), 360 'vfreebusy' => Array ( 361 'state' => 'optional', 362 'multiples' => False 363 ), 364 'vtodo' => Array ( 365 'state' => 'optional', 366 'multiples' => False 367 ) 368 ), 369 'exdate' => Array ( 372 370 'type' => 'date-time', 373 371 'to_text' => False, 374 'vevent' => Array(375 'state' => 'optional', 376 'multiples' => True 377 ), 378 'vjournal' => Array(379 'state' => 'optional', 380 'multiples' => True 381 ), 382 'vtodo' => Array(383 'state' => 'optional', 384 'multiples' => True 385 ) 386 ), 387 'exrule' => Array(372 'vevent' => Array ( 373 'state' => 'optional', 374 'multiples' => True 375 ), 376 'vjournal' => Array ( 377 'state' => 'optional', 378 'multiples' => True 379 ), 380 'vtodo' => Array ( 381 'state' => 'optional', 382 'multiples' => True 383 ) 384 ), 385 'exrule' => Array ( 388 386 'type' => 'recur', 389 387 'to_text' => False, 390 'vevent' => Array(391 'state' => 'optional', 392 'multiples' => True 393 ), 394 'vjournal' => Array(395 'state' => 'optional', 396 'multiples' => True 397 ), 398 'vtodo' => Array(399 'state' => 'optional', 400 'multiples' => True 401 ) 402 ), 403 'freebusy' => Array(388 'vevent' => Array ( 389 'state' => 'optional', 390 'multiples' => True 391 ), 392 'vjournal' => Array ( 393 'state' => 'optional', 394 'multiples' => True 395 ), 396 'vtodo' => Array ( 397 'state' => 'optional', 398 'multiples' => True 399 ) 400 ), 401 'freebusy' => Array ( 404 402 'type' => 'freebusy', 405 403 'to_text' => False, 406 'vfreebusy' => Array(407 'state' => 'optional', 408 'multiples' => True 409 ) 410 ), 411 'geo' => Array(404 'vfreebusy' => Array ( 405 'state' => 'optional', 406 'multiples' => True 407 ) 408 ), 409 'geo' => Array ( 412 410 'type' => 'float', 413 411 'to_text' => True, 414 'vevent' => Array(415 'state' => 'optional', 416 'multiples' => False 417 ), 418 'vtodo' => Array(419 'state' => 'optional', 420 'multiples' => False 421 ) 422 ), 423 'last_modified' => Array(412 'vevent' => Array ( 413 'state' => 'optional', 414 'multiples' => False 415 ), 416 'vtodo' => Array ( 417 'state' => 'optional', 418 'multiples' => False 419 ) 420 ), 421 'last_modified' => Array ( 424 422 'type' => 'date-time', 425 423 'to_text' => False, 426 'vevent' => Array(427 'state' => 'optional', 428 'multiples' => False 429 ), 430 'vtodo' => Array(431 'state' => 'optional', 432 'multiples' => False 433 ), 434 'vjournal' => Array(435 'state' => 'optional', 436 'multiples' => False 437 ), 438 'vtimezone' => Array(439 'state' => 'optional', 440 'multiples' => False 441 ) 442 ), 443 'location' => Array(424 'vevent' => Array ( 425 'state' => 'optional', 426 'multiples' => False 427 ), 428 'vtodo' => Array ( 429 'state' => 'optional', 430 'multiples' => False 431 ), 432 'vjournal' => Array ( 433 'state' => 'optional', 434 'multiples' => False 435 ), 436 'vtimezone' => Array ( 437 'state' => 'optional', 438 'multiples' => False 439 ) 440 ), 441 'location' => Array ( 444 442 'type' => 'text', 445 443 'to_text' => True, 446 'vevent' => Array(447 'state' => 'optional', 448 'multiples' => False 449 ), 450 'vtodo' => Array(451 'state' => 'optional', 452 'multiples' => False 453 ) 454 ), 455 'method' => Array(444 'vevent' => Array ( 445 'state' => 'optional', 446 'multiples' => False 447 ), 448 'vtodo' => Array ( 449 'state' => 'optional', 450 'multiples' => False 451 ) 452 ), 453 'method' => Array ( 456 454 'type' => 'text', 457 455 'to_text' => True, 458 'ical' => Array(456 'ical' => Array ( 459 457 'state' => 'required', 460 458 'multiples' => False 461 459 ) 462 460 ), 463 'organizer' => Array(461 'organizer' => Array ( 464 462 'type' => 'cal-address', 465 463 'to_text' => False, 466 'vevent' => Array(467 'state' => 'optional', 468 'multiples' => False 469 ), 470 'vtodo' => Array(471 'state' => 'optional', 472 'multiples' => False 473 ), 474 'vjournal' => Array(475 'state' => 'optional', 476 'multiples' => False 477 ), 478 'vfreebusy' => Array(479 'state' => 'optional', 480 'multiples' => False 481 ) 482 ), 483 'percent_complete' => Array(464 'vevent' => Array ( 465 'state' => 'optional', 466 'multiples' => False 467 ), 468 'vtodo' => Array ( 469 'state' => 'optional', 470 'multiples' => False 471 ), 472 'vjournal' => Array ( 473 'state' => 'optional', 474 'multiples' => False 475 ), 476 'vfreebusy' => Array ( 477 'state' => 'optional', 478 'multiples' => False 479 ) 480 ), 481 'percent_complete' => Array ( 484 482 'type' => 'integer', 485 483 'to_text' => False, 486 'vtodo' => Array(487 'state' => 'optional', 488 'multiples' => False 489 ) 490 ), 491 'priority' => Array(484 'vtodo' => Array ( 485 'state' => 'optional', 486 'multiples' => False 487 ) 488 ), 489 'priority' => Array ( 492 490 'type' => 'integer', 493 491 'to_text' => True, 494 'vevent' => Array(495 'state' => 'optional', 496 'multiples' => False 497 ), 498 'vtodo' => Array(499 'state' => 'optional', 500 'multiples' => False 501 ) 502 ), 503 'prodid' => Array(492 'vevent' => Array ( 493 'state' => 'optional', 494 'multiples' => False 495 ), 496 'vtodo' => Array ( 497 'state' => 'optional', 498 'multiples' => False 499 ) 500 ), 501 'prodid' => Array ( 504 502 'type' => 'text', 505 503 'to_text' => True, 506 'ical' => Array(504 'ical' => Array ( 507 505 'state' => 'required', 508 506 'multiples' => False 509 507 ) 510 508 ), 511 'rdate' => Array(509 'rdate' => Array ( 512 510 'type' => 'date-time', 513 511 'to_text' => False, 514 'daylight' => Array(515 'state' => 'optional', 516 'multiples' => True 517 ), 518 'standard' => Array(519 'state' => 'optional', 520 'multiples' => True 521 ), 522 'vevent' => Array(523 'state' => 'optional', 524 'multiples' => True 525 ), 526 'vtodo' => Array(527 'state' => 'optional', 528 'multiples' => True 529 ), 530 'vjournal' => Array(531 'state' => 'optional', 532 'multiples' => True 533 ) 534 ), 535 'recurrence_id' => Array(512 'daylight' => Array ( 513 'state' => 'optional', 514 'multiples' => True 515 ), 516 'standard' => Array ( 517 'state' => 'optional', 518 'multiples' => True 519 ), 520 'vevent' => Array ( 521 'state' => 'optional', 522 'multiples' => True 523 ), 524 'vtodo' => Array ( 525 'state' => 'optional', 526 'multiples' => True 527 ), 528 'vjournal' => Array ( 529 'state' => 'optional', 530 'multiples' => True 531 ) 532 ), 533 'recurrence_id' => Array ( 536 534 'type' => 'date-time', 537 535 'to_text' => False, 538 'vevent' => Array(539 'state' => 'optional', 540 'multiples' => False 541 ), 542 'vjournal' => Array(543 'state' => 'optional', 544 'multiples' => False 545 ), 546 'vtodo' => Array(547 'state' => 'optional', 548 'multiples' => False 549 ) 550 ), 551 'related_to' => Array(536 'vevent' => Array ( 537 'state' => 'optional', 538 'multiples' => False 539 ), 540 'vjournal' => Array ( 541 'state' => 'optional', 542 'multiples' => False 543 ), 544 'vtodo' => Array ( 545 'state' => 'optional', 546 'multiples' => False 547 ) 548 ), 549 'related_to' => Array ( 552 550 'type' => 'text', 553 551 'to_text' => False, 554 'vevent' => Array(555 'state' => 'optional', 556 'multiples' => False 557 ), 558 'vjournal' => Array(559 'state' => 'optional', 560 'multiples' => True 561 ), 562 'vtodo' => Array(563 'state' => 'optional', 564 'multiples' => True 565 ) 566 ), 567 'request_status' => Array(552 'vevent' => Array ( 553 'state' => 'optional', 554 'multiples' => False 555 ), 556 'vjournal' => Array ( 557 'state' => 'optional', 558 'multiples' => True 559 ), 560 'vtodo' => Array ( 561 'state' => 'optional', 562 'multiples' => True 563 ) 564 ), 565 'request_status' => Array ( 568 566 'type' => 'text', 569 567 'to_text' => True, 570 'vevent' => Array(571 'state' => 'optional', 572 'multiples' => False 573 ), 574 'vtodo' => Array(575 'state' => 'optional', 576 'multiples' => False 577 ), 578 'vjournal' => Array(579 'state' => 'optional', 580 'multiples' => True 581 ), 582 'vfreebusy' => Array(583 'state' => 'optional', 584 'multiples' => True 585 ) 586 ), 587 'resources' => Array(568 'vevent' => Array ( 569 'state' => 'optional', 570 'multiples' => False 571 ), 572 'vtodo' => Array ( 573 'state' => 'optional', 574 'multiples' => False 575 ), 576 'vjournal' => Array ( 577 'state' => 'optional', 578 'multiples' => True 579 ), 580 'vfreebusy' => Array ( 581 'state' => 'optional', 582 'multiples' => True 583 ) 584 ), 585 'resources' => Array ( 588 586 'type' => 'text', 589 587 'to_text' => False, 590 'vevent' => Array(591 'state' => 'optional', 592 'multiples' => False 593 ), 594 'vtodo' => Array(595 'state' => 'optional', 596 'multiples' => False 597 ) 598 ), 599 'rrule' => Array(588 'vevent' => Array ( 589 'state' => 'optional', 590 'multiples' => False 591 ), 592 'vtodo' => Array ( 593 'state' => 'optional', 594 'multiples' => False 595 ) 596 ), 597 'rrule' => Array ( 600 598 'type' => 'recur', 601 599 'to_text' => False, 602 'daylight' => Array(603 'state' => 'optional', 604 'multiples' => True 605 ), 606 'standard' => Array(607 'state' => 'optional', 608 'multiples' => True 609 ), 610 'vevent' => Array(611 'state' => 'optional', 612 'multiples' => True 613 ), 614 'vtodo' => Array(615 'state' => 'optional', 616 'multiples' => True 617 ), 618 'vjournal' => Array(619 'state' => 'optional', 620 'multiples' => True 621 ) 622 ), 623 'sequence' => Array(600 'daylight' => Array ( 601 'state' => 'optional', 602 'multiples' => True 603 ), 604 'standard' => Array ( 605 'state' => 'optional', 606 'multiples' => True 607 ), 608 'vevent' => Array ( 609 'state' => 'optional', 610 'multiples' => True 611 ), 612 'vtodo' => Array ( 613 'state' => 'optional', 614 'multiples' => True 615 ), 616 'vjournal' => Array ( 617 'state' => 'optional', 618 'multiples' => True 619 ) 620 ), 621 'sequence' => Array ( 624 622 'type' => 'integer', 625 623 'to_text' => True, 626 'vevent' => Array(627 'state' => 'optional', 628 'multiples' => False 629 ), 630 'vjournal' => Array(631 'state' => 'optional', 632 'multiples' => False 633 ), 634 'vtodo' => Array(635 'state' => 'optional', 636 'multiples' => False 637 ) 638 ), 639 'status' => Array(624 'vevent' => Array ( 625 'state' => 'optional', 626 'multiples' => False 627 ), 628 'vjournal' => Array ( 629 'state' => 'optional', 630 'multiples' => False 631 ), 632 'vtodo' => Array ( 633 'state' => 'optional', 634 'multiples' => False 635 ) 636 ), 637 'status' => Array ( 640 638 'type' => 'text', 641 639 'to_text' => True, 642 'vevent' => Array(643 'state' => 'optional', 644 'multiples' => False 645 ), 646 'vjournal' => Array(647 'state' => 'optional', 648 'multiples' => False 649 ), 650 'vtodo' => Array(651 'state' => 'optional', 652 'multiples' => False 653 ) 654 ), 655 'summary' => Array(640 'vevent' => Array ( 641 'state' => 'optional', 642 'multiples' => False 643 ), 644 'vjournal' => Array ( 645 'state' => 'optional', 646 'multiples' => False 647 ), 648 'vtodo' => Array ( 649 'state' => 'optional', 650 'multiples' => False 651 ) 652 ), 653 'summary' => Array ( 656 654 'type' => 'text', 657 655 'to_text' => True, 658 'vevent' => Array(659 'state' => 'optional', 660 'multiples' => False 661 ), 662 'vtodo' => Array(663 'state' => 'optional', 664 'multiples' => False 665 ), 666 'vjournal' => Array(667 'state' => 'optional', 668 'multiples' => False 669 ), 670 'valarm' => Array(671 'state' => 'optional', 672 'multiples' => False 673 ) 674 ), 675 'transp' => Array(656 'vevent' => Array ( 657 'state' => 'optional', 658 'multiples' => False 659 ), 660 'vtodo' => Array ( 661 'state' => 'optional', 662 'multiples' => False 663 ), 664 'vjournal' => Array ( 665 'state' => 'optional', 666 'multiples' => False 667 ), 668 'valarm' => Array ( 669 'state' => 'optional', 670 'multiples' => False 671 ) 672 ), 673 'transp' => Array ( 676 674 'type' => 'text', 677 675 'to_text' => True, 678 'vevent' => Array(679 'state' => 'optional', 680 'multiples' => False 681 ) 682 ), 683 'trigger' => Array(676 'vevent' => Array ( 677 'state' => 'optional', 678 'multiples' => False 679 ) 680 ), 681 'trigger' => Array ( 684 682 'type' => 'text', 685 683 'to_text' => True, 686 'valarm' => Array(687 'state' => 'optional', 688 'multiples' => False 689 ) 690 ), 691 'tzid' => Array(684 'valarm' => Array ( 685 'state' => 'optional', 686 'multiples' => False 687 ) 688 ), 689 'tzid' => Array ( 692 690 'type' => 'text', 693 691 'to_text' => True, 694 'vtimezone' => Array(692 'vtimezone' => Array ( 695 693 'state' => 'required', 696 694 'multiples' => False 697 695 ) 698 696 ), 699 'tzname' => Array(697 'tzname' => Array ( 700 698 'type' => 'text', 701 699 'to_text' => True, 702 'daylight' => Array(703 'state' => 'optional', 704 'multiples' => True 705 ), 706 'standard' => Array(707 'state' => 'optional', 708 'multiples' => True 709 ) 710 ), 711 'tzoffsetfrom' => Array(700 'daylight' => Array ( 701 'state' => 'optional', 702 'multiples' => True 703 ), 704 'standard' => Array ( 705 'state' => 'optional', 706 'multiples' => True 707 ) 708 ), 709 'tzoffsetfrom' => Array ( 712 710 'type' => 'utc-offset', 713 711 'to_text' => True, 714 'daylight' => Array(712 'daylight' => Array ( 715 713 'state' => 'required', 716 714 'multiples' => False 717 715 ), 718 'standard' => Array(716 'standard' => Array ( 719 717 'state' => 'required', 720 718 'multiples' => False 721 719 ) 722 720 ), 723 'tzoffsetto' => Array(721 'tzoffsetto' => Array ( 724 722 'type' => 'utc-offset', 725 723 'to_text' => True, 726 'daylight' => Array(724 'daylight' => Array ( 727 725 'state' => 'required', 728 726 'multiples' => False 729 727 ), 730 'standard' => Array(728 'standard' => Array ( 731 729 'state' => 'required', 732 730 'multiples' => False 733 731 ) 734 732 ), 735 'tzurl' => Array(733 'tzurl' => Array ( 736 734 'type' => 'uri', 737 735 'to_text' => True, 738 'vtimezone' => Array(739 'state' => 'optional', 740 'multiples' => False 741 ) 742 ), 743 'uid' => Array(736 'vtimezone' => Array ( 737 'state' => 'optional', 738 'multiples' => False 739 ) 740 ), 741 'uid' => Array ( 744 742 'type' => 'text', 745 743 'to_text' => True, 746 'vevent' => Array(744 'vevent' => Array ( 747 745 'state' => 'required', 748 746 'multiples' => False 749 747 ), 750 'vfreebusy' => Array(748 'vfreebusy' => Array ( 751 749 'state' => 'required', 752 750 'multiples' => False 753 751 ), 754 'vjournal' => Array(752 'vjournal' => Array ( 755 753 'state' => 'required', 756 754 'multiples' => False 757 755 ), 758 'vtodo' => Array(756 'vtodo' => Array ( 759 757 'state' => 'required', 760 758 'multiples' => False 761 759 ) 762 760 ), 763 'url' => Array(761 'url' => Array ( 764 762 'type' => 'text', 765 763 'to_text' => True, 766 'vevent' => Array(764 'vevent' => Array ( 767 765 'state' => 'required', 768 766 'multiples' => False 769 767 ), 770 'vfreebusy' => Array(768 'vfreebusy' => Array ( 771 769 'state' => 'required', 772 770 'multiples' => False 773 771 ), 774 'vjournal' => Array(775 'state' => 'optional', 776 'multiples' => False 777 ), 778 'vtodo' => Array(772 'vjournal' => Array ( 773 'state' => 'optional', 774 'multiples' => False 775 ), 776 'vtodo' => Array ( 779 777 'state' => 'required', 780 778 'multiples' => False 781 779 ) 782 780 ), 783 'version' => Array(781 'version' => Array ( 784 782 'type' => 'text', 785 783 'to_text' => True, 786 'ical' => Array(784 'ical' => Array ( 787 785 'state' => 'required', 788 786 'multiples' => False … … 790 788 ) 791 789 ); 792 $this->parameter = Array(793 'altrep' => Array(790 $this->parameter = Array ( 791 'altrep' => Array ( 794 792 'type' => 'uri', 795 793 'quoted' => True, 796 794 'to_text' => True, 797 'properties' => Array(795 'properties' => Array ( 798 796 'comment' => True, 799 797 'description' => True, … … 805 803 ) 806 804 ), 807 'byday' => Array(805 'byday' => Array ( 808 806 'type' => 'text', 809 807 'quoted' => False, 810 808 'to_text' => False, 811 'properties' => Array(809 'properties' => Array ( 812 810 'rrule' => True 813 811 ) 814 812 ), 815 'byhour' => Array(813 'byhour' => Array ( 816 814 'type' => 'text', 817 815 'quoted' => False, 818 816 'to_text' => False, 819 'properties' => Array(817 'properties' => Array ( 820 818 'rrule' => True 821 819 ) 822 820 ), 823 'byminute' => Array(821 'byminute' => Array ( 824 822 'type' => 'text', 825 823 'quoted' => False, 826 824 'to_text' => False, 827 'properties' => Array(825 'properties' => Array ( 828 826 'rrule' => True 829 827 ) 830 828 ), 831 'bymonth' => Array(829 'bymonth' => Array ( 832 830 'type' => 'text', 833 831 'quoted' => False, 834 832 'to_text' => False, 835 'properties' => Array(833 'properties' => Array ( 836 834 'rrule' => True 837 835 ) 838 836 ), 839 'bymonthday' => Array(837 'bymonthday' => Array ( 840 838 'type' => 'text', 841 839 'quoted' => False, 842 840 'to_text' => False, 843 'properties' => Array(841 'properties' => Array ( 844 842 'rrule' => True 845 843 ) 846 844 ), 847 'bysecond' => Array(845 'bysecond' => Array ( 848 846 'type' => 'text', 849 847 'quoted' => False, 850 848 'to_text' => False, 851 'properties' => Array(849 'properties' => Array ( 852 850 'rrule' => True 853 851 ) 854 852 ), 855 'bysetpos' => Array(853 'bysetpos' => Array ( 856 854 'type' => 'text', 857 855 'quoted' => False, 858 856 'to_text' => False, 859 'properties' => Array(857 'properties' => Array ( 860 858 'rrule' => True 861 859 ) 862 860 ), 863 'byweekno' => Array(861 'byweekno' => Array ( 864 862 'type' => 'text', 865 863 'quoted' => False, 866 864 'to_text' => False, 867 'properties' => Array(865 'properties' => Array ( 868 866 'rrule' => True 869 867 ) 870 868 ), 871 'byyearday' => Array(869 'byyearday' => Array ( 872 870 'type' => 'text', 873 871 'quoted' => False, 874 872 'to_text' => False, 875 'properties' => Array(873 'properties' => Array ( 876 874 'rrule' => True 877 875 ) 878 876 ), 879 'class' => Array(877 'class' => Array ( 880 878 'type' => 'function', 881 879 'function' => 'switch_class', 882 880 'quoted' => False, 883 881 'to_text' => False, 884 'properties' => Array(882 'properties' => Array ( 885 883 'class' => True 886 884 ) 887 885 ), 888 'cn' => Array(886 'cn' => Array ( 889 887 'type' => 'text', 890 888 'quoted' => True, 891 889 'to_text' => False, 892 'properties' => Array(890 'properties' => Array ( 893 891 'attendee' => True, 894 892 'organizer' => True 895 893 ) 896 894 ), 897 'count' => Array(895 'count' => Array ( 898 896 'type' => 'integer', 899 897 'quoted' => False, 900 898 'to_text' => False, 901 'properties' => Array(899 'properties' => Array ( 902 900 'rrule' => True 903 901 ) 904 902 ), 905 'cu' => Array(903 'cu' => Array ( 906 904 'type' => 'function', 907 905 'function' => 'switch_cu', 908 906 'quoted' => False, 909 907 'to_text' => False, 910 'properties' => Array(908 'properties' => Array ( 911 909 'attendee' => True 912 910 ) 913 911 ), 914 'delegated_from' => Array(912 'delegated_from' => Array ( 915 913 'type' => 'function', 916 914 'function' => 'switch_mailto', 917 915 'quoted' => True, 918 916 'to_text' => False, 919 'properties' => Array(917 'properties' => Array ( 920 918 'attendee' => True 921 919 ) 922 920 ), 923 'delegated_to' => Array(921 'delegated_to' => Array ( 924 922 'type' => 'function', 925 923 'function' => 'switch_mailto', 926 924 'quoted' => True, 927 925 'to_text' => False, 928 'properties' => Array(926 'properties' => Array ( 929 927 'attendee' => True 930 928 ) 931 929 ), 932 'dir' => Array(930 'dir' => Array ( 933 931 'type' => 'dir', 934 932 'quoted' => True, 935 933 'to_text' => True, 936 'properties' => Array(934 'properties' => Array ( 937 935 'attendee' => True, 938 936 'organizer' => True 939 937 ) 940 938 ), 941 'dtend' => Array(939 'dtend' => Array ( 942 940 'type' => 'function', 943 941 'function' => 'switch_date', 944 942 'quoted' => False, 945 943 'to_text' => False, 946 'properties' => Array(944 'properties' => Array ( 947 945 'dtend' => True 948 946 ) 949 947 ), 950 'dtstamp' => Array(948 'dtstamp' => Array ( 951 949 'type' => 'function', 952 950 'function' => 'switch_date', 953 951 'quoted' => False, 954 952 'to_text' => False, 955 'properties' => Array(953 'properties' => Array ( 956 954 'dtstamp' => True 957 955 ) 958 956 ), 959 'dtstart' => Array(957 'dtstart' => Array ( 960 958 'type' => 'function', 961 959 'function' => 'switch_date', 962 960 'quoted' => False, 963 961 'to_text' => False, 964 'properties' => Array(962 'properties' => Array ( 965 963 'dtstart' => True 966 964 ) 967 965 ), 968 'encoding' => Array(// was enocding ???966 'encoding' => Array (// was enocding ??? 969 967 'type' => 'function', 970 968 'function' => 'switch_encoding', 971 969 'quoted' => False, 972 970 'to_text' => False, 973 'properties' => Array(971 'properties' => Array ( 974 972 'attach' => True 975 973 ) 976 974 ), 977 'fmttype' => Array(975 'fmttype' => Array ( 978 976 'type' => 'text', 979 977 'quoted' => False, 980 978 'to_text' => False, 981 'properties' => Array(979 'properties' => Array ( 982 980 'attach' => True 983 981 ) 984 982 ), 985 'fbtype' => Array(983 'fbtype' => Array ( 986 984 'type' => 'function', 987 985 'function' => 'switch_fbtype', 988 986 'quoted' => False, 989 987 'to_text' => False, 990 'properties' => Array(988 'properties' => Array ( 991 989 'attach' => True 992 990 ) 993 991 ), 994 'freq' => Array(992 'freq' => Array ( 995 993 'type' => 'function', 996 994 'function' => 'switch_freq', 997 995 'quoted' => False, 998 996 'to_text' => False, 999 'properties' => Array(997 'properties' => Array ( 1000 998 'rrule' => True 1001 999 ) 1002 1000 ), 1003 'interval' => Array(1001 'interval' => Array ( 1004 1002 'type' => 'integer', 1005 1003 'quoted' => False, 1006 1004 'to_text' => False, 1007 'properties' => Array(1005 'properties' => Array ( 1008 1006 'rrule' => True 1009 1007 ) 1010 1008 ), 1011 'language' => Array(1009 'language' => Array ( 1012 1010 'type' => 'text', 1013 1011 'quoted' => False, 1014 1012 'to_text' => False, 1015 'properties' => Array(1013 'properties' => Array ( 1016 1014 'categories' => True, 1017 1015 'comment' => True, … … 1027 1025 ) 1028 1026 ), 1029 'last_modified' => Array(1027 'last_modified' => Array ( 1030 1028 'type' => 'function', 1031 1029 'function' => 'switch_date', 1032 1030 'quoted' => False, 1033 1031 'to_text' => False, 1034 'properties' => Array(1032 'properties' => Array ( 1035 1033 'last_modified' => True 1036 1034 ) 1037 1035 ), 1038 'mailto' => Array(1036 'mailto' => Array ( 1039 1037 'type' => 'function', 1040 1038 'function' => 'switch_mailto', 1041 1039 'quoted' => False, 1042 1040 'to_text' => False, 1043 'properties' => Array(1041 'properties' => Array ( 1044 1042 'attendee' => True, 1045 1043 'organizer' => True 1046 1044 ) 1047 1045 ), 1048 'member' => Array(1046 'member' => Array ( 1049 1047 'type' => 'function', 1050 1048 'function' => 'switch_mailto', 1051 1049 'quoted' => True, 1052 1050 'to_text' => False, 1053 'properties' => Array(1051 'properties' => Array ( 1054 1052 'attendee' => True 1055 1053 ) 1056 1054 ), 1057 'partstat' => Array(1055 'partstat' => Array ( 1058 1056 'type' => 'function', 1059 1057 'function' => 'switch_partstat', 1060 1058 'quoted' => False, 1061 1059 'to_text' => False, 1062 'properties' => Array(1060 'properties' => Array ( 1063 1061 'attendee' => True, 1064 1062 'organizer' => True 1065 1063 ) 1066 1064 ), 1067 'range' => Array(1065 'range' => Array ( 1068 1066 'type' => 'function', 1069 1067 'function' => 'switch_range', 1070 1068 'quoted' => False, 1071 1069 'to_text' => False, 1072 'properties' => Array(1070 'properties' => Array ( 1073 1071 'recurrence_id' => True 1074 1072 ) 1075 1073 ), 1076 'related' => Array(1074 'related' => Array ( 1077 1075 'type' => 'function', 1078 1076 'function' => 'switch_related', 1079 1077 'quoted' => False, 1080 1078 'to_text' => False, 1081 'properties' => Array(1079 'properties' => Array ( 1082 1080 'related_to' => True 1083 1081 ) 1084 1082 ), 1085 'role' => Array(1083 'role' => Array ( 1086 1084 'type' => 'function', 1087 1085 'function' => 'switch_role', 1088 1086 'quoted' => False, 1089 1087 'to_text' => False, 1090 'properties' => Array(1088 'properties' => Array ( 1091 1089 'attendee' => True, 1092 1090 'organizer' => True 1093 1091 ) 1094 1092 ), 1095 'rsvp' => Array(1093 'rsvp' => Array ( 1096 1094 'type' => 'function', 1097 1095 'function' => 'switch_rsvp', 1098 1096 'quoted' => False, 1099 1097 'to_text' => False, 1100 'properties' => Array(1098 'properties' => Array ( 1101 1099 'attendee' => True 1102 1100 ) 1103 1101 ), 1104 'sent_by' => Array(1102 'sent_by' => Array ( 1105 1103 'type' => 'function', 1106 1104 'function' => 'parse_user_host', 1107 1105 'quoted' => True, 1108 1106 'to_text' => False, 1109 'properties' => Array(1107 'properties' => Array ( 1110 1108 'attendee' => True, 1111 1109 'organizer' => True 1112 1110 ) 1113 1111 ), 1114 'tzid' => Array(1112 'tzid' => Array ( 1115 1113 'type' => 'text', 1116 1114 'quoted' => False, 1117 1115 'to_text' => False, 1118 'properties' => Array(1116 'properties' => Array ( 1119 1117 'dtend' => True, 1120 1118 'due' => True, … … 1125 1123 ) 1126 1124 ), 1127 'until' => Array(1125 'until' => Array ( 1128 1126 'type' => 'function', 1129 1127 'function' => 'switch_date', 1130 1128 'quoted' => False, 1131 1129 'to_text' => False, 1132 'properties' => Array(1130 'properties' => Array ( 1133 1131 'rrule' => True 1134 1132 ) 1135 1133 ), 1136 'value' => Array(1134 'value' => Array ( 1137 1135 'type' => 'value', 1138 1136 'quoted' => False, 1139 1137 'to_text' => False, 1140 'properties' => Array(1138 'properties' => Array ( 1141 1139 'calscale' => True, 1142 1140 'prodid' => True, … … 1188 1186 ) 1189 1187 ), 1190 'wkst' => Array(1188 'wkst' => Array ( 1191 1189 'type' => 'string', 1192 1190 'quoted' => False, 1193 1191 'to_text' => False, 1194 'properties' => Array(1192 'properties' => Array ( 1195 1193 'rrule' => True 1196 1194 ) 1197 1195 ), 1198 'x_type' => Array(1196 'x_type' => Array ( 1199 1197 'type' => 'x_type', 1200 1198 'quoted' => False, 1201 1199 'to_text' => False, 1202 'properties' => Array(1200 'properties' => Array ( 1203 1201 'calscale' => True, 1204 1202 'method' => True, … … 1251 1249 ) 1252 1250 ); 1253 if(!is_object($GLOBALS['phpgw']->datetime)) 1254 { 1251 if (!is_object($GLOBALS['phpgw']->datetime)) { 1255 1252 $GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time'); 1256 1253 } 1257 1254 } 1258 1255 1259 function set_var(&$event,$type,$value) 1260 { 1261 $type = strtolower(str_replace('-','_',$type)); 1256 function set_var(& $event, $type, $value) { 1257 $type = strtolower(str_replace('-', '_', $type)); 1262 1258 $event[$type] = $value; 1263 1259 /* … … 1273 1269 } 1274 1270 1275 function read_line_unfold($ical_text) 1276 { 1277 if($this->line < count($ical_text)) 1278 { 1279 $str = str_replace(array("\r\n","\r","\n"), '', $ical_text[$this->line]); 1271 function read_line_unfold($ical_text) { 1272 if ($this->line < count($ical_text)) { 1273 $str = str_replace(array ( 1274 "\r\n", 1275 "\r", 1276 "\n" 1277 ), '', $ical_text[$this->line]); 1280 1278 1281 1279 $this->line = $this->line + 1; 1282 while(ereg("^[[:space:]]",$ical_text[$this->line])) 1283 { 1284 $str .= substr(str_replace("\r\n",'',$ical_text[$this->line]),1); 1280 while (ereg("^[[:space:]]", $ical_text[$this->line])) { 1281 $str .= substr(str_replace("\r\n", '', $ical_text[$this->line]), 1); 1285 1282 $this->line = $this->line + 1; 1286 1283 } 1287 1284 1288 // Corrige a codificacao dos caracteres 1289 $str = trim ($str); 1290 if ( mb_detect_encoding($str, 'auto') == 'UTF-8' ) 1291 $str = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e","chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)",$str); 1285 // Corrige a codificacao dos caracteres, caso haja suporte a mesma. 1286 $str = trim($str); 1287 if (mb_detect_encoding($str, 'auto') == 'UTF-8') 1288 if ($conv = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e", "chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $str)) 1289 $str = $conv; 1292 1290 1293 1291 //$this->debug("LINE : ".$str); 1294 1292 return $str; 1295 } 1296 else 1297 { 1293 } else { 1298 1294 return False; 1299 1295 } 1300 1296 } 1301 1297 1302 function fold($str) 1303 { 1304 return $this->chunk_split==True ? chunk_split($str,FOLD_LENGTH,"\r\n") : $str."\r\n"; 1305 } 1306 1307 function strip_quotes($str) 1308 { 1309 return str_replace('"','',$str); 1310 } 1311 1312 function from_text($str) 1313 { 1314 $str = str_replace("\\,",",",$str); 1315 $str = str_replace("\\;",";",$str); 1316 $str = str_replace("\\N","\n",$str); 1317 $str = str_replace("\\n","\n",$str); 1318 $str = str_replace("\\\\","\\",$str); 1298 function fold($str) { 1299 return $this->chunk_split == True ? chunk_split($str, FOLD_LENGTH, "\r\n") : $str . "\r\n"; 1300 } 1301 1302 function strip_quotes($str) { 1303 return str_replace('"', '', $str); 1304 } 1305 1306 function from_text($str) { 1307 $str = str_replace("\\,", ",", $str); 1308 $str = str_replace("\\;", ";", $str); 1309 $str = str_replace("\\N", "\n", $str); 1310 $str = str_replace("\\n", "\n", $str); 1311 $str = str_replace("\\\\", "\\", $str); 1319 1312 return "$str"; 1320 1313 } 1321 1314 1322 function to_text($str) 1323 { 1324 $str = str_replace("\\","\\\\",$str); 1325 $str = str_replace(",","\\,",$str); 1326 $str = str_replace(";","\\;",$str); 1327 $str = str_replace("\n","\\n",$str); 1315 function to_text($str) { 1316 $str = str_replace("\\", "\\\\", $str); 1317 $str = str_replace(",", "\\,", $str); 1318 $str = str_replace(";", "\\;", $str); 1319 $str = str_replace("\n", "\\n", $str); 1328 1320 return "$str"; 1329 1321 } 1330 1322 1331 function from_dir($str) 1332 { 1333 return str_replace('=3D','=',str_replace('%20',' ',$str)); 1334 } 1335 1336 function to_dir($str) 1337 { 1338 return str_replace('=','=3D',str_replace(' ','%20',$str)); 1339 } 1340 1341 function find_parameters($property) 1342 { 1323 function from_dir($str) { 1324 return str_replace('=3D', '=', str_replace('%20', ' ', $str)); 1325 } 1326 1327 function to_dir($str) { 1328 return str_replace('=', '=3D', str_replace(' ', '%20', $str)); 1329 } 1330 1331 function find_parameters($property) { 1343 1332 static $cached_returns; 1344 1333 1345 if(isset($cached_returns[$property])) 1346 { 1334 if (isset ($cached_returns[$property])) { 1347 1335 reset($cached_returns[$property]); 1348 1336 return $cached_returns[$property]; … … 1350 1338 1351 1339 reset($this->parameter); 1352 while(list($key,$param_array) = each($this->parameter)) 1353 { 1354 if($param_array['properties'][$property]) 1355 { 1340 while (list ($key, $param_array) = each($this->parameter)) { 1341 if ($param_array['properties'][$property]) { 1356 1342 $param[] = $key; 1357 $this->debug('Property : '.$property.' = Parameter : '.$key);1343 $this->debug('Property : ' . $property . ' = Parameter : ' . $key); 1358 1344 } 1359 1345 } … … 1363 1349 } 1364 1350 1365 function find_properties($ical_type) 1366 { 1351 function find_properties($ical_type) { 1367 1352 static $cached_returns; 1368 1353 1369 if(isset($cached_returns[$ical_type])) 1370 { 1354 if (isset ($cached_returns[$ical_type])) { 1371 1355 reset($cached_returns[$ical_type]); 1372 1356 return $cached_returns[$ical_type]; … … 1374 1358 1375 1359 reset($this->property); 1376 while(list($key,$param_array) = each($this->property)) 1377 { 1378 if($param_array[$ical_type]) 1379 { 1360 while (list ($key, $param_array) = each($this->property)) { 1361 if ($param_array[$ical_type]) { 1380 1362 $prop[] = $key; 1381 1363 } … … 1386 1368 } 1387 1369 1388 function new_ical() 1389 { 1390 return Array(); 1370 function new_ical() { 1371 return Array (); 1391 1372 } 1392 1373 … … 1395 1376 */ 1396 1377 1397 function parse_geo(&$event,$value) 1398 { 1378 function parse_geo(& $event, $value) { 1399 1379 // $return_value = $this->explode_param($value,True); 1400 if(count($return_value) == 2) 1401 { 1380 if (count($return_value) == 2) { 1402 1381 $event['lat'] = $return_value[0]; 1403 1382 $event['lon'] = $return_value[1]; … … 1405 1384 } 1406 1385 1407 function parse_xtype(&$event,$majortype,$value) 1408 { 1409 $temp_x_type['name'] = strtoupper(substr($majortype,2)); 1386 function parse_xtype(& $event, $majortype, $value) { 1387 $temp_x_type['name'] = strtoupper(substr($majortype, 2)); 1410 1388 $temp_x_type['value'] = $value; 1411 1389 $event['x_type'][] = $temp_x_type; 1412 1390 } 1413 1391 1414 function parse_parameters(&$event,$majortype,$value) 1415 { 1392 function parse_parameters(& $event, $majortype, $value) { 1416 1393 //$this->debug ('value: '.$value); 1417 if(!ereg('[\=\;]',$value)) 1418 { 1419 $return_value[] = Array( 1394 if (!ereg('[\=\;]', $value)) { 1395 $return_value[] = Array ( 1420 1396 'param' => $majortype, 1421 1397 'value' => $value … … 1423 1399 $value = ''; 1424 1400 } 1425 elseif(ereg('(.*(\:\\\\)?.*):(.*)',$value,$temp)) 1426 { 1401 elseif (ereg('(.*(\:\\\\)?.*):(.*)', $value, $temp)) { 1427 1402 //$this->debug('Value : '._debug_array($temp,False)); 1428 1403 //$this->debug('Param '.$majortype.' Value : '.$temp[3]); 1429 if($temp[3]) 1430 { 1431 $return_value[] = Array( 1404 if ($temp[3]) { 1405 $return_value[] = Array ( 1432 1406 'param' => $majortype, 1433 1407 'value' => $temp[3] 1434 1408 ); 1435 $value = str_replace(':MAILTO','',$temp[1]); 1436 } 1437 while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) 1438 { 1409 $value = str_replace(':MAILTO', '', $temp[1]); 1410 } 1411 while (ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)', $value, $temp)) { 1439 1412 //$this->debug('Value : '._debug_array($temp,False)); 1440 1413 //$this->debug('Param '.$temp[2].' Value : '.$temp[3]); 1441 $return_value[] = Array(1414 $return_value[] = Array ( 1442 1415 'param' => $temp[2], 1443 1416 'value' => $temp[3] … … 1446 1419 //$this->debug('Value would be = '.$value); 1447 1420 } 1448 } 1449 else 1450 { 1451 while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) 1452 { 1453 $this->debug('Value : '._debug_array($temp,False)); 1454 $this->debug('Param '.$temp[2].' Value : '.$temp[3]); 1455 $return_value[] = Array( 1421 } else { 1422 while (ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)', $value, $temp)) { 1423 $this->debug('Value : ' . _debug_array($temp, False)); 1424 $this->debug('Param ' . $temp[2] . ' Value : ' . $temp[3]); 1425 $return_value[] = Array ( 1456 1426 'param' => $temp[2], 1457 1427 'value' => $temp[3] 1458 1428 ); 1459 1429 $value = chop($temp[5]); 1460 $this->debug('Value would be = '.$value);1430 $this->debug('Value would be = ' . $value); 1461 1431 } 1462 1432 } … … 1464 1434 //$this->debug('parse_parameters array return_value: '._debug_array($return_value,False)); 1465 1435 1466 for($i=0;$i<count($return_value);$i++) 1467 { 1436 for ($i = 0; $i < count($return_value); $i++) { 1468 1437 $name = strtolower($return_value[$i]['param']); 1469 1438 $value = $this->strip_quotes($return_value[$i]['value']); 1470 if(substr($name,0,2) == 'x-') 1471 { 1439 if (substr($name, 0, 2) == 'x-') { 1472 1440 $param = 'x_type'; 1473 $name = str_replace('-','_',$return_value[$i]['param']); 1474 } 1475 else 1476 { 1477 $param = str_replace('-','_',strtolower($name)); 1478 if(!isset($this->parameter[$param]) || $majortype == 'tzid') 1479 { 1480 if($majortype == 'attendee' || $majortype == 'organizer') 1481 { 1441 $name = str_replace('-', '_', $return_value[$i]['param']); 1442 } else { 1443 $param = str_replace('-', '_', strtolower($name)); 1444 if (!isset ($this->parameter[$param]) || $majortype == 'tzid') { 1445 if ($majortype == 'attendee' || $majortype == 'organizer') { 1482 1446 $param = 'mailto'; 1483 1447 $name = $param; 1484 } 1485 else 1486 { 1448 } else { 1487 1449 $param = 'value'; 1488 1450 } … … 1490 1452 } 1491 1453 //$this->debug('name : '.$name.' : Param = '.$param); 1492 if(@$this->parameter[$param]['properties'][$majortype]) 1493 { 1494 switch(@$this->parameter[$param]['type']) 1495 { 1496 case 'dir': 1497 $this->set_var($event,$name,$this->from_dir($value)); 1454 if (@ $this->parameter[$param]['properties'][$majortype]) { 1455 switch (@ $this->parameter[$param]['type']) { 1456 case 'dir' : 1457 $this->set_var($event, $name, $this->from_dir($value)); 1498 1458 break; 1499 case 'text':1500 $this->set_var($event,$name,$value);1459 case 'text' : 1460 $this->set_var($event, $name, $value); 1501 1461 break; 1502 case 'x_type':1503 $this->parse_xtype($event,$name,$value);1462 case 'x_type' : 1463 $this->parse_xtype($event, $name, $value); 1504 1464 break; 1505 case 'function':1465 case 'function' : 1506 1466 $function = $this->parameter[$param]['function']; 1507 $this->set_var($event,$name,$this->$function($value));1467 $this->set_var($event, $name, $this-> $function ($value)); 1508 1468 break; 1509 case 'uri': 1510 if(@$this->parameter[$param]['to_text']) 1511 { 1469 case 'uri' : 1470 if (@ $this->parameter[$param]['to_text']) { 1512 1471 $value = $this->to_text($value); 1513 1472 } 1514 $this->set_var($event,$name,$value);1473 $this->set_var($event, $name, $value); 1515 1474 break; 1516 case 'integer':1517 $this->set_var($event,$name,(int)$value);1475 case 'integer' : 1476 $this->set_var($event, $name, (int) $value); 1518 1477 break; 1519 case 'value': 1520 if(@$this->property[$majortype]['type'] == 'date-time') 1521 { 1522 $this->set_var($event,$param,$this->switch_date($name)); 1478 case 'value' : 1479 if (@ $this->property[$majortype]['type'] == 'date-time') { 1480 $this->set_var($event, $param, $this->switch_date($name)); 1523 1481 } 1524 elseif($value <> "\\n" && $value) 1525 { 1526 $this->set_var($event[$majortype],$param,$value); 1482 elseif ($value <> "\\n" && $value) { 1483 $this->set_var($event[$majortype], $param, $value); 1527 1484 } 1528 $this->debug('Event : '._debug_array($event,False));1485 $this->debug('Event : ' . _debug_array($event, False)); 1529 1486 break; 1530 1487 } … … 1533 1490 } 1534 1491 1535 function parse_value(&$event,$majortype,$value,$mode) 1536 { 1537 $var = Array(); 1492 function parse_value(& $event, $majortype, $value, $mode) { 1493 $var = Array (); 1538 1494 //$this->debug('Mode : '.$mode.' Majortype : '.$majortype); 1539 $this->parse_parameters($var,$majortype,$value); 1540 if($this->property[$majortype][$mode]['multiples']) 1541 { 1495 $this->parse_parameters($var, $majortype, $value); 1496 if ($this->property[$majortype][$mode]['multiples']) { 1542 1497 //$this->debug('parse_value var array: '._debug_array($var,False)); 1543 1498 $event[$majortype][] = $var; 1544 } 1545 else 1546 { 1499 } else { 1547 1500 //$this->debug('Majortype : '.$majortype); 1548 1501 //$this->debug('Property : '.$this->property[$majortype]['type']); 1549 if($this->property[$majortype]['type'] == 'date-time') 1550 { 1502 if ($this->property[$majortype]['type'] == 'date-time') { 1551 1503 //$this->debug('Got a DATE-TIME type!'); 1552 1504 $t_var = $var[$majortype]; 1553 unset($var[$majortype]); 1554 if ( $t_var ) 1555 { 1505 unset ($var[$majortype]); 1506 if ($t_var) { 1556 1507 reset($t_var); 1557 while(list($key,$val) = each($t_var)) 1558 { 1508 while (list ($key, $val) = each($t_var)) { 1559 1509 $var[$key] = $val; 1560 1510 } … … 1562 1512 } 1563 1513 } 1564 $this->set_var($event,$majortype,$var);1514 $this->set_var($event, $majortype, $var); 1565 1515 } 1566 1516 } … … 1570 1520 */ 1571 1521 1572 function build_xtype($x_type,$seperator='=') 1573 { 1522 function build_xtype($x_type, $seperator = '=') { 1574 1523 $quote = ''; 1575 if($seperator == '=') 1576 { 1524 if ($seperator == '=') { 1577 1525 $quote = '"'; 1578 1526 } 1579 1527 1580 $return_value = $this->fold('X-'.$x_type['name'].$seperator.$quote.$x_type['value'].$quote); 1581 if($seperator == '=') 1582 { 1583 return str_replace("\r\n",'',$return_value); 1584 } 1585 else 1586 { 1528 $return_value = $this->fold('X-' . $x_type['name'] . $seperator . $quote . $x_type['value'] . $quote); 1529 if ($seperator == '=') { 1530 return str_replace("\r\n", '', $return_value); 1531 } else { 1587 1532 return $return_value; 1588 1533 } 1589 1534 } 1590 1535 1591 function build_parameters($event,$property) 1592 { 1536 function build_parameters($event, $property) { 1593 1537 $str = ''; 1594 1538 $include_mailto = False; … … 1596 1540 $param = $this->find_parameters($property); 1597 1541 1598 if($property == 'exdate') 1599 { 1600 while(list($key,$value) = each($event)) 1601 { 1542 if ($property == 'exdate') { 1543 while (list ($key, $value) = each($event)) { 1602 1544 $exdates[] = $this->switch_date($value); 1603 1545 } 1604 return ':'.implode($exdates,','); 1605 } 1606 else 1607 { 1608 while(list($dumb_key,$key) = each($param)) 1609 { 1610 if($key == 'value') 1611 { 1546 return ':' . implode($exdates, ','); 1547 } else { 1548 while (list ($dumb_key, $key) = each($param)) { 1549 if ($key == 'value') { 1612 1550 continue; 1613 1551 } 1614 if($key == 'mailto') 1615 { 1552 if ($key == 'mailto') { 1616 1553 $include_mailto = True; 1617 1554 continue; 1618 1555 } 1619 $param_array = @$this->parameter[$key]; 1620 $type = @$this->parameter[$key]['type']; 1621 if($type == 'date-time') 1622 { 1556 $param_array = @ $this->parameter[$key]; 1557 $type = @ $this->parameter[$key]['type']; 1558 if ($type == 'date-time') { 1623 1559 $include_datetime = True; 1624 1560 continue; 1625 1561 } 1626 $quote = (@$this->parameter[$key]['quoted']?'"':''); 1627 if(isset($event[$key]) && @$this->parameter[$key]['properties'][$property]) 1628 { 1629 $change_text = @$this->parameter[$key]['to_text']; 1562 $quote = (@ $this->parameter[$key]['quoted'] ? '"' : ''); 1563 if (isset ($event[$key]) && @ $this->parameter[$key]['properties'][$property]) { 1564 $change_text = @ $this->parameter[$key]['to_text']; 1630 1565 $value = $event[$key]; 1631 if($change_text && $type == 'text') 1632 { 1566 if ($change_text && $type == 'text') { 1633 1567 $value = $this->to_text($value); 1634 1568 } 1635 switch($type) 1636 { 1637 case 'dir': 1638 $str .= ';'.str_replace('_','-',strtoupper($key)).'='.$quote.$this->to_dir($value).$quote; 1569 switch ($type) { 1570 case 'dir' : 1571 $str .= ';' . str_replace('_', '-', strtoupper($key)) . '=' . $quote . $this->to_dir($value) . $quote; 1639 1572 break; 1640 case 'function':1641 $str .= ';'.str_replace('_','-',strtoupper($key)).'=';1573 case 'function' : 1574 $str .= ';' . str_replace('_', '-', strtoupper($key)) . '='; 1642 1575 $function = $this->parameter[$key]['function']; 1643 $this->debug($key.' Function Param : '.$value);1644 $str .= $quote.$this->$function($value).$quote;1576 $this->debug($key . ' Function Param : ' . $value); 1577 $str .= $quote . $this-> $function ($value) . $quote; 1645 1578 break; 1646 case 'text':1647 case 'string':1648 $str .= ';'.strtoupper($key).'='.$quote.$value.$quote;1579 case 'text' : 1580 case 'string' : 1581 $str .= ';' . strtoupper($key) . '=' . $quote . $value . $quote; 1649 1582 break; 1650 case 'date-time':1651 $str .= ($key=='until'?':':';UNTIL=').date('Ymd\THis',mktime($event['hour'],$event['min'],$event['sec'],$event['month'],$event['mday'],$event['year'])).(!@isset($event['tzid'])?'Z':'');1583 case 'date-time' : 1584 $str .= ($key == 'until' ? ':' : ';UNTIL=') . date('Ymd\THis', mktime($event['hour'], $event['min'], $event['sec'], $event['month'], $event['mday'], $event['year'])) . (!@ isset ($event['tzid']) ? 'Z' : ''); 1652 1585 break; 1653 1586 } 1654 unset($value); 1655 } 1656 } 1657 1658 if(!empty($event['x_type'])) 1659 { 1587 unset ($value); 1588 } 1589 } 1590 1591 if (!empty ($event['x_type'])) { 1660 1592 $c_x_type = count($event['x_type']); 1661 for($j=0;$j<$c_x_type;$j++) 1662 { 1663 $str .= ';'.$this->build_xtype($event['x_type'][$j],'='); 1664 } 1665 } 1666 if(!empty($event['value'])) 1667 { 1668 if($property == 'trigger') 1669 { 1593 for ($j = 0; $j < $c_x_type; $j++) { 1594 $str .= ';' . $this->build_xtype($event['x_type'][$j], '='); 1595 } 1596 } 1597 if (!empty ($event['value'])) { 1598 if ($property == 'trigger') { 1670 1599 $seperator = ';'; 1671 } 1672 else 1673 { 1600 } else { 1674 1601 $seperator = ':'; 1675 1602 } 1676 $str .= $seperator.($this->parameter['value']['to_text']?$this->to_text($event['value']):$event['value']); 1677 } 1678 if($include_mailto == True) 1679 { 1603 $str .= $seperator . ($this->parameter['value']['to_text'] ? $this->to_text($event['value']) : $event['value']); 1604 } 1605 if ($include_mailto == True) { 1680 1606 $key = 'mailto'; 1681 1607 $function = $this->parameter[$key]['function']; 1682 $ret_value = $this->$function($event[$key]); 1683 $str .= ($ret_value?':'.$ret_value:''); 1684 } 1685 if($include_datetime == True || @$this->property[$property]['type'] == 'date-time') 1686 { 1687 $str .= ':'.date('Ymd\THis',mktime($event['hour'],$event['min'],$event['sec'],$event['month'],$event['mday'],$event['year'])).(!@isset($event['tzid'])?'Z':''); 1688 } 1689 return ($property=='rrule'?':'.substr($str,1):$str); 1690 } 1691 } 1692 1693 function build_text($event,$property) 1694 { 1608 $ret_value = $this-> $function ($event[$key]); 1609 $str .= ($ret_value ? ':' . $ret_value : ''); 1610 } 1611 if ($include_datetime == True || @ $this->property[$property]['type'] == 'date-time') { 1612 $str .= ':' . date('Ymd\THis', mktime($event['hour'], $event['min'], $event['sec'], $event['month'], $event['mday'], $event['year'])) . (!@ isset ($event['tzid']) ? 'Z' : ''); 1613 } 1614 return ($property == 'rrule' ? ':' . substr($str, 1) : $str); 1615 } 1616 } 1617 1618 function build_text($event, $property) { 1695 1619 $str = ''; 1696 1620 $param = $this->find_parameters($property); 1697 while(list($dumb_key,$key) = each($param)) 1698 { 1699 if(!empty($event[$key]) && $key != 'value') 1700 { 1701 $type = @$this->parameter[$key]['type']; 1702 $quote = @$this->parameter[$key]['quote']; 1703 if(@$this->parameter[$key]['to_text'] == True) 1704 { 1621 while (list ($dumb_key, $key) = each($param)) { 1622 if (!empty ($event[$key]) && $key != 'value') { 1623 $type = @ $this->parameter[$key]['type']; 1624 $quote = @ $this->parameter[$key]['quote']; 1625 if (@ $this->parameter[$key]['to_text'] == True) { 1705 1626 $value = $this->to_text($event[$key]); 1706 } 1707 else 1708 { 1627 } else { 1709 1628 $value = $event[$key]; 1710 1629 } 1711 switch($type) 1712 { 1713 case 'text': 1714 $str .= ';'.strtoupper($key).'='.$quote.$value.$quote; 1715 break; 1716 } 1717 } 1718 } 1719 if(!empty($event['x_type'])) 1720 { 1630 switch ($type) { 1631 case 'text' : 1632 $str .= ';' . strtoupper($key) . '=' . $quote . $value . $quote; 1633 break; 1634 } 1635 } 1636 } 1637 if (!empty ($event['x_type'])) { 1721 1638 $c_x_type = count($event['x_type']); 1722 for($j=0;$j<$c_x_type;$j++) 1723 { 1724 $str .= ';'.$this->build_xtype($event['x_type'][$j],'='); 1725 } 1726 } 1727 if(!empty($event['value'])) 1728 { 1729 $str .= ':'.($this->parameter['value']['to_text']?$this->to_text($event['value']):$event['value']); 1639 for ($j = 0; $j < $c_x_type; $j++) { 1640 $str .= ';' . $this->build_xtype($event['x_type'][$j], '='); 1641 } 1642 } 1643 if (!empty ($event['value'])) { 1644 $str .= ':' . ($this->parameter['value']['to_text'] ? $this->to_text($event['value']) : $event['value']); 1730 1645 } 1731 1646 return $str; 1732 1647 } 1733 1648 1734 function build_card_internals($ical_item,$event) 1735 { 1649 function build_card_internals($ical_item, $event) { 1736 1650 $prop = $this->find_properties($ical_item); 1737 1651 reset($prop); 1738 while(list($dumb_key,$key) = each($prop)) 1739 { 1652 while (list ($dumb_key, $key) = each($prop)) { 1740 1653 $value = $key; 1741 1654 $varray = $this->property[$key]; 1742 1655 $type = $varray['type']; 1743 1656 $to_text = $varray['to_text']; 1744 $state = @$varray[$ical_item]['state']; 1745 $multiples = @$varray[$ical_item]['multiples']; 1746 switch($type) 1747 { 1748 case 'date-time': 1749 if(!empty($event[$value])) 1750 { 1751 if($multiples && $value != 'exdate') 1752 { 1753 for($i=0;$i<count($event[$value]);$i++) 1754 { 1755 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); 1657 $state = @ $varray[$ical_item]['state']; 1658 $multiples = @ $varray[$ical_item]['multiples']; 1659 switch ($type) { 1660 case 'date-time' : 1661 if (!empty ($event[$value])) { 1662 if ($multiples && $value != 'exdate') { 1663 for ($i = 0; $i < count($event[$value]); $i++) { 1664 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $value)); 1665 } 1666 } else { 1667 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value], $value)); 1668 } 1669 } 1670 elseif ($value == 'dtstamp' || $value == 'created') { 1671 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . gmdate('Ymd\THis\Z')); 1672 } 1673 break; 1674 case 'uri' : 1675 if (!empty ($event[$value])) { 1676 for ($i = 0; $i < count($event[$value]); $i++) { 1677 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $to_text)); 1678 } 1679 } 1680 break; 1681 case 'recur' : 1682 if (!empty ($event[$value])) { 1683 if ($multiples) { 1684 for ($i = 0; $i < count($event[$value]); $i++) { 1685 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $value)); 1686 } 1687 } else { 1688 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value], $value)); 1689 } 1690 } 1691 break; 1692 case 'integer' : 1693 if (!empty ($event[$value])) { 1694 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $event[$value]); 1695 } 1696 elseif ($value == 'sequence' || $value == 'percent_complete') { 1697 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':0'); 1698 } 1699 break; 1700 case 'function' : 1701 $str .= ';' . str_replace('_', '-', strtoupper($value)) . '='; 1702 $function = @ $this->parameter[$key]['function']; 1703 $str .= (@ $this->parameter[$key]['quoted'] ? '"' : '') . $this-> $function ($event[$key]) . (@ $this->parameter[$key]['quoted'] ? '"' : ''); 1704 break; 1705 case 'float' : 1706 if (!empty ($event[$value])) { 1707 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $event[$value]['lat'] . ';' . $event[$value]['lon']); 1708 } 1709 break; 1710 case 'text' : 1711 if (isset ($event[$value])) { 1712 if (@ $this->parameter[$key]['type'] != 'function') { 1713 if ($multiples && count($event[$value]) > 1) { 1714 for ($i = 0; $i < count($event[$value]); $i++) { 1715 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $value)); 1716 } 1717 } else { 1718 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value], $value)); 1719 } 1720 } else { 1721 $function = $this->parameter[$value]['function']; 1722 if ($multiples) { 1723 for ($i = 0; $i < count($event[$value]); $i++) { 1724 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $this-> $function ($event[$value][$i])); 1725 } 1726 } else { 1727 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $this-> $function ($event[$value])); 1756 1728 } 1757 1729 } 1758 else 1759 { 1760 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); 1730 } 1731 break; 1732 case 'cal-address' : 1733 if (is_array($event[$value][0])) { 1734 for ($j = 0; $j < count($event[$value]); $j++) { 1735 $temp_output = $this->build_parameters($event[$value][$j], $value); 1736 if ($temp_output) { 1737 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $temp_output); 1761 1738 } 1762 1739 } 1763 elseif($value == 'dtstamp' || $value == 'created') 1764 { 1765 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.gmdate('Ymd\THis\Z')); 1766 } 1767 break; 1768 case 'uri': 1769 if(!empty($event[$value])) 1770 { 1771 for($i=0;$i<count($event[$value]);$i++) 1772 { 1773 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$to_text)); 1740 } else { 1741 $temp_output = $this->build_parameters($event[$value], $value); 1742 if ($temp_output) { 1743 $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $temp_output); 1774 1744 } 1775 1745 } 1776 1746 break; 1777 case 'recur': 1778 if(!empty($event[$value])) 1779 { 1780 if($multiples) 1781 { 1782 for($i=0;$i<count($event[$value]);$i++) 1783 { 1784 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); 1785 } 1786 } 1787 else 1788 { 1789 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); 1790 } 1791 } 1792 break; 1793 case 'integer': 1794 if(!empty($event[$value])) 1795 { 1796 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$event[$value]); 1797 } 1798 elseif($value == 'sequence' || $value == 'percent_complete') 1799 { 1800 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':0'); 1801 } 1802 break; 1803 case 'function': 1804 $str .= ';'.str_replace('_','-',strtoupper($value)).'='; 1805 $function = @$this->parameter[$key]['function']; 1806 $str .= (@$this->parameter[$key]['quoted']?'"':'').$this->$function($event[$key]).(@$this->parameter[$key]['quoted']?'"':''); 1807 break; 1808 case 'float': 1809 if(!empty($event[$value])) 1810 { 1811 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$event[$value]['lat'].';'.$event[$value]['lon']); 1812 } 1813 break; 1814 case 'text': 1815 if(isset($event[$value])) 1816 { 1817 if(@$this->parameter[$key]['type'] != 'function') 1818 { 1819 if($multiples && count($event[$value]) > 1) 1820 { 1821 for($i=0;$i<count($event[$value]);$i++) 1822 { 1823 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); 1824 } 1825 } 1826 else 1827 { 1828 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); 1829 } 1830 } 1831 else 1832 { 1833 $function = $this->parameter[$value]['function']; 1834 if($multiples) 1835 { 1836 for($i=0;$i<count($event[$value]);$i++) 1837 { 1838 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$this->$function($event[$value][$i])); 1839 } 1840 } 1841 else 1842 { 1843 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$this->$function($event[$value])); 1844 } 1845 } 1846 } 1847 break; 1848 case 'cal-address': 1849 if(is_array($event[$value][0])) 1850 { 1851 for($j=0;$j<count($event[$value]);$j++) 1852 { 1853 $temp_output = $this->build_parameters($event[$value][$j],$value); 1854 if($temp_output) 1855 { 1856 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$temp_output); 1857 } 1858 } 1859 } 1860 else 1861 { 1862 $temp_output = $this->build_parameters($event[$value],$value); 1863 if($temp_output) 1864 { 1865 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$temp_output); 1866 } 1867 } 1868 break; 1869 } 1870 } 1871 if(!empty($event['x_type'])) 1872 { 1873 for($i=0;$i<count($event['x_type']);$i++) 1874 { 1875 $str .= $this->build_xtype($event['x_type'][$i],':'); 1876 } 1877 } 1878 1879 if($ical_item == 'vtimezone') 1880 { 1881 if($event['tzdata']) 1882 { 1883 for($k=0;$k<count($event['tzdata']);$k++) 1884 { 1885 $str .= 'BEGIN:'.strtoupper($event['tzdata'][$k]['type'])."\r\n"; 1886 $str .= $this->build_card_internals(strtolower($event['tzdata'][$k]['type']),$event['tzdata'][$k]); 1887 $str .= 'END:'.strtoupper($event['tzdata'][$k]['type'])."\r\n"; 1888 } 1889 } 1890 } 1891 elseif($event['alarm']) 1892 { 1893 for($k=0;$k<count($event['alarm']);$k++) 1894 { 1895 $str .= 'BEGIN:VALARM'."\r\n"; 1896 $str .= $this->build_card_internals('valarm',$event['alarm'][$k]); 1897 $str .= 'END:VALARM'."\r\n"; 1747 } 1748 } 1749 if (!empty ($event['x_type'])) { 1750 for ($i = 0; $i < count($event['x_type']); $i++) { 1751 $str .= $this->build_xtype($event['x_type'][$i], ':'); 1752 } 1753 } 1754 1755 if ($ical_item == 'vtimezone') { 1756 if ($event['tzdata']) { 1757 for ($k = 0; $k < count($event['tzdata']); $k++) { 1758 $str .= 'BEGIN:' . strtoupper($event['tzdata'][$k]['type']) . "\r\n"; 1759 $str .= $this->build_card_internals(strtolower($event['tzdata'][$k]['type']), $event['tzdata'][$k]); 1760 $str .= 'END:' . strtoupper($event['tzdata'][$k]['type']) . "\r\n"; 1761 } 1762 } 1763 } 1764 elseif ($event['alarm']) { 1765 for ($k = 0; $k < count($event['alarm']); $k++) { 1766 $str .= 'BEGIN:VALARM' . "\r\n"; 1767 $str .= $this->build_card_internals('valarm', $event['alarm'][$k]); 1768 $str .= 'END:VALARM' . "\r\n"; 1898 1769 } 1899 1770 } … … 1905 1776 */ 1906 1777 1907 function parse_user_host ($var) 1908 { 1778 function parse_user_host($var) { 1909 1779 return $this->switch_mailto($var); 1910 1780 } 1911 1781 1912 function switch_class($var) 1913 { 1914 if(is_string($var)) 1915 { 1916 switch($var) 1917 { 1918 case '_PRIVATE': 1782 function switch_class($var) { 1783 if (is_string($var)) { 1784 switch ($var) { 1785 case '_PRIVATE' : 1919 1786 $var = _PRIVATE; 1920 1787 break; 1921 case '_PUBLIC':1788 case '_PUBLIC' : 1922 1789 $var = _PUBLIC; 1923 1790 break; 1924 case '_CONFIDENTIAL':1791 case '_CONFIDENTIAL' : 1925 1792 $var = _CONFIDENTIAL; 1926 1793 break; 1927 1794 } 1928 1795 } 1929 elseif(is_int($var)) 1930 { 1931 switch((int)$var) 1932 { 1933 case _PRIVATE: 1796 elseif (is_int($var)) { 1797 switch ((int) $var) { 1798 case _PRIVATE : 1934 1799 $var = '_PRIVATE'; 1935 1800 break; 1936 case _PUBLIC:1801 case _PUBLIC : 1937 1802 $var = '_PUBLIC'; 1938 1803 break; 1939 case _CONFIDENTIAL:1804 case _CONFIDENTIAL : 1940 1805 $var = '_CONFIDENTIAL'; 1941 1806 break; … … 1945 1810 } 1946 1811 1947 function switch_cu($var) 1948 { 1949 if(gettype($var) == 'string') 1950 { 1951 switch($var) 1952 { 1953 case 'INDIVIDUAL': 1812 function switch_cu($var) { 1813 if (gettype($var) == 'string') { 1814 switch ($var) { 1815 case 'INDIVIDUAL' : 1954 1816 return INDIVIDUAL; 1955 1817 break; 1956 case 'GROUP':1818 case 'GROUP' : 1957 1819 return GROUP; 1958 1820 break; 1959 case 'RESOURCE':1821 case 'RESOURCE' : 1960 1822 return RESOURCE; 1961 1823 break; 1962 case 'ROOM':1824 case 'ROOM' : 1963 1825 return ROOM; 1964 1826 break; 1965 case 'UNKNOWN':1827 case 'UNKNOWN' : 1966 1828 return UNKNOWN; 1967 1829 break; 1968 default:1830 default : 1969 1831 return OTHER; 1970 1832 break; 1971 1833 } 1972 1834 } 1973 elseif(gettype($var) == 'integer') 1974 { 1975 switch($var) 1976 { 1977 case INDIVIDUAL: 1835 elseif (gettype($var) == 'integer') { 1836 switch ($var) { 1837 case INDIVIDUAL : 1978 1838 return 'INDIVIDUAL'; 1979 1839 break; 1980 case GROUP:1840 case GROUP : 1981 1841 return 'GROUP'; 1982 1842 break; 1983 case RESOURCE:1843 case RESOURCE : 1984 1844 return 'RESOURCE'; 1985 1845 break; 1986 case ROOM:1846 case ROOM : 1987 1847 return 'ROOM'; 1988 1848 break; 1989 case UNKNOWN:1849 case UNKNOWN : 1990 1850 return 'UNKNOWN'; 1991 1851 break; 1992 default:1852 default : 1993 1853 return 'X-OTHER'; 1994 1854 break; 1995 1855 } 1996 } 1997 else 1998 { 1856 } else { 1999 1857 return $var; 2000 1858 } 2001 1859 } 2002 1860 2003 function switch_date($var) 2004 { 2005 $this->debug('SWITCH_DATE: gettype = '.gettype($var)); 2006 if(is_string($var)) 2007 { 2008 $dtime = Array(); 2009 if(strpos($var,':')) 2010 { 2011 $pos = explode(':',$var); 1861 function switch_date($var) { 1862 $this->debug('SWITCH_DATE: gettype = ' . gettype($var)); 1863 if (is_string($var)) { 1864 $dtime = Array (); 1865 if (strpos($var, ':')) { 1866 $pos = explode(':', $var); 2012 1867 $var = $pos[1]; 2013 1868 } 2014 $this->set_var($dtime,'year',(int)(substr($var,0,4))); 2015 $this->set_var($dtime,'month',(int)(substr($var,4,2))); 2016 $this->set_var($dtime,'mday',(int)(substr($var,6,2))); 2017 if(substr($var,8,1) == 'T') 2018 { 2019 $this->set_var($dtime,'hour',(int)(substr($var,9,2))); 2020 $this->set_var($dtime,'min',(int)(substr($var,11,2))); 2021 $this->set_var($dtime,'sec',(int)(substr($var,13,2))); 2022 if(strlen($var) > 14) 2023 { 2024 if(substr($var,14,1) != 'Z') 2025 { 2026 if($this->api) 2027 { 1869 $this->set_var($dtime, 'year', (int) (substr($var, 0, 4))); 1870 $this->set_var($dtime, 'month', (int) (substr($var, 4, 2))); 1871 $this->set_var($dtime, 'mday', (int) (substr($var, 6, 2))); 1872 if (substr($var, 8, 1) == 'T') { 1873 $this->set_var($dtime, 'hour', (int) (substr($var, 9, 2))); 1874 $this->set_var($dtime, 'min', (int) (substr($var, 11, 2))); 1875 $this->set_var($dtime, 'sec', (int) (substr($var, 13, 2))); 1876 if (strlen($var) > 14) { 1877 if (substr($var, 14, 1) != 'Z') { 1878 if ($this->api) { 2028 1879 $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; 2029 if($dtime['hour'] < 0) 2030 { 1880 if ($dtime['hour'] < 0) { 2031 1881 $dtime['mday'] -= 1; 2032 1882 $dtime['hour'] = 24 - $dtime['hour']; 2033 1883 } 2034 elseif($dtime['hour'] >= 24) 2035 { 1884 elseif ($dtime['hour'] >= 24) { 2036 1885 $dtime['mday'] += 1; 2037 1886 $dtime['hour'] = $dtime['hour'] - 24; … … 2039 1888 } 2040 1889 } 2041 } 2042 else 2043 { 1890 } else { 2044 1891 /* 2045 1892 * The time provided by the iCal is considered local time. … … 2062 1909 // } 2063 1910 } 2064 } 2065 else 2066 { 2067 $this->set_var($dtime,'hour',0); 2068 $this->set_var($dtime,'min',0); 2069 $this->set_var($dtime,'sec',0); 2070 if($this->api) 2071 { 1911 } else { 1912 $this->set_var($dtime, 'hour', 0); 1913 $this->set_var($dtime, 'min', 0); 1914 $this->set_var($dtime, 'sec', 0); 1915 if ($this->api) { 2072 1916 $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; 2073 if($dtime['hour'] < 0) 2074 { 1917 if ($dtime['hour'] < 0) { 2075 1918 $dtime['mday'] -= 1; 2076 1919 $dtime['hour'] = 24 - $dtime['hour']; 2077 1920 } 2078 elseif($dtime['hour'] >= 24) 2079 { 1921 elseif ($dtime['hour'] >= 24) { 2080 1922 $dtime['mday'] += 1; 2081 1923 $dtime['hour'] = $dtime['hour'] - 24; … … 2083 1925 } 2084 1926 } 2085 $this->debug('DATETIME : '._debug_array($dtime,False));1927 $this->debug('DATETIME : ' . _debug_array($dtime, False)); 2086 1928 return $dtime; 2087 1929 } 2088 elseif(is_array($var)) 2089 { 2090 return date('Ymd\THis\Z',mktime($var['hour'],$var['min'],$var['sec'],$var['month'],$var['mday'],$var['year'])); 2091 } 2092 else 2093 { 1930 elseif (is_array($var)) { 1931 return date('Ymd\THis\Z', mktime($var['hour'], $var['min'], $var['sec'], $var['month'], $var['mday'], $var['year'])); 1932 } else { 2094 1933 return $var; 2095 1934 } 2096 1935 } 2097 1936 2098 function switch_encoding($var) 2099 { 2100 if(is_string($var)) 2101 { 2102 switch($var) 2103 { 2104 case '8BIT': 1937 function switch_encoding($var) { 1938 if (is_string($var)) { 1939 switch ($var) { 1940 case '8BIT' : 2105 1941 return _8BIT; 2106 1942 break; 2107 case 'BASE64':1943 case 'BASE64' : 2108 1944 return _BASE64; 2109 1945 break; 2110 default:1946 default : 2111 1947 return OTHER; 2112 1948 break; 2113 1949 } 2114 1950 } 2115 elseif(is_int($var)) 2116 { 2117 switch($var) 2118 { 2119 case _8BIT: 1951 elseif (is_int($var)) { 1952 switch ($var) { 1953 case _8BIT : 2120 1954 return '8BIT'; 2121 1955 break; 2122 case _BASE64:1956 case _BASE64 : 2123 1957 return 'BASE64'; 2124 1958 break; 2125 case OTHER:1959 case OTHER : 2126 1960 return 'OTHER'; 2127 1961 break; 2128 1962 } 2129 } 2130 else 2131 { 1963 } else { 2132 1964 return $var; 2133 1965 } 2134 1966 } 2135 1967 2136 function switch_fbtype($var) 2137 { 2138 if(is_string($var)) 2139 { 2140 switch($var) 2141 { 2142 case 'FREE': 1968 function switch_fbtype($var) { 1969 if (is_string($var)) { 1970 switch ($var) { 1971 case 'FREE' : 2143 1972 return FREE; 2144 1973 break; 2145 case 'BUSY':1974 case 'BUSY' : 2146 1975 return BUSY; 2147 1976 break; 2148 case 'BUSY-UNAVAILABLE':1977 case 'BUSY-UNAVAILABLE' : 2149 1978 return BUSY_UNAVAILABLE; 2150 1979 break; 2151 case 'BUSY-TENTATIVE':1980 case 'BUSY-TENTATIVE' : 2152 1981 return BUSY_TENTATIVE; 2153 1982 break; 2154 default:1983 default : 2155 1984 return OTHER; 2156 1985 break; 2157 1986 } 2158 1987 } 2159 elseif(is_int($var)) 2160 { 2161 switch($var) 2162 { 2163 case FREE: 1988 elseif (is_int($var)) { 1989 switch ($var) { 1990 case FREE : 2164 1991 return 'FREE'; 2165 1992 break; 2166 case BUSY:1993 case BUSY : 2167 1994 return 'BUSY'; 2168 1995 break; 2169 case BUSY_UNAVAILABLE:1996 case BUSY_UNAVAILABLE : 2170 1997 return 'BUSY-UNAVAILABLE'; 2171 1998 break; 2172 case BUSY_TENTATIVE:1999 case BUSY_TENTATIVE : 2173 2000 return 'BUSY-TENTATIVE'; 2174 2001 break; 2175 default:2002 default : 2176 2003 return 'OTHER'; 2177 2004 break; 2178 2005 } 2179 } 2180 else 2181 { 2006 } else { 2182 2007 return $var; 2183 2008 } 2184 2009 } 2185 2010 2186 function switch_freq($var) 2187 { 2188 if(is_string($var)) 2189 { 2190 switch($var) 2191 { 2192 case 'SECONDLY': 2011 function switch_freq($var) { 2012 if (is_string($var)) { 2013 switch ($var) { 2014 case 'SECONDLY' : 2193 2015 return SECONDLY; 2194 2016 break; 2195 case 'MINUTELY':2017 case 'MINUTELY' : 2196 2018 return MINUTELY; 2197 2019 break; 2198 case 'HOURLY':2020 case 'HOURLY' : 2199 2021 return HOURLY; 2200 2022 break; 2201 case 'DAILY':2023 case 'DAILY' : 2202 2024 return DAILY; 2203 2025 break; 2204 case 'WEEKLY':2026 case 'WEEKLY' : 2205 2027 return WEEKLY; 2206 2028 break; 2207 case 'MONTHLY':2029 case 'MONTHLY' : 2208 2030 return MONTHLY; 2209 2031 break; 2210 case 'YEARLY':2032 case 'YEARLY' : 2211 2033 return YEARLY; 2212 2034 break; 2213 2035 } 2214 2036 } 2215 elseif(is_int($var)) 2216 { 2217 switch($var) 2218 { 2219 case SECONDLY: 2037 elseif (is_int($var)) { 2038 switch ($var) { 2039 case SECONDLY : 2220 2040 return 'SECONDLY'; 2221 2041 break; 2222 case MINUTELY:2042 case MINUTELY : 2223 2043 return 'MINUTELY'; 2224 2044 break; 2225 case HOURLY:2045 case HOURLY : 2226 2046 return 'HOURLY'; 2227 2047 break; 2228 case DAILY:2048 case DAILY : 2229 2049 return 'DAILY'; 2230 2050 break; 2231 case WEEKLY:2051 case WEEKLY : 2232 2052 return 'WEEKLY'; 2233 2053 break; 2234 case MONTHLY:2054 case MONTHLY : 2235 2055 return 'MONTHLY'; 2236 2056 break; 2237 case YEARLY:2057 case YEARLY : 2238 2058 return 'YEARLY'; 2239 2059 break; 2240 2060 } 2241 } 2242 else 2243 { 2061 } else { 2244 2062 return $var; 2245 2063 } 2246 2064 } 2247 2065 2248 function switch_mailto($var) 2249 { 2250 if(is_string($var)) 2251 { 2252 $var = str_replace(array("\r\n", "\n", "\r"), "", $var); 2253 if(strpos(' '.$var,':')) 2254 { 2255 $parts = explode(':',$var); 2066 function switch_mailto($var) { 2067 if (is_string($var)) { 2068 $var = str_replace(array ( 2069 "\r\n", 2070 "\n", 2071 "\r" 2072 ), "", $var); 2073 if (strpos(' ' . $var, ':')) { 2074 $parts = explode(':', $var); 2256 2075 $var = $parts[1]; 2257 2076 } 2258 2077 2259 $parts = explode('@',$var);2078 $parts = explode('@', $var); 2260 2079 //$this->debug("Count of mailto parts : ".count($parts)); 2261 if(count($parts) == 2) 2262 { 2080 if (count($parts) == 2) { 2263 2081 //$this->debug("Splitting ".$parts[0]." @ ".$parts[1]); 2264 $temp_address = Array();2082 $temp_address = Array (); 2265 2083 $temp_address['user'] = $parts[0]; 2266 2084 $temp_address['host'] = $parts[1]; 2267 2085 return $temp_address; 2268 } 2269 else 2270 { 2086 } else { 2271 2087 return False; 2272 2088 } 2273 2089 } 2274 elseif(is_array($var)) 2275 { 2276 // return 'MAILTO:'.$var['user'].'@'.$var['host']; 2277 return $var['user'].'@'.$var['host']; 2278 } 2279 } 2280 2281 function switch_partstat($var) 2282 { 2283 $this->debug('PARTSTAT = '.$var); 2284 if(is_string($var)) 2285 { 2286 switch($var) 2287 { 2288 case 'NEEDS-ACTION': 2090 elseif (is_array($var)) { 2091 // return 'MAILTO:'.$var['user'].'@'.$var['host']; 2092 return $var['user'] . '@' . $var['host']; 2093 } 2094 } 2095 2096 function switch_partstat($var) { 2097 $this->debug('PARTSTAT = ' . $var); 2098 if (is_string($var)) { 2099 switch ($var) { 2100 case 'NEEDS-ACTION' : 2289 2101 return 0; // NEEDS_ACTION; 2290 2102 break; 2291 case 'ACCEPTED':2103 case 'ACCEPTED' : 2292 2104 return 1; // ACCEPTED; 2293 2105 break; 2294 case 'DECLINED':2106 case 'DECLINED' : 2295 2107 return 2; // DECLINED; 2296 2108 break; 2297 case 'TENTATIVE':2109 case 'TENTATIVE' : 2298 2110 return 3; // TENTATIVE; 2299 2111 break; 2300 case 'DELEGATED':2112 case 'DELEGATED' : 2301 2113 return 4; // DELEGATED; 2302 2114 break; 2303 case 'COMPLETED':2115 case 'COMPLETED' : 2304 2116 return 5; // COMPLETED; 2305 2117 break; 2306 case 'IN-PROCESS':2118 case 'IN-PROCESS' : 2307 2119 return 6; // IN_PROCESS; 2308 2120 break; 2309 default:2121 default : 2310 2122 return 99; // OTHER; 2311 2123 break; 2312 2124 } 2313 2125 } 2314 elseif(is_int($var)) 2315 { 2316 switch((int)$var) 2317 { 2318 case 0: // NEEDS_ACTION: 2126 elseif (is_int($var)) { 2127 switch ((int) $var) { 2128 case 0 : // NEEDS_ACTION: 2319 2129 return 'NEEDS-ACTION'; 2320 2130 break; 2321 case 1: // ACCEPTED:2131 case 1 : // ACCEPTED: 2322 2132 return 'ACCEPTED'; 2323 2133 break; 2324 case 2: // DECLINED:2134 case 2 : // DECLINED: 2325 2135 return 'DECLINED'; 2326 2136 break; 2327 case 3: // TENTATIVE:2137 case 3 : // TENTATIVE: 2328 2138 return 'TENTATIVE'; 2329 2139 break; 2330 case 4: // DELEGATED:2140 case 4 : // DELEGATED: 2331 2141 return 'DELEGATED'; 2332 2142 break; 2333 case 5: // COMPLETED:2143 case 5 : // COMPLETED: 2334 2144 return 'COMPLETED'; 2335 2145 break; 2336 case 6: // IN_PROCESS:2146 case 6 : // IN_PROCESS: 2337 2147 return 'IN-PROCESS'; 2338 2148 break; 2339 default:2149 default : 2340 2150 return 'X-OTHER'; 2341 2151 break; 2342 2152 } 2343 } 2344 else 2345 { 2153 } else { 2346 2154 return $var; 2347 2155 } 2348 2156 } 2349 2157 2350 function switch_range($var) 2351 { 2352 if(is_string($var)) 2353 { 2354 switch($var) 2355 { 2356 case 'THISANDPRIOR': 2158 function switch_range($var) { 2159 if (is_string($var)) { 2160 switch ($var) { 2161 case 'THISANDPRIOR' : 2357 2162 return THISANDPRIOR; 2358 2163 break; 2359 case 'THISANDFUTURE':2164 case 'THISANDFUTURE' : 2360 2165 return THISANDFUTURE; 2361 2166 break; 2362 2167 } 2363 2168 } 2364 elseif(is_int($var)) 2365 { 2366 switch($var) 2367 { 2368 case THISANDPRIOR: 2169 elseif (is_int($var)) { 2170 switch ($var) { 2171 case THISANDPRIOR : 2369 2172 return 'THISANDPRIOR'; 2370 2173 break; 2371 case THISANDFUTURE:2174 case THISANDFUTURE : 2372 2175 return 'THISANDFUTURE'; 2373 2176 break; 2374 2177 } 2375 } 2376 else 2377 { 2178 } else { 2378 2179 return $var; 2379 2180 } 2380 2181 } 2381 2182 2382 function switch_related($var) 2383 { 2384 if(is_string($var)) 2385 { 2386 switch($var) 2387 { 2388 case 'START': 2183 function switch_related($var) { 2184 if (is_string($var)) { 2185 switch ($var) { 2186 case 'START' : 2389 2187 return START; 2390 2188 break; 2391 case 'END':2189 case 'END' : 2392 2190 return END; 2393 2191 break; 2394 2192 } 2395 2193 } 2396 elseif(is_int($var)) 2397 { 2398 switch($var) 2399 { 2400 case START: 2194 elseif (is_int($var)) { 2195 switch ($var) { 2196 case START : 2401 2197 return 'START'; 2402 2198 break; 2403 case END:2199 case END : 2404 2200 return 'END'; 2405 2201 break; 2406 2202 } 2407 } 2408 else 2409 { 2203 } else { 2410 2204 return $var; 2411 2205 } 2412 2206 } 2413 2207 2414 function switch_reltype($var) 2415 { 2416 if(is_string($var)) 2417 { 2418 switch($var) 2419 { 2420 case 'PARENT': 2208 function switch_reltype($var) { 2209 if (is_string($var)) { 2210 switch ($var) { 2211 case 'PARENT' : 2421 2212 return PARENT; 2422 2213 break; 2423 case 'CHILD':2214 case 'CHILD' : 2424 2215 return CHILD; 2425 2216 break; 2426 case 'SIBLING':2217 case 'SIBLING' : 2427 2218 return SIBLING; 2428 2219 break; 2429 2220 } 2430 2221 } 2431 elseif(is_int($var)) 2432 { 2433 switch($var) 2434 { 2435 case PARENT: 2222 elseif (is_int($var)) { 2223 switch ($var) { 2224 case PARENT : 2436 2225 return 'PARENT'; 2437 2226 break; 2438 case CHILD:2227 case CHILD : 2439 2228 return 'CHILD'; 2440 2229 break; 2441 case SIBLING:2230 case SIBLING : 2442 2231 return 'SIBLING'; 2443 2232 break; 2444 2233 } 2445 } 2446 else 2447 { 2234 } else { 2235 return $var; 2236 } 2237 } 2238 2239 function switch_role($var) { 2240 if (is_string($var)) { 2241 switch ($var) { 2242 case 'NONE' : 2243 return NONE; 2244 break; 2245 case 'CHAIR' : 2246 return CHAIR; 2247 break; 2248 case 'REQ-PARTICIPANT' : 2249 return REQ_PARTICIPANT; 2250 break; 2251 case 'OPT-PARTICIPANT' : 2252 return OPT_PARTICIPANT; 2253 break; 2254 case 'NON-PARTICIPANT' : 2255 return NON_PARTICIPANT; 2256 break; 2257 } 2258 } 2259 elseif (is_int($var)) { 2260 switch ($var) { 2261 case NONE : 2262 return 'NONE'; 2263 break; 2264 case CHAIR : 2265 return 'CHAIR'; 2266 break; 2267 case REQ_PARTICIPANT : 2268 return 'REQ-PARTICIPANT'; 2269 break; 2270 case OPT_PARTICIPANT : 2271 return 'OPT-PARTICIPANT'; 2272 break; 2273 case NON_PARTICIPANT : 2274 return 'NON-PARTICIPANT'; 2275 break; 2276 } 2277 } else { 2448 2278 return $var; 2449 2279 } 2450 2280 } 2451 2281 2452 function switch_role($var) 2453 { 2454 if(is_string($var)) 2455 { 2456 switch($var) 2457 { 2458 case 'NONE': 2459 return NONE; 2460 break; 2461 case 'CHAIR': 2462 return CHAIR; 2463 break; 2464 case 'REQ-PARTICIPANT': 2465 return REQ_PARTICIPANT; 2466 break; 2467 case 'OPT-PARTICIPANT': 2468 return OPT_PARTICIPANT; 2469 break; 2470 case 'NON-PARTICIPANT': 2471 return NON_PARTICIPANT; 2472 break; 2473 } 2474 } 2475 elseif(is_int($var)) 2476 { 2477 switch($var) 2478 { 2479 case NONE: 2480 return 'NONE'; 2481 break; 2482 case CHAIR: 2483 return 'CHAIR'; 2484 break; 2485 case REQ_PARTICIPANT: 2486 return 'REQ-PARTICIPANT'; 2487 break; 2488 case OPT_PARTICIPANT: 2489 return 'OPT-PARTICIPANT'; 2490 break; 2491 case NON_PARTICIPANT: 2492 return 'NON-PARTICIPANT'; 2493 break; 2494 } 2495 } 2496 else 2497 { 2282 function switch_rsvp($var) { 2283 if (is_string($var)) { 2284 if ($var == 'TRUE') { 2285 return 1; 2286 } 2287 elseif ($var == 'FALSE') { 2288 return 0; 2289 } 2290 } 2291 elseif (is_int($var) || $var == False) { 2292 if ($var == 1) { 2293 return 'TRUE'; 2294 } 2295 elseif ($var == 0) { 2296 return 'FALSE'; 2297 } 2298 } else { 2498 2299 return $var; 2499 2300 } 2500 2301 } 2501 2302 2502 function switch_rsvp($var) 2503 { 2504 if(is_string($var)) 2505 { 2506 if($var == 'TRUE') 2507 { 2508 return 1; 2509 } 2510 elseif($var == 'FALSE') 2511 { 2512 return 0; 2513 } 2514 } 2515 elseif(is_int($var) || $var == False) 2516 { 2517 if($var == 1) 2518 { 2519 return 'TRUE'; 2520 } 2521 elseif($var == 0) 2522 { 2523 return 'FALSE'; 2524 } 2525 } 2526 else 2527 { 2528 return $var; 2529 } 2530 } 2531 2532 function switch_transp($var) 2533 { 2534 if(is_string($var)) 2535 { 2536 switch($var) 2537 { 2538 case 'TRANSPARENT': 2303 function switch_transp($var) { 2304 if (is_string($var)) { 2305 switch ($var) { 2306 case 'TRANSPARENT' : 2539 2307 return TRANSPARENT; 2540 2308 break; 2541 case 'OPAQUE':2309 case 'OPAQUE' : 2542 2310 return OPAQUE; 2543 2311 break; 2544 2312 } 2545 2313 } 2546 elseif(is_int($var)) 2547 { 2548 switch($var) 2549 { 2550 case TRANSPARENT: 2314 elseif (is_int($var)) { 2315 switch ($var) { 2316 case TRANSPARENT : 2551 2317 return 'TRANSPARENT'; 2552 2318 break; 2553 case OPAQUE:2319 case OPAQUE : 2554 2320 return 'OPAQUE'; 2555 2321 break; 2556 2322 } 2557 } 2558 else 2559 { 2323 } else { 2560 2324 return $var; 2561 2325 } … … 2566 2330 */ 2567 2331 2568 function parse($ical_text) 2569 { 2332 function parse($ical_text) { 2570 2333 $begin_regexp = '^'; 2571 2334 $semi_colon_regexp = '[\;\:]'; … … 2573 2336 $catch_all_regexp = '(.*)'; 2574 2337 $end_regexp = '$'; 2575 $property_regexp = $begin_regexp.'([A-Z\-]*)'.$semi_colon_regexp.$catch_all_regexp.$end_regexp;2576 $param_regexp = $begin_regexp.$catch_all_regexp.':'.$catch_all_regexp.$end_regexp;2338 $property_regexp = $begin_regexp . '([A-Z\-]*)' . $semi_colon_regexp . $catch_all_regexp . $end_regexp; 2339 $param_regexp = $begin_regexp . $catch_all_regexp . ':' . $catch_all_regexp . $end_regexp; 2577 2340 2578 2341 $mode = 'none'; 2579 2342 $text = $this->read_line_unfold($ical_text); 2580 while($text) 2581 { 2582 // if(strlen($ical_text[$i]) > 75) 2583 // { 2584 // continue; 2585 // } 2586 2587 ereg($property_regexp,$text,$temp); 2343 while ($text) { 2344 // if(strlen($ical_text[$i]) > 75) 2345 // { 2346 // continue; 2347 // } 2348 2349 ereg($property_regexp, $text, $temp); 2588 2350 //$this->debug ('Majortype dump: '._debug_array($temp, false) ); 2589 $majortype = str_replace('-','_',strtolower($temp[1]));2351 $majortype = str_replace('-', '_', strtolower($temp[1])); 2590 2352 $value = chop($temp[2]); 2591 2592 if($mode != 'none' && ($majortype != 'begin' && $majortype != 'end')) 2593 { 2353 if ($mode != 'none' && ($majortype != 'begin' && $majortype != 'end')) { 2594 2354 //$this->debug('PARSE:MAJORTYPE : '.$majortype); 2595 if(isset($this->property[$majortype])) 2596 { 2597 $state = @$this->property[$majortype]["$mode"]['state']; 2598 $type = @$this->property[$majortype]['type']; 2599 $multiples = @$this->property[$majortype]["$mode"]['multiples']; 2600 $do_to_text = @$this->property[$majortype]['to_text']; 2601 } 2602 elseif(substr($majortype,0,2) == 'x_') 2603 { 2355 if (isset ($this->property[$majortype])) { 2356 $state = @ $this->property[$majortype]["$mode"]['state']; 2357 $type = @ $this->property[$majortype]['type']; 2358 $multiples = @ $this->property[$majortype]["$mode"]['multiples']; 2359 $do_to_text = @ $this->property[$majortype]['to_text']; 2360 } 2361 elseif (substr($majortype, 0, 2) == 'x_') { 2604 2362 $state = 'optional'; 2605 2363 $type = 'xtype'; 2606 2364 $multiples = True; 2607 2365 $do_to_test = True; 2608 } 2609 else 2610 { 2366 } else { 2611 2367 $state = ''; 2612 2368 } 2613 } 2614 else 2615 { 2369 } else { 2616 2370 $state = 'required'; 2617 2371 } 2618 2372 2619 if($majortype == 'duration') 2620 { 2373 if ($majortype == 'duration') { 2621 2374 // Unset dur var 2622 unset($dur);2375 unset ($dur); 2623 2376 2624 2377 // Split DURATION 2625 list($_f_['day_raw'], $_f_['time_raw']) = split('T', substr($value, 1, strlen($value)-1));2378 list ($_f_['day_raw'], $_f_['time_raw']) = split('T', substr($value, 1, strlen($value) - 1)); 2626 2379 2627 2380 /* Datecode */ 2628 if(isset($_f_['day_raw']) OR $_f_['day_raw']) 2629 { 2381 if (isset ($_f_['day_raw']) OR $_f_['day_raw']) { 2630 2382 // Days 2631 // if(ereg('D', $_f_['day_raw'])) 2632 if(strstr($_f_['day_raw'],'D')) 2633 { 2383 // if(ereg('D', $_f_['day_raw'])) 2384 if (strstr($_f_['day_raw'], 'D')) { 2634 2385 $dur['days'] = eregi_replace("([0-9]+)D(.*)", "\\1", $_f_['day_raw']); 2635 2386 } 2636 2387 2637 2388 // Weeks 2638 // if(ereg("W", $_f_["day_raw"])) 2639 if(strstr($_f_['day_raw'],'W')) 2640 { 2389 // if(ereg("W", $_f_["day_raw"])) 2390 if (strstr($_f_['day_raw'], 'W')) { 2641 2391 $dur['weeks'] = eregi_replace("([^|.*]+D)?([0-9]+)W", "\\2", $_f_['day_raw']); 2642 2392 } … … 2644 2394 2645 2395 /* Timecode */ 2646 if(isset($_f_['time_raw']) OR $_f_['time_raw']) 2647 { 2396 if (isset ($_f_['time_raw']) OR $_f_['time_raw']) { 2648 2397 // Hours 2649 // if(ereg("H", $_f_["time_raw"])) 2650 if(strstr($_f_['time_raw'],'H')) 2651 { 2398 // if(ereg("H", $_f_["time_raw"])) 2399 if (strstr($_f_['time_raw'], 'H')) { 2652 2400 $dur['hours'] = eregi_replace("([0-9]+)H(.*)", "\\1", $_f_['time_raw']); 2653 2401 } … … 2655 2403 // Minutes 2656 2404 /* If you find better, contact me very quickly :) */ 2657 // if(ereg("M", $_f_["time_raw"])) 2658 if(strstr($_f_['time_raw'],'M')) 2659 { 2405 // if(ereg("M", $_f_["time_raw"])) 2406 if (strstr($_f_['time_raw'], 'M')) { 2660 2407 $dur['minutes'] = eregi_replace("([^|.*]+H)?([0-9]+)M(.*)", "\\2", $_f_['time_raw']); 2661 2408 } … … 2663 2410 // Seconds 2664 2411 /* Same comment :) */ 2665 // if(ereg("S", $_f_["time_raw"]) ) 2666 if(strstr($_f_['time_raw'],'S')) 2667 { 2412 // if(ereg("S", $_f_["time_raw"]) ) 2413 if (strstr($_f_['time_raw'], 'S')) { 2668 2414 $dur['seconds'] = eregi_replace("([^|.*]+M)?([0-9]+)S(.*)", "\\2", $_f_['time_raw']); 2669 2415 } 2670 2416 } 2671 2417 2672 $dur['raw'] = Array(2418 $dur['raw'] = Array ( 2673 2419 'timecode' => $_f_['time_raw'], 2674 2420 'datecode' => $_f_['day_raw'], … … 2679 2425 } 2680 2426 2681 if($majortype == 'begin') 2682 { 2427 if ($majortype == 'begin') { 2683 2428 $tmode = $mode; 2684 2429 $mode = strtolower($value); 2685 switch(strtolower($value)) 2686 { 2687 case 'daylight': 2688 case 'standard': 2689 $t_event = Array(); 2430 switch (strtolower($value)) { 2431 case 'daylight' : 2432 case 'standard' : 2433 $t_event = Array (); 2690 2434 $t_event = $event; 2691 $event = Array();2435 $event = Array (); 2692 2436 break; 2693 case 'valarm': 2694 if($tmode == 'vevent' || $tmode == 'vtodo') 2695 { 2437 case 'valarm' : 2438 if ($tmode == 'vevent' || $tmode == 'vtodo') { 2696 2439 $t_event = $event; 2697 unset($event); 2698 $event = Array(); 2699 } 2700 else 2701 { 2440 unset ($event); 2441 $event = Array (); 2442 } else { 2702 2443 $mode = $tmode; 2703 2444 } 2704 2445 break; 2705 case 'vcalendar':2446 case 'vcalendar' : 2706 2447 $ical = $this->new_ical(); 2707 2448 break; 2708 case 'vevent':2709 case 'vfreebusy':2710 case 'vjournal':2711 case 'vtimezone':2712 case 'vtodo':2713 $event = Array();2449 case 'vevent' : 2450 case 'vfreebusy' : 2451 case 'vjournal' : 2452 case 'vtimezone' : 2453 case 'vtodo' : 2454 $event = Array (); 2714 2455 break; 2715 2456 } 2716 2457 $event['type'] = strtolower($value); 2717 2458 } 2718 elseif($majortype == 'end') 2719 { 2459 elseif ($majortype == 'end') { 2720 2460 $mode = 'none'; 2721 switch(strtolower($value)) 2722 { 2723 case 'daylight': 2724 case 'standard': 2461 switch (strtolower($value)) { 2462 case 'daylight' : 2463 case 'standard' : 2725 2464 $tzdata[] = $event; 2726 unset($event);2465 unset ($event); 2727 2466 $event = $t_event; 2728 unset($t_event);2467 unset ($t_event); 2729 2468 $mode = 'vtimezone'; 2730 2469 break; 2731 case 'valarm':2470 case 'valarm' : 2732 2471 $alarm[] = $event; 2733 unset($event);2472 unset ($event); 2734 2473 $event = $t_event; 2735 unset($t_event);2474 unset ($t_event); 2736 2475 $mode = $tmode; 2737 2476 break; 2738 case 'vevent': 2739 if(!empty($alarm)) 2740 { 2477 case 'vevent' : 2478 if (!empty ($alarm)) { 2741 2479 $event['alarm'] = $alarm; 2742 unset($alarm);2480 unset ($alarm); 2743 2481 } 2744 2482 $this->event[] = $event; 2745 unset($event);2483 unset ($event); 2746 2484 break; 2747 case 'vfreebusy':2485 case 'vfreebusy' : 2748 2486 $this->freebusy[] = $event; 2749 unset($event);2487 unset ($event); 2750 2488 break; 2751 case 'vjournal':2489 case 'vjournal' : 2752 2490 $this->journal[] = $event; 2753 unset($event);2491 unset ($event); 2754 2492 break; 2755 case 'vtimezone': 2756 if(!empty($tzdata)) 2757 { 2493 case 'vtimezone' : 2494 if (!empty ($tzdata)) { 2758 2495 $event['tzdata'] = $tzdata; 2759 unset($tzdata);2496 unset ($tzdata); 2760 2497 } 2761 2498 $this->timezone[] = $event; 2762 unset($event);2499 unset ($event); 2763 2500 break; 2764 case 'vtodo': 2765 if(!empty($alarm)) 2766 { 2501 case 'vtodo' : 2502 if (!empty ($alarm)) { 2767 2503 $event['alarm'] = $alarm; 2768 unset($alarm);2504 unset ($alarm); 2769 2505 } 2770 2506 $this->todo[] = $event['alarm']; 2771 unset($event);2507 unset ($event); 2772 2508 break; 2773 case 'vcalendar':2509 case 'vcalendar' : 2774 2510 $this->ical = $ical; 2775 2511 $this->ical['event'] = $this->event; … … 2781 2517 } 2782 2518 } 2783 elseif($majortype == 'prodid' || $majortype == 'version' || $majortype == 'method' || $majortype == 'calscale') 2784 { 2785 $this->parse_parameters($ical,$majortype,$this->from_text($value)); 2786 } 2787 elseif($state == 'optional' || $state == 'required') 2788 { 2519 elseif ($majortype == 'prodid' || $majortype == 'version' || $majortype == 'method' || $majortype == 'calscale') { 2520 $this->parse_parameters($ical, $majortype, $this->from_text($value)); 2521 } 2522 elseif ($state == 'optional' || $state == 'required') { 2789 2523 //$this->debug('Mode : '.$mode.' Majortype : '.$majortype . ' Type : '.$type); 2790 if($do_to_text) 2791 { 2524 if ($do_to_text) { 2792 2525 $value = $this->from_text($value); 2793 2526 } 2794 switch($type) 2795 { 2796 case 'text': 2797 $this->parse_parameters($event,$majortype,$value); 2798 break; 2799 case 'recur': 2800 case 'date-time': 2801 case 'cal-address': 2802 $this->parse_value($event,$majortype,$value,$mode); 2803 break; 2804 case 'integer': 2805 if($multiples) 2806 { 2807 $event[$majortype][] = (int)$value; 2808 } 2809 else 2810 { 2811 $this->set_var($event,$majortype,(int)$value); 2812 } 2813 break; 2814 case 'float': 2815 $event->$majortype = new class_geo; 2816 $this->parse_geo($event->$majortype,$value); 2817 break; 2818 case 'utc-offset': 2819 $this->set_var($event,$majortype,(int)$value); 2820 break; 2821 case 'uri': 2822 $new_var = Array(); 2823 $this->parse_parameters($new_var,$majortype,$value); 2824 if($multiples) 2825 { 2826 switch($mode) 2827 { 2828 case 'valarm': 2527 switch ($type) { 2528 case 'text' : 2529 $this->parse_parameters($event, $majortype, $value); 2530 break; 2531 case 'recur' : 2532 case 'date-time' : 2533 case 'cal-address' : 2534 $this->parse_value($event, $majortype, $value, $mode); 2535 break; 2536 case 'integer' : 2537 if ($multiples) { 2538 $event[$majortype][] = (int) $value; 2539 } else { 2540 $this->set_var($event, $majortype, (int) $value); 2541 } 2542 break; 2543 case 'float' : 2544 $event-> $majortype = new class_geo; 2545 $this->parse_geo($event-> $majortype, $value); 2546 break; 2547 case 'utc-offset' : 2548 $this->set_var($event, $majortype, (int) $value); 2549 break; 2550 case 'uri' : 2551 $new_var = Array (); 2552 $this->parse_parameters($new_var, $majortype, $value); 2553 if ($multiples) { 2554 switch ($mode) { 2555 case 'valarm' : 2829 2556 $alarm['attach'][] = $new_var; 2830 2557 break; 2831 default:2558 default : 2832 2559 $event[$majortype][] = $new_var; 2833 2560 break; 2834 2561 } 2835 } 2836 else 2837 { 2562 } else { 2838 2563 $event[$majortype] = $new_var; 2839 2564 } 2840 unset($new_var);2565 unset ($new_var); 2841 2566 break; 2842 case 'xtype':2843 $this->parse_xtype($event,$majortype,$value);2567 case 'xtype' : 2568 $this->parse_xtype($event, $majortype, $value); 2844 2569 break; 2845 2570 } … … 2850 2575 } 2851 2576 2852 2853 function switch_to_phpgw_status($partstat) 2854 { 2855 switch($partstat) 2856 { 2857 case 0: 2577 function switch_to_phpgw_status($partstat) { 2578 switch ($partstat) { 2579 case 0 : 2858 2580 return 'U'; 2859 2581 break; 2860 case 1:2582 case 1 : 2861 2583 return 'A'; 2862 2584 break; 2863 case 2:2585 case 2 : 2864 2586 return 'R'; 2865 2587 break; 2866 case 3:2588 case 3 : 2867 2589 return 'T'; 2868 2590 break; 2869 default:2591 default : 2870 2592 return 'U'; 2871 2593 break; … … 2873 2595 } 2874 2596 2875 function switch_phpgw_status($status) 2876 { 2877 switch($status) 2878 { 2879 case 'U': 2597 function switch_phpgw_status($status) { 2598 switch ($status) { 2599 case 'U' : 2880 2600 return 0; 2881 2601 break; 2882 case 'A':2602 case 'A' : 2883 2603 return 1; 2884 2604 break; 2885 case 'R':2605 case 'R' : 2886 2606 return 2; 2887 2607 break; 2888 case 'T':2608 case 'T' : 2889 2609 return 3; 2890 2610 break; … … 2892 2612 } 2893 2613 2894 function is_owner($part_record) 2895 { 2896 if(($part_record['user'].'@'.$part_record['host'] == $GLOBALS['phpgw_info']['user']['preferences']['email']['address']) || 2897 ($part_record['cn'] == $GLOBALS['phpgw_info']['user']['account_lid'])) 2898 { 2614 function is_owner($part_record) { 2615 if (($part_record['user'] . '@' . $part_record['host'] == $GLOBALS['phpgw_info']['user']['preferences']['email']['address']) || ($part_record['cn'] == $GLOBALS['phpgw_info']['user']['account_lid']) || 2616 ($part_record['mailto']['user'] == $GLOBALS['phpgw_info']['user']['account_lid'])) { 2899 2617 return True; 2900 } 2901 else 2902 { 2618 } else { 2903 2619 return False; 2904 2620 } 2905 2621 } 2906 2622 2907 function check_owner(&$event,$ical,$so_event) 2908 { 2909 if(!isset($event['participant'][$GLOBALS['phpgw_info']['user']['account_id']])) 2910 { 2911 if(isset($ical['organizer'])) 2912 { 2913 if($this->is_owner($ical['organizer'])) 2914 { 2915 $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); 2916 $so_event->add_attribute('participants',$this->switch_to_phpgw_status($ical['organizer']['partstat']),$GLOBALS['phpgw_info']['user']['account_id']); 2917 } 2918 } 2919 elseif(isset($ical['attendee'])) 2920 { 2623 function check_owner(& $event, $ical, $so_event) { 2624 if (!isset ($event['participant'][$GLOBALS['phpgw_info']['user']['account_id']])) { 2625 if (isset ($ical['organizer'])) { 2626 if ($this->is_owner($ical['organizer'])) { 2627 $so_event->add_attribute('owner', $GLOBALS['phpgw_info']['user']['account_id']); 2628 $so_event->add_attribute('participants', $this->switch_to_phpgw_status($ical['organizer']['partstat']), $GLOBALS['phpgw_info']['user']['account_id']); 2629 } 2630 } 2631 elseif (isset ($ical['attendee'])) { 2921 2632 $attendee_count = count($ical['attendee']); 2922 2633 2923 for($j=0;$j<$attendee_count;$j++) 2924 { 2925 if($this->is_owner($ical['attendee'][$j])) 2926 { 2927 $so_event->add_attribute('participants',$this->switch_to_phpgw_status($ical['attendee'][$j]['partstat']),(int)$GLOBALS['phpgw_info']['user']['account_id']); 2928 } 2929 } 2930 } 2931 else 2932 { 2933 $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); 2934 $so_event->add_attribute('participants','A',$GLOBALS['phpgw_info']['user']['account_id']); 2935 } 2936 } 2937 } 2938 2939 function import_file() 2940 { 2941 if($_FILES['uploadedfile']['tmp_name'] == 'none' || $_FILES['uploadedfile']['tmp_name'] == '') 2942 { 2943 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', 2944 Array( 2634 for ($j = 0; $j < $attendee_count; $j++) { 2635 if ($this->is_owner($ical['attendee'][$j])) { 2636 $so_event->add_attribute('participants', $this->switch_to_phpgw_status($ical['attendee'][$j]['partstat']), (int) $GLOBALS['phpgw_info']['user']['account_id']); 2637 } 2638 } 2639 } else { 2640 $so_event->add_attribute('owner', $GLOBALS['phpgw_info']['user']['account_id']); 2641 $so_event->add_attribute('participants', 'A', $GLOBALS['phpgw_info']['user']['account_id']); 2642 } 2643 } 2644 } 2645 2646 function import_file() { 2647 if ($_FILES['uploadedfile']['tmp_name'] == 'none' || $_FILES['uploadedfile']['tmp_name'] == '') { 2648 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', Array ( 2945 2649 'menuaction' => 'calendar.uiicalendar.import', 2946 2650 'action' => 'GetFile' 2947 ) 2948 ) 2949 ); 2651 ))); 2950 2652 $GLOBALS['phpwg']->common->phpgw_exit(); 2951 2653 } 2952 2654 $uploaddir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 2953 2655 2954 srand((double)microtime()*1000000); 2955 $random_number = rand(100000000,999999999); 2956 $newfilename = md5($_FILES['uploadedfile']['tmp_name'].", ".$uploadedfile_name.", " 2957 . time() . getenv("REMOTE_ADDR") . $random_number ); 2656 srand((double) microtime() * 1000000); 2657 $random_number = rand(100000000, 999999999); 2658 $newfilename = md5($_FILES['uploadedfile']['tmp_name'] . ", " . $uploadedfile_name . ", " . time() . getenv("REMOTE_ADDR") . $random_number); 2958 2659 2959 2660 $filename = $uploaddir . $newfilename; 2960 2661 2961 2662 move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $filename); 2962 // $ftp = fopen($uploaddir . $newfilename . '.info','wb');2963 // fputs($ftp,$uploadedfile_type."\n".$uploadedfile_name."\n");2964 // fclose($ftp);2663 // $ftp = fopen($uploaddir . $newfilename . '.info','wb'); 2664 // fputs($ftp,$uploadedfile_type."\n".$uploadedfile_name."\n"); 2665 // fclose($ftp); 2965 2666 return $filename; 2966 2667 } 2967 2668 2968 function import($mime_msg='', $from_ajax = false) 2969 { 2970 if($_FILES['uploadedfile']['tmp_name'] != 'none' && $_FILES['uploadedfile']['tmp_name'] != '') 2971 { 2669 function safeBitCheck($number, $comparison) { 2670 $binNumber = base_convert($number, 10, 2); 2671 $binComparison = strrev(base_convert($comparison, 10, 2)); 2672 $str = strlen($binNumber); 2673 2674 if (($str <= strlen($binComparison)) && ($binComparison { 2675 $str -1 } 2676 === "1")) 2677 return '1'; 2678 else 2679 return '0'; 2680 } 2681 2682 function import($mime_msg = '', $from_ajax = false, $importAccount = false) { 2683 /* 2684 * Caso seja uma importação para conta compartilhada carrega as acls do usuario 2685 */ 2686 if ($importAccount != false) { 2687 $colunas = array ( 2688 'acl_appname', 2689 'acl_location', 2690 'acl_account', 2691 'acl_rights' 2692 ); 2693 $where = array ( 2694 'acl_appname' => 'calendar', 2695 'acl_account' => $importAccount['uidnumber'], 2696 'acl_location' => $GLOBALS['phpgw_info']['user']['account_id'] 2697 ); 2698 $db = $GLOBALS['phpgw']->db; 2699 $db->select('phpgw_acl', $colunas, $where, null, null); 2700 $row = $db->row(true); 2701 2702 if (!$this->safeBitCheck(2, $row['acl_rights'])) //Se o usuario não tem permisão de adicionar eventos 2703 return 'You do not have permission to add events'; 2704 } 2705 2706 if ($_FILES['uploadedfile']['tmp_name'] != 'none' && $_FILES['uploadedfile']['tmp_name'] != '') { 2972 2707 $filename = $this->import_file(); 2973 $fp=fopen($filename,'rt');2974 $mime_msg = explode("\n",fread($fp, filesize($filename)));2708 $fp = fopen($filename, 'rt'); 2709 $mime_msg = explode("\n", fread($fp, filesize($filename))); 2975 2710 fclose($fp); 2976 2711 unlink($filename); 2977 2712 } 2978 elseif(!$mime_msg) 2979 { 2980 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', 2981 Array( 2713 elseif (!$mime_msg) { 2714 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', Array ( 2982 2715 'menuaction' => 'calendar.uiicalendar.import', 2983 2716 'action' => 'GetFile' 2984 ) 2985 ) 2986 ); 2717 ))); 2987 2718 $GLOBALS['phpwg']->common->phpgw_exit(); 2988 2719 } 2989 2720 2990 if(!is_object($GLOBALS['uicalendar'])) 2991 { 2992 $so_event = createobject('calendar.socalendar', 2993 Array( 2721 if (!is_object($GLOBALS['uicalendar'])) { 2722 $so_event = createobject('calendar.socalendar', Array ( 2994 2723 'owner' => 0, 2995 2724 'filter' => '', 2996 2725 'category' => '' 2997 ) 2998 ); 2999 } 3000 else 3001 { 2726 )); 2727 } else { 3002 2728 $so_event = $GLOBALS['uicalendar']->bo->so; 3003 2729 } 3004 2730 3005 $datetime_vars = Array(2731 $datetime_vars = Array ( 3006 2732 'start' => 'dtstart', 3007 2733 'end' => 'dtend', … … 3010 2736 ); 3011 2737 3012 $date_array = Array(2738 $date_array = Array ( 3013 2739 'Y' => 'year', 3014 2740 'm' => 'month', … … 3020 2746 3021 2747 // time limit should be controlled elsewhere 3022 @set_time_limit(0); 3023 2748 @ set_time_limit(0); 3024 2749 $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences(); 3025 2750 $users_email = $GLOBALS['phpgw_info']['user']['preferences']['email']['address']; 3026 2751 $cats = CreateObject('phpgwapi.categories'); 3027 2752 $ical = $this->parse($mime_msg); 3028 switch($ical['version']['value']) 3029 { 3030 case '1.0': 2753 switch ($ical['version']['value']) { 2754 case '1.0' : 3031 2755 $cat_sep = ';'; 3032 2756 break; 3033 case '2.0':3034 default:2757 case '2.0' : 2758 default : 3035 2759 $cat_sep = ','; 3036 2760 break; 3037 2761 } 3038 2762 3039 $c_events = count($ical['event']); 3040 for($i=0; $i<$c_events; $i++) 3041 { 3042 if($ical['event'][$i]['uid']['value']) 2763 /* 2764 * Caso seja um Reply. 2765 */ 2766 if (strtoupper($ical['method']['value']) == 'REPLY') { 2767 //atualiza evento caso seja evento externo 2768 if (isset ($ical['event']['0']['x_type'])) 2769 foreach ($ical['event']['0']['x_type'] as $property) 2770 if ($property['name'] === 'MICROSOFT_CDO_IMPORTANCE') 2771 return $this->updateHour($ical); 2772 2773 //Ignora respostas externas 2774 return 'The import was executed successfully.'; 2775 } 2776 2777 /*-------------------------------------------------------------*/ 2778 2779 /* 2780 * Ativa a flag de cancelamento caso o ical for do method CANCEL 2781 */ 2782 $cancelEvent = false; 2783 if (strtoupper($ical['method']['value']) == 'CANCEL') 2784 $cancelEvent = true; 2785 /*-------------------------------------------------------------*/ 2786 2787 require_once ($_SESSION['rootPath'] . '/calendar/inc/class.ex_participants.inc.php'); 2788 2789 $c_events = count($ical['event']); 2790 for ($i = 0; $i < $c_events; $i++) { 2791 $ex_participants = new exParticipants(); 2792 2793 if ($ical['event'][$i]['uid']['value']) 2794 $uid_exists = $so_event->find_cal_id($ical['event'][$i]['uid']['value']); 2795 else 2796 $uid_exists = False; 2797 2798 if ($cancelEvent) // If cancelamento 3043 2799 { 3044 $uid_exists = $so_event->find_uid($ical['event'][$i]['uid']['value']); 3045 } 3046 else 3047 { 3048 $uid_exists = False; 3049 } 3050 if($uid_exists) 3051 { 3052 // $event = $so_event->read_entry($uid_exists); 3053 // $this->check_owner($event,$ical['event'][$i],$so_event); 3054 // $event = $so_event->get_cached_event(); 3055 // $so_event->add_entry($event); 3056 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', 3057 Array( 3058 'menuaction' => 'calendar.uiicalendar.import', 3059 'error_number' => 1 3060 ) 3061 ) 3062 ); 3063 $GLOBALS['phpwg']->common->phpgw_exit(); 3064 3065 } 3066 else 3067 { 2800 if ($importAccount != false && !$this->safeBitCheck(8, $row['acl_rights'])) // se for em uma conta compartilhada e se tem permisão de deletar 2801 return 'You do not have permission to delete events'; 2802 2803 if ($uid_exists) // If o evento existe na agenda 2804 $so_event->delete_entry($uid_exists); // Adicona o id a lista de eventos a deletar 2805 2806 continue; // Continua o for nenhum processamento mais é nescessario 2807 } 2808 2809 if ($uid_exists) { 2810 $event = $so_event->read_entry($uid_exists); 2811 $this->check_owner($event, $ical['event'][$i], $so_event); 2812 } else { 3068 2813 $so_event->event_init(); 3069 $so_event->add_attribute('id',0);3070 $so_event->add_attribute('reference',0);3071 if($ical['event'][$i]['uid']['value'])3072 { 3073 $so_event->add_attribute('uid',$ical['event'][$i]['uid']['value']);3074 }3075 if($ical['event'][$i]['summary']['value'])3076 2814 $so_event->add_attribute('id', 0); 2815 $so_event->add_attribute('reference', 0); 2816 } 2817 2818 if ($ical['event'][$i]['uid']['value']) { 2819 $so_event->add_attribute('uid', $ical['event'][$i]['uid']['value']); 2820 } 2821 if ($ical['event'][$i]['summary']['value']) { 3077 2822 $so_event->set_title($ical['event'][$i]['summary']['value']); 3078 2823 } 3079 if($ical['event'][$i]['description']['value']) 3080 { 2824 if ($ical['event'][$i]['description']['value']) { 3081 2825 $so_event->set_description($ical['event'][$i]['description']['value']); 3082 2826 } 3083 if($ical['event'][$i]['ex_participants']['value']) 3084 { 3085 $so_event->set_ex_participants($ical['event'][$i]['ex_participants']['value']); 2827 if ($ical['event'][$i]['ex_participants']['value']) { 2828 $ex_participants->setParticipantsByString($ical['event'][$i]['ex_participants']['value']); 3086 2829 } 3087 2830 // Compatibilidade com agendamentos vindos do outlook/exchange 3088 if ( isset ($ical['event'][$i]['attendee']) ) 3089 { 2831 if (isset ($ical['event'][$i]['attendee'])) { 3090 2832 $c_attendees = count($ical['event'][$i]['attendee']); 3091 2833 $all_attendees = ''; 3092 for ( $a=0; $a < $c_attendees; $a++ ) 3093 { 3094 $cname = '"'. $ical['event'][$i]['attendee'][$a]['cn'] .'"'; 2834 for ($a = 0; $a < $c_attendees; $a++) { 2835 $cname = '"' . $ical['event'][$i]['attendee'][$a]['cn'] . '"'; 3095 2836 $email = $ical['event'][$i]['attendee'][$a]['mailto']['user']; 3096 if ( $email ) 3097 { 2837 if ($email) { 3098 2838 // Remove os espaços, tabs e quebra-de-linha no dominio 3099 2839 //$email_domain = preg_replace('/\s*/m', '', $ical['event'][$i]['attendee'][$a]['mailto']['host']); 3100 2840 $email_domain = $ical['event'][$i]['attendee'][$a]['mailto']['host']; 3101 $email = '<'. $email .'@'. $email_domain .'>'; 3102 } 3103 else 2841 $email = '<' . $email . '@' . $email_domain . '>'; 2842 } else 3104 2843 $email = ''; 3105 2844 3106 $all_attendees .= $cname . $email .', '; 3107 } 3108 $this->debug ('All attendees: ' . $all_attendees); 3109 $so_event->set_ex_participants($all_attendees); 3110 } 3111 3112 if($ical['event'][$i]['location']['value']) 3113 { 3114 $so_event->add_attribute('location',$ical['event'][$i]['location']['value']); 3115 } 3116 if(isset($ical['event'][$i]['priority'])) 3117 { 3118 $so_event->add_attribute('priority',$ical['event'][$i]['priority']); 3119 } 3120 else 3121 { 3122 $so_event->add_attribute('priority',2); 3123 } 3124 if(!isset($ical['event'][$i]['class'])) 3125 { 2845 $all_attendees .= $cname . $email . ', '; 2846 } 2847 $this->debug('All attendees: ' . $all_attendees); 2848 2849 $ex_participants->setParticipantsByString($all_attendees); 2850 2851 } 2852 2853 if ($ical['event'][$i]['location']['value']) { 2854 $so_event->add_attribute('location', $ical['event'][$i]['location']['value']); 2855 } 2856 if (isset ($ical['event'][$i]['priority'])) { 2857 $so_event->add_attribute('priority', $ical['event'][$i]['priority']); 2858 } else { 2859 $so_event->add_attribute('priority', 2); 2860 } 2861 if (!isset ($ical['event'][$i]['class'])) { 3126 2862 $ical['event'][$i]['class'] = 1; 3127 2863 } 3128 2864 $so_event->set_class($ical['event'][$i]['class']); 3129 2865 3130 @reset($datetime_vars); 3131 while(list($e_datevar,$i_datevar) = each($datetime_vars)) 3132 { 3133 if(isset($ical['event'][$i][$i_datevar])) 3134 { 2866 @ reset($datetime_vars); 2867 while (list ($e_datevar, $i_datevar) = each($datetime_vars)) { 2868 if (isset ($ical['event'][$i][$i_datevar])) { 3135 2869 $temp_time = $so_event->maketime($ical['event'][$i][$i_datevar]) + $GLOBALS['phpgw']->datetime->tz_offset; 3136 3137 //verifica se o vcard importado tem a referência do timezone 3138 if($ical['event'][$i][$i_datevar]['tzid']) { 3139 $dateTimeZone = new DateTimeZone( $ical['event'][$i][$i_datevar]['tzid'] ); 3140 $dateTime = new DateTime("now", $dateTimeZone); 3141 $timeOffset = $dateTimeZone->getOffset($dateTime); 3142 3143 //tira o time zone do vcard para só ficar o time zone do sistema 3144 $temp_time = $temp_time - $timeOffset; 2870 @ reset($date_array); 2871 while (list ($key, $var) = each($date_array)) { 2872 $event[$e_datevar][$var] = (int) (date($key, $temp_time)); 3145 2873 } 3146 3147 @reset($date_array); 3148 while(list($key,$var) = each($date_array)) 3149 { 3150 $event[$e_datevar][$var] = (int)(date($key,$temp_time)); 3151 } 3152 $so_event->set_date($e_datevar,$event[$e_datevar]['year'],$event[$e_datevar]['month'],$event[$e_datevar]['mday'],$event[$e_datevar]['hour'],$event[$e_datevar]['min'],$event[$e_datevar]['sec']); 3153 } 3154 } 3155 if(!isset($ical['event'][$i]['categories']['value']) || !$ical['event'][$i]['categories']['value']) 3156 { 2874 $so_event->set_date($e_datevar, $event[$e_datevar]['year'], $event[$e_datevar]['month'], $event[$e_datevar]['mday'], $event[$e_datevar]['hour'], $event[$e_datevar]['min'], $event[$e_datevar]['sec']); 2875 } 2876 } 2877 if (!isset ($ical['event'][$i]['categories']['value']) || !$ical['event'][$i]['categories']['value']) { 3157 2878 $so_event->set_category(0); 3158 } 3159 else 3160 { 3161 $ical_cats = Array(); 3162 if(strpos($ical['event'][$i]['categories']['value'],$cat_sep)) 3163 { 3164 $ical_cats = explode($cat_sep,$ical['event'][$i]['categories']['value']); 3165 } 3166 else 3167 { 2879 } else { 2880 $ical_cats = Array (); 2881 if (strpos($ical['event'][$i]['categories']['value'], $cat_sep)) { 2882 $ical_cats = explode($cat_sep, $ical['event'][$i]['categories']['value']); 2883 } else { 3168 2884 $ical_cats[] = $ical['event'][$i]['categories']['value']; 3169 2885 } 3170 2886 3171 @reset($ical_cats); 3172 $cat_id_nums = Array(); 3173 while(list($key,$cat) = each($ical_cats)) 3174 { 3175 if(!$cats->exists('appandmains',$cat)) 3176 { 3177 $cats->add( 3178 Array( 2887 @ reset($ical_cats); 2888 $cat_id_nums = Array (); 2889 while (list ($key, $cat) = each($ical_cats)) { 2890 if (!$cats->exists('appandmains', $cat)) { 2891 $cats->add(Array ( 3179 2892 'name' => $cat, 3180 2893 'descr' => $cat, … … 3182 2895 'access' => 'private', 3183 2896 'data' => '' 3184 ) 3185 ); 2897 )); 3186 2898 } 3187 // $temp_id = $cats->name2id($cat);3188 // echo 'Category Name : '.$cat.' : Category ID :'.$temp_id."<br>\n";3189 // $cat_id_nums[] = $temp_id;2899 // $temp_id = $cats->name2id($cat); 2900 // echo 'Category Name : '.$cat.' : Category ID :'.$temp_id."<br>\n"; 2901 // $cat_id_nums[] = $temp_id; 3190 2902 $cat_id_nums[] = $cats->name2id($cat); 3191 2903 } 3192 @reset($cat_id_nums); 3193 if(count($cat_id_nums) > 1) 3194 { 3195 $so_event->set_category(implode($cat_id_nums,',')); 3196 } 3197 else 3198 { 2904 @ reset($cat_id_nums); 2905 if (count($cat_id_nums) > 1) { 2906 $so_event->set_category(implode($cat_id_nums, ',')); 2907 } else { 3199 2908 $so_event->set_category($cat_id_nums[0]); 3200 2909 } 3201 2910 } 3202 2911 3203 //rrule 3204 if(isset($ical['event'][$i]['rrule']) OR isset($ical['event'][$i]['duration']) ) 3205 { 3206 // recur_enddate 3207 if(isset($ical['event'][$i]['rrule']['until'])) 3208 { 3209 $recur_enddate['year'] = (int)($ical['event'][$i]['rrule']['until']['year']); 3210 $recur_enddate['month'] = (int)($ical['event'][$i]['rrule']['until']['month']); 3211 $recur_enddate['mday'] = (int)($ical['event'][$i]['rrule']['until']['mday']); 3212 } 3213 elseif( isset($ical['event'][$i]['duration']) ) 3214 { 2912 //rrule 2913 if (isset ($ical['event'][$i]['rrule']) OR isset ($ical['event'][$i]['duration'])) { 2914 // recur_enddate 2915 if (isset ($ical['event'][$i]['rrule']['until'])) { 2916 $recur_enddate['year'] = (int) ($ical['event'][$i]['rrule']['until']['year']); 2917 $recur_enddate['month'] = (int) ($ical['event'][$i]['rrule']['until']['month']); 2918 $recur_enddate['mday'] = (int) ($ical['event'][$i]['rrule']['until']['mday']); 2919 } 2920 elseif (isset ($ical['event'][$i]['duration'])) { 3215 2921 // Create timecode for strtotime 3216 $ptimer = mktime($ical['event'][$i]['dtstart']['hour'], 3217 $ical['event'][$i]['dtstart']['min'], 3218 $ical['event'][$i]['dtstart']['sec'], 3219 $ical['event'][$i]['dtstart']['month'], 3220 $ical['event'][$i]['dtstart']['mday'], 3221 $ical['event'][$i]['dtstart']['year'] 3222 ); 2922 $ptimer = mktime($ical['event'][$i]['dtstart']['hour'], $ical['event'][$i]['dtstart']['min'], $ical['event'][$i]['dtstart']['sec'], $ical['event'][$i]['dtstart']['month'], $ical['event'][$i]['dtstart']['mday'], $ical['event'][$i]['dtstart']['year']); 3223 2923 3224 2924 /* -- Fixbug -- … … 3230 2930 3231 2931 // Weeks::Day-- 3232 if( $ical['event'][$i]['duration']['weeks'] 3233 AND 3234 ( $ical['event'][$i]['duration']['hours'] == 0 ) 3235 AND 3236 ( $ical['event'][$i]['duration']['minutes'] == 0 ) 3237 ) 3238 { 3239 $ical['event'][$i]['duration']['days'] = ( 3240 $ical['event'][$i]['duration']['days'] + 3241 ($ical['event'][$i]['duration']['weeks']*7))-1; 3242 unset($ical['event'][$i]['duration']['weeks']); 2932 if ($ical['event'][$i]['duration']['weeks'] AND ($ical['event'][$i]['duration']['hours'] == 0) AND ($ical['event'][$i]['duration']['minutes'] == 0)) { 2933 $ical['event'][$i]['duration']['days'] = ($ical['event'][$i]['duration']['days'] + ($ical['event'][$i]['duration']['weeks'] * 7)) - 1; 2934 unset ($ical['event'][$i]['duration']['weeks']); 3243 2935 $ical['event'][$i]['duration']['hours'] = "23"; 3244 2936 $ical['event'][$i]['duration']['minutes'] = "59"; … … 3246 2938 } 3247 2939 // Days::Day-- 3248 if( 3249 $ical['event'][$i]['duration']['days'] 3250 AND 3251 ( $ical['event'][$i]['duration']['hours'] == 0 ) 3252 AND 3253 ( $ical['event'][$i]['duration']['minutes'] == 0 ) 3254 ) 3255 { 2940 if ($ical['event'][$i]['duration']['days'] AND ($ical['event'][$i]['duration']['hours'] == 0) AND ($ical['event'][$i]['duration']['minutes'] == 0)) { 3256 2941 $ical['event'][$i]['duration']['days']--; 3257 2942 $ical['event'][$i]['duration']['hours'] = "23"; … … 3262 2947 // Create string contains datetime for strtotime 3263 2948 $pdate = "+"; 3264 if( isset($ical['event'][$i]['duration']['weeks']))2949 if (isset ($ical['event'][$i]['duration']['weeks'])) 3265 2950 $pdate .= $ical['event'][$i]['duration']['weeks'] . " weeks "; 3266 if( isset($ical['event'][$i]['duration']['days']))2951 if (isset ($ical['event'][$i]['duration']['days'])) 3267 2952 $pdate .= $ical['event'][$i]['duration']['days'] . " days "; 3268 if( isset($ical['event'][$i]['duration']['hours']))2953 if (isset ($ical['event'][$i]['duration']['hours'])) 3269 2954 $pdate .= $ical['event'][$i]['duration']['hours'] . " hours "; 3270 if( isset($ical['event'][$i]['duration']['minutes']))2955 if (isset ($ical['event'][$i]['duration']['minutes'])) 3271 2956 $pdate .= $ical['event'][$i]['duration']['minutes'] . " minutes "; 3272 if( isset($ical['event'][$i]['duration']['seconds']))2957 if (isset ($ical['event'][$i]['duration']['seconds'])) 3273 2958 $pdate .= $ical['event'][$i]['duration']['seconds'] . " seconds "; 3274 2959 3275 2960 // What is datetime in 2192 ? 3276 2961 $enddate = strtotime($pdate, $ptimer); 3277 list( $recur_enddate['year'], 3278 $recur_enddate['month'], 3279 $recur_enddate['mday'], 3280 $recur_enddate['hour'], 3281 $recur_enddate['min'], 3282 $recur_enddate['sec'] ) = split(":", date("Y:m:d:H:i:s", $enddate)); 2962 list ($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $recur_enddate['hour'], $recur_enddate['min'], $recur_enddate['sec']) = split(":", date("Y:m:d:H:i:s", $enddate)); 3283 2963 3284 2964 // Set End of event 3285 $so_event->set_end( $recur_enddate['year'], 3286 $recur_enddate['month'], 3287 $recur_enddate['mday'], 3288 $recur_enddate['hour'], 3289 $recur_enddate['min'], 3290 $recur_enddate['sec']); 3291 3292 } 3293 else 3294 { 2965 $so_event->set_end($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $recur_enddate['hour'], $recur_enddate['min'], $recur_enddate['sec']); 2966 2967 } else { 3295 2968 $recur_enddate['year'] = 0; 3296 2969 $recur_enddate['month'] = 0; … … 3298 2971 } 3299 2972 3300 // recur_data2973 // recur_data 3301 2974 $recur_data = 0; 3302 if(isset($ical['event'][$i]['rrule']['byday'])) 3303 { 3304 $week_days = Array( 2975 if (isset ($ical['event'][$i]['rrule']['byday'])) { 2976 $week_days = Array ( 3305 2977 MCAL_M_SUNDAY => 'SU', 3306 2978 MCAL_M_MONDAY => 'MO', … … 3311 2983 MCAL_M_SATURDAY => 'SA' 3312 2984 ); 3313 @reset($week_days); 3314 while(list($key,$val) = each($week_days)) 3315 { 3316 if(strpos(' '.$ical['event'][$i]['rrule']['byday'],$val)) 3317 { 2985 @ reset($week_days); 2986 while (list ($key, $val) = each($week_days)) { 2987 if (strpos(' ' . $ical['event'][$i]['rrule']['byday'], $val)) { 3318 2988 $recur_data += $key; 3319 2989 } … … 3321 2991 } 3322 2992 3323 // interval 3324 if(!isset($ical['event'][$i]['rrule']['interval'])) 3325 { 2993 // interval 2994 if (!isset ($ical['event'][$i]['rrule']['interval'])) { 3326 2995 $interval = 1; 3327 } 3328 else 3329 { 3330 $interval = (int)$ical['event'][$i]['rrule']['interval']; 3331 } 3332 // recur_type 3333 switch($ical['event'][$i]['rrule']['freq']) 3334 { 3335 case DAILY: 2996 } else { 2997 $interval = (int) $ical['event'][$i]['rrule']['interval']; 2998 } 2999 // recur_type 3000 switch ($ical['event'][$i]['rrule']['freq']) { 3001 case DAILY : 3336 3002 $recur_type = MCAL_RECUR_DAILY; 3337 3003 break; 3338 case WEEKLY:3339 $so_event->set_recur_weekly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$interval,$recur_data);3004 case WEEKLY : 3005 $so_event->set_recur_weekly($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $interval, $recur_data); 3340 3006 break; 3341 case MONTHLY:3342 // Still need to determine if this is by day or by week for the month..3343 // $recur_type = MCAL_RECUR_M??????;3007 case MONTHLY : 3008 // Still need to determine if this is by day or by week for the month.. 3009 // $recur_type = MCAL_RECUR_M??????; 3344 3010 break; 3345 case YEARLY:3346 $so_event->set_recur_yearly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$interval);3011 case YEARLY : 3012 $so_event->set_recur_yearly($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $interval); 3347 3013 break; 3348 3014 } 3349 } 3350 else 3015 } else { 3016 $so_event->set_recur_none(); 3017 } 3018 3019 // Owner 3020 $organizer = $ical['event'][$i]['organizer']; 3021 3022 if (isset ($organizer)) { 3023 if ($this->is_owner($organizer) || $organizer == -2) { 3024 $so_event->add_attribute('owner', $GLOBALS['phpgw_info']['user']['account_id']); 3025 } else { 3026 $so_event->add_attribute('owner', -2); 3027 $aux = explode(':', $organizer['cn']); 3028 $so_event->add_attribute('organizer', '' . $aux[0] . ' <' . $organizer['mailto']['user'] . '@'. $organizer['mailto']['host'].'>'); 3029 } 3030 } 3031 3032 // se for importação para conta compartilhada 3033 $user = (int) ($importAccount ? $importAccount['uidnumber'] : $GLOBALS['phpgw_info']['user']['account_id']); 3034 $userMail = $importAccount['mail'] ? $importAccount['mail'] : $GLOBALS['phpgw_info']['user']['email']; 3035 3036 $so_event->add_attribute('participants', 'A', $user); 3037 $event = $so_event->get_cached_event(); 3038 3039 /* 3040 * Remove Email do participantes externos 3041 */ 3042 $usersToRemove = array (); 3043 $usersToRemove[] = $user; 3044 foreach ($event['participants'] as $auxi=> $v) 3045 $usersToRemove[] = $auxi; 3046 3047 $ldapService = ServiceLocator :: getService('ldap'); 3048 foreach ($usersToRemove as $v) { 3049 $ex_participants->removeParticipant($ldapService->getMailByUidNumber($v)); 3050 $alternates = $ldapService->getMailAlternateByUidNumber($v); 3051 foreach ($alternates as $ii => $vv) 3052 $ex_participants->removeParticipant($vv); 3053 } 3054 $ex_participants->removeParticipant($event['organizer']); 3055 /// -------------------------------------------------------- /// 3056 3057 $event['ex_participants'] = $ex_participants->getParticipantsSerializable(); 3058 3059 if (!isset ($this->bo)) { 3060 require_once ($_SESSION['rootPath'] . '/calendar/inc/class.bocalendar.inc.php'); 3061 $this->bo = new bocalendar(); 3062 } 3063 3064 if ($c_events < 2) //Ignora verificação de conflito quando o ical é de varios eventos 3065 { 3066 if ($overlapping_events = $this->bo->event_overlap($event, (!$from_ajax), null, $user)) { 3067 if ($_GET['calendarImport'] == 1) //caso venha do modulo calendar 3351 3068 { 3352 $so_event->set_recur_none(); 3353 } 3354 3355 // Owner 3356 if(!isset($ical['event'][$i]['organizer']) || (isset($ical['event'][$i]['organizer']) && $this->is_owner($ical['event'][$i]['organizer']))) 3357 { 3358 $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); 3359 $so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']); 3360 } 3361 else 3362 { 3363 $so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']); 3364 } 3365 3366 $event = $so_event->get_cached_event(); 3367 $so_event->add_entry($event); 3368 // $event = $so_event->get_cached_event(); 3369 } 3370 } 3371 if(!$from_ajax) { 3372 Header('Location: '.$GLOBALS['phpgw']->link('/index.php', 3373 Array( 3069 $url = 'expressoMail1_2/controller.php?action=' . implode("&", array ( 3070 'calendar.uicalendar.overlap', 3071 'o_events=' . implode(';', $overlapping_events), 3072 'this_event=' . $event['id'], 3073 'this_account=' . $user 3074 )); 3075 3076 echo "<script>document.location='" . $url . "'</script>"; 3077 exit; 3078 } else 3079 return array ( 3080 'url' => implode("&", array ( 3081 'calendar.uicalendar.overlap', 3082 'o_events=' . implode(';', $overlapping_events), 3083 'this_event=' . $event['id'], 3084 'this_account=' . $user 3085 )) 3086 ); 3087 } 3088 } 3089 3090 if ($importAccount) 3091 $so_event->add_entry($event, true, $importAccount); 3092 else 3093 $so_event->add_entry($event); 3094 3095 } 3096 3097 /* 3098 * Exclue os eventos que estão na lista para serem deletados 3099 */ 3100 if ($cancelEvent) 3101 $so_event->expunge(); 3102 /*----------------------------------------------------------*/ 3103 3104 if (!$from_ajax) { 3105 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', Array ( 3374 3106 'menuaction' => 'calendar.uicalendar.view', 3375 3107 'cal_id' => $event['id'] 3376 ) 3377 ) 3378 ); 3108 ))); 3379 3109 $GLOBALS['phpgw']->common->phpgw_exit(); 3380 }3381 else3110 } else // checando se o icalendar veio no formato esperado, ou seja, foi parseado corretamente 3111 if (!empty ($ical)) 3382 3112 return true; 3383 } 3384 3385 function export($params) 3386 { 3113 else 3114 return 'Cannot import target event. Please check if the format is right.'; 3115 3116 } 3117 3118 function updateHour($ical) { 3119 3120 if (!is_object($GLOBALS['uicalendar'])) { 3121 $so_event = createobject('calendar.socalendar', Array ( 3122 'owner' => 0, 3123 'filter' => '', 3124 'category' => '' 3125 )); 3126 } else 3127 $so_event = $GLOBALS['uicalendar']->bo->so; 3128 3129 $cal_id = $so_event->find_cal_id($ical['event'][0]['uid']['value']); 3130 3131 //Agendamento nao ecnontrado 3132 if (!$cal_id) 3133 return 'The event was not found in your calendar'; 3134 3135 $event = $so_event->read_entry($cal_id); 3136 3137 $datetime_vars = Array ( 3138 'start' => 'dtstart', 3139 'end' => 'dtend', 3140 'modtime' => 'dtstamp', 3141 'modtime' => 'last_modified' 3142 ); 3143 3144 $date_array = Array ( 3145 'Y' => 'year', 3146 'm' => 'month', 3147 'd' => 'mday', 3148 'H' => 'hour', 3149 'i' => 'min', 3150 's' => 'sec' 3151 ); 3152 3153 @ reset($datetime_vars); 3154 while (list ($e_datevar, $i_datevar) = each($datetime_vars)) { 3155 if (isset ($ical['event'][0][$i_datevar])) { 3156 $temp_time = $so_event->maketime($ical['event'][0][$i_datevar]); 3157 @ reset($date_array); 3158 while (list ($key, $var) = each($date_array)) 3159 $event[$e_datevar][$var] = (int) (date($key, $temp_time)); 3160 3161 $so_event->set_date($e_datevar, $event[$e_datevar]['year'], $event[$e_datevar]['month'], $event[$e_datevar]['mday'], $event[$e_datevar]['hour'], $event[$e_datevar]['min'], $event[$e_datevar]['sec']); 3162 } 3163 } 3164 3165 $so_event->add_entry($event, false); 3166 $bo_event = createobject('calendar.bocalendar'); 3167 $bo_event->send_update(MSG_MODIFIED, $event['participants'], $event, $event); 3168 3169 return 'Event successfully updated'; 3170 } 3171 3172 function export($params) { 3387 3173 $event_id = $params['l_event_id'] ? $params['l_event_id'] : $_GET['cal_id']; 3388 3174 $this->chunk_split = $params['chunk_split']; … … 3390 3176 $vtype = $params['vtype'] ? $params['vtype'] : 'event'; 3391 3177 3392 $string_array = Array(3178 $string_array = Array ( 3393 3179 'summary' => 'description', 3394 3180 'location' => 'location', … … 3399 3185 $cats = CreateObject('phpgwapi.categories'); 3400 3186 3401 include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); 3402 if(!is_array($event_id)) 3403 { 3187 include (PHPGW_SERVER_ROOT . '/calendar/setup/setup.inc.php'); 3188 if (!is_array($event_id)) { 3404 3189 $ids[] = $event_id; 3405 } 3406 else 3407 { 3190 } else { 3408 3191 $ids = $event_id; 3409 3192 } … … 3411 3194 $ical = $this->new_ical(); 3412 3195 3413 $this->set_var($ical['prodid'],'value','-//eGroupWare//eGroupWare '.$setup_info['calendar']['version'].' MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])); 3414 $this->set_var($ical['version'],'value','2.0'); 3415 $this->set_var($ical['method'],'value',strtoupper($method)); 3416 3417 if(!$GLOBALS['phpgw_info']['flags']['included_classes']['uicalendar']) 3418 { 3419 if(!$GLOBALS['phpgw_info']['flags']['included_classes']['bocalendar']) 3420 { 3421 $so_event = createobject('calendar.socalendar', 3422 Array( 3196 $this->set_var($ical['prodid'], 'value', '-//eGroupWare//eGroupWare ' . $setup_info['calendar']['version'] . ' MIMEDIR//' . strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])); 3197 $this->set_var($ical['version'], 'value', '2.0'); 3198 $this->set_var($ical['method'], 'value', strtoupper($method)); 3199 3200 if (!$GLOBALS['phpgw_info']['flags']['included_classes']['uicalendar']) { 3201 if (!$GLOBALS['phpgw_info']['flags']['included_classes']['bocalendar']) { 3202 $so_event = createobject('calendar.socalendar', Array ( 3423 3203 'owner' => 0, 3424 3204 'filter' => '', 3425 3205 'category' => '' 3426 ) 3427 ); 3428 } 3429 else 3430 { 3206 )); 3207 } else { 3431 3208 $so_event = $GLOBALS['bocalendar']->so; 3432 3209 } 3433 } 3434 else 3435 { 3210 } else { 3436 3211 $so_event = $GLOBALS['uicalendar']->bo->so; 3437 3212 } 3438 3213 3439 foreach($ids as $event) 3440 { 3441 $ical_event = Array(); 3442 if (!is_array($event)) 3443 { 3214 foreach ($ids as $event) { 3215 $ical_event = Array (); 3216 if (!is_array($event)) { 3444 3217 $event = $so_event->read_entry($event); 3445 3218 } 3446 if($event['alarm']) 3447 { 3448 foreach($event['alarm'] as $alarm) 3449 { 3450 $ical_temp = Array(); 3219 if ($event['alarm']) { 3220 foreach ($event['alarm'] as $alarm) { 3221 $ical_temp = Array (); 3451 3222 $ical_temp['action']['value'] = 'DISPLAY'; 3452 3223 $ical_temp['description']['value'] = $alarm['text']; 3453 $this->set_var($ical_temp['trigger'],'value','VALUE=DATE-TIME:'.date('Ymd\THis\Z',$alarm['time']),'valarm');3224 $this->set_var($ical_temp['trigger'], 'value', 'VALUE=DATE-TIME:' . date('Ymd\THis\Z', $alarm['time']), 'valarm'); 3454 3225 $ical_event['alarm'][] = $ical_temp; 3455 3226 } … … 3458 3229 // use system's date info for caluculating local timezone's offset in minutes 3459 3230 // 3460 $gmt_offset = date('O',$GLOBALS['phpgw']->datetime->users_localtime);// offset to GMT3461 $offset = (int)(substr($gmt_offset, 0, 3)) * 60 + (int)(substr($gmt_offset, 3, 2));3231 $gmt_offset = date('O', $GLOBALS['phpgw']->datetime->users_localtime); // offset to GMT 3232 $offset = (int) (substr($gmt_offset, 0, 3)) * 60 + (int) (substr($gmt_offset, 3, 2)); 3462 3233 $event['start']['min'] -= $offset; 3463 3234 $event['end']['min'] -= $offset; … … 3465 3236 3466 3237 $ical_event['priority'] = $event['priority']; 3467 $ical_event['class'] = (int)$event['public'];3238 $ical_event['class'] = (int) $event['public']; 3468 3239 $dtstart_mktime = $so_event->maketime($event['start']); 3469 $this->parse_value($ical_event,'dtstart',date('Ymd\THis\Z',$dtstart_mktime),'vevent');3240 $this->parse_value($ical_event, 'dtstart', date('Ymd\THis\Z', $dtstart_mktime), 'vevent'); 3470 3241 $dtend_mktime = $so_event->maketime($event['end']); 3471 $this->parse_value($ical_event,'dtend',date('Ymd\THis\Z',$dtend_mktime),'vevent');3242 $this->parse_value($ical_event, 'dtend', date('Ymd\THis\Z', $dtend_mktime), 'vevent'); 3472 3243 $mod_mktime = $so_event->maketime($event['modtime']); 3473 $this->parse_value($ical_event,'last_modified',date('Ymd\THis\Z',$mod_mktime),'vevent'); 3474 foreach($string_array as $ical_value => $event_value) 3475 { 3476 if($event[$event_value]) 3477 { 3478 $this->set_var($ical_event[$ical_value],'value',$event[$event_value]); 3479 } 3480 } 3481 3482 if ($event['category']) 3483 { 3484 $cats->categories(0,'calendar'); 3485 foreach(explode(',',$event['category']) as $cat) 3486 { 3244 $this->parse_value($ical_event, 'last_modified', date('Ymd\THis\Z', $mod_mktime), 'vevent'); 3245 foreach ($string_array as $ical_value => $event_value) { 3246 if ($event[$event_value]) { 3247 $this->set_var($ical_event[$ical_value], 'value', $event[$event_value]); 3248 } 3249 } 3250 3251 if ($event['category']) { 3252 $cats->categories(0, 'calendar'); 3253 foreach (explode(',', $event['category']) as $cat) { 3487 3254 $_cat = $cats->return_single($cat); 3488 3255 $cat_string[] = $_cat[0]['name']; 3489 3256 } 3490 @reset($cat_string); 3491 $this->set_var($ical_event['categories'],'value',implode($cat_string,',')); 3492 } 3493 3494 if(count($event['participants']) > 1) 3495 { 3496 if(!is_object($db)) 3497 { 3257 @ reset($cat_string); 3258 $this->set_var($ical_event['categories'], 'value', implode($cat_string, ',')); 3259 } 3260 3261 if (count($event['participants']) > 1) { 3262 if (!is_object($db)) { 3498 3263 $db = $GLOBALS['phpgw']->db; 3499 3264 } 3500 foreach($event['participants'] as $part => $status) 3501 { 3502 $GLOBALS['phpgw']->accounts->get_account_name($part,$lid,$fname,$lname); 3503 $name = $fname.' '.$lname; 3504 3505 $owner_status = $this->switch_partstat((int)$this->switch_phpgw_status($event['participants'][$part])); 3265 foreach ($event['participants'] as $part => $status) { 3266 $GLOBALS['phpgw']->accounts->get_account_name($part, $lid, $fname, $lname); 3267 $name = $fname . ' ' . $lname; 3268 3269 $owner_status = $this->switch_partstat((int) $this->switch_phpgw_status($event['participants'][$part])); 3506 3270 3507 3271 $mail_prefs = $GLOBALS['phpgw']->preferences->create_email_preferences($part); 3508 3272 $mailto = $mail_prefs['email']['address']; 3509 3273 3510 $str = 'CN="'.$name.'";PARTSTAT='.$owner_status.':'.$mailto; 3511 if($part == $event['owner']) 3512 { 3513 $str = 'ROLE=CHAIR;'.$str; 3514 } 3515 else 3516 { 3517 $str = 'ROLE=REQ-PARTICIPANT;'.$str; 3518 } 3519 if ($method != 'reply' || $part == $GLOBALS['phpgw_info']['user']['account_id']) 3520 { 3521 $this->parse_value($ical_event,'attendee',$str,'vevent'); 3522 } 3523 if($part == $event['owner']) 3524 { 3525 $this->parse_value($ical_event,'organizer',$str,'vevent'); 3526 } 3527 } 3528 } 3529 if($event['recur_type']) 3530 { 3274 $str = 'CN="' . $name . '";PARTSTAT=' . $owner_status . ':' . $mailto; 3275 if ($part == $event['owner']) { 3276 $str = 'ROLE=CHAIR;' . $str; 3277 } else { 3278 $str = 'ROLE=REQ-PARTICIPANT;' . $str; 3279 } 3280 if ($method != 'reply' || $part == $GLOBALS['phpgw_info']['user']['account_id']) { 3281 $this->parse_value($ical_event, 'attendee', $str, 'vevent'); 3282 } 3283 if ($part == $event['owner']) { 3284 $this->parse_value($ical_event, 'organizer', $str, 'vevent'); 3285 } 3286 } 3287 } 3288 if ($event['recur_type']) { 3531 3289 $str = ''; 3532 switch($event['recur_type']) 3533 { 3534 case MCAL_RECUR_DAILY: 3290 switch ($event['recur_type']) { 3291 case MCAL_RECUR_DAILY : 3535 3292 $str .= 'FREQ=DAILY'; 3536 3293 break; 3537 case MCAL_RECUR_WEEKLY:3294 case MCAL_RECUR_WEEKLY : 3538 3295 $str .= 'FREQ=WEEKLY'; 3539 if($event['recur_data']) 3540 { 3296 if ($event['recur_data']) { 3541 3297 $str .= ';BYDAY='; 3542 for($i=1;$i<MCAL_M_ALLDAYS;$i=$i*2) 3543 { 3544 if($i & $event['recur_data']) 3545 { 3546 switch($i) 3547 { 3548 case MCAL_M_SUNDAY: 3298 for ($i = 1; $i < MCAL_M_ALLDAYS; $i = $i * 2) { 3299 if ($i & $event['recur_data']) { 3300 switch ($i) { 3301 case MCAL_M_SUNDAY : 3549 3302 $day[] = 'SU'; 3550 3303 break; 3551 case MCAL_M_MONDAY:3304 case MCAL_M_MONDAY : 3552 3305 $day[] = 'MO'; 3553 3306 break; 3554 CASE MCAL_M_TUESDAY:3307 CASE MCAL_M_TUESDAY : 3555 3308 $day[] = 'TU'; 3556 3309 break; 3557 case MCAL_M_WEDNESDAY:3310 case MCAL_M_WEDNESDAY : 3558 3311 $day[] = 'WE'; 3559 3312 break; 3560 case MCAL_M_THURSDAY:3313 case MCAL_M_THURSDAY : 3561 3314 $day[] = 'TH'; 3562 3315 break; 3563 case MCAL_M_FRIDAY:3316 case MCAL_M_FRIDAY : 3564 3317 $day[] = 'FR'; 3565 3318 break; 3566 case MCAL_M_SATURDAY:3319 case MCAL_M_SATURDAY : 3567 3320 $day[] = 'SA'; 3568 3321 break; … … 3570 3323 } 3571 3324 } 3572 $str .= implode(',',$day);3325 $str .= implode(',', $day); 3573 3326 } 3574 3327 break; 3575 case MCAL_RECUR_MONTHLY_MDAY:3328 case MCAL_RECUR_MONTHLY_MDAY : 3576 3329 break; 3577 case MCAL_RECUR_MONTHLY_WDAY:3330 case MCAL_RECUR_MONTHLY_WDAY : 3578 3331 break; 3579 case MCAL_RECUR_YEARLY:3332 case MCAL_RECUR_YEARLY : 3580 3333 $str .= 'FREQ=YEARLY'; 3581 3334 break; 3582 3335 } 3583 if($event['recur_interval']) 3584 { 3585 $str .= ';INTERVAL='.$event['recur_interval']; 3586 } 3587 if($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) 3588 { 3336 if ($event['recur_interval']) { 3337 $str .= ';INTERVAL=' . $event['recur_interval']; 3338 } 3339 if ($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) { 3589 3340 $recur_mktime = $so_event->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; 3590 $str .= ';UNTIL='.date('Ymd\THis\Z',$recur_mktime);3591 } 3592 $this->parse_value($ical_event,'rrule',$str,'vevent');3341 $str .= ';UNTIL=' . date('Ymd\THis\Z', $recur_mktime); 3342 } 3343 $this->parse_value($ical_event, 'rrule', $str, 'vevent'); 3593 3344 3594 3345 $exceptions = $event['recur_exception']; 3595 if(is_array($exceptions)) 3596 { 3597 foreach($exceptions as $except_datetime) 3598 { 3599 $ical_event['exdate'][] = $this->switch_date(date('Ymd\THis\Z',$except_datetime)); 3346 if (is_array($exceptions)) { 3347 foreach ($exceptions as $except_datetime) { 3348 $ical_event['exdate'][] = $this->switch_date(date('Ymd\THis\Z', $except_datetime)); 3600 3349 } 3601 3350 } … … 3607 3356 3608 3357 // iCals are by default utf-8 3609 return $GLOBALS['phpgw']->translation->convert($this->build_ical($ical),$GLOBALS['phpgw']->translation->charset(),'utf-8');3610 3611 3612 function freebusy($params=False) 3613 {3614 if (!$params)$params = $_GET;3358 return $GLOBALS['phpgw']->translation->convert($this->build_ical($ical), $GLOBALS['phpgw']->translation->charset(), 'utf-8'); 3359 } 3360 3361 function freebusy($params = False) { 3362 if (!$params) 3363 $params = $_GET; 3615 3364 $user = is_numeric($params['user']) ? (int) $params['user'] : $GLOBALS['phpgw']->accounts->name2id($params['user']); 3616 $start = isset($params['start']) ? $params['start'] : date('Ymd');3617 $end = isset($params['end']) ? $params['end'] : (date('Y')+1).date('md');3365 $start = isset ($params['start']) ? $params['start'] : date('Ymd'); 3366 $end = isset ($params['end']) ? $params['end'] : (date('Y') + 1) . date('md'); 3618 3367 3619 3368 $this->bo = CreateObject('calendar.bocalendar'); 3620 $events_per_day = $this->bo->store_to_cache(array(3369 $events_per_day = $this->bo->store_to_cache(array ( 3621 3370 'owner' => $user, 3622 'syear' => (int) substr($start,0,4),3623 'smonth' => (int) substr($start,4,2),3624 'sday' => (int) substr($start,6,2),3625 'eyear' => (int) substr($end,0,4),3626 'emonth' => (int) substr($end,4,2),3627 'eday' => (int) substr($end,6,2),3371 'syear' => (int) substr($start, 0, 4), 3372 'smonth' => (int) substr($start, 4, 2), 3373 'sday' => (int) substr($start, 6, 2), 3374 'eyear' => (int) substr($end, 0, 4), 3375 'emonth' => (int) substr($end, 4, 2), 3376 'eday' => (int) substr($end, 6, 2), 3628 3377 'no_doubles' => True, // report events only on the startday 3378 3629 3379 )); 3630 if (!is_array($events_per_day)) $events_per_day = array(); 3631 $ids = array(); 3632 foreach($events_per_day as $day => $events) 3633 { 3634 foreach($events as $event) 3635 { 3380 if (!is_array($events_per_day)) 3381 $events_per_day = array (); 3382 $ids = array (); 3383 foreach ($events_per_day as $day => $events) { 3384 foreach ($events as $event) { 3636 3385 $ids[] = $event; 3637 3386 } 3638 3387 } 3639 3388 $browser = CreateObject('phpgwapi.browser'); 3640 $browser->content_header($GLOBALS['phpgw']->accounts->id2name($user).'.ifb','text/calendar');3641 3642 echo $this->export(array(3389 $browser->content_header($GLOBALS['phpgw']->accounts->id2name($user) . '.ifb', 'text/calendar'); 3390 3391 echo $this->export(array ( 3643 3392 'vtype' => 'freebusy', 3644 3393 'l_event_id' => $ids, 3394 3645 3395 )); 3646 } 3647 3648 function debug($str='') 3649 { 3650 if($this->debug_str) 3651 { 3396 } 3397 3398 function debug($str = '') { 3399 if ($this->debug_str) { 3652 3400 //echo $str."<br>\n"; 3653 3401 $log = fopen('/tmp/calendar.log', 'a') or die("nao foi possivel abrir o arquivo /tmp/calendar.log"); … … 3655 3403 fclose($log); 3656 3404 } 3657 } 3658 } 3405 } 3406 3407 function updateExParticipantState($cal_uid, $mail, $situation, $cn = false) { 3408 $db = $GLOBALS['phpgw']->db; 3409 $query = 'SELECT ex_participants FROM phpgw_cal WHERE uid = \'' . trim($cal_uid) . '\''; 3410 if (!$db->query($query)) 3411 return false; 3412 $row = $db->row(true); 3413 3414 if (!$row) 3415 return false; 3416 3417 include_once ($_SESSION['rootPath'] . '/calendar/inc/class.ex_participants.inc.php'); 3418 $exParticipants = new exParticipants(); 3419 $exParticipants->setParticipantsBySerializable($row['ex_participants']); 3420 $exParticipants->updateParticipant($mail, $situation, $cn); 3421 $query = 'UPDATE phpgw_cal SET ex_participants = \'' . $exParticipants->getParticipantsSerializable() . '\' WHERE uid = \'' . trim($cal_uid) . '\''; 3422 if (!$db->query($query)) 3423 return false; 3424 3425 return true; 3426 } 3427 } 3659 3428 ?>
Note: See TracChangeset
for help on using the changeset viewer.