@@ -178,15 +178,17 @@ discard block |
||
| 178 | 178 | $acl = new Acl($anon_user); |
| 179 | 179 | $acl->read_repository(); |
| 180 | 180 | foreach ($calendar_bo->resources as $type => $data) |
| 181 | - { |
|
| 181 | + { |
|
| 182 | 182 | // Check anon user's permissions - must have at least run for the hook to be available |
| 183 | 183 | if($acl->check('run',EGW_ACL_READ, $data['app']) && |
| 184 | 184 | $type != '' && $data['app'] && Link::get_registry($data['app'], 'query') |
| 185 | - ) |
|
| 186 | - { |
|
| 185 | + ) { |
|
| 187 | 186 | $_results = Link::query($data['app'], $query,$options); |
| 188 | 187 | } |
| 189 | - if(!$_results) continue; |
|
| 188 | + if(!$_results) |
|
| 189 | + { |
|
| 190 | + continue; |
|
| 191 | + } |
|
| 190 | 192 | $_results = array_unique($_results); |
| 191 | 193 | foreach ($_results as $key => $value) |
| 192 | 194 | { |
@@ -223,8 +225,14 @@ discard block |
||
| 223 | 225 | $arguments['sortby'] = 'month'; |
| 224 | 226 | $arguments['date'] = substr($arguments['date'],0,4).'0101'; |
| 225 | 227 | } |
| 226 | - if (isset($_GET['date'])) $arguments['date'] = $_GET['date']; |
|
| 227 | - if (empty($arguments['cat_id'])) $arguments['cat_id'] = ''; |
|
| 228 | + if (isset($_GET['date'])) |
|
| 229 | + { |
|
| 230 | + $arguments['date'] = $_GET['date']; |
|
| 231 | + } |
|
| 232 | + if (empty($arguments['cat_id'])) |
|
| 233 | + { |
|
| 234 | + $arguments['cat_id'] = ''; |
|
| 235 | + } |
|
| 228 | 236 | if(isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
| 229 | 237 | { |
| 230 | 238 | foreach($arguments['resources'] as $index => $value) |
@@ -259,7 +267,8 @@ discard block |
||
| 259 | 267 | if (is_array($params['owner'])) |
| 260 | 268 | { |
| 261 | 269 | // Buffer, and add anything that gets cleared to the content |
| 262 | - ob_start(function($buffer) use(&$html) { |
|
| 270 | + ob_start(function($buffer) use(&$html) |
|
| 271 | + { |
|
| 263 | 272 | $html .= $buffer; |
| 264 | 273 | return ''; |
| 265 | 274 | }); |
@@ -268,20 +277,26 @@ discard block |
||
| 268 | 277 | $ui->sortby = $arguments['sortby']; |
| 269 | 278 | $ui->owner = $params['owner']; |
| 270 | 279 | |
| 271 | - if (!$ui->planner_view || $ui->planner_view == 'month') // planner monthview |
|
| 280 | + if (!$ui->planner_view || $ui->planner_view == 'month') |
|
| 281 | + { |
|
| 282 | + // planner monthview |
|
| 272 | 283 | { |
| 273 | 284 | if ($ui->day < 15) // show one complete month |
| 274 | 285 | { |
| 275 | 286 | $ui->_week_align_month($ui->first,$ui->last); |
| 287 | + } |
|
| 276 | 288 | } |
| 277 | 289 | else // show 2 half month |
| 278 | 290 | { |
| 279 | 291 | $ui->_week_align_month($ui->first,$ui->last,15); |
| 280 | 292 | } |
| 281 | 293 | } |
| 282 | - elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') // weeekview |
|
| 294 | + elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') |
|
| 295 | + { |
|
| 296 | + // weeekview |
|
| 283 | 297 | { |
| 284 | 298 | $start = new Api\DateTime($ui->date); |
| 299 | + } |
|
| 285 | 300 | $start->setWeekstart(); |
| 286 | 301 | $ui->first = $start->format('ts'); |
| 287 | 302 | $ui->last = $ui->bo->date2array($this->first); |
@@ -115,7 +115,8 @@ |
||
| 115 | 115 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
| 116 | 116 | } |
| 117 | 117 | $this->arguments['category']['options'] = $cat_ids; |
| 118 | - if (count($cat_ids) > 5) { |
|
| 118 | + if (count($cat_ids) > 5) |
|
| 119 | + { |
|
| 119 | 120 | $this->arguments['category']['multiple'] = 5; |
| 120 | 121 | } |
| 121 | 122 | |
@@ -165,7 +165,8 @@ discard block |
||
| 165 | 165 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
| 166 | 166 | } |
| 167 | 167 | $this->arguments['category']['options'] = $cat_ids; |
| 168 | - if (count($cat_ids) > 5) { |
|
| 168 | + if (count($cat_ids) > 5) |
|
| 169 | + { |
|
| 169 | 170 | $this->arguments['category']['multiple'] = 5; |
| 170 | 171 | } |
| 171 | 172 | |
@@ -310,8 +311,16 @@ discard block |
||
| 310 | 311 | foreach((array) $this->bo->search($search_params) as $event) |
| 311 | 312 | { |
| 312 | 313 | $event['date'] = $this->bo->date2string($event['start']); |
| 313 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
| 314 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
| 314 | + if (empty($event['description'])) |
|
| 315 | + { |
|
| 316 | + $event['description'] = ' '; |
|
| 317 | + } |
|
| 318 | + // no description screws the titles horz. alignment |
|
| 319 | + if (empty($event['location'])) |
|
| 320 | + { |
|
| 321 | + $event['location'] = ' '; |
|
| 322 | + } |
|
| 323 | + // no location screws the owner horz. alignment |
|
| 315 | 324 | $rows[] = $event; |
| 316 | 325 | } |
| 317 | 326 | if (($arguments['showWeeks']) && ((int)$arguments['offset'] == 0)) |
@@ -337,7 +346,8 @@ discard block |
||
| 337 | 346 | } |
| 338 | 347 | $last_week = adodb_date('W-Y',$event['start']); |
| 339 | 348 | $html .= " <!-- Event -->\n"; |
| 340 | - if ($event_count % 2 == 0) { |
|
| 349 | + if ($event_count % 2 == 0) |
|
| 350 | + { |
|
| 341 | 351 | $html .= ' <div class="cal_list_event cal_event_even">'."\n"; |
| 342 | 352 | } |
| 343 | 353 | else |
@@ -353,7 +363,8 @@ discard block |
||
| 353 | 363 | $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
| 354 | 364 | $html .= $this->bo->format_date($event['end'])."</span></div>\n"; |
| 355 | 365 | $descr = trim($event['description']); |
| 356 | - if (! empty($descr)) { |
|
| 366 | + if (! empty($descr)) |
|
| 367 | + { |
|
| 357 | 368 | $html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/',"<br>\n",$event['description'])."</div>\n"; |
| 358 | 369 | } |
| 359 | 370 | $html .= " </div><!-- cal_list_event -->\n"; |
@@ -1429,13 +1429,18 @@ discard block |
||
| 1429 | 1429 | function calendar_upgrade1_0_1_008() |
| 1430 | 1430 | { |
| 1431 | 1431 | $config_data = Api\Config::read('calendar'); |
| 1432 | - if (isset($config_data['fields'])) // old custom fields |
|
| 1432 | + if (isset($config_data['fields'])) |
|
| 1433 | + { |
|
| 1434 | + // old custom fields |
|
| 1433 | 1435 | { |
| 1434 | 1436 | $customfields = array(); |
| 1437 | + } |
|
| 1435 | 1438 | $order = 0; |
| 1436 | 1439 | foreach($config_data['fields'] as $name => $data) |
| 1437 | 1440 | { |
| 1438 | - if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
|
| 1441 | + if ($name{0} == '#' && !$data['disabled']) |
|
| 1442 | + { |
|
| 1443 | + // real not-disabled custom field |
|
| 1439 | 1444 | { |
| 1440 | 1445 | $customfields[substr($name,1)] = array( |
| 1441 | 1446 | 'type' => 'text', |
@@ -1444,6 +1449,7 @@ discard block |
||
| 1444 | 1449 | 'order' => ($order += 10), |
| 1445 | 1450 | ); |
| 1446 | 1451 | } |
| 1452 | + } |
|
| 1447 | 1453 | } |
| 1448 | 1454 | if (count($customfields)) |
| 1449 | 1455 | { |
@@ -2589,9 +2595,12 @@ discard block |
||
| 2589 | 2595 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2590 | 2596 | 'cal_user_type' => 'e', |
| 2591 | 2597 | $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), |
| 2592 | - ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
|
| 2598 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) |
|
| 2599 | + { |
|
| 2600 | + // order A, T, U, X |
|
| 2593 | 2601 | { |
| 2594 | 2602 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2603 | + } |
|
| 2595 | 2604 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status')))); |
| 2596 | 2605 | } |
| 2597 | 2606 | } |
@@ -44,15 +44,23 @@ |
||
| 44 | 44 | if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D') |
| 45 | 45 | { |
| 46 | 46 | $_GET['user'] = substr($_GET['user'],2); |
| 47 | - if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2); |
|
| 48 | - if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2); |
|
| 49 | -} |
|
| 47 | + if (isset($_GET['password'])) |
|
| 48 | + { |
|
| 49 | + $_GET['password'] = substr($_GET['password'],2); |
|
| 50 | + } |
|
| 51 | + if (isset($_GET['cred'])) |
|
| 52 | + { |
|
| 53 | + $_GET['cred'] = substr($_GET['cred'],2); |
|
| 54 | + } |
|
| 55 | + } |
|
| 50 | 56 | if (!is_numeric($user = $_GET['user'])) |
| 51 | 57 | { |
| 52 | 58 | // check if user contains the current domain --> remove it |
| 53 | 59 | list(,$domain) = explode('@',$user); |
| 54 | 60 | if ($domain === $GLOBALS['egw_info']['user']['domain']) |
| 55 | - list($user) = explode('@',$user); |
|
| 61 | + { |
|
| 62 | + list($user) = explode('@',$user); |
|
| 63 | + } |
|
| 56 | 64 | $user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u'); |
| 57 | 65 | } |
| 58 | 66 | if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user))) |
@@ -177,7 +177,10 @@ discard block |
||
| 177 | 177 | function __construct(&$_clientProperties = array()) |
| 178 | 178 | { |
| 179 | 179 | parent::__construct(); |
| 180 | - if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
| 180 | + if ($this->log) |
|
| 181 | + { |
|
| 182 | + $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
| 183 | + } |
|
| 181 | 184 | $this->clientProperties = $_clientProperties; |
| 182 | 185 | $this->vCalendar = new Horde_Icalendar; |
| 183 | 186 | $this->addressbook = new Api\Contacts; |
@@ -226,10 +229,14 @@ discard block |
||
| 226 | 229 | 'ATTACH' => 'attachments', |
| 227 | 230 | ); |
| 228 | 231 | |
| 229 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 232 | + if (!is_array($this->supportedFields)) |
|
| 233 | + { |
|
| 234 | + $this->setSupportedFields(); |
|
| 235 | + } |
|
| 230 | 236 | |
| 231 | 237 | if ($this->productManufacturer == '' ) |
| 232 | - { // syncevolution is broken |
|
| 238 | + { |
|
| 239 | +// syncevolution is broken |
|
| 233 | 240 | $version = '2.0'; |
| 234 | 241 | } |
| 235 | 242 | |
@@ -237,10 +244,16 @@ discard block |
||
| 237 | 244 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
| 238 | 245 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 239 | 246 | $vcal->setAttribute('VERSION', $version); |
| 240 | - if ($method) $vcal->setAttribute('METHOD', $method); |
|
| 247 | + if ($method) |
|
| 248 | + { |
|
| 249 | + $vcal->setAttribute('METHOD', $method); |
|
| 250 | + } |
|
| 241 | 251 | $events_exported = false; |
| 242 | 252 | |
| 243 | - if (!is_array($events)) $events = array($events); |
|
| 253 | + if (!is_array($events)) |
|
| 254 | + { |
|
| 255 | + $events = array($events); |
|
| 256 | + } |
|
| 244 | 257 | |
| 245 | 258 | $vtimezones_added = array(); |
| 246 | 259 | foreach ($events as $event) |
@@ -306,7 +319,10 @@ discard block |
||
| 306 | 319 | self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']); |
| 307 | 320 | } |
| 308 | 321 | |
| 309 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 322 | + if ($this->so->isWholeDay($event)) |
|
| 323 | + { |
|
| 324 | + $event['whole_day'] = true; |
|
| 325 | + } |
|
| 310 | 326 | |
| 311 | 327 | if ($this->log) |
| 312 | 328 | { |
@@ -317,7 +333,10 @@ discard block |
||
| 317 | 333 | |
| 318 | 334 | if ($recurrence) |
| 319 | 335 | { |
| 320 | - if (!($master = $this->read($event['id'], 0, true, 'server'))) continue; |
|
| 336 | + if (!($master = $this->read($event['id'], 0, true, 'server'))) |
|
| 337 | + { |
|
| 338 | + continue; |
|
| 339 | + } |
|
| 321 | 340 | |
| 322 | 341 | if (!isset($this->supportedFields['participants'])) |
| 323 | 342 | { |
@@ -374,7 +393,8 @@ discard block |
||
| 374 | 393 | if ($this->productManufacturer != 'file' && $this->uidExtension) |
| 375 | 394 | { |
| 376 | 395 | // Append UID to DESCRIPTION |
| 377 | - if (!preg_match('/\[UID:.+\]/m', $event['description'])) { |
|
| 396 | + if (!preg_match('/\[UID:.+\]/m', $event['description'])) |
|
| 397 | + { |
|
| 378 | 398 | $event['description'] .= "\n[UID:" . $event['uid'] . "]"; |
| 379 | 399 | } |
| 380 | 400 | } |
@@ -434,11 +454,21 @@ discard block |
||
| 434 | 454 | $quantity = $role = null; |
| 435 | 455 | calendar_so::split_status($status, $quantity, $role); |
| 436 | 456 | // do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant |
| 437 | - if (count($event['participants']) == 1 && $event['owner'] == $uid) continue; |
|
| 457 | + if (count($event['participants']) == 1 && $event['owner'] == $uid) |
|
| 458 | + { |
|
| 459 | + continue; |
|
| 460 | + } |
|
| 438 | 461 | |
| 439 | - if (!($info = $this->resource_info($uid))) continue; |
|
| 462 | + if (!($info = $this->resource_info($uid))) |
|
| 463 | + { |
|
| 464 | + continue; |
|
| 465 | + } |
|
| 440 | 466 | |
| 441 | - if (in_array($status, array('X','E'))) continue; // dont include deleted participants |
|
| 467 | + if (in_array($status, array('X','E'))) |
|
| 468 | + { |
|
| 469 | + continue; |
|
| 470 | + } |
|
| 471 | + // dont include deleted participants |
|
| 442 | 472 | |
| 443 | 473 | if ($this->log) |
| 444 | 474 | { |
@@ -517,24 +547,49 @@ discard block |
||
| 517 | 547 | } |
| 518 | 548 | // ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*} |
| 519 | 549 | $options = array(); |
| 520 | - if (!empty($participantCN)) $options['CN'] = $participantCN; |
|
| 521 | - if (!empty($role)) $options['ROLE'] = $role; |
|
| 522 | - if (!empty($status)) $options['PARTSTAT'] = $status; |
|
| 523 | - if (!empty($cutype)) $options['CUTYPE'] = $cutype; |
|
| 524 | - if (!empty($rsvp)) $options['RSVP'] = $rsvp; |
|
| 550 | + if (!empty($participantCN)) |
|
| 551 | + { |
|
| 552 | + $options['CN'] = $participantCN; |
|
| 553 | + } |
|
| 554 | + if (!empty($role)) |
|
| 555 | + { |
|
| 556 | + $options['ROLE'] = $role; |
|
| 557 | + } |
|
| 558 | + if (!empty($status)) |
|
| 559 | + { |
|
| 560 | + $options['PARTSTAT'] = $status; |
|
| 561 | + } |
|
| 562 | + if (!empty($cutype)) |
|
| 563 | + { |
|
| 564 | + $options['CUTYPE'] = $cutype; |
|
| 565 | + } |
|
| 566 | + if (!empty($rsvp)) |
|
| 567 | + { |
|
| 568 | + $options['RSVP'] = $rsvp; |
|
| 569 | + } |
|
| 525 | 570 | if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email']) |
| 526 | 571 | { |
| 527 | 572 | $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
| 528 | 573 | } |
| 529 | - if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
| 530 | - if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
|
| 574 | + if ($info['type'] != 'e') |
|
| 575 | + { |
|
| 576 | + $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
| 577 | + } |
|
| 578 | + if ($quantity > 1) |
|
| 579 | + { |
|
| 580 | + $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
|
| 581 | + } |
|
| 531 | 582 | $attributes['ATTENDEE'][] = $participantURL; |
| 532 | 583 | $parameters['ATTENDEE'][] = $options; |
| 533 | 584 | } |
| 534 | 585 | break; |
| 535 | 586 | |
| 536 | 587 | case 'CLASS': |
| 537 | - if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
| 588 | + if ($event['public']) |
|
| 589 | + { |
|
| 590 | + continue; |
|
| 591 | + } |
|
| 592 | + // public is default, no need to export, fails CalDAVTester if added as default |
|
| 538 | 593 | $attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE'; |
| 539 | 594 | // Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!) |
| 540 | 595 | if (!$event['public'] && $this->productManufacturer == 'groupdav') |
@@ -566,9 +621,18 @@ discard block |
||
| 566 | 621 | 'CUTYPE' => 'INDIVIDUAL', |
| 567 | 622 | //'RSVP' => 'FALSE', |
| 568 | 623 | ); |
| 569 | - if (!empty($organizerCN)) $options['CN'] = $organizerCN; |
|
| 570 | - if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail; |
|
| 571 | - if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner']; |
|
| 624 | + if (!empty($organizerCN)) |
|
| 625 | + { |
|
| 626 | + $options['CN'] = $organizerCN; |
|
| 627 | + } |
|
| 628 | + if (!empty($organizerEMail)) |
|
| 629 | + { |
|
| 630 | + $options['EMAIL'] = $organizerEMail; |
|
| 631 | + } |
|
| 632 | + if (!empty($event['owner'])) |
|
| 633 | + { |
|
| 634 | + $options['X-EGROUPWARE-UID'] = $event['owner']; |
|
| 635 | + } |
|
| 572 | 636 | $attributes['ATTENDEE'][] = $organizerURL; |
| 573 | 637 | $parameters['ATTENDEE'][] = $options; |
| 574 | 638 | } |
@@ -597,9 +661,12 @@ discard block |
||
| 597 | 661 | { |
| 598 | 662 | // Hack for CalDAVTester to export duration instead of endtime |
| 599 | 663 | if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400) |
| 600 | - $attributes['duration'] = $event['end'] - $event['start']; |
|
| 601 | - else |
|
| 602 | - $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 664 | + { |
|
| 665 | + $attributes['duration'] = $event['end'] - $event['start']; |
|
| 666 | + } |
|
| 667 | + else { |
|
| 668 | + $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 669 | + } |
|
| 603 | 670 | } |
| 604 | 671 | else |
| 605 | 672 | { |
@@ -619,7 +686,11 @@ discard block |
||
| 619 | 686 | break; |
| 620 | 687 | |
| 621 | 688 | case 'RRULE': |
| 622 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
| 689 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
| 690 | + { |
|
| 691 | + break; |
|
| 692 | + } |
|
| 693 | + // no recuring event |
|
| 623 | 694 | $rriter = calendar_rrule::event2rrule($event, false, $tzid); |
| 624 | 695 | $rrule = $rriter->generate_rrule($version); |
| 625 | 696 | if ($event['recur_enddate']) |
@@ -653,7 +724,10 @@ discard block |
||
| 653 | 724 | break; |
| 654 | 725 | |
| 655 | 726 | case 'EXDATE': |
| 656 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; |
|
| 727 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
| 728 | + { |
|
| 729 | + break; |
|
| 730 | + } |
|
| 657 | 731 | if (!empty($event['recur_exception'])) |
| 658 | 732 | { |
| 659 | 733 | if (empty($event['whole_day'])) |
@@ -680,14 +754,21 @@ discard block |
||
| 680 | 754 | ); |
| 681 | 755 | } |
| 682 | 756 | $event['recur_exception'] = $days; |
| 683 | - if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
| 757 | + if ($version != '1.0') |
|
| 758 | + { |
|
| 759 | + $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
| 760 | + } |
|
| 684 | 761 | } |
| 685 | 762 | $vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']); |
| 686 | 763 | } |
| 687 | 764 | break; |
| 688 | 765 | |
| 689 | 766 | case 'PRIORITY': |
| 690 | - if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 767 | + if (!$event['priority']) |
|
| 768 | + { |
|
| 769 | + continue; |
|
| 770 | + } |
|
| 771 | + // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 691 | 772 | if ($this->productManufacturer == 'funambol' && |
| 692 | 773 | (strpos($this->productName, 'outlook') !== false |
| 693 | 774 | || strpos($this->productName, 'pocket pc') !== false)) |
@@ -701,7 +782,11 @@ discard block |
||
| 701 | 782 | break; |
| 702 | 783 | |
| 703 | 784 | case 'TRANSP': |
| 704 | - if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 785 | + if (!$event['non_blocking']) |
|
| 786 | + { |
|
| 787 | + continue; |
|
| 788 | + } |
|
| 789 | + // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 705 | 790 | if ($version == '1.0') |
| 706 | 791 | { |
| 707 | 792 | $attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0); |
@@ -758,7 +843,11 @@ discard block |
||
| 758 | 843 | elseif ($event['recurrence'] && $event['reference']) |
| 759 | 844 | { |
| 760 | 845 | // $event['reference'] is a calendar_id, not a timestamp |
| 761 | - if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
| 846 | + if (!($revent = $this->read($event['reference']))) |
|
| 847 | + { |
|
| 848 | + break; |
|
| 849 | + } |
|
| 850 | + // referenced event does not exist |
|
| 762 | 851 | |
| 763 | 852 | if (empty($revent['whole_day'])) |
| 764 | 853 | { |
@@ -884,7 +973,10 @@ discard block |
||
| 884 | 973 | foreach ((array)$event['alarm'] as $alarmData) |
| 885 | 974 | { |
| 886 | 975 | // skip over alarms that don't have the minimum required info |
| 887 | - if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue; |
|
| 976 | + if (!isset($alarmData['offset']) && !isset($alarmData['time'])) |
|
| 977 | + { |
|
| 978 | + continue; |
|
| 979 | + } |
|
| 888 | 980 | |
| 889 | 981 | // skip alarms not being set for all users and alarms owned by other users |
| 890 | 982 | if ($alarmData['all'] != true && $alarmData['owner'] != $this->user) |
@@ -901,7 +993,10 @@ discard block |
||
| 901 | 993 | |
| 902 | 994 | if ($version == '1.0') |
| 903 | 995 | { |
| 904 | - if ($event['title']) $description = $event['title']; |
|
| 996 | + if ($event['title']) |
|
| 997 | + { |
|
| 998 | + $description = $event['title']; |
|
| 999 | + } |
|
| 905 | 1000 | if ($description) |
| 906 | 1001 | { |
| 907 | 1002 | $values['DALARM']['snooze_time'] = ''; |
@@ -921,7 +1016,10 @@ discard block |
||
| 921 | 1016 | // VCalendar 2.0 / RFC 2445 |
| 922 | 1017 | |
| 923 | 1018 | // RFC requires DESCRIPTION for DISPLAY |
| 924 | - if (!$event['title'] && !$description) $description = 'Alarm'; |
|
| 1019 | + if (!$event['title'] && !$description) |
|
| 1020 | + { |
|
| 1021 | + $description = 'Alarm'; |
|
| 1022 | + } |
|
| 925 | 1023 | |
| 926 | 1024 | /* Disabling for now |
| 927 | 1025 | // Lightning infinitly pops up alarms for recuring events, if the only use an offset |
@@ -1112,13 +1210,20 @@ discard block |
||
| 1112 | 1210 | $this->events_imported = 0; |
| 1113 | 1211 | $replace = $delete_exceptions= false; |
| 1114 | 1212 | |
| 1115 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 1213 | + if (!is_array($this->supportedFields)) |
|
| 1214 | + { |
|
| 1215 | + $this->setSupportedFields(); |
|
| 1216 | + } |
|
| 1116 | 1217 | |
| 1117 | 1218 | if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset))) |
| 1118 | 1219 | { |
| 1119 | 1220 | return false; |
| 1120 | 1221 | } |
| 1121 | - if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1222 | + if (!is_array($events)) |
|
| 1223 | + { |
|
| 1224 | + $cal_id = -1; |
|
| 1225 | + } |
|
| 1226 | + // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1122 | 1227 | |
| 1123 | 1228 | if ($cal_id > 0) |
| 1124 | 1229 | { |
@@ -1126,8 +1231,14 @@ discard block |
||
| 1126 | 1231 | { |
| 1127 | 1232 | $replace = $recur_date == 0; |
| 1128 | 1233 | $events[0]['id'] = $cal_id; |
| 1129 | - if (!is_null($etag)) $events[0]['etag'] = (int) $etag; |
|
| 1130 | - if ($recur_date) $events[0]['recurrence'] = $recur_date; |
|
| 1234 | + if (!is_null($etag)) |
|
| 1235 | + { |
|
| 1236 | + $events[0]['etag'] = (int) $etag; |
|
| 1237 | + } |
|
| 1238 | + if ($recur_date) |
|
| 1239 | + { |
|
| 1240 | + $events[0]['recurrence'] = $recur_date; |
|
| 1241 | + } |
|
| 1131 | 1242 | } |
| 1132 | 1243 | elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) && |
| 1133 | 1244 | ($eventId = array_shift($foundEvent)) && |
@@ -1135,7 +1246,10 @@ discard block |
||
| 1135 | 1246 | { |
| 1136 | 1247 | foreach ($events as $k => $event) |
| 1137 | 1248 | { |
| 1138 | - if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid']; |
|
| 1249 | + if (!isset($event['uid'])) |
|
| 1250 | + { |
|
| 1251 | + $events[$k]['uid'] = $egwEvent['uid']; |
|
| 1252 | + } |
|
| 1139 | 1253 | } |
| 1140 | 1254 | } |
| 1141 | 1255 | } |
@@ -1165,10 +1279,17 @@ discard block |
||
| 1165 | 1279 | $msg = null; |
| 1166 | 1280 | foreach ($events as $event) |
| 1167 | 1281 | { |
| 1168 | - if (!is_array($event)) continue; // the iterator may return false |
|
| 1282 | + if (!is_array($event)) |
|
| 1283 | + { |
|
| 1284 | + continue; |
|
| 1285 | + } |
|
| 1286 | + // the iterator may return false |
|
| 1169 | 1287 | ++$this->events_imported; |
| 1170 | 1288 | |
| 1171 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 1289 | + if ($this->so->isWholeDay($event)) |
|
| 1290 | + { |
|
| 1291 | + $event['whole_day'] = true; |
|
| 1292 | + } |
|
| 1172 | 1293 | if (is_array($event['category'])) |
| 1173 | 1294 | { |
| 1174 | 1295 | $event['category'] = $this->find_or_add_categories($event['category'], |
@@ -1205,7 +1326,10 @@ discard block |
||
| 1205 | 1326 | } |
| 1206 | 1327 | else |
| 1207 | 1328 | { |
| 1208 | - if (!($exception = $this->read($id))) continue; |
|
| 1329 | + if (!($exception = $this->read($id))) |
|
| 1330 | + { |
|
| 1331 | + continue; |
|
| 1332 | + } |
|
| 1209 | 1333 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1210 | 1334 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1211 | 1335 | $this->update($exception, true,true,false,true,$msg,$skip_notification); |
@@ -1294,7 +1418,10 @@ discard block |
||
| 1294 | 1418 | break; |
| 1295 | 1419 | |
| 1296 | 1420 | default: |
| 1297 | - if (!empty($value)) $event[$key] = $value; |
|
| 1421 | + if (!empty($value)) |
|
| 1422 | + { |
|
| 1423 | + $event[$key] = $value; |
|
| 1424 | + } |
|
| 1298 | 1425 | } |
| 1299 | 1426 | } |
| 1300 | 1427 | } |
@@ -1392,7 +1519,10 @@ discard block |
||
| 1392 | 1519 | else // common adjustments for new events |
| 1393 | 1520 | { |
| 1394 | 1521 | unset($event['id']); |
| 1395 | - if ($caldav_name) $event['caldav_name'] = $caldav_name; |
|
| 1522 | + if ($caldav_name) |
|
| 1523 | + { |
|
| 1524 | + $event['caldav_name'] = $caldav_name; |
|
| 1525 | + } |
|
| 1396 | 1526 | // set non blocking all day depending on the user setting |
| 1397 | 1527 | if (!empty($event['whole_day']) && $this->nonBlockingAllday) |
| 1398 | 1528 | { |
@@ -1440,7 +1570,10 @@ discard block |
||
| 1440 | 1570 | || !isset($event['participants'][$event['owner']])) |
| 1441 | 1571 | { |
| 1442 | 1572 | $status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR'); |
| 1443 | - if (!is_array($event['participants'])) $event['participants'] = array(); |
|
| 1573 | + if (!is_array($event['participants'])) |
|
| 1574 | + { |
|
| 1575 | + $event['participants'] = array(); |
|
| 1576 | + } |
|
| 1444 | 1577 | $event['participants'][$event['owner']] = $status; |
| 1445 | 1578 | } |
| 1446 | 1579 | else |
@@ -1593,7 +1726,10 @@ discard block |
||
| 1593 | 1726 | $occurence = $exception = false; |
| 1594 | 1727 | foreach ($event_info['master_event']['recur_exception'] as $exception) |
| 1595 | 1728 | { |
| 1596 | - if ($exception > $event['start']) break; |
|
| 1729 | + if ($exception > $event['start']) |
|
| 1730 | + { |
|
| 1731 | + break; |
|
| 1732 | + } |
|
| 1597 | 1733 | $occurence = $exception; |
| 1598 | 1734 | } |
| 1599 | 1735 | if (!$occurence) |
@@ -1683,12 +1819,15 @@ discard block |
||
| 1683 | 1819 | case 'SERIES-MASTER': |
| 1684 | 1820 | case 'SERIES-EXCEPTION': |
| 1685 | 1821 | case 'SERIES-EXCEPTION-PROPAGATE': |
| 1686 | - if (is_array($event_info['stored_event'])) // status update requires a stored event |
|
| 1822 | + if (is_array($event_info['stored_event'])) |
|
| 1823 | + { |
|
| 1824 | + // status update requires a stored event |
|
| 1687 | 1825 | { |
| 1688 | 1826 | if ($event_info['acl_edit']) |
| 1689 | 1827 | { |
| 1690 | 1828 | // update all participants if we have the right to do that |
| 1691 | 1829 | $this->update_status($event, $event_info['stored_event'],0,$skip_notification); |
| 1830 | + } |
|
| 1692 | 1831 | } |
| 1693 | 1832 | elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user])) |
| 1694 | 1833 | { |
@@ -1700,9 +1839,12 @@ discard block |
||
| 1700 | 1839 | break; |
| 1701 | 1840 | |
| 1702 | 1841 | case 'SERIES-PSEUDO-EXCEPTION': |
| 1703 | - if (is_array($event_info['master_event'])) // status update requires a stored master event |
|
| 1842 | + if (is_array($event_info['master_event'])) |
|
| 1843 | + { |
|
| 1844 | + // status update requires a stored master event |
|
| 1704 | 1845 | { |
| 1705 | 1846 | $recurrence = $this->date2usertime($event['recurrence']); |
| 1847 | + } |
|
| 1706 | 1848 | if ($event_info['acl_edit']) |
| 1707 | 1849 | { |
| 1708 | 1850 | // update all participants if we have the right to do that |
@@ -1775,7 +1917,10 @@ discard block |
||
| 1775 | 1917 | */ |
| 1776 | 1918 | public function sync_alarms(array &$event, array $old_alarms, $user) |
| 1777 | 1919 | { |
| 1778 | - if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
| 1920 | + if ($this->debug) |
|
| 1921 | + { |
|
| 1922 | + error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
| 1923 | + } |
|
| 1779 | 1924 | $modified = 0; |
| 1780 | 1925 | foreach($event['alarm'] as &$alarm) |
| 1781 | 1926 | { |
@@ -1799,19 +1944,40 @@ discard block |
||
| 1799 | 1944 | if ($alarm['offset'] != $old_alarm['offset'] || $old_alarm['owner'] != $user && !$alarm['all']) |
| 1800 | 1945 | { |
| 1801 | 1946 | $alarm['owner'] = $user; |
| 1802 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1803 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1804 | - if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
| 1805 | - if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
| 1947 | + if (!isset($alarm['time'])) |
|
| 1948 | + { |
|
| 1949 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1950 | + } |
|
| 1951 | + if ($alarm['time'] < time()) |
|
| 1952 | + { |
|
| 1953 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1954 | + } |
|
| 1955 | + if ($this->debug) |
|
| 1956 | + { |
|
| 1957 | + error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
| 1958 | + } |
|
| 1959 | + if ($event['id']) |
|
| 1960 | + { |
|
| 1961 | + $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
| 1962 | + } |
|
| 1806 | 1963 | ++$modified; |
| 1807 | 1964 | } |
| 1808 | 1965 | // existing alarm --> update it |
| 1809 | 1966 | elseif ($alarm['offset'] == $old_alarm['offset'] && ($old_alarm['owner'] == $user || $old_alarm['all'])) |
| 1810 | 1967 | { |
| 1811 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1812 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1968 | + if (!isset($alarm['time'])) |
|
| 1969 | + { |
|
| 1970 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1971 | + } |
|
| 1972 | + if ($alarm['time'] < time()) |
|
| 1973 | + { |
|
| 1974 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1975 | + } |
|
| 1813 | 1976 | $alarm = array_merge($old_alarm, $alarm); |
| 1814 | - if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
| 1977 | + if ($this->debug) |
|
| 1978 | + { |
|
| 1979 | + error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
| 1980 | + } |
|
| 1815 | 1981 | $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
| 1816 | 1982 | ++$modified; |
| 1817 | 1983 | } |
@@ -1825,7 +1991,10 @@ discard block |
||
| 1825 | 1991 | unset($old_alarm[$id]); |
| 1826 | 1992 | continue; |
| 1827 | 1993 | } |
| 1828 | - if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
| 1994 | + if ($this->debug) |
|
| 1995 | + { |
|
| 1996 | + error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
| 1997 | + } |
|
| 1829 | 1998 | $this->delete_alarm($id); |
| 1830 | 1999 | ++$modified; |
| 1831 | 2000 | } |
@@ -2244,7 +2413,10 @@ discard block |
||
| 2244 | 2413 | array2string($_vcalData)."\n",3,$this->logfile); |
| 2245 | 2414 | } |
| 2246 | 2415 | |
| 2247 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 2416 | + if (!is_array($this->supportedFields)) |
|
| 2417 | + { |
|
| 2418 | + $this->setSupportedFields(); |
|
| 2419 | + } |
|
| 2248 | 2420 | |
| 2249 | 2421 | // we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0]) |
| 2250 | 2422 | if (is_resource($_vcalData)) |
@@ -2589,19 +2761,27 @@ discard block |
||
| 2589 | 2761 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2590 | 2762 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2])); |
| 2591 | 2763 | } |
| 2592 | - else break; |
|
| 2764 | + else { |
|
| 2765 | + break; |
|
| 2766 | + } |
|
| 2593 | 2767 | // fall-through |
| 2594 | 2768 | case 'DAILY': // 2.0 |
| 2595 | 2769 | $vcardData['recur_type'] = MCAL_RECUR_DAILY; |
| 2596 | - if (stripos($recurence, 'BYDAY') === false) break; |
|
| 2770 | + if (stripos($recurence, 'BYDAY') === false) |
|
| 2771 | + { |
|
| 2772 | + break; |
|
| 2773 | + } |
|
| 2597 | 2774 | // hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval |
| 2598 | 2775 | // fall-through |
| 2599 | 2776 | case 'W': |
| 2600 | 2777 | case 'WEEKLY': |
| 2601 | 2778 | $days = array(); |
| 2602 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
| 2779 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) |
|
| 2780 | + { |
|
| 2781 | + // 1.0 |
|
| 2603 | 2782 | { |
| 2604 | 2783 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2784 | + } |
|
| 2605 | 2785 | if (empty($recurenceMatches[2])) |
| 2606 | 2786 | { |
| 2607 | 2787 | $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
@@ -2614,7 +2794,10 @@ discard block |
||
| 2614 | 2794 | $repeatMatches = null; |
| 2615 | 2795 | if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
| 2616 | 2796 | { |
| 2617 | - if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
|
| 2797 | + if ($repeatMatches[1]) |
|
| 2798 | + { |
|
| 2799 | + $vcardData['recur_count'] = $repeatMatches[1]; |
|
| 2800 | + } |
|
| 2618 | 2801 | } |
| 2619 | 2802 | else |
| 2620 | 2803 | { |
@@ -2623,9 +2806,12 @@ discard block |
||
| 2623 | 2806 | |
| 2624 | 2807 | $recur_days = $this->recur_days_1_0; |
| 2625 | 2808 | } |
| 2626 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
| 2809 | + elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) |
|
| 2810 | + { |
|
| 2811 | + // 2.0 |
|
| 2627 | 2812 | { |
| 2628 | 2813 | $days = explode(',',$recurenceMatches[1]); |
| 2814 | + } |
|
| 2629 | 2815 | $recur_days = $this->recur_days; |
| 2630 | 2816 | } |
| 2631 | 2817 | else // no day given, use the day of dtstart |
@@ -2684,7 +2870,10 @@ discard block |
||
| 2684 | 2870 | { |
| 2685 | 2871 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2686 | 2872 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
| 2687 | - } else break; |
|
| 2873 | + } |
|
| 2874 | + else { |
|
| 2875 | + break; |
|
| 2876 | + } |
|
| 2688 | 2877 | // fall-through |
| 2689 | 2878 | case 'YEARLY': // 2.0 |
| 2690 | 2879 | if (strpos($recurence, 'BYDAY') === false) |
@@ -2704,7 +2893,10 @@ discard block |
||
| 2704 | 2893 | } |
| 2705 | 2894 | break; |
| 2706 | 2895 | case 'EXDATE': |
| 2707 | - if (!$attributes['value']) break; |
|
| 2896 | + if (!$attributes['value']) |
|
| 2897 | + { |
|
| 2898 | + break; |
|
| 2899 | + } |
|
| 2708 | 2900 | if ((isset($attributes['params']['VALUE']) |
| 2709 | 2901 | && $attributes['params']['VALUE'] == 'DATE') || |
| 2710 | 2902 | (!isset($attributes['params']['VALUE']) && $isDate)) |
@@ -2784,13 +2976,16 @@ discard block |
||
| 2784 | 2976 | // fall throught |
| 2785 | 2977 | case 'ATTENDEE': |
| 2786 | 2978 | if (isset($attributes['params']['PARTSTAT'])) |
| 2787 | - { |
|
| 2979 | + { |
|
| 2788 | 2980 | $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
| 2789 | 2981 | } |
| 2790 | 2982 | if (isset($attributes['params']['STATUS'])) |
| 2791 | - { |
|
| 2983 | + { |
|
| 2792 | 2984 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
| 2793 | - if (empty($status)) $status = 'X'; |
|
| 2985 | + if (empty($status)) |
|
| 2986 | + { |
|
| 2987 | + $status = 'X'; |
|
| 2988 | + } |
|
| 2794 | 2989 | } |
| 2795 | 2990 | else |
| 2796 | 2991 | { |
@@ -2850,7 +3045,10 @@ discard block |
||
| 2850 | 3045 | $uid = $this->user; |
| 2851 | 3046 | } |
| 2852 | 3047 | // check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY |
| 2853 | - if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
| 3048 | + if (!$uid) |
|
| 3049 | + { |
|
| 3050 | + $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
| 3051 | + } |
|
| 2854 | 3052 | |
| 2855 | 3053 | // try to find an email address |
| 2856 | 3054 | if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email'))) |
@@ -2918,7 +3116,10 @@ discard block |
||
| 2918 | 3116 | } |
| 2919 | 3117 | $status = 'U'; // keep the group |
| 2920 | 3118 | } |
| 2921 | - else continue; // can't find this group |
|
| 3119 | + else { |
|
| 3120 | + continue; |
|
| 3121 | + } |
|
| 3122 | + // can't find this group |
|
| 2922 | 3123 | } |
| 2923 | 3124 | elseif (empty($searcharray)) |
| 2924 | 3125 | { |
@@ -2977,7 +3178,9 @@ discard block |
||
| 2977 | 3178 | |
| 2978 | 3179 | try { |
| 2979 | 3180 | if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR') |
| 2980 | - $component->getAttribute('ORGANIZER'); |
|
| 3181 | + { |
|
| 3182 | + $component->getAttribute('ORGANIZER'); |
|
| 3183 | + } |
|
| 2981 | 3184 | } |
| 2982 | 3185 | catch(Horde_Icalendar_Exception $e) |
| 2983 | 3186 | { |
@@ -3014,7 +3217,10 @@ discard block |
||
| 3014 | 3217 | } |
| 3015 | 3218 | break; |
| 3016 | 3219 | case 'CREATED': // will be written direct to the event |
| 3017 | - if ($event['modified']) break; |
|
| 3220 | + if ($event['modified']) |
|
| 3221 | + { |
|
| 3222 | + break; |
|
| 3223 | + } |
|
| 3018 | 3224 | // fall through |
| 3019 | 3225 | case 'LAST-MODIFIED': // will be written direct to the event |
| 3020 | 3226 | $event['modified'] = $attributes['value']; |
@@ -3035,7 +3241,11 @@ discard block |
||
| 3035 | 3241 | break; |
| 3036 | 3242 | |
| 3037 | 3243 | case 'ATTACH': |
| 3038 | - if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
| 3244 | + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) |
|
| 3245 | + { |
|
| 3246 | + break; |
|
| 3247 | + } |
|
| 3248 | + // handeled by managed attachment code |
|
| 3039 | 3249 | // fall throught to store external attachment url |
| 3040 | 3250 | default: // X- attribute or other by EGroupware unsupported property |
| 3041 | 3251 | //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); |
@@ -3166,7 +3376,10 @@ discard block |
||
| 3166 | 3376 | $event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength']; |
| 3167 | 3377 | } |
| 3168 | 3378 | |
| 3169 | - if ($this->calendarOwner) $event['owner'] = $this->calendarOwner; |
|
| 3379 | + if ($this->calendarOwner) |
|
| 3380 | + { |
|
| 3381 | + $event['owner'] = $this->calendarOwner; |
|
| 3382 | + } |
|
| 3170 | 3383 | |
| 3171 | 3384 | // parsing ATTACH attributes for managed attachments |
| 3172 | 3385 | $event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE'; |
@@ -3192,7 +3405,10 @@ discard block |
||
| 3192 | 3405 | $filter = $relax ? 'relax' : 'check'; |
| 3193 | 3406 | $event = array_shift($events); |
| 3194 | 3407 | $eventId = -1; |
| 3195 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 3408 | + if ($this->so->isWholeDay($event)) |
|
| 3409 | + { |
|
| 3410 | + $event['whole_day'] = true; |
|
| 3411 | + } |
|
| 3196 | 3412 | if ($contentID) |
| 3197 | 3413 | { |
| 3198 | 3414 | $parts = preg_split('/:/', $contentID); |
@@ -3224,8 +3440,16 @@ discard block |
||
| 3224 | 3440 | */ |
| 3225 | 3441 | function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
| 3226 | 3442 | { |
| 3227 | - if (!$start) $start = time(); // default now |
|
| 3228 | - if (!$end) $end = time() + 100*DAY_s; // default next 100 days |
|
| 3443 | + if (!$start) |
|
| 3444 | + { |
|
| 3445 | + $start = time(); |
|
| 3446 | + } |
|
| 3447 | + // default now |
|
| 3448 | + if (!$end) |
|
| 3449 | + { |
|
| 3450 | + $end = time() + 100*DAY_s; |
|
| 3451 | + } |
|
| 3452 | + // default next 100 days |
|
| 3229 | 3453 | |
| 3230 | 3454 | $vcal = new Horde_Icalendar; |
| 3231 | 3455 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
@@ -3247,10 +3471,13 @@ discard block |
||
| 3247 | 3471 | $attributes[$attr] = date('Ymd\THis', $value); |
| 3248 | 3472 | } |
| 3249 | 3473 | } |
| 3250 | - if (is_null($extra)) $extra = array( |
|
| 3474 | + if (is_null($extra)) |
|
| 3475 | + { |
|
| 3476 | + $extra = array( |
|
| 3251 | 3477 | 'URL' => $this->freebusy_url($user), |
| 3252 | 3478 | 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'), |
| 3253 | 3479 | ); |
| 3480 | + } |
|
| 3254 | 3481 | foreach($attributes+$extra as $attr => $value) |
| 3255 | 3482 | { |
| 3256 | 3483 | $vfreebusy->setAttribute($attr, $value); |
@@ -3266,9 +3493,18 @@ discard block |
||
| 3266 | 3493 | { |
| 3267 | 3494 | foreach ($fbdata as $event) |
| 3268 | 3495 | { |
| 3269 | - if ($event['non_blocking']) continue; |
|
| 3270 | - if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue; |
|
| 3271 | - if ($event['participants'][$user] == 'R') continue; |
|
| 3496 | + if ($event['non_blocking']) |
|
| 3497 | + { |
|
| 3498 | + continue; |
|
| 3499 | + } |
|
| 3500 | + if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) |
|
| 3501 | + { |
|
| 3502 | + continue; |
|
| 3503 | + } |
|
| 3504 | + if ($event['participants'][$user] == 'R') |
|
| 3505 | + { |
|
| 3506 | + continue; |
|
| 3507 | + } |
|
| 3272 | 3508 | |
| 3273 | 3509 | $fbtype = $event['participants'][$user] == 'T' ? 'BUSY-TENTATIVE' : 'BUSY'; |
| 3274 | 3510 | |
@@ -17,7 +17,8 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * class import_csv for calendar |
| 19 | 19 | */ |
| 20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
| 20 | +class calendar_import_csv extends importexport_basic_import_csv |
|
| 21 | +{ |
|
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * actions wich could be done to data entries |
@@ -83,8 +84,10 @@ discard block |
||
| 83 | 84 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
| 84 | 85 | |
| 85 | 86 | // Set owner, unless it's supposed to come from CSV file |
| 86 | - if($options['owner_from_csv']) { |
|
| 87 | - if(!is_numeric($record['owner'])) { |
|
| 87 | + if($options['owner_from_csv']) |
|
| 88 | + { |
|
| 89 | + if(!is_numeric($record['owner'])) |
|
| 90 | + { |
|
| 88 | 91 | $this->errors[$import_csv->get_current_position()] = lang( |
| 89 | 92 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
| 90 | 93 | $record->owner, |
@@ -106,14 +109,16 @@ discard block |
||
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | // Parse particpants |
| 109 | - if ($record->participants && !is_array($record->participants)) { |
|
| 112 | + if ($record->participants && !is_array($record->participants)) |
|
| 113 | + { |
|
| 110 | 114 | // Importing participants in human friendly format: |
| 111 | 115 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
| 112 | 116 | preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
| 113 | 117 | $p_participants = array(); |
| 114 | 118 | $missing = array(); |
| 115 | 119 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
| 116 | - foreach($names as $key => $name) { |
|
| 120 | + foreach($names as $key => $name) |
|
| 121 | + { |
|
| 117 | 122 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
| 118 | 123 | |
| 119 | 124 | // Search for direct account name, then user in accounts first |
@@ -121,9 +126,13 @@ discard block |
||
| 121 | 126 | $id = importexport_helper_functions::account_name2id($name); |
| 122 | 127 | |
| 123 | 128 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
| 124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
| 129 | + if(!$id || $names[$key] !== $this->bo->participant_name($id)) |
|
| 130 | + { |
|
| 125 | 131 | $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
| 126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 132 | + if($contacts) |
|
| 133 | + { |
|
| 134 | + $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 135 | + } |
|
| 127 | 136 | } |
| 128 | 137 | if(!$id) |
| 129 | 138 | { |
@@ -131,7 +140,10 @@ discard block |
||
| 131 | 140 | foreach($this->bo->resources as $resource) |
| 132 | 141 | { |
| 133 | 142 | // Can't search for email |
| 134 | - if($resource['app'] == 'email') continue; |
|
| 143 | + if($resource['app'] == 'email') |
|
| 144 | + { |
|
| 145 | + continue; |
|
| 146 | + } |
|
| 135 | 147 | // Special resource search, since it does special stuff in link_query |
| 136 | 148 | if($resource['app'] == 'resources') |
| 137 | 149 | { |
@@ -140,7 +152,8 @@ discard block |
||
| 140 | 152 | $this->resource_so = new resources_so(); |
| 141 | 153 | } |
| 142 | 154 | $result = $this->resource_so->search($search,'res_id'); |
| 143 | - if(count($result) >= 1) { |
|
| 155 | + if(count($result) >= 1) |
|
| 156 | + { |
|
| 144 | 157 | $id = $resource['type'].$result[0]['res_id']; |
| 145 | 158 | break; |
| 146 | 159 | } |
@@ -158,7 +171,8 @@ discard block |
||
| 158 | 171 | } |
| 159 | 172 | } |
| 160 | 173 | } |
| 161 | - if($id) { |
|
| 174 | + if($id) |
|
| 175 | + { |
|
| 162 | 176 | $p_participants[$id] = calendar_so::combine_status( |
| 163 | 177 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
| 164 | 178 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -187,27 +201,38 @@ discard block |
||
| 187 | 201 | } |
| 188 | 202 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
| 189 | 203 | |
| 190 | - if ( $options['conditions'] ) { |
|
| 191 | - foreach ( $options['conditions'] as $condition ) { |
|
| 204 | + if ( $options['conditions'] ) |
|
| 205 | + { |
|
| 206 | + foreach ( $options['conditions'] as $condition ) |
|
| 207 | + { |
|
| 192 | 208 | $records = array(); |
| 193 | - switch ( $condition['type'] ) { |
|
| 209 | + switch ( $condition['type'] ) |
|
| 210 | + { |
|
| 194 | 211 | // exists |
| 195 | 212 | case 'exists' : |
| 196 | 213 | // Check for that record |
| 197 | 214 | $result = $this->exists($record, $condition, $records); |
| 198 | 215 | |
| 199 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 216 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 217 | + { |
|
| 200 | 218 | // apply action to all records matching this exists condition |
| 201 | 219 | $action = $condition['true']; |
| 202 | - foreach ( (array)$records as $event ) { |
|
| 220 | + foreach ( (array)$records as $event ) |
|
| 221 | + { |
|
| 203 | 222 | $record->id = $event['id']; |
| 204 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 205 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
| 223 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
| 224 | + { |
|
| 225 | + if ( !is_array( $record->category ) ) |
|
| 226 | + { |
|
| 227 | + $record->category = explode( ',', $record->category ); |
|
| 228 | + } |
|
| 206 | 229 | $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
| 207 | 230 | } |
| 208 | 231 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 209 | 232 | } |
| 210 | - } else { |
|
| 233 | + } |
|
| 234 | + else |
|
| 235 | + { |
|
| 211 | 236 | $action = $condition['false']; |
| 212 | 237 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 213 | 238 | } |
@@ -218,9 +243,14 @@ discard block |
||
| 218 | 243 | die('condition / action not supported!!!'); |
| 219 | 244 | break; |
| 220 | 245 | } |
| 221 | - if ($action['last']) break; |
|
| 246 | + if ($action['last']) |
|
| 247 | + { |
|
| 248 | + break; |
|
| 249 | + } |
|
| 222 | 250 | } |
| 223 | - } else { |
|
| 251 | + } |
|
| 252 | + else |
|
| 253 | + { |
|
| 224 | 254 | // unconditional insert |
| 225 | 255 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 226 | 256 | } |
@@ -239,12 +269,14 @@ discard block |
||
| 239 | 269 | */ |
| 240 | 270 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
| 241 | 271 | { |
| 242 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
| 272 | + if($record->__get($condition['string']) && $condition['string'] == 'id') |
|
| 273 | + { |
|
| 243 | 274 | $event = $this->bo->read($record->__get($condition['string'])); |
| 244 | 275 | $records = array($event); |
| 245 | 276 | } |
| 246 | 277 | |
| 247 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 278 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 279 | + { |
|
| 248 | 280 | return true; |
| 249 | 281 | } |
| 250 | 282 | return false; |
@@ -260,7 +292,8 @@ discard block |
||
| 260 | 292 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
| 261 | 293 | { |
| 262 | 294 | $_data = $record->get_record_array(); |
| 263 | - switch ($_action) { |
|
| 295 | + switch ($_action) |
|
| 296 | + { |
|
| 264 | 297 | case 'none' : |
| 265 | 298 | return true; |
| 266 | 299 | case 'update' : |
@@ -268,7 +301,8 @@ discard block |
||
| 268 | 301 | $old = $this->bo->read($_data['id']); |
| 269 | 302 | |
| 270 | 303 | // Don't change a user account into a record |
| 271 | - if(!$this->definition->plugin_options['change_owner']) { |
|
| 304 | + if(!$this->definition->plugin_options['change_owner']) |
|
| 305 | + { |
|
| 272 | 306 | // Don't change owner of an existing record |
| 273 | 307 | unset($_data['owner']); |
| 274 | 308 | } |
@@ -276,31 +310,40 @@ discard block |
||
| 276 | 310 | // Merge to deal with fields not in import record |
| 277 | 311 | $_data = array_merge($old, $_data); |
| 278 | 312 | $changed = $this->tracking->changed_fields($_data, $old); |
| 279 | - if(count($changed) == 0) { |
|
| 313 | + if(count($changed) == 0) |
|
| 314 | + { |
|
| 280 | 315 | return true; |
| 281 | 316 | } |
| 282 | 317 | // Fall through |
| 283 | 318 | case 'insert' : |
| 284 | - if($_action == 'insert') { |
|
| 319 | + if($_action == 'insert') |
|
| 320 | + { |
|
| 285 | 321 | // Backend doesn't like inserting with ID specified, can overwrite existing |
| 286 | 322 | unset($_data['id']); |
| 287 | 323 | } |
| 288 | 324 | // Make sure participants are set |
| 289 | - if(!$_data['participants']) { |
|
| 325 | + if(!$_data['participants']) |
|
| 326 | + { |
|
| 290 | 327 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
| 291 | 328 | $_data['participants'] = array( |
| 292 | 329 | $user => 'U' |
| 293 | 330 | ); |
| 294 | 331 | } |
| 295 | - if ( $this->dry_run ) { |
|
| 332 | + if ( $this->dry_run ) |
|
| 333 | + { |
|
| 296 | 334 | //print_r($_data); |
| 297 | 335 | $this->results[$_action]++; |
| 298 | 336 | return true; |
| 299 | - } else { |
|
| 337 | + } |
|
| 338 | + else |
|
| 339 | + { |
|
| 300 | 340 | $result = $this->bo->save( $_data, $this->is_admin); |
| 301 | - if(!$result) { |
|
| 341 | + if(!$result) |
|
| 342 | + { |
|
| 302 | 343 | $this->errors[$record_num] = lang('Unable to save'); |
| 303 | - } else { |
|
| 344 | + } |
|
| 345 | + else |
|
| 346 | + { |
|
| 304 | 347 | $this->results[$_action]++; |
| 305 | 348 | // This does nothing (yet?) but update the identifier |
| 306 | 349 | $record->save($result); |
@@ -318,7 +361,8 @@ discard block |
||
| 318 | 361 | * |
| 319 | 362 | * @return string name |
| 320 | 363 | */ |
| 321 | - public static function get_name() { |
|
| 364 | + public static function get_name() |
|
| 365 | + { |
|
| 322 | 366 | return lang('Calendar CSV import'); |
| 323 | 367 | } |
| 324 | 368 | |
@@ -327,7 +371,8 @@ discard block |
||
| 327 | 371 | * |
| 328 | 372 | * @return string descriprion |
| 329 | 373 | */ |
| 330 | - public static function get_description() { |
|
| 374 | + public static function get_description() |
|
| 375 | + { |
|
| 331 | 376 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
| 332 | 377 | } |
| 333 | 378 | |
@@ -336,7 +381,8 @@ discard block |
||
| 336 | 381 | * |
| 337 | 382 | * @return string suffix (comma seperated) |
| 338 | 383 | */ |
| 339 | - public static function get_filesuffix() { |
|
| 384 | + public static function get_filesuffix() |
|
| 385 | + { |
|
| 340 | 386 | return 'csv'; |
| 341 | 387 | } |
| 342 | 388 | |
@@ -20,8 +20,12 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
| 22 | 22 | { |
| 23 | - interface activesync_plugin_write {} |
|
| 24 | - interface activesync_plugin_meeting_requests {} |
|
| 23 | + interface activesync_plugin_write |
|
| 24 | + { |
|
| 25 | +} |
|
| 26 | + interface activesync_plugin_meeting_requests |
|
| 27 | + { |
|
| 28 | +} |
|
| 25 | 29 | } |
| 26 | 30 | |
| 27 | 31 | /** |
@@ -81,7 +85,10 @@ discard block |
||
| 81 | 85 | */ |
| 82 | 86 | public function GetFolderList() |
| 83 | 87 | { |
| 84 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 88 | + if (!isset($this->calendar)) |
|
| 89 | + { |
|
| 90 | + $this->calendar = new calendar_boupdate(); |
|
| 91 | + } |
|
| 85 | 92 | |
| 86 | 93 | $cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
| 87 | 94 | $cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P' |
@@ -180,13 +187,20 @@ discard block |
||
| 180 | 187 | */ |
| 181 | 188 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
| 182 | 189 | { |
| 183 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 190 | + if (!isset($this->calendar)) |
|
| 191 | + { |
|
| 192 | + $this->calendar = new calendar_boupdate(); |
|
| 193 | + } |
|
| 184 | 194 | |
| 185 | 195 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)"); |
| 186 | 196 | $type = $user = null; |
| 187 | 197 | $this->backend->splitID($id,$type,$user); |
| 188 | 198 | |
| 189 | - if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
| 199 | + if (!$cutoffdate) |
|
| 200 | + { |
|
| 201 | + $cutoffdate = $this->bo->now - 100*24*3600; |
|
| 202 | + } |
|
| 203 | + // default three month back -30 breaks all sync recurrences |
|
| 190 | 204 | |
| 191 | 205 | $filter = array( |
| 192 | 206 | 'users' => $user, |
@@ -205,7 +219,10 @@ discard block |
||
| 205 | 219 | $messagelist = array(); |
| 206 | 220 | foreach ($this->calendar->search($filter) as $event) |
| 207 | 221 | { |
| 208 | - if ($not_uids && in_array($event['uid'], $not_uids)) continue; |
|
| 222 | + if ($not_uids && in_array($event['uid'], $not_uids)) |
|
| 223 | + { |
|
| 224 | + continue; |
|
| 225 | + } |
|
| 209 | 226 | $messagelist[] = $this->StatMessage($id, $event); |
| 210 | 227 | |
| 211 | 228 | // add virtual exceptions for recuring events too |
@@ -279,7 +296,10 @@ discard block |
||
| 279 | 296 | { |
| 280 | 297 | unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
| 281 | 298 | |
| 282 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 299 | + if (!isset($this->calendar)) |
|
| 300 | + { |
|
| 301 | + $this->calendar = new calendar_boupdate(); |
|
| 302 | + } |
|
| 283 | 303 | |
| 284 | 304 | if (!($event = $this->calendar->read(abs($id), 0, false, 'server'))) |
| 285 | 305 | { |
@@ -357,7 +377,10 @@ discard block |
||
| 357 | 377 | 'created' => 'dtstamp', |
| 358 | 378 | ) as $key => $attr) |
| 359 | 379 | { |
| 360 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 380 | + if (!empty($event[$key])) |
|
| 381 | + { |
|
| 382 | + $message->$attr = $event[$key]; |
|
| 383 | + } |
|
| 361 | 384 | } |
| 362 | 385 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
| 363 | 386 | { |
@@ -369,7 +392,10 @@ discard block |
||
| 369 | 392 | 'location' => 'location', |
| 370 | 393 | ) as $key => $attr) |
| 371 | 394 | { |
| 372 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 395 | + if (!empty($event[$key])) |
|
| 396 | + { |
|
| 397 | + $message->$attr = $event[$key]; |
|
| 398 | + } |
|
| 373 | 399 | } |
| 374 | 400 | $message->organizer = $event['organizer']; |
| 375 | 401 | |
@@ -404,7 +430,10 @@ discard block |
||
| 404 | 430 | */ |
| 405 | 431 | function MeetingResponse($folderid, $requestid, $response) |
| 406 | 432 | { |
| 407 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 433 | + if (!isset($this->calendar)) |
|
| 434 | + { |
|
| 435 | + $this->calendar = new calendar_boupdate(); |
|
| 436 | + } |
|
| 408 | 437 | |
| 409 | 438 | static $as2status = array( // different from self::$status2as! |
| 410 | 439 | 1 => 'A', |
@@ -414,9 +443,12 @@ discard block |
||
| 414 | 443 | $status_in = isset($as2status[$response]) ? $as2status[$response] : 'U'; |
| 415 | 444 | $uid = $GLOBALS['egw_info']['user']['account_id']; |
| 416 | 445 | |
| 417 | - if (!is_numeric($requestid)) // iCal from fmail |
|
| 446 | + if (!is_numeric($requestid)) |
|
| 447 | + { |
|
| 448 | + // iCal from fmail |
|
| 418 | 449 | { |
| 419 | 450 | $ical = new calendar_ical(); |
| 451 | + } |
|
| 420 | 452 | if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1) |
| 421 | 453 | { |
| 422 | 454 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!"); |
@@ -526,7 +558,10 @@ discard block |
||
| 526 | 558 | { |
| 527 | 559 | unset($contentParameters); // unused, but required by function signature |
| 528 | 560 | |
| 529 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 561 | + if (!isset($this->calendar)) |
|
| 562 | + { |
|
| 563 | + $this->calendar = new calendar_boupdate(); |
|
| 564 | + } |
|
| 530 | 565 | |
| 531 | 566 | $old_event = array(); |
| 532 | 567 | $type = $account = null; |
@@ -541,10 +576,13 @@ discard block |
||
| 541 | 576 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing"); |
| 542 | 577 | return false; |
| 543 | 578 | } |
| 544 | - if ($recur_date) // virtual exception |
|
| 579 | + if ($recur_date) |
|
| 580 | + { |
|
| 581 | + // virtual exception |
|
| 545 | 582 | { |
| 546 | 583 | // @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed |
| 547 | 584 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
| 585 | + } |
|
| 548 | 586 | //error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
| 549 | 587 | } |
| 550 | 588 | if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account)) |
@@ -554,7 +592,11 @@ discard block |
||
| 554 | 592 | //error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
| 555 | 593 | return false; |
| 556 | 594 | } |
| 557 | - if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
| 595 | + if (!$id) |
|
| 596 | + { |
|
| 597 | + $old_event['owner'] = $account; |
|
| 598 | + } |
|
| 599 | + // we do NOT allow to change the owner of existing events |
|
| 558 | 600 | |
| 559 | 601 | $event = $this->message2event($message, $account, $old_event); |
| 560 | 602 | |
@@ -583,7 +625,10 @@ discard block |
||
| 583 | 625 | unset($ex_event['etag']); |
| 584 | 626 | foreach(array_keys($ex_event) as $name) |
| 585 | 627 | { |
| 586 | - if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
| 628 | + if (substr($name,0,6) == 'recur_') |
|
| 629 | + { |
|
| 630 | + unset($ex_event[$name]); |
|
| 631 | + } |
|
| 587 | 632 | } |
| 588 | 633 | $ex_event['recur_type'] = calendar_rrule::NONE; |
| 589 | 634 | |
@@ -636,7 +681,10 @@ discard block |
||
| 636 | 681 | 'end' => 'endtime', |
| 637 | 682 | ) as $key => $attr) |
| 638 | 683 | { |
| 639 | - if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr); |
|
| 684 | + if (isset($message->$attr)) |
|
| 685 | + { |
|
| 686 | + $event[$key] = Api\DateTime::server2user($message->$attr); |
|
| 687 | + } |
|
| 640 | 688 | } |
| 641 | 689 | // copying strings |
| 642 | 690 | foreach(array( |
@@ -645,7 +693,10 @@ discard block |
||
| 645 | 693 | 'location' => 'location', |
| 646 | 694 | ) as $key => $attr) |
| 647 | 695 | { |
| 648 | - if (isset($message->$attr)) $event[$key] = $message->$attr; |
|
| 696 | + if (isset($message->$attr)) |
|
| 697 | + { |
|
| 698 | + $event[$key] = $message->$attr; |
|
| 699 | + } |
|
| 649 | 700 | } |
| 650 | 701 | |
| 651 | 702 | // only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse |
@@ -664,14 +715,22 @@ discard block |
||
| 664 | 715 | |
| 665 | 716 | if (($event['whole_day'] = $message->alldayevent)) |
| 666 | 717 | { |
| 667 | - if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
| 718 | + if ($event['end'] == $event['start']) |
|
| 719 | + { |
|
| 720 | + $event['end'] += 24*3600; |
|
| 721 | + } |
|
| 722 | + // some clients send equal start&end for 1day |
|
| 668 | 723 | $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
| 669 | 724 | } |
| 670 | 725 | |
| 671 | 726 | $participants = array(); |
| 672 | 727 | foreach((array)$message->attendees as $attendee) |
| 673 | 728 | { |
| 674 | - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
| 729 | + if ($attendee->type == 3) |
|
| 730 | + { |
|
| 731 | + continue; |
|
| 732 | + } |
|
| 733 | + // we can not identify resources and re-add them anyway later |
|
| 675 | 734 | |
| 676 | 735 | $matches = null; |
| 677 | 736 | if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
@@ -686,7 +745,10 @@ discard block |
||
| 686 | 745 | //'n_fn' => $attendee->name, // not sure if we want matches without email |
| 687 | 746 | ); |
| 688 | 747 | // search addressbook for participant |
| 689 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
| 748 | + if (!isset($this->addressbook)) |
|
| 749 | + { |
|
| 750 | + $this->addressbook = new Api\Contacts(); |
|
| 751 | + } |
|
| 690 | 752 | if ((list($data) = $this->addressbook->search($search, |
| 691 | 753 | array('id','egw_addressbook.account_id as account_id','n_fn'), |
| 692 | 754 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
@@ -694,10 +756,13 @@ discard block |
||
| 694 | 756 | { |
| 695 | 757 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
| 696 | 758 | } |
| 697 | - elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
| 759 | + elseif($attendee->name === $attendee->email || empty($attendee->name)) |
|
| 760 | + { |
|
| 761 | + // dont store empty or email as name |
|
| 698 | 762 | { |
| 699 | 763 | $uid = 'e'.$attendee->email; |
| 700 | 764 | } |
| 765 | + } |
|
| 701 | 766 | else // store just the email |
| 702 | 767 | { |
| 703 | 768 | $uid = 'e'.$attendee->name.' <'.$attendee->email.'>'; |
@@ -726,7 +791,11 @@ discard block |
||
| 726 | 791 | $role = 'REQ-PARTICIPANT'; |
| 727 | 792 | //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
| 728 | 793 | } |
| 729 | - if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
| 794 | + if ($role == 'CHAIR') |
|
| 795 | + { |
|
| 796 | + $chair_set = true; |
|
| 797 | + } |
|
| 798 | + // by role from existing participant |
|
| 730 | 799 | |
| 731 | 800 | if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
| 732 | 801 | { |
@@ -740,10 +809,13 @@ discard block |
||
| 740 | 809 | elseif (isset($attendee->attendeetype) && |
| 741 | 810 | !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
| 742 | 811 | ($r = array_search($attendee->attendeetype,self::$role2as)) && |
| 743 | - (int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
|
| 812 | + (int)self::$role2as[$role] != $attendee->attendeetype) |
|
| 813 | + { |
|
| 814 | + // if old role gives same type, use old role, as we have a lot more roles then AS |
|
| 744 | 815 | { |
| 745 | 816 | $role = $r; |
| 746 | 817 | } |
| 818 | + } |
|
| 747 | 819 | //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
| 748 | 820 | $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
| 749 | 821 | } |
@@ -758,12 +830,19 @@ discard block |
||
| 758 | 830 | // $account is also preserved, as AS does not add him as participant! |
| 759 | 831 | foreach((array)$event['participant_types'] as $type => $parts) |
| 760 | 832 | { |
| 761 | - if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
| 833 | + if (in_array($type,array('c','e'))) |
|
| 834 | + { |
|
| 835 | + continue; |
|
| 836 | + } |
|
| 837 | + // they are correctly representable in AS |
|
| 762 | 838 | |
| 763 | 839 | foreach($parts as $id => $status) |
| 764 | 840 | { |
| 765 | 841 | // accounts are represented correctly, but the event owner which is no participant in AS |
| 766 | - if ($type == 'u' && $id != $account) continue; |
|
| 842 | + if ($type == 'u' && $id != $account) |
|
| 843 | + { |
|
| 844 | + continue; |
|
| 845 | + } |
|
| 767 | 846 | |
| 768 | 847 | $uid = calendar_so::combine_user($type, $id); |
| 769 | 848 | if (!isset($participants[$uid])) |
@@ -788,10 +867,13 @@ discard block |
||
| 788 | 867 | // check if event is recurring and import recur information (incl. timezone) |
| 789 | 868 | if ($message->recurrence) |
| 790 | 869 | { |
| 791 | - if ($message->timezone && !$event['id']) // dont care for timezone, if no new and recurring event |
|
| 870 | + if ($message->timezone && !$event['id']) |
|
| 871 | + { |
|
| 872 | + // dont care for timezone, if no new and recurring event |
|
| 792 | 873 | { |
| 793 | 874 | $event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
| 794 | 875 | } |
| 876 | + } |
|
| 795 | 877 | $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
| 796 | 878 | array_search($message->recurrence->type, self::$recur_type2as); |
| 797 | 879 | $event['recur_interval'] = $message->recurrence->interval; |
@@ -828,10 +910,13 @@ discard block |
||
| 828 | 910 | { |
| 829 | 911 | // calculate enddate from occurences count, as we only support enddate |
| 830 | 912 | $count = $message->recurrence->occurrences; |
| 831 | - foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
| 913 | + foreach(calendar_rrule::event2rrule($event, true) as $rtime) |
|
| 914 | + { |
|
| 915 | + // true = timestamps are user time here, because of save! |
|
| 832 | 916 | { |
| 833 | 917 | if (--$count <= 0) break; |
| 834 | 918 | } |
| 919 | + } |
|
| 835 | 920 | $event['recur_enddate'] = $rtime->format('ts'); |
| 836 | 921 | } |
| 837 | 922 | } |
@@ -846,7 +931,9 @@ discard block |
||
| 846 | 931 | break; |
| 847 | 932 | } |
| 848 | 933 | } |
| 849 | - if ($alarm !== true) // new alarm |
|
| 934 | + if ($alarm !== true) |
|
| 935 | + { |
|
| 936 | + // new alarm |
|
| 850 | 937 | { |
| 851 | 938 | // delete all earlier alarms of that user |
| 852 | 939 | // user get's per AS only the earliest alarm, as AS only supports one alarm |
@@ -856,6 +943,7 @@ discard block |
||
| 856 | 943 | if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
| 857 | 944 | { |
| 858 | 945 | unset($event['alarm'][$key]); |
| 946 | + } |
|
| 859 | 947 | } |
| 860 | 948 | } |
| 861 | 949 | $event['alarm'][] = $alarm = array( |
@@ -936,7 +1024,10 @@ discard block |
||
| 936 | 1024 | { |
| 937 | 1025 | unset($contentParameters); // not used, but required by function signature |
| 938 | 1026 | |
| 939 | - if (!isset($this->caledar)) $this->calendar = new calendar_boupdate(); |
|
| 1027 | + if (!isset($this->caledar)) |
|
| 1028 | + { |
|
| 1029 | + $this->calendar = new calendar_boupdate(); |
|
| 1030 | + } |
|
| 940 | 1031 | |
| 941 | 1032 | $ret = $this->calendar->delete($id); |
| 942 | 1033 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -997,7 +1088,10 @@ discard block |
||
| 997 | 1088 | */ |
| 998 | 1089 | public function GetMessage($folderid, $id, $contentparameters) |
| 999 | 1090 | { |
| 1000 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1091 | + if (!isset($this->calendar)) |
|
| 1092 | + { |
|
| 1093 | + $this->calendar = new calendar_boupdate(); |
|
| 1094 | + } |
|
| 1001 | 1095 | //error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace()); |
| 1002 | 1096 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 1003 | 1097 | $mimesupport = $contentparameters->GetMimeSupport(); |
@@ -1045,7 +1139,10 @@ discard block |
||
| 1045 | 1139 | 'modified' => 'dtstamp', |
| 1046 | 1140 | ) as $key => $attr) |
| 1047 | 1141 | { |
| 1048 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 1142 | + if (!empty($event[$key])) |
|
| 1143 | + { |
|
| 1144 | + $message->$attr = $event[$key]; |
|
| 1145 | + } |
|
| 1049 | 1146 | } |
| 1050 | 1147 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
| 1051 | 1148 | { |
@@ -1058,7 +1155,10 @@ discard block |
||
| 1058 | 1155 | 'location' => 'location', |
| 1059 | 1156 | ) as $key => $attr) |
| 1060 | 1157 | { |
| 1061 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 1158 | + if (!empty($event[$key])) |
|
| 1159 | + { |
|
| 1160 | + $message->$attr = $event[$key]; |
|
| 1161 | + } |
|
| 1062 | 1162 | } |
| 1063 | 1163 | |
| 1064 | 1164 | // appoint description |
@@ -1092,7 +1192,10 @@ discard block |
||
| 1092 | 1192 | foreach($event['participants'] as $uid => $status) |
| 1093 | 1193 | { |
| 1094 | 1194 | // AS does NOT want calendar owner as participant |
| 1095 | - if ($uid == $account) continue; |
|
| 1195 | + if ($uid == $account) |
|
| 1196 | + { |
|
| 1197 | + continue; |
|
| 1198 | + } |
|
| 1096 | 1199 | $quantity = $role = null; |
| 1097 | 1200 | calendar_so::split_status($status, $quantity, $role); |
| 1098 | 1201 | |
@@ -1109,7 +1212,10 @@ discard block |
||
| 1109 | 1212 | list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
| 1110 | 1213 | ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
| 1111 | 1214 | |
| 1112 | - if (!$info) continue; |
|
| 1215 | + if (!$info) |
|
| 1216 | + { |
|
| 1217 | + continue; |
|
| 1218 | + } |
|
| 1113 | 1219 | |
| 1114 | 1220 | if (!$info['email'] && $info['responsible']) |
| 1115 | 1221 | { |
@@ -1125,10 +1231,17 @@ discard block |
||
| 1125 | 1231 | $message->organizeremail = $attendee->email; |
| 1126 | 1232 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
| 1127 | 1233 | } |
| 1128 | - if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
| 1234 | + if ($uid[0] == 'r') |
|
| 1235 | + { |
|
| 1236 | + $attendee->type = 3; |
|
| 1237 | + } |
|
| 1238 | + // 3 = resource |
|
| 1129 | 1239 | } |
| 1130 | 1240 | // email must NOT be empty, but MAY be an arbitrary text |
| 1131 | - if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
| 1241 | + if (empty($attendee->email)) |
|
| 1242 | + { |
|
| 1243 | + $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
| 1244 | + } |
|
| 1132 | 1245 | |
| 1133 | 1246 | $message->attendees[] = $attendee; |
| 1134 | 1247 | } |
@@ -1163,9 +1276,12 @@ discard block |
||
| 1163 | 1276 | $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
| 1164 | 1277 | break; |
| 1165 | 1278 | } |
| 1166 | - if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
|
| 1279 | + if ($rrule->enddate) |
|
| 1280 | + { |
|
| 1281 | + // enddate is only a date, but AS needs a time incl. correct starttime! |
|
| 1167 | 1282 | { |
| 1168 | 1283 | $enddate = clone $rrule->time; |
| 1284 | + } |
|
| 1169 | 1285 | $enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'), |
| 1170 | 1286 | $rrule->enddate->format('d')); |
| 1171 | 1287 | $recurrence->until = $enddate->format('server'); |
@@ -1187,12 +1303,19 @@ discard block |
||
| 1187 | 1303 | { |
| 1188 | 1304 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
| 1189 | 1305 | } |
| 1190 | - if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
| 1306 | + if (count($ex_events)>=1) |
|
| 1307 | + { |
|
| 1308 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
| 1309 | + } |
|
| 1191 | 1310 | |
| 1192 | 1311 | $message->exceptions = array(); |
| 1193 | 1312 | foreach($ex_events as $ex_event) |
| 1194 | 1313 | { |
| 1195 | - if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
| 1314 | + if ($ex_event['id'] == $event['id']) |
|
| 1315 | + { |
|
| 1316 | + continue; |
|
| 1317 | + } |
|
| 1318 | + // ignore series master |
|
| 1196 | 1319 | $exception = $this->GetMessage($folderid, $ex_event, $contentparameters); |
| 1197 | 1320 | $exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
| 1198 | 1321 | foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
@@ -1212,7 +1335,10 @@ discard block |
||
| 1212 | 1335 | { |
| 1213 | 1336 | if (!empty($exception_time)) |
| 1214 | 1337 | { |
| 1215 | - if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
| 1338 | + if (empty($event['uid'])) |
|
| 1339 | + { |
|
| 1340 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
| 1341 | + } |
|
| 1216 | 1342 | $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
| 1217 | 1343 | $exception->deleted = 1; |
| 1218 | 1344 | $exception->exceptionstarttime = $exception_time; |
@@ -1268,12 +1394,18 @@ discard block |
||
| 1268 | 1394 | { |
| 1269 | 1395 | unset($folderid); // not used ($id is unique), but required by function signature |
| 1270 | 1396 | |
| 1271 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1397 | + if (!isset($this->calendar)) |
|
| 1398 | + { |
|
| 1399 | + $this->calendar = new calendar_boupdate(); |
|
| 1400 | + } |
|
| 1272 | 1401 | |
| 1273 | 1402 | $nul = null; |
| 1274 | - if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) // last true: $only_master=true |
|
| 1403 | + if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) |
|
| 1404 | + { |
|
| 1405 | + // last true: $only_master=true |
|
| 1275 | 1406 | { |
| 1276 | 1407 | $stat = false; |
| 1408 | + } |
|
| 1277 | 1409 | // error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
| 1278 | 1410 | $backup = $this->calendar->debug; |
| 1279 | 1411 | //$this->calendar->debug = 2; |
@@ -1307,13 +1439,22 @@ discard block |
||
| 1307 | 1439 | $type = $owner = null; |
| 1308 | 1440 | $this->backend->splitID($folderid, $type, $owner); |
| 1309 | 1441 | |
| 1310 | - if ($type != 'calendar') return false; |
|
| 1442 | + if ($type != 'calendar') |
|
| 1443 | + { |
|
| 1444 | + return false; |
|
| 1445 | + } |
|
| 1311 | 1446 | |
| 1312 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1447 | + if (!isset($this->calendar)) |
|
| 1448 | + { |
|
| 1449 | + $this->calendar = new calendar_boupdate(); |
|
| 1450 | + } |
|
| 1313 | 1451 | //$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
| 1314 | 1452 | $syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
| 1315 | 1453 | // workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
| 1316 | - if ($syncstate == 0) $syncstate = 1; |
|
| 1454 | + if ($syncstate == 0) |
|
| 1455 | + { |
|
| 1456 | + $syncstate = 1; |
|
| 1457 | + } |
|
| 1317 | 1458 | |
| 1318 | 1459 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'"); |
| 1319 | 1460 | } |
@@ -1385,7 +1526,10 @@ discard block |
||
| 1385 | 1526 | ); |
| 1386 | 1527 | |
| 1387 | 1528 | $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
| 1388 | - if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
| 1529 | + if (strpos($component, 'VTIMEZONE') === false) |
|
| 1530 | + { |
|
| 1531 | + $component = calendar_timezones::tz2id($name,'component'); |
|
| 1532 | + } |
|
| 1389 | 1533 | // parse ical timezone defintion |
| 1390 | 1534 | $ical = self::ical2array($component); |
| 1391 | 1535 | $standard = $ical['VTIMEZONE']['STANDARD']; |
@@ -1428,11 +1572,17 @@ discard block |
||
| 1428 | 1572 | $data[$prefix.'week'] = 5; |
| 1429 | 1573 | } |
| 1430 | 1574 | // if both start and end use 1SU use week=5 and decrement month |
| 1431 | - if ($prefix == 'dststart') $start_byday = $matches[1]; |
|
| 1575 | + if ($prefix == 'dststart') |
|
| 1576 | + { |
|
| 1577 | + $start_byday = $matches[1]; |
|
| 1578 | + } |
|
| 1432 | 1579 | if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU') |
| 1433 | 1580 | { |
| 1434 | 1581 | $data[$prefix.'week'] = 5; |
| 1435 | - if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
|
| 1582 | + if ($prefix == 'dstend') |
|
| 1583 | + { |
|
| 1584 | + $data[$prefix.'month'] -= 1; |
|
| 1585 | + } |
|
| 1436 | 1586 | } |
| 1437 | 1587 | static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
| 1438 | 1588 | $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
@@ -1508,7 +1658,10 @@ discard block |
||
| 1508 | 1658 | static public function ical2array(&$ical,$section=null) |
| 1509 | 1659 | { |
| 1510 | 1660 | $arr = array(); |
| 1511 | - if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
|
| 1661 | + if (!is_array($ical)) |
|
| 1662 | + { |
|
| 1663 | + $ical = preg_split("/[\r\n]+/m", $ical); |
|
| 1664 | + } |
|
| 1512 | 1665 | while (($line = array_shift($ical))) |
| 1513 | 1666 | { |
| 1514 | 1667 | list($name,$value) = explode(':',$line,2); |
@@ -1518,7 +1671,10 @@ discard block |
||
| 1518 | 1671 | } |
| 1519 | 1672 | elseif($name == 'END') |
| 1520 | 1673 | { |
| 1521 | - if ($section && $section==$value) return $arr; |
|
| 1674 | + if ($section && $section==$value) |
|
| 1675 | + { |
|
| 1676 | + return $arr; |
|
| 1677 | + } |
|
| 1522 | 1678 | break; |
| 1523 | 1679 | } |
| 1524 | 1680 | else |
@@ -1549,13 +1705,19 @@ discard block |
||
| 1549 | 1705 | |
| 1550 | 1706 | for($n = 0; !isset($cache[$key]); ++$n) |
| 1551 | 1707 | { |
| 1552 | - if (!$n) // check users timezone first |
|
| 1708 | + if (!$n) |
|
| 1709 | + { |
|
| 1710 | + // check users timezone first |
|
| 1553 | 1711 | { |
| 1554 | 1712 | $tz = Api\DateTime::$user_timezone->getName(); |
| 1555 | 1713 | } |
| 1556 | - elseif (!($tz = calendar_timezones::id2tz($n))) // no further timezones to check |
|
| 1714 | + } |
|
| 1715 | + elseif (!($tz = calendar_timezones::id2tz($n))) |
|
| 1716 | + { |
|
| 1717 | + // no further timezones to check |
|
| 1557 | 1718 | { |
| 1558 | 1719 | $cache[$key] = 'UTC'; |
| 1720 | + } |
|
| 1559 | 1721 | error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!'); |
| 1560 | 1722 | break; |
| 1561 | 1723 | } |
@@ -1619,7 +1781,11 @@ discard block |
||
| 1619 | 1781 | $account_id = $entry['grantor']; |
| 1620 | 1782 | $cals[$account_id] = $entry['name']; |
| 1621 | 1783 | } |
| 1622 | - if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
| 1784 | + if ($hook_data['account_id'] > 0) |
|
| 1785 | + { |
|
| 1786 | + unset($cals[$hook_data['account_id']]); |
|
| 1787 | + } |
|
| 1788 | + // skip current user |
|
| 1623 | 1789 | } |
| 1624 | 1790 | $cals['G'] = lang('Primary group'); |
| 1625 | 1791 | $cals['A'] = lang('All'); |
@@ -1647,13 +1813,16 @@ discard block |
||
| 1647 | 1813 | * |
| 1648 | 1814 | * You need to comment implements activesync_plugin_write |
| 1649 | 1815 | */ |
| 1650 | -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
|
| 1816 | +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
|
| 1817 | +{ |
|
| 1818 | + // some tests |
|
| 1651 | 1819 | { |
| 1652 | 1820 | $GLOBALS['egw_info'] = array( |
| 1653 | 1821 | 'flags' => array( |
| 1654 | 1822 | 'currentapp' => 'login' |
| 1655 | 1823 | ) |
| 1656 | 1824 | ); |
| 1825 | +} |
|
| 1657 | 1826 | require_once('../../header.inc.php'); |
| 1658 | 1827 | ini_set('display_errors',1); |
| 1659 | 1828 | error_reporting(E_ALL & ~E_NOTICE); |
@@ -37,12 +37,15 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param string $_identifier |
| 39 | 39 | */ |
| 40 | - public function __construct( $_identifier='' ){ |
|
| 40 | + public function __construct( $_identifier='' ) |
|
| 41 | + { |
|
| 41 | 42 | $this->identifier = $_identifier; |
| 42 | - if(!is_object($this->bo)) { |
|
| 43 | + if(!is_object($this->bo)) |
|
| 44 | + { |
|
| 43 | 45 | $this->bo = new calendar_bo(); |
| 44 | 46 | } |
| 45 | - if($this->identifier) { |
|
| 47 | + if($this->identifier) |
|
| 48 | + { |
|
| 46 | 49 | $this->record = $this->bo->read($this->identifier); |
| 47 | 50 | } |
| 48 | 51 | } |
@@ -52,7 +55,8 @@ discard block |
||
| 52 | 55 | * |
| 53 | 56 | * @param string $_attribute_name |
| 54 | 57 | */ |
| 55 | - public function __get($_attribute_name) { |
|
| 58 | + public function __get($_attribute_name) |
|
| 59 | + { |
|
| 56 | 60 | return $this->record[$_attribute_name]; |
| 57 | 61 | } |
| 58 | 62 | |
@@ -62,7 +66,8 @@ discard block |
||
| 62 | 66 | * @param string $_attribute_name |
| 63 | 67 | * @param data $data |
| 64 | 68 | */ |
| 65 | - public function __set($_attribute_name, $data) { |
|
| 69 | + public function __set($_attribute_name, $data) |
|
| 70 | + { |
|
| 66 | 71 | $this->record[$_attribute_name] = $data; |
| 67 | 72 | } |
| 68 | 73 | |
@@ -74,7 +79,8 @@ discard block |
||
| 74 | 79 | * |
| 75 | 80 | * @return array complete record as associative array |
| 76 | 81 | */ |
| 77 | - public function get_record_array() { |
|
| 82 | + public function get_record_array() |
|
| 83 | + { |
|
| 78 | 84 | return $this->record; |
| 79 | 85 | } |
| 80 | 86 | |
@@ -83,8 +89,10 @@ discard block |
||
| 83 | 89 | * |
| 84 | 90 | *@return string tiltle |
| 85 | 91 | */ |
| 86 | - public function get_title() { |
|
| 87 | - if (empty($this->record)) { |
|
| 92 | + public function get_title() |
|
| 93 | + { |
|
| 94 | + if (empty($this->record)) |
|
| 95 | + { |
|
| 88 | 96 | $this->get_record(); |
| 89 | 97 | } |
| 90 | 98 | return $this->record['title']; |
@@ -96,7 +104,8 @@ discard block |
||
| 96 | 104 | * @todo add some checks |
| 97 | 105 | * @return void |
| 98 | 106 | */ |
| 99 | - public function set_record(array $_record){ |
|
| 107 | + public function set_record(array $_record) |
|
| 108 | + { |
|
| 100 | 109 | $this->record = $_record; |
| 101 | 110 | } |
| 102 | 111 | |
@@ -105,7 +114,8 @@ discard block |
||
| 105 | 114 | * |
| 106 | 115 | * @return string identifier of current record |
| 107 | 116 | */ |
| 108 | - public function get_identifier() { |
|
| 117 | + public function get_identifier() |
|
| 118 | + { |
|
| 109 | 119 | return $this->identifier; |
| 110 | 120 | } |
| 111 | 121 | |
@@ -115,7 +125,8 @@ discard block |
||
| 115 | 125 | * |
| 116 | 126 | * @return string Full URL of an icon, or appname/icon_name |
| 117 | 127 | */ |
| 118 | - public function get_icon() { |
|
| 128 | + public function get_icon() |
|
| 129 | + { |
|
| 119 | 130 | return 'calendar/navbar'; |
| 120 | 131 | } |
| 121 | 132 | |
@@ -124,7 +135,8 @@ discard block |
||
| 124 | 135 | * |
| 125 | 136 | * @return string identifier |
| 126 | 137 | */ |
| 127 | - public function save ( $_dst_identifier ) { |
|
| 138 | + public function save ( $_dst_identifier ) |
|
| 139 | + { |
|
| 128 | 140 | // Not yet implemeted |
| 129 | 141 | $this->identifier = $_dst_identifier; |
| 130 | 142 | } |
@@ -135,7 +147,8 @@ discard block |
||
| 135 | 147 | * @param string $_dst_identifier |
| 136 | 148 | * @return string dst_identifier |
| 137 | 149 | */ |
| 138 | - public function copy ( $_dst_identifier ) { |
|
| 150 | + public function copy ( $_dst_identifier ) |
|
| 151 | + { |
|
| 139 | 152 | unset($_dst_identifier); // not used |
| 140 | 153 | } |
| 141 | 154 | |
@@ -146,7 +159,8 @@ discard block |
||
| 146 | 159 | * @param string $_dst_identifier |
| 147 | 160 | * @return string dst_identifier |
| 148 | 161 | */ |
| 149 | - public function move ( $_dst_identifier ) { |
|
| 162 | + public function move ( $_dst_identifier ) |
|
| 163 | + { |
|
| 150 | 164 | unset($_dst_identifier); // not used |
| 151 | 165 | } |
| 152 | 166 | |
@@ -154,7 +168,8 @@ discard block |
||
| 154 | 168 | * delets current record from backend |
| 155 | 169 | * |
| 156 | 170 | */ |
| 157 | - public function delete () { |
|
| 171 | + public function delete () |
|
| 172 | + { |
|
| 158 | 173 | |
| 159 | 174 | } |
| 160 | 175 | |
@@ -162,7 +177,8 @@ discard block |
||
| 162 | 177 | * destructor |
| 163 | 178 | * |
| 164 | 179 | */ |
| 165 | - public function __destruct() { |
|
| 180 | + public function __destruct() |
|
| 181 | + { |
|
| 166 | 182 | } |
| 167 | 183 | |
| 168 | 184 | } |
| 169 | 185 | \ No newline at end of file |