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