@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
82 | 82 | |
83 | 83 | $cals = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
84 | - $cals = $cals ? explode(',',$cals) : array('P'); // implicit default of 'P' |
|
84 | + $cals = $cals ? explode(',', $cals) : array('P'); // implicit default of 'P' |
|
85 | 85 | $folderlist = array(); |
86 | 86 | |
87 | 87 | foreach ($this->calendar->list_cals() as $entry) |
88 | 88 | { |
89 | 89 | $account_id = $entry['grantor']; |
90 | 90 | $label = $entry['name']; |
91 | - if (in_array('A',$cals) || in_array($account_id,$cals) || |
|
92 | - $account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar! |
|
93 | - $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals)) |
|
91 | + if (in_array('A', $cals) || in_array($account_id, $cals) || |
|
92 | + $account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar! |
|
93 | + $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals)) |
|
94 | 94 | { |
95 | 95 | $folderlist[] = $f = array( |
96 | - 'id' => $this->backend->createID('calendar',$account_id), |
|
97 | - 'mod' => $GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'), |
|
96 | + 'id' => $this->backend->createID('calendar', $account_id), |
|
97 | + 'mod' => $GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'), |
|
98 | 98 | 'parent'=> '0', |
99 | 99 | ); |
100 | 100 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $folderObj = new SyncFolder(); |
118 | 118 | $folderObj->serverid = $id; |
119 | 119 | $folderObj->parentid = '0'; |
120 | - $folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'); |
|
120 | + $folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'); |
|
121 | 121 | if ($owner == $GLOBALS['egw_info']['user']['account_id']) |
122 | 122 | { |
123 | 123 | $folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $stat = array( |
153 | 153 | 'id' => $id, |
154 | - 'mod' => $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'), |
|
154 | + 'mod' => $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'), |
|
155 | 155 | 'parent' => '0', |
156 | 156 | ); |
157 | 157 | //error_log(__METHOD__."('$id') folderObj=".array2string($stat)); |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | * @param array $not_uids=null uids NOT to return for meeting requests |
176 | 176 | * @return array |
177 | 177 | */ |
178 | - function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
|
178 | + function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null) |
|
179 | 179 | { |
180 | 180 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
181 | 181 | |
182 | - debugLog (__METHOD__."('$id',$cutoffdate)"); |
|
183 | - $this->backend->splitID($id,$type,$user); |
|
182 | + debugLog(__METHOD__."('$id',$cutoffdate)"); |
|
183 | + $this->backend->splitID($id, $type, $user); |
|
184 | 184 | |
185 | - if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
185 | + if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences |
|
186 | 186 | |
187 | 187 | $filter = array( |
188 | 188 | 'users' => $user, |
189 | - 'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences |
|
189 | + 'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences |
|
190 | 190 | 'enum_recuring' => false, |
191 | 191 | 'daywise' => false, |
192 | 192 | 'date_format' => 'server', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | 'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default', |
196 | 196 | // @todo return only etag relevant information (seems not to work ...) |
197 | 197 | //'cols' => array('egw_cal.cal_id', 'cal_start', 'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'), |
198 | - 'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions |
|
198 | + 'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions |
|
199 | 199 | ); |
200 | 200 | |
201 | 201 | $messagelist = array(); |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | * @param int $cutoffdate=null |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - function GetMeetingRequests(array $not_uids, $cutoffdate=NULL) |
|
229 | + function GetMeetingRequests(array $not_uids, $cutoffdate = NULL) |
|
230 | 230 | { |
231 | -return array(); // temporary disabling meeting requests from calendar |
|
232 | - $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
231 | +return array(); // temporary disabling meeting requests from calendar |
|
232 | + $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
233 | 233 | |
234 | 234 | $ret = $this->GetMessageList($folderid, $cutoffdate, $not_uids); |
235 | 235 | // return all id's negative to not conflict with uids from fmail |
236 | - foreach($ret as &$message) |
|
236 | + foreach ($ret as &$message) |
|
237 | 237 | { |
238 | 238 | $message['id'] = -$message['id']; |
239 | 239 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | function StatMeetingRequest($id) |
252 | 252 | { |
253 | - $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
253 | + $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
254 | 254 | |
255 | 255 | $ret = $this->StatMessage($folderid, abs($id)); |
256 | 256 | $ret['id'] = $id; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param bool $mimesupport |
270 | 270 | * @return SyncMail |
271 | 271 | */ |
272 | - function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
272 | + function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
273 | 273 | { |
274 | 274 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
275 | 275 | |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | $message = new SyncMail(); |
283 | 283 | $message->read = false; |
284 | 284 | $message->subject = $event['title']; |
285 | - $message->importance = 1; // 0=Low, 1=Normal, 2=High |
|
285 | + $message->importance = 1; // 0=Low, 1=Normal, 2=High |
|
286 | 286 | $message->datereceived = $event['created']; |
287 | 287 | $message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email']; |
288 | - $message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'). |
|
289 | - ' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>'; |
|
288 | + $message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname'). |
|
289 | + ' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>'; |
|
290 | 290 | $message->internetcpid = 65001; |
291 | - $message->contentclass="urn:content-classes:message"; |
|
291 | + $message->contentclass = "urn:content-classes:message"; |
|
292 | 292 | |
293 | 293 | $message->meetingrequest = self::meetingRequest($event); |
294 | 294 | $message->messageclass = "IPM.Schedule.Meeting.Request"; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | else |
304 | 304 | { |
305 | 305 | $message->airsyncbasebody = new SyncAirSyncBaseBody(); |
306 | - $message->airsyncbasenativebodytype=1; |
|
306 | + $message->airsyncbasenativebodytype = 1; |
|
307 | 307 | $this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody); |
308 | 308 | } |
309 | 309 | } |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | $as_tz = self::tz2as($event['tzid']); |
339 | 339 | $message->timezone = base64_encode(calendar_activesync::_getSyncBlobFromTZ($as_tz)); |
340 | 340 | } |
341 | - catch(Exception $e) { |
|
341 | + catch (Exception $e) { |
|
342 | 342 | // ignore exception, simply set no timezone, as it is optional |
343 | 343 | } |
344 | 344 | // copying timestamps (they are already read in servertime, so non tz conversation) |
345 | - foreach(array( |
|
345 | + foreach (array( |
|
346 | 346 | 'start' => 'starttime', |
347 | 347 | 'end' => 'endtime', |
348 | 348 | 'created' => 'dtstamp', |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | } |
353 | 353 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
354 | 354 | { |
355 | - ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
355 | + ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
356 | 356 | } |
357 | 357 | // copying strings |
358 | - foreach(array( |
|
358 | + foreach (array( |
|
359 | 359 | 'title' => 'subject', |
360 | 360 | 'location' => 'location', |
361 | 361 | ) as $key => $attr) |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | } |
365 | 365 | $message->organizer = $event['organizer']; |
366 | 366 | |
367 | - $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
367 | + $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
368 | 368 | |
369 | 369 | // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
370 | 370 | $message->busystatus = $event['non_blocking'] ? 0 : 2; |
371 | 371 | |
372 | 372 | // ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ... |
373 | - $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception |
|
373 | + $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception |
|
374 | 374 | |
375 | - $message->responserequested = 1; //0=No, 1=Yes |
|
376 | - $message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed |
|
375 | + $message->responserequested = 1; //0=No, 1=Yes |
|
376 | + $message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed |
|
377 | 377 | //$message->messagemeetingtype; // email2 |
378 | 378 | |
379 | 379 | // ToDo: alarme: Reminder |
@@ -419,14 +419,14 @@ discard block |
||
419 | 419 | // check if event already exist (invitation of or already imported by other user) |
420 | 420 | if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server'))) |
421 | 421 | { |
422 | - $event = $parsed_event; // create new event from external invitation |
|
422 | + $event = $parsed_event; // create new event from external invitation |
|
423 | 423 | } |
424 | - elseif(!isset($event['participants'][$uid])) |
|
424 | + elseif (!isset($event['participants'][$uid])) |
|
425 | 425 | { |
426 | 426 | debugLog(__METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event)); |
427 | 427 | // maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ... |
428 | 428 | } |
429 | - elseif($event['deleted']) |
|
429 | + elseif ($event['deleted']) |
|
430 | 430 | { |
431 | 431 | debugLog(__METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false"); |
432 | 432 | return false; |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | } |
440 | 440 | // keep role and quantity as AS has no idea about it |
441 | 441 | calendar_so::split_status($event['participants'][$uid], $quantity, $role); |
442 | - $status = calendar_so::combine_status($status,$quantity,$role); |
|
442 | + $status = calendar_so::combine_status($status, $quantity, $role); |
|
443 | 443 | |
444 | 444 | if ($event['id'] && isset($event['participants'][$uid])) |
445 | 445 | { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | else |
449 | 449 | { |
450 | 450 | $event['participants'][$uid] = $status; |
451 | - $ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS |
|
451 | + $ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS |
|
452 | 452 | } |
453 | 453 | debugLog(__METHOD__.'('.array2string($requestid).", '$folderid', $response) returning ".array2string($ret)); |
454 | 454 | return $ret; |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | * @var array |
461 | 461 | */ |
462 | 462 | static $status2as = array( |
463 | - 'U' => 0, // unknown |
|
464 | - 'T' => 2, // tentative |
|
465 | - 'A' => 3, // accepted |
|
466 | - 'R' => 4, // decline |
|
463 | + 'U' => 0, // unknown |
|
464 | + 'T' => 2, // tentative |
|
465 | + 'A' => 3, // accepted |
|
466 | + 'R' => 4, // decline |
|
467 | 467 | // 5 = not responded |
468 | 468 | ); |
469 | 469 | /** |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | * @var array |
473 | 473 | */ |
474 | 474 | static $role2as = array( |
475 | - 'REQ-PARTICIPANT' => 1, // required |
|
476 | - 'CHAIR' => 1, // required |
|
477 | - 'OPT-PARTICIPANT' => 2, // optional |
|
475 | + 'REQ-PARTICIPANT' => 1, // required |
|
476 | + 'CHAIR' => 1, // required |
|
477 | + 'OPT-PARTICIPANT' => 2, // optional |
|
478 | 478 | 'NON-PARTICIPANT' => 2, |
479 | 479 | // 3 = ressource |
480 | 480 | ); |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | static $recur_type2as = array( |
487 | 487 | calendar_rrule::DAILY => 0, |
488 | 488 | calendar_rrule::WEEKLY => 1, |
489 | - calendar_rrule::MONTHLY_MDAY => 2, // monthly |
|
490 | - calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day |
|
489 | + calendar_rrule::MONTHLY_MDAY => 2, // monthly |
|
490 | + calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day |
|
491 | 491 | calendar_rrule::YEARLY => 5, |
492 | 492 | // 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears) |
493 | 493 | ); |
@@ -518,9 +518,9 @@ discard block |
||
518 | 518 | $event = array(); |
519 | 519 | $this->backend->splitID($folderid, $type, $account); |
520 | 520 | |
521 | - debugLog (__METHOD__."('$folderid', $id, ".array2string($message).") type='$type', account=$account"); |
|
521 | + debugLog(__METHOD__."('$folderid', $id, ".array2string($message).") type='$type', account=$account"); |
|
522 | 522 | |
523 | - list($id,$recur_date) = explode(':',$id); |
|
523 | + list($id, $recur_date) = explode(':', $id); |
|
524 | 524 | |
525 | 525 | if ($type != 'calendar' || $id && !($event = $this->calendar->read($id, $recur_date, false, 'server'))) |
526 | 526 | { |
@@ -533,25 +533,25 @@ discard block |
||
533 | 533 | debugLog(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
534 | 534 | error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
535 | 535 | } |
536 | - if (!$this->calendar->check_perms($id ? EGW_ACL_EDIT : EGW_ACL_ADD,$event ? $event : 0,$account)) |
|
536 | + if (!$this->calendar->check_perms($id ? EGW_ACL_EDIT : EGW_ACL_ADD, $event ? $event : 0, $account)) |
|
537 | 537 | { |
538 | 538 | // @todo: write in users calendar and make account only a participant |
539 | 539 | debugLog(__METHOD__."('$folderid',$id,...) no rights to add/edit event!"); |
540 | 540 | error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
541 | 541 | return false; |
542 | 542 | } |
543 | - if (!$id) $event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
543 | + if (!$id) $event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
544 | 544 | |
545 | 545 | $event = $this->message2event($message, $account, $event); |
546 | 546 | |
547 | 547 | // store event, ignore conflicts and skip notifications, as AS clients do their own notifications |
548 | 548 | $skip_notification = false; |
549 | 549 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']) && |
550 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']=='send') |
|
550 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations'] == 'send') |
|
551 | 551 | { |
552 | 552 | $skip_notification = true; // to avoid double notification from client AND Server |
553 | 553 | } |
554 | - if (!($id = $this->calendar->update($event,$ignore_conflicts=true,$touch_modified=true,$ignore_acl=false,$updateTS=true,$messages=null, $skip_notification))) |
|
554 | + if (!($id = $this->calendar->update($event, $ignore_conflicts = true, $touch_modified = true, $ignore_acl = false, $updateTS = true, $messages = null, $skip_notification))) |
|
555 | 555 | { |
556 | 556 | debugLog(__METHOD__."('$folderid',$id,...) error saving event=".array2string($event)."!"); |
557 | 557 | return false; |
@@ -559,24 +559,24 @@ discard block |
||
559 | 559 | // store non-delete exceptions |
560 | 560 | if ($message->exceptions) |
561 | 561 | { |
562 | - foreach($message->exceptions as $exception) |
|
562 | + foreach ($message->exceptions as $exception) |
|
563 | 563 | { |
564 | 564 | if (!$exception->deleted) |
565 | 565 | { |
566 | 566 | $ex_event = $event; |
567 | 567 | unset($ex_event['id']); |
568 | 568 | unset($ex_event['etag']); |
569 | - foreach($ex_event as $name => $value) if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
569 | + foreach ($ex_event as $name => $value) if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]); |
|
570 | 570 | $ex_event['recur_type'] = calendar_rrule::NONE; |
571 | 571 | |
572 | 572 | if ($event['id'] && ($ex_events = $this->calendar->search(array( |
573 | 573 | 'user' => $user, |
574 | 574 | 'enum_recuring' => false, |
575 | 575 | 'daywise' => false, |
576 | - 'filter' => 'owner', // return all possible entries |
|
576 | + 'filter' => 'owner', // return all possible entries |
|
577 | 577 | 'query' => array( |
578 | 578 | 'cal_uid' => $event['uid'], |
579 | - 'cal_recurrence' => $exception->exceptionstarttime, // in servertime |
|
579 | + 'cal_recurrence' => $exception->exceptionstarttime, // in servertime |
|
580 | 580 | ), |
581 | 581 | )))) |
582 | 582 | { |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | $participants = $event['participants']; |
589 | 589 | } |
590 | 590 | $ex_event = $this->message2event($exception, $account, $ex_event); |
591 | - $ex_event['participants'] = $participants; // not contained in $exception |
|
591 | + $ex_event['participants'] = $participants; // not contained in $exception |
|
592 | 592 | $ex_event['reference'] = $event['id']; |
593 | 593 | $ex_event['recurrence'] = egw_time::server2user($exception->exceptionstarttime); |
594 | 594 | $ex_ok = $this->calendar->save($ex_event); |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | * @param array $event=array() |
611 | 611 | * @return array |
612 | 612 | */ |
613 | - private function message2event(SyncAppointment $message, $account, $event=array()) |
|
613 | + private function message2event(SyncAppointment $message, $account, $event = array()) |
|
614 | 614 | { |
615 | 615 | // timestamps (created & modified are updated automatically) |
616 | - foreach(array( |
|
616 | + foreach (array( |
|
617 | 617 | 'start' => 'starttime', |
618 | 618 | 'end' => 'endtime', |
619 | 619 | ) as $key => $attr) |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | if (isset($message->$attr)) $event[$key] = egw_time::server2user($message->$attr); |
622 | 622 | } |
623 | 623 | // copying strings |
624 | - foreach(array( |
|
624 | + foreach (array( |
|
625 | 625 | 'title' => 'subject', |
626 | 626 | 'uid' => 'uid', |
627 | 627 | 'location' => 'location', |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | { |
637 | 637 | $event['description'] = $description; |
638 | 638 | } |
639 | - $event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential |
|
639 | + $event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential |
|
640 | 640 | |
641 | 641 | // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
642 | 642 | if (isset($message->busystatus)) |
@@ -646,20 +646,20 @@ discard block |
||
646 | 646 | |
647 | 647 | if (($event['whole_day'] = $message->alldayevent)) |
648 | 648 | { |
649 | - if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
650 | - $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
|
649 | + if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day |
|
650 | + $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | $participants = array(); |
654 | - foreach((array)$message->attendees as $attendee) |
|
654 | + foreach ((array)$message->attendees as $attendee) |
|
655 | 655 | { |
656 | - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
656 | + if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
657 | 657 | |
658 | - if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
|
658 | + if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches)) |
|
659 | 659 | { |
660 | 660 | $uid = $matches[1]; |
661 | 661 | } |
662 | - elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email'))) |
|
662 | + elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email'))) |
|
663 | 663 | { |
664 | 664 | $search = array( |
665 | 665 | 'email' => $attendee->email, |
@@ -669,13 +669,13 @@ discard block |
||
669 | 669 | // search addressbook for participant |
670 | 670 | if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
671 | 671 | if ((list($data) = $this->addressbook->search($search, |
672 | - array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
672 | + array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
673 | 673 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
674 | - '','',false,'OR'))) |
|
674 | + '', '', false, 'OR'))) |
|
675 | 675 | { |
676 | 676 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
677 | 677 | } |
678 | - elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
678 | + elseif ($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
679 | 679 | { |
680 | 680 | $uid = 'e'.$attendee->email; |
681 | 681 | } |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | //debugLog("old status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
693 | 693 | } |
694 | 694 | // check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set |
695 | - elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) || |
|
696 | - (isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>'])))) |
|
695 | + elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) || |
|
696 | + (isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>'])))) |
|
697 | 697 | { |
698 | 698 | $status = $event['participants'][$u]; |
699 | 699 | calendar_so::split_status($status, $quantity, $role); |
@@ -706,9 +706,9 @@ discard block |
||
706 | 706 | $role = 'REQ-PARTICIPANT'; |
707 | 707 | //debugLog("default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
708 | 708 | } |
709 | - if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
709 | + if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
710 | 710 | |
711 | - if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
|
711 | + if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as))) |
|
712 | 712 | { |
713 | 713 | $status = $s; |
714 | 714 | } |
@@ -718,29 +718,29 @@ discard block |
||
718 | 718 | $chair_set = true; |
719 | 719 | } |
720 | 720 | elseif (isset($attendee->attendeetype) && |
721 | - !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
|
722 | - ($r = array_search($attendee->attendeetype,self::$role2as)) && |
|
721 | + !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
|
722 | + ($r = array_search($attendee->attendeetype, self::$role2as)) && |
|
723 | 723 | (int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
724 | 724 | { |
725 | 725 | $role = $r; |
726 | 726 | } |
727 | 727 | //debugLog("-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
728 | - $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
|
728 | + $participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role); |
|
729 | 729 | } |
730 | 730 | // if organizer is not already participant, add him as chair |
731 | - if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid])) |
|
731 | + if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid])) |
|
732 | 732 | { |
733 | 733 | $participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ? |
734 | - 'A' : 'U',1,'CHAIR'); |
|
734 | + 'A' : 'U', 1, 'CHAIR'); |
|
735 | 735 | $chair_set = true; |
736 | 736 | } |
737 | 737 | // preserve all resource types not account, contact or email (eg. resources) for existing events |
738 | 738 | // $account is also preserved, as AS does not add him as participant! |
739 | - foreach((array)$event['participant_types'] as $type => $parts) |
|
739 | + foreach ((array)$event['participant_types'] as $type => $parts) |
|
740 | 740 | { |
741 | - if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
741 | + if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS |
|
742 | 742 | |
743 | - foreach($parts as $id => $status) |
|
743 | + foreach ($parts as $id => $status) |
|
744 | 744 | { |
745 | 745 | // accounts are represented correctly, but the event owner which is no participant in AS |
746 | 746 | if ($type == 'u' && $id != $account) continue; |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | if (!$event['id'] || !$participants || !isset($participants[$account])) |
757 | 757 | { |
758 | 758 | $participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ? |
759 | - 'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
759 | + 'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
760 | 760 | } |
761 | 761 | $event['participants'] = $participants; |
762 | 762 | |
763 | 763 | if (isset($message->categories)) |
764 | 764 | { |
765 | - $event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen')); |
|
765 | + $event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen')); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | // check if event is recurring and import recur information (incl. timezone) |
@@ -772,8 +772,7 @@ discard block |
||
772 | 772 | { |
773 | 773 | $event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
774 | 774 | } |
775 | - $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
|
776 | - array_search($message->recurrence->type, self::$recur_type2as); |
|
775 | + $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as); |
|
777 | 776 | $event['recur_interval'] = $message->recurrence->interval; |
778 | 777 | |
779 | 778 | switch ($event['recur_type']) |
@@ -782,7 +781,7 @@ discard block |
||
782 | 781 | // $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date |
783 | 782 | // fall throught |
784 | 783 | case calendar_rrule::WEEKLY: |
785 | - $event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
784 | + $event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
786 | 785 | break; |
787 | 786 | case calendar_rrule::MONTHLY_MDAY: |
788 | 787 | // $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date |
@@ -798,7 +797,7 @@ discard block |
||
798 | 797 | $event['recur_exceptions'] = array(); |
799 | 798 | if ($message->exceptions) |
800 | 799 | { |
801 | - foreach($message->exceptions as $exception) |
|
800 | + foreach ($message->exceptions as $exception) |
|
802 | 801 | { |
803 | 802 | $event['recur_exception'][] = egw_time::server2user($exception->exceptionstarttime); |
804 | 803 | } |
@@ -808,7 +807,7 @@ discard block |
||
808 | 807 | { |
809 | 808 | // calculate enddate from occurences count, as we only support enddate |
810 | 809 | $count = $message->recurrence->occurrences; |
811 | - foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
810 | + foreach (calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
812 | 811 | { |
813 | 812 | if (--$count <= 0) break; |
814 | 813 | } |
@@ -818,11 +817,11 @@ discard block |
||
818 | 817 | // only import alarms in own calendar |
819 | 818 | if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id']) |
820 | 819 | { |
821 | - foreach((array)$event['alarm'] as $alarm) |
|
820 | + foreach ((array)$event['alarm'] as $alarm) |
|
822 | 821 | { |
823 | - if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder) |
|
822 | + if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder) |
|
824 | 823 | { |
825 | - $alarm = true; // alarm already exists --> do nothing |
|
824 | + $alarm = true; // alarm already exists --> do nothing |
|
826 | 825 | break; |
827 | 826 | } |
828 | 827 | } |
@@ -831,16 +830,16 @@ discard block |
||
831 | 830 | // delete all earlier alarms of that user |
832 | 831 | // user get's per AS only the earliest alarm, as AS only supports one alarm |
833 | 832 | // --> if a later alarm is returned, user probably modifed an existing alarm |
834 | - foreach((array)$event['alarm'] as $key => $alarm) |
|
833 | + foreach ((array)$event['alarm'] as $key => $alarm) |
|
835 | 834 | { |
836 | - if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
|
835 | + if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder) |
|
837 | 836 | { |
838 | 837 | unset($event['alarm'][$key]); |
839 | 838 | } |
840 | 839 | } |
841 | 840 | $event['alarm'][] = $alarm = array( |
842 | 841 | 'owner' => $account, |
843 | - 'offset' => 60*$message->reminder, |
|
842 | + 'offset' => 60 * $message->reminder, |
|
844 | 843 | ); |
845 | 844 | } |
846 | 845 | } |
@@ -963,11 +962,11 @@ discard block |
||
963 | 962 | * @param int $mimesupport=0 |
964 | 963 | * @return SyncAppointment|boolean false on error |
965 | 964 | */ |
966 | - public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
965 | + public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
967 | 966 | { |
968 | 967 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
969 | 968 | |
970 | - debugLog (__METHOD__."('$folderid', ".array2string($id).", truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
|
969 | + debugLog(__METHOD__."('$folderid', ".array2string($id).", truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
|
971 | 970 | $this->backend->splitID($folderid, $type, $account); |
972 | 971 | if (is_array($id)) |
973 | 972 | { |
@@ -976,15 +975,15 @@ discard block |
||
976 | 975 | } |
977 | 976 | else |
978 | 977 | { |
979 | - list($id,$recur_date) = explode(':',$id); |
|
980 | - if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account))) |
|
978 | + list($id, $recur_date) = explode(':', $id); |
|
979 | + if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account))) |
|
981 | 980 | { |
982 | 981 | error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false"); |
983 | 982 | return false; |
984 | 983 | } |
985 | 984 | } |
986 | - debugLog(__METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence'])); |
|
987 | - foreach($event['recur_exception'] as $ex) debugLog("exception=$ex=".date('Y-m-d H:i:s',$ex)); |
|
985 | + debugLog(__METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s', $event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s', $event['recurrence'])); |
|
986 | + foreach ($event['recur_exception'] as $ex) debugLog("exception=$ex=".date('Y-m-d H:i:s', $ex)); |
|
988 | 987 | |
989 | 988 | $message = new SyncAppointment(); |
990 | 989 | |
@@ -993,11 +992,11 @@ discard block |
||
993 | 992 | $as_tz = self::tz2as($event['tzid']); |
994 | 993 | $message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz)); |
995 | 994 | } |
996 | - catch(Exception $e) { |
|
995 | + catch (Exception $e) { |
|
997 | 996 | // ignore exception, simply set no timezone, as it is optional |
998 | 997 | } |
999 | 998 | // copying timestamps (they are already read in servertime, so non tz conversation) |
1000 | - foreach(array( |
|
999 | + foreach (array( |
|
1001 | 1000 | 'start' => 'starttime', |
1002 | 1001 | 'end' => 'endtime', |
1003 | 1002 | 'created' => 'dtstamp', |
@@ -1008,10 +1007,10 @@ discard block |
||
1008 | 1007 | } |
1009 | 1008 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
1010 | 1009 | { |
1011 | - ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
1010 | + ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
1012 | 1011 | } |
1013 | 1012 | // copying strings |
1014 | - foreach(array( |
|
1013 | + foreach (array( |
|
1015 | 1014 | 'title' => 'subject', |
1016 | 1015 | 'uid' => 'uid', |
1017 | 1016 | 'location' => 'location', |
@@ -1033,22 +1032,22 @@ discard block |
||
1033 | 1032 | { |
1034 | 1033 | debugLog("airsyncbasebody!"); |
1035 | 1034 | $message->airsyncbasebody = new SyncAirSyncBaseBody(); |
1036 | - $message->airsyncbasenativebodytype=1; |
|
1035 | + $message->airsyncbasenativebodytype = 1; |
|
1037 | 1036 | $this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody); |
1038 | 1037 | } |
1039 | 1038 | } |
1040 | 1039 | $message->md5body = md5($event['description']); |
1041 | 1040 | |
1042 | - $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'); |
|
1043 | - $message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
1041 | + $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname'); |
|
1042 | + $message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email'); |
|
1044 | 1043 | |
1045 | - $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
1044 | + $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
1046 | 1045 | |
1047 | 1046 | // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
1048 | 1047 | $message->busystatus = $event['non_blocking'] ? 0 : 2; |
1049 | 1048 | |
1050 | 1049 | $message->attendees = array(); |
1051 | - foreach($event['participants'] as $uid => $status) |
|
1050 | + foreach ($event['participants'] as $uid => $status) |
|
1052 | 1051 | { |
1053 | 1052 | // AS does NOT want calendar owner as participant |
1054 | 1053 | if ($uid == $account) continue; |
@@ -1059,19 +1058,19 @@ discard block |
||
1059 | 1058 | $attendee->attendeetype = (int)self::$role2as[$role]; |
1060 | 1059 | if (is_numeric($uid)) |
1061 | 1060 | { |
1062 | - $attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname'); |
|
1063 | - $attendee->email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'); |
|
1061 | + $attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname'); |
|
1062 | + $attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'); |
|
1064 | 1063 | } |
1065 | 1064 | else |
1066 | 1065 | { |
1067 | 1066 | list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
1068 | - ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
|
1067 | + ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false); |
|
1069 | 1068 | |
1070 | 1069 | if (!$info) continue; |
1071 | 1070 | |
1072 | 1071 | if (!$info['email'] && $info['responsible']) |
1073 | 1072 | { |
1074 | - $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email'); |
|
1073 | + $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email'); |
|
1075 | 1074 | } |
1076 | 1075 | $attendee->name = empty($info['cn']) ? $info['name'] : $info['cn']; |
1077 | 1076 | $attendee->email = $info['email']; |
@@ -1083,7 +1082,7 @@ discard block |
||
1083 | 1082 | $message->organizeremail = $attendee->email; |
1084 | 1083 | debugLog(__METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
1085 | 1084 | } |
1086 | - if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
1085 | + if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
1087 | 1086 | } |
1088 | 1087 | // email must NOT be empty, but MAY be an arbitrary text |
1089 | 1088 | if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
@@ -1091,7 +1090,7 @@ discard block |
||
1091 | 1090 | $message->attendees[] = $attendee; |
1092 | 1091 | } |
1093 | 1092 | $message->categories = array(); |
1094 | - foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id) |
|
1093 | + foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id) |
|
1095 | 1094 | { |
1096 | 1095 | $message->categories[] = categories::id2name($cat_id); |
1097 | 1096 | } |
@@ -1100,25 +1099,25 @@ discard block |
||
1100 | 1099 | if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date) |
1101 | 1100 | { |
1102 | 1101 | $message->recurrence = $recurrence = new SyncRecurrence(); |
1103 | - $rrule = calendar_rrule::event2rrule($event,false); // false = timestamps in $event are servertime |
|
1102 | + $rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime |
|
1104 | 1103 | $recurrence->type = (int)self::$recur_type2as[$rrule->type]; |
1105 | 1104 | $recurrence->interval = $rrule->interval; |
1106 | 1105 | switch ($rrule->type) |
1107 | 1106 | { |
1108 | 1107 | case calendar_rrule::MONTHLY_WDAY: |
1109 | 1108 | $recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ? |
1110 | - $rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1 |
|
1109 | + $rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1 |
|
1111 | 1110 | // fall throught |
1112 | 1111 | case calendar_rrule::WEEKLY: |
1113 | - $recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
1112 | + $recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
1114 | 1113 | break; |
1115 | 1114 | case calendar_rrule::MONTHLY_MDAY: |
1116 | - $recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31 |
|
1117 | - $rrule->monthly_bymonthday : 31; // not -1 for last day of month! |
|
1115 | + $recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31 |
|
1116 | + $rrule->monthly_bymonthday : 31; // not -1 for last day of month! |
|
1118 | 1117 | break; |
1119 | 1118 | case calendar_rrule::YEARLY: |
1120 | - $recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31 |
|
1121 | - $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
|
1119 | + $recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31 |
|
1120 | + $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
|
1122 | 1121 | break; |
1123 | 1122 | } |
1124 | 1123 | if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
@@ -1134,9 +1133,9 @@ discard block |
||
1134 | 1133 | // search real / non-virtual exceptions |
1135 | 1134 | if (!empty($event['uid'])) |
1136 | 1135 | { |
1137 | - $ex_events =& $this->calendar->search(array( |
|
1136 | + $ex_events = & $this->calendar->search(array( |
|
1138 | 1137 | 'query' => array('cal_uid' => $event['uid']), |
1139 | - 'filter' => 'owner', // return all possible entries |
|
1138 | + 'filter' => 'owner', // return all possible entries |
|
1140 | 1139 | 'daywise' => false, |
1141 | 1140 | 'date_format' => 'server', |
1142 | 1141 | )); |
@@ -1145,36 +1144,36 @@ discard block |
||
1145 | 1144 | { |
1146 | 1145 | debugLog(__METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
1147 | 1146 | } |
1148 | - if (count($ex_events)>=1) debugLog(__METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1147 | + if (count($ex_events) >= 1) debugLog(__METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1149 | 1148 | |
1150 | 1149 | $message->exceptions = array(); |
1151 | - foreach($ex_events as $ex_event) |
|
1150 | + foreach ($ex_events as $ex_event) |
|
1152 | 1151 | { |
1153 | - if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
1152 | + if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
1154 | 1153 | $exception = $this->GetMessage($folderid, $ex_event, $truncsize, $bodypreference, $mimesupport); |
1155 | 1154 | $exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
1156 | - foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
|
1155 | + foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported) |
|
1157 | 1156 | { |
1158 | - $exception->$not_supported = null; // not allowed in exceptions :-( |
|
1157 | + $exception->$not_supported = null; // not allowed in exceptions :-( |
|
1159 | 1158 | } |
1160 | 1159 | $exception->deleted = 0; |
1161 | - if (($key = array_search($exception_time,$event['recur_exception'])) !== false) |
|
1160 | + if (($key = array_search($exception_time, $event['recur_exception'])) !== false) |
|
1162 | 1161 | { |
1163 | 1162 | unset($event['recur_exception'][$key]); |
1164 | 1163 | } |
1165 | - debugLog(__METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception)); |
|
1164 | + debugLog(__METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception)); |
|
1166 | 1165 | $message->exceptions[] = $exception; |
1167 | 1166 | } |
1168 | 1167 | // add rest of exceptions as deleted |
1169 | - foreach($event['recur_exception'] as $exception_time) |
|
1168 | + foreach ($event['recur_exception'] as $exception_time) |
|
1170 | 1169 | { |
1171 | 1170 | if (!empty($exception_time)) |
1172 | 1171 | { |
1173 | 1172 | if (empty($event['uid'])) debugLog(__METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
1174 | - $exception = new SyncAppointment(); // exceptions seems to be full SyncAppointments, with only starttime required |
|
1173 | + $exception = new SyncAppointment(); // exceptions seems to be full SyncAppointments, with only starttime required |
|
1175 | 1174 | $exception->deleted = 1; |
1176 | 1175 | $exception->exceptionstarttime = $exception_time; |
1177 | - debugLog(__METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception)); |
|
1176 | + debugLog(__METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception)); |
|
1178 | 1177 | $message->exceptions[] = $exception; |
1179 | 1178 | } |
1180 | 1179 | } |
@@ -1196,12 +1195,12 @@ discard block |
||
1196 | 1195 | // only return alarms if in own calendar |
1197 | 1196 | if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm']) |
1198 | 1197 | { |
1199 | - foreach($event['alarm'] as $alarm) |
|
1198 | + foreach ($event['alarm'] as $alarm) |
|
1200 | 1199 | { |
1201 | 1200 | if ($alarm['all'] || $alarm['owner'] == $account) |
1202 | 1201 | { |
1203 | - $message->reminder = $alarm['offset']/60; // is in minutes, not seconds as in EGw |
|
1204 | - break; // AS supports only one alarm! (we use the next/earliest one) |
|
1202 | + $message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw |
|
1203 | + break; // AS supports only one alarm! (we use the next/earliest one) |
|
1205 | 1204 | } |
1206 | 1205 | } |
1207 | 1206 | } |
@@ -1232,7 +1231,7 @@ discard block |
||
1232 | 1231 | // error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
1233 | 1232 | $backup = $this->calendar->debug; |
1234 | 1233 | //$this->calendar->debug = 2; |
1235 | - list($id) = explode(':',$id); |
|
1234 | + list($id) = explode(':', $id); |
|
1236 | 1235 | $this->calendar->check_perms(EGW_ACL_FREEBUSY, $id, 0, 'server'); |
1237 | 1236 | $this->calendar->debug = $backup; |
1238 | 1237 | } |
@@ -1267,10 +1266,10 @@ discard block |
||
1267 | 1266 | |
1268 | 1267 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
1269 | 1268 | //$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
1270 | - $ctag = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
|
1269 | + $ctag = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too |
|
1271 | 1270 | // workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
1272 | 1271 | if ($ctag == 0) $ctag = 1; |
1273 | - $changes = array(); // no change |
|
1272 | + $changes = array(); // no change |
|
1274 | 1273 | $syncstate_was = $syncstate; |
1275 | 1274 | |
1276 | 1275 | if ($ctag !== $syncstate) |
@@ -1314,7 +1313,7 @@ discard block |
||
1314 | 1313 | * @link http://download.microsoft.com/download/5/D/D/5DD33FDF-91F5-496D-9884-0A0B0EE698BB/%5BMS-ASDTYPE%5D.pdf |
1315 | 1314 | * @throws egw_exception_assertion_failed if no vtimezone data found for given timezone |
1316 | 1315 | */ |
1317 | - static public function tz2as($tz,$ts=null) |
|
1316 | + static public function tz2as($tz, $ts = null) |
|
1318 | 1317 | { |
1319 | 1318 | /* |
1320 | 1319 | BEGIN:VTIMEZONE |
@@ -1350,20 +1349,20 @@ discard block |
||
1350 | 1349 | 'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0, |
1351 | 1350 | ); |
1352 | 1351 | |
1353 | - $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
|
1354 | - if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
1352 | + $name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz; |
|
1353 | + if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component'); |
|
1355 | 1354 | // parse ical timezone defintion |
1356 | - $ical = self::ical2array($ical=$component); |
|
1355 | + $ical = self::ical2array($ical = $component); |
|
1357 | 1356 | $standard = $ical['VTIMEZONE']['STANDARD']; |
1358 | 1357 | $daylight = $ical['VTIMEZONE']['DAYLIGHT']; |
1359 | 1358 | |
1360 | 1359 | if (!isset($standard)) |
1361 | 1360 | { |
1362 | - if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches)) |
|
1361 | + if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches)) |
|
1363 | 1362 | { |
1364 | 1363 | $standard = array( |
1365 | - 'TZOFFSETTO' => sprintf('%s%02d00',$matches[1],$matches[2]), |
|
1366 | - 'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]), |
|
1364 | + 'TZOFFSETTO' => sprintf('%s%02d00', $matches[1], $matches[2]), |
|
1365 | + 'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]), |
|
1367 | 1366 | ); |
1368 | 1367 | unset($daylight); |
1369 | 1368 | } |
@@ -1374,15 +1373,15 @@ discard block |
||
1374 | 1373 | } |
1375 | 1374 | // get bias and dstbias from standard component, which is present in all tz's |
1376 | 1375 | // (dstbias is relative to bias and almost always 60 or 0) |
1377 | - $data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2)); |
|
1378 | - $data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']); |
|
1376 | + $data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2)); |
|
1377 | + $data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']); |
|
1379 | 1378 | |
1380 | 1379 | // check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving |
1381 | 1380 | if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE'])) |
1382 | 1381 | { |
1383 | - foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp) |
|
1382 | + foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp) |
|
1384 | 1383 | { |
1385 | - if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches)) |
|
1384 | + if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches)) |
|
1386 | 1385 | { |
1387 | 1386 | $data[$prefix.'month'] = (int)$matches[2]; |
1388 | 1387 | $data[$prefix.'week'] = (int)$matches[1]; |
@@ -1399,20 +1398,20 @@ discard block |
||
1399 | 1398 | $data[$prefix.'week'] = 5; |
1400 | 1399 | if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
1401 | 1400 | } |
1402 | - static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
|
1403 | - $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
|
1401 | + static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6); |
|
1402 | + $data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)]; |
|
1404 | 1403 | } |
1405 | - if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches)) |
|
1404 | + if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches)) |
|
1406 | 1405 | { |
1407 | - $data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60; |
|
1408 | - $data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60; |
|
1409 | - $data[$prefix.'second'] = (int)substr($matches[1],4,2); |
|
1406 | + $data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60; |
|
1407 | + $data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60; |
|
1408 | + $data[$prefix.'second'] = (int)substr($matches[1], 4, 2); |
|
1410 | 1409 | } |
1411 | 1410 | } |
1412 | 1411 | // for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute |
1413 | 1412 | if ($data['dststartmonth'] > $data['dstendmonth']) |
1414 | 1413 | { |
1415 | - $start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start; |
|
1414 | + $start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start; |
|
1416 | 1415 | $start = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $start; |
1417 | 1416 | } |
1418 | 1417 | } |
@@ -1471,18 +1470,18 @@ discard block |
||
1471 | 1470 | * @param string $component=null |
1472 | 1471 | * @return array with parsed ical components |
1473 | 1472 | */ |
1474 | - static public function ical2array(&$ical,$component=null) |
|
1473 | + static public function ical2array(&$ical, $component = null) |
|
1475 | 1474 | { |
1476 | 1475 | $arr = array(); |
1477 | 1476 | if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
1478 | 1477 | while (($line = array_shift($ical))) |
1479 | 1478 | { |
1480 | - list($name,$value) = explode(':',$line,2); |
|
1479 | + list($name, $value) = explode(':', $line, 2); |
|
1481 | 1480 | if ($name == 'BEGIN') |
1482 | 1481 | { |
1483 | - $arr[$value] = self::ical2array($ical,$value); |
|
1482 | + $arr[$value] = self::ical2array($ical, $value); |
|
1484 | 1483 | } |
1485 | - elseif($name == 'END') |
|
1484 | + elseif ($name == 'END') |
|
1486 | 1485 | { |
1487 | 1486 | break; |
1488 | 1487 | } |
@@ -1506,13 +1505,13 @@ discard block |
||
1506 | 1505 | */ |
1507 | 1506 | public static function as2tz(array $data) |
1508 | 1507 | { |
1509 | - static $cache; // some caching withing the request |
|
1508 | + static $cache; // some caching withing the request |
|
1510 | 1509 | |
1511 | - unset($data['name']); // not used, but can stall the match |
|
1510 | + unset($data['name']); // not used, but can stall the match |
|
1512 | 1511 | |
1513 | 1512 | $key = serialize($data); |
1514 | 1513 | |
1515 | - for($n = 0; !isset($cache[$key]); ++$n) |
|
1514 | + for ($n = 0; !isset($cache[$key]); ++$n) |
|
1516 | 1515 | { |
1517 | 1516 | if (!$n) // check users timezone first |
1518 | 1517 | { |
@@ -1531,7 +1530,7 @@ discard block |
||
1531 | 1530 | break; |
1532 | 1531 | } |
1533 | 1532 | } |
1534 | - catch(Exception $e) { |
|
1533 | + catch (Exception $e) { |
|
1535 | 1534 | // simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component |
1536 | 1535 | } |
1537 | 1536 | } |
@@ -1545,8 +1544,8 @@ discard block |
||
1545 | 1544 | */ |
1546 | 1545 | static public function _getTZFromSyncBlob($data) |
1547 | 1546 | { |
1548 | - $tz = unpack( "lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" . |
|
1549 | - "lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" . |
|
1547 | + $tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/". |
|
1548 | + "lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/". |
|
1550 | 1549 | "ldstbias", $data); |
1551 | 1550 | |
1552 | 1551 | return $tz; |
@@ -1559,7 +1558,7 @@ discard block |
||
1559 | 1558 | */ |
1560 | 1559 | static public function _getSyncBlobFromTZ($tz) |
1561 | 1560 | { |
1562 | - $packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l", |
|
1561 | + $packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l", |
|
1563 | 1562 | $tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"], |
1564 | 1563 | $tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"], |
1565 | 1564 | $tz["dstbias"]); |
@@ -1583,7 +1582,7 @@ discard block |
||
1583 | 1582 | $account_id = $entry['grantor']; |
1584 | 1583 | $cals[$account_id] = $entry['name']; |
1585 | 1584 | } |
1586 | - if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
1585 | + if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
1587 | 1586 | } |
1588 | 1587 | $cals['G'] = lang('Primary group'); |
1589 | 1588 | $cals['A'] = lang('All'); |
@@ -1619,8 +1618,8 @@ discard block |
||
1619 | 1618 | ) |
1620 | 1619 | ); |
1621 | 1620 | require_once('../../header.inc.php'); |
1622 | - ini_set('display_errors',1); |
|
1623 | - error_reporting(E_ALL & ~E_NOTICE); |
|
1621 | + ini_set('display_errors', 1); |
|
1622 | + error_reporting(E_ALL&~E_NOTICE); |
|
1624 | 1623 | |
1625 | 1624 | echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n"; |
1626 | 1625 | echo "<h3>Conversation of ActiveSync Timezone Blobs to TZID's</h3>\n"; |
@@ -1634,7 +1633,7 @@ discard block |
||
1634 | 1633 | </script>\n"; |
1635 | 1634 | |
1636 | 1635 | // TZID => AS timezone blobs reported by various devices |
1637 | - foreach(array( |
|
1636 | + foreach (array( |
|
1638 | 1637 | 'Europe/Berlin' => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==', |
1639 | 1638 | 'Europe/Helsinki' => 'iP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAQAAAAAAAAAxP///w==', |
1640 | 1639 | 'Asia/Tokyo' => '5P3//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///w==', |
@@ -1647,9 +1646,9 @@ discard block |
||
1647 | 1646 | ) as $tz => $sync_blob) |
1648 | 1647 | { |
1649 | 1648 | // get as timezone data for a given timezone |
1650 | - $ical = calendar_timezones::tz2id($tz,'component'); |
|
1649 | + $ical = calendar_timezones::tz2id($tz, 'component'); |
|
1651 | 1650 | //echo "<pre>".print_r($ical,true)."</pre>\n"; |
1652 | - $ical_arr = calendar_activesync::ical2array($ical_tz=$ical); |
|
1651 | + $ical_arr = calendar_activesync::ical2array($ical_tz = $ical); |
|
1653 | 1652 | //echo "<pre>".print_r($ical_arr,true)."</pre>\n"; |
1654 | 1653 | $as_tz = calendar_activesync::tz2as($tz); |
1655 | 1654 | //echo "$tz=<pre>".print_r($as_tz,true)."</pre>\n"; |
@@ -1663,22 +1662,22 @@ discard block |
||
1663 | 1662 | //echo array2string($matched); |
1664 | 1663 | |
1665 | 1664 | echo "<tr><td><b onclick='toggle_display(this.nextSibling);' style='cursor:pointer;'>$tz</b><pre style='margin:0; font-size: 90%; display:none;'>$ical</pre></td><td>$as_tz_org[bias]<br/>$as_tz[bias]</td><td>$as_tz_org[dstbias]<br/>$as_tz[dstbias]</td>\n"; |
1666 | - foreach(array('dststart','dstend') as $prefix) |
|
1665 | + foreach (array('dststart', 'dstend') as $prefix) |
|
1667 | 1666 | { |
1668 | 1667 | echo "<td>\n"; |
1669 | - foreach(array($as_tz_org,$as_tz) as $n => $arr) |
|
1668 | + foreach (array($as_tz_org, $as_tz) as $n => $arr) |
|
1670 | 1669 | { |
1671 | 1670 | $parts = array(); |
1672 | - foreach(array('year','month','day','week','hour','minute','second') as $postfix) |
|
1671 | + foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix) |
|
1673 | 1672 | { |
1674 | 1673 | $failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix]; |
1675 | - $parts[] = ($failed?'<font color="red">':'').$arr[$prefix.$postfix].($failed?'</font>':''); |
|
1674 | + $parts[] = ($failed ? '<font color="red">' : '').$arr[$prefix.$postfix].($failed ? '</font>' : ''); |
|
1676 | 1675 | } |
1677 | - echo implode(' ', $parts).(!$n?'<br/>':''); |
|
1676 | + echo implode(' ', $parts).(!$n ? '<br/>' : ''); |
|
1678 | 1677 | } |
1679 | 1678 | echo "</td>\n"; |
1680 | 1679 | } |
1681 | - echo "<td> <br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n"; |
|
1680 | + echo "<td> <br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n"; |
|
1682 | 1681 | } |
1683 | 1682 | echo "</tbody></table>\n"; |
1684 | 1683 | echo "</body></html>\n"; |
@@ -24,7 +24,7 @@ |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | $calc_include = EGW_INCLUDE_ROOT.'/calendar/inc/class.holidaycalc_'.$rule.'.inc.php'; |
27 | - if(@file_exists($calc_include)) |
|
27 | + if (@file_exists($calc_include)) |
|
28 | 28 | { |
29 | 29 | include($calc_include); |
30 | 30 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function DateTimeZone($tzid) |
71 | 71 | { |
72 | - if (($id = self::tz2id($tzid,'alias'))) |
|
72 | + if (($id = self::tz2id($tzid, 'alias'))) |
|
73 | 73 | { |
74 | 74 | $tzid = self::id2tz($id); |
75 | 75 | } |
@@ -87,34 +87,34 @@ discard block |
||
87 | 87 | * @param string $what ='id' what to return, default id, null for whole array |
88 | 88 | * @return int tz_id or null if not found |
89 | 89 | */ |
90 | - public static function tz2id($tzid,$what='id') |
|
90 | + public static function tz2id($tzid, $what = 'id') |
|
91 | 91 | { |
92 | - $id =& self::$tz2id[$tzid]; |
|
92 | + $id = & self::$tz2id[$tzid]; |
|
93 | 93 | |
94 | 94 | if (!isset($id)) |
95 | 95 | { |
96 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
96 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
97 | 97 | 'tz_tzid' => $tzid, |
98 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
98 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
99 | 99 | { |
100 | 100 | $id = $data['tz_id']; |
101 | - self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_'); |
|
101 | + self::$tz_cache[$id] = egw_db::strip_array_keys($data, 'tz_'); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | // check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires' |
105 | 105 | if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2) |
106 | 106 | { |
107 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
107 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
108 | 108 | 'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]), |
109 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
109 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
110 | 110 | { |
111 | 111 | $id = $data['tz_id']; |
112 | - self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_'); |
|
112 | + self::$tz_cache[$id] = egw_db::strip_array_keys($data, 'tz_'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | if (isset($id) && $what != 'id') |
116 | 116 | { |
117 | - return self::id2tz($id,$what); |
|
117 | + return self::id2tz($id, $what); |
|
118 | 118 | } |
119 | 119 | return $id; |
120 | 120 | } |
@@ -132,24 +132,24 @@ discard block |
||
132 | 132 | * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude' |
133 | 133 | * @return mixed false: if not found |
134 | 134 | */ |
135 | - public static function id2tz($id,$what='tzid') |
|
135 | + public static function id2tz($id, $what = 'tzid') |
|
136 | 136 | { |
137 | - $data =& self::$tz_cache[$id]; |
|
137 | + $data = & self::$tz_cache[$id]; |
|
138 | 138 | |
139 | 139 | if (!isset($data)) |
140 | 140 | { |
141 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
141 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
142 | 142 | 'tz_id' => $id, |
143 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
143 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
144 | 144 | { |
145 | - $data = egw_db::strip_array_keys($data,'tz_'); |
|
145 | + $data = egw_db::strip_array_keys($data, 'tz_'); |
|
146 | 146 | self::$tz2id[$data['tzid']] = $id; |
147 | 147 | } |
148 | 148 | } |
149 | 149 | // if not tzid queried, resolve aliases automatically |
150 | 150 | if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias') |
151 | 151 | { |
152 | - $data = self::id2tz($data['alias'],null); |
|
152 | + $data = self::id2tz($data['alias'], null); |
|
153 | 153 | } |
154 | 154 | return !$data ? $data : ($what ? $data[$what] : $data); |
155 | 155 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public static function init_static() |
170 | 170 | { |
171 | - self::$tz_cache =& egw_cache::getSession(__CLASS__,'tz_cache'); |
|
172 | - self::$tz2id =& egw_cache::getSession(__CLASS__,'tz2id'); |
|
171 | + self::$tz_cache = & egw_cache::getSession(__CLASS__, 'tz_cache'); |
|
172 | + self::$tz2id = & egw_cache::getSession(__CLASS__, 'tz2id'); |
|
173 | 173 | |
174 | 174 | // init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar |
175 | 175 | if (!is_array(self::$tz2id)) |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | { |
187 | 187 | $updated = false; |
188 | 188 | $msg = self::import_zones($updated); |
189 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
189 | + if ($updated) error_log($msg); // log that timezones have been updated |
|
190 | 190 | |
191 | 191 | $alias_msg = self::import_tz_aliases($updated); |
192 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
192 | + if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
193 | 193 | |
194 | 194 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
195 | 195 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @throws egw_exception_wrong_userinput for broken sqlite extension |
209 | 209 | * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json |
210 | 210 | */ |
211 | - public static function import_zones(&$updated=null, $file='calendar/setup/zones.json') |
|
211 | + public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json') |
|
212 | 212 | { |
213 | 213 | $path = EGW_SERVER_ROOT.'/'.$file; |
214 | 214 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | { |
231 | 231 | $updated = false; |
232 | 232 | fclose($fp); |
233 | - return lang('Nothing to update, version is already %1.',$config['tz_version']); // we already have the right |
|
233 | + return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right |
|
234 | 234 | } |
235 | - $json .= fread($fp, 1024*1024); |
|
235 | + $json .= fread($fp, 1024 * 1024); |
|
236 | 236 | fclose($fp); |
237 | 237 | if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones'])) |
238 | 238 | { |
@@ -240,38 +240,38 @@ discard block |
||
240 | 240 | } |
241 | 241 | // import zones first and then aliases |
242 | 242 | $tz2id = array(); |
243 | - foreach(array('zones', 'aliases') as $type) |
|
243 | + foreach (array('zones', 'aliases') as $type) |
|
244 | 244 | { |
245 | - foreach($zones[$type] as $tzid => $data) |
|
245 | + foreach ($zones[$type] as $tzid => $data) |
|
246 | 246 | { |
247 | 247 | if ($type == 'aliases') |
248 | 248 | { |
249 | 249 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
250 | - if (!$data['alias']) continue; // there's no such tzid |
|
250 | + if (!$data['alias']) continue; // there's no such tzid |
|
251 | 251 | } |
252 | 252 | // check if already in database |
253 | - $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
|
253 | + $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array( |
|
254 | 254 | 'tz_tzid' => $tzid, |
255 | - ),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
255 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
256 | 256 | |
257 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
257 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
258 | 258 | 'tz_alias' => $data['alias'], |
259 | 259 | 'tz_latitude' => $data['latitude'], |
260 | 260 | 'tz_longitude' => $data['longitude'], |
261 | 261 | 'tz_component' => $data['ics'], |
262 | - ),array( |
|
262 | + ), array( |
|
263 | 263 | 'tz_tzid' => $tzid, |
264 | - ),__LINE__,__FILE__,'calendar'); |
|
264 | + ), __LINE__, __FILE__, 'calendar'); |
|
265 | 265 | |
266 | 266 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
267 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
267 | + if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id'); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | config::save_value('tz_version', $tz_version, 'phpgwapi'); |
271 | 271 | |
272 | 272 | //_debug_array($tz2id); |
273 | 273 | $updated = true; |
274 | - return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id)); |
|
274 | + return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return string message about update |
283 | 283 | * @throws egw_exception_wrong_parameter if $file is not readable or wrong format/version |
284 | 284 | */ |
285 | - public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php') |
|
285 | + public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php') |
|
286 | 286 | { |
287 | 287 | $path = EGW_SERVER_ROOT.'/'.$file; |
288 | 288 | |
@@ -295,27 +295,27 @@ discard block |
||
295 | 295 | if ($tz_aliases_mtime === $config['tz_aliases_mtime']) |
296 | 296 | { |
297 | 297 | $updated = false; |
298 | - return lang('Nothing to update, version is already %1.',$tz_aliases_mtime); |
|
298 | + return lang('Nothing to update, version is already %1.', $tz_aliases_mtime); |
|
299 | 299 | } |
300 | 300 | $tz_aliases = array(); |
301 | - include($path); // sets $tz_aliases |
|
301 | + include($path); // sets $tz_aliases |
|
302 | 302 | |
303 | 303 | $updates = 0; |
304 | - foreach($tz_aliases as $alias => $tzid) |
|
304 | + foreach ($tz_aliases as $alias => $tzid) |
|
305 | 305 | { |
306 | - if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
306 | + if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
307 | 307 | ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
308 | 308 | { |
309 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
309 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
310 | 310 | 'tz_alias' => $tz_id, |
311 | - ),array( |
|
311 | + ), array( |
|
312 | 312 | 'tz_tzid' => $alias, |
313 | - ),__LINE__,__FILE__,'calendar'); |
|
313 | + ), __LINE__, __FILE__, 'calendar'); |
|
314 | 314 | ++$updates; |
315 | 315 | } |
316 | 316 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
317 | 317 | } |
318 | - config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi'); |
|
318 | + config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi'); |
|
319 | 319 | |
320 | 320 | //_debug_array($tz2id); |
321 | 321 | $updated = true; |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | } |
357 | 357 | // $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly |
358 | 358 | // --> we have to parse it and let Horde_Icalendar add it again |
359 | - $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false); |
|
360 | - $horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE'); |
|
359 | + $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false); |
|
360 | + $horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE'); |
|
361 | 361 | // DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing |
362 | 362 | $standard = $horde_vtimezone->findComponent('STANDARD'); |
363 | 363 | if (is_a($standard, 'Horde_Icalendar')) |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public static function user_timezone($user=null, $type='vcalendar') |
|
391 | + public static function user_timezone($user = null, $type = 'vcalendar') |
|
392 | 392 | { |
393 | 393 | if (!$user || $user == $GLOBALS['egw_info']['user']['account_id']) |
394 | 394 | { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | case 'vcalendar': |
408 | 408 | // checking type of $val, now we included the object definition (no need to always include it!) |
409 | 409 | $vcal = new Horde_Icalendar; |
410 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
410 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
411 | 411 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
412 | 412 | self::add_vtimezone($vcal, $tzid); |
413 | 413 | $tzid = $vcal->exportvCalendar('utf-8'); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | case 'tzid': |
416 | 416 | break; |
417 | 417 | default: |
418 | - $tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type); |
|
418 | + $tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type); |
|
419 | 419 | break; |
420 | 420 | } |
421 | 421 | return $tzid; |
@@ -11,55 +11,55 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | include_once('../../phpgwapi/inc/common_functions.inc.php'); |
14 | -check_load_extension('gd',true); // true = throw exception if not loadable |
|
14 | +check_load_extension('gd', true); // true = throw exception if not loadable |
|
15 | 15 | |
16 | -foreach(array('width'=>-20,'height'=>40,'border'=>1,'color'=>'000080','bgcolor'=>'0000FF') as $name => $default) |
|
16 | +foreach (array('width'=>-20, 'height'=>40, 'border'=>1, 'color'=>'000080', 'bgcolor'=>'0000FF') as $name => $default) |
|
17 | 17 | { |
18 | 18 | $$name = isset($_GET[$name]) ? $_GET[$name] : $default; |
19 | 19 | } |
20 | 20 | |
21 | -$image = @imagecreate(abs($width),abs($height)) |
|
21 | +$image = @imagecreate(abs($width), abs($height)) |
|
22 | 22 | or die("Cannot Initialize new GD image stream"); |
23 | 23 | |
24 | 24 | $white = imagecolorallocate($image, 254, 254, 254); |
25 | 25 | imagecolortransparent($image, $white); |
26 | 26 | |
27 | -foreach(array('color','bgcolor') as $name) |
|
27 | +foreach (array('color', 'bgcolor') as $name) |
|
28 | 28 | { |
29 | - preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$$name,$rgb) or |
|
29 | + preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/', $$name, $rgb) or |
|
30 | 30 | die("Wrong value '".htmlspecialchars($$name)."' for $name, should be something like #80FFFF' !!!"); |
31 | 31 | |
32 | - $$name = imagecolorallocate($image,hexdec($rgb[1]),hexdec($rgb[2]),hexdec($rgb[3])); |
|
32 | + $$name = imagecolorallocate($image, hexdec($rgb[1]), hexdec($rgb[2]), hexdec($rgb[3])); |
|
33 | 33 | } |
34 | -$radius = min(abs($width),abs($height)); |
|
35 | -$center_x = $width > 0 ? abs($width)-$radius-1 : $radius; |
|
36 | -$center_y = $height < 0 ? abs($height)-$radius-1 : $radius; |
|
34 | +$radius = min(abs($width), abs($height)); |
|
35 | +$center_x = $width > 0 ? abs($width) - $radius - 1 : $radius; |
|
36 | +$center_y = $height < 0 ? abs($height) - $radius - 1 : $radius; |
|
37 | 37 | //echo "width=$width, height=$height => radius=$radius: center_x=$center_x, center_y=$center_y"; |
38 | -if ($border) imagefilledellipse($image,$center_x,$center_y,2*$radius,2*$radius,$color); |
|
39 | -imagefilledellipse($image,$center_x,$center_y,2*($radius-$border),2*($radius-$border),$bgcolor); |
|
38 | +if ($border) imagefilledellipse($image, $center_x, $center_y, 2 * $radius, 2 * $radius, $color); |
|
39 | +imagefilledellipse($image, $center_x, $center_y, 2 * ($radius - $border), 2 * ($radius - $border), $bgcolor); |
|
40 | 40 | |
41 | 41 | if (abs($height) > abs($width)) |
42 | 42 | { |
43 | 43 | if ($height < 0) // lower corners |
44 | 44 | { |
45 | 45 | $y1 = 0; |
46 | - $y2 = abs($height)-$radius-1; |
|
46 | + $y2 = abs($height) - $radius - 1; |
|
47 | 47 | } |
48 | 48 | else |
49 | 49 | { |
50 | 50 | $y1 = $radius; |
51 | - $y2 = abs($height)-1; |
|
51 | + $y2 = abs($height) - 1; |
|
52 | 52 | } |
53 | - imagefilledrectangle($image,0,$y1,abs($width),$y2,$bgcolor); |
|
53 | + imagefilledrectangle($image, 0, $y1, abs($width), $y2, $bgcolor); |
|
54 | 54 | if ($border) |
55 | 55 | { |
56 | - $x1 = $width < 0 ? 0 : abs($width)-$border; |
|
57 | - $x2 = $width < 0 ? $border-1 : abs($width)-1; |
|
58 | - imagefilledrectangle($image,$x1,$y1,$x2,$y2,$color); |
|
56 | + $x1 = $width < 0 ? 0 : abs($width) - $border; |
|
57 | + $x2 = $width < 0 ? $border - 1 : abs($width) - 1; |
|
58 | + imagefilledrectangle($image, $x1, $y1, $x2, $y2, $color); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | -session_cache_limiter('public'); // allow caching |
|
62 | +session_cache_limiter('public'); // allow caching |
|
63 | 63 | if (function_exists('imagegif')) |
64 | 64 | { |
65 | 65 | header("Content-type: image/gif"); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param egw_record $_definition |
23 | 23 | */ |
24 | - public function export( $_stream, importexport_definition $_definition) { |
|
24 | + public function export($_stream, importexport_definition $_definition) { |
|
25 | 25 | $options = $_definition->plugin_options; |
26 | 26 | $this->bo = new calendar_bo(); |
27 | 27 | $boical = new calendar_ical(); |
@@ -32,34 +32,34 @@ discard block |
||
32 | 32 | $limit_exception = bo_merge::is_export_limit_excepted(); |
33 | 33 | if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar'); |
34 | 34 | |
35 | - if($options['selection'] == 'criteria') |
|
35 | + if ($options['selection'] == 'criteria') |
|
36 | 36 | { |
37 | 37 | $query = array( |
38 | 38 | 'start' => $options['criteria']['start'], |
39 | - 'end' => strtotime('+1 day',$options['criteria']['end'])-1, |
|
39 | + 'end' => strtotime('+1 day', $options['criteria']['end']) - 1, |
|
40 | 40 | 'categories' => $options['categories'], |
41 | 41 | 'daywise' => false, |
42 | 42 | 'users' => $options['criteria']['owner'], |
43 | 43 | 'cfs' => $cfs // Otherwise we shouldn't get any custom fields |
44 | 44 | ); |
45 | - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
45 | + if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
46 | 46 | $query['offset'] = 0; |
47 | - $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
|
47 | + $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
|
48 | 48 | } |
49 | - $events =& $this->bo->search($query); |
|
49 | + $events = & $this->bo->search($query); |
|
50 | 50 | } |
51 | 51 | // Scheduled export will use 'all', which we don't allow through UI |
52 | 52 | elseif ($options['selection'] == 'search_results' || $options['selection'] == 'all') |
53 | 53 | { |
54 | - $states = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
55 | - if($states['view'] == 'listview') |
|
54 | + $states = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
55 | + if ($states['view'] == 'listview') |
|
56 | 56 | { |
57 | - $query = $GLOBALS['egw']->session->appsession('calendar_list','calendar'); |
|
58 | - $query['num_rows'] = -1; // all |
|
57 | + $query = $GLOBALS['egw']->session->appsession('calendar_list', 'calendar'); |
|
58 | + $query['num_rows'] = -1; // all |
|
59 | 59 | $query['start'] = 0; |
60 | 60 | $query['cfs'] = $cfs; |
61 | 61 | |
62 | - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
62 | + if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
63 | 63 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
64 | 64 | } |
65 | 65 | $ui = new calendar_uilist(); |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | } |
69 | 69 | else |
70 | 70 | { |
71 | - $query = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
71 | + $query = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
72 | 72 | $query['users'] = explode(',', $query['owner']); |
73 | 73 | $query['num_rows'] = -1; |
74 | - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) |
|
74 | + if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) |
|
75 | 75 | { |
76 | - $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
|
76 | + $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
|
77 | 77 | } |
78 | 78 | |
79 | - switch($states['view']) |
|
79 | + switch ($states['view']) |
|
80 | 80 | { |
81 | 81 | case 'month': |
82 | 82 | $query += calendar_export_csv::get_query_month($states); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | default: |
91 | 91 | // Let UI set the date ranges |
92 | 92 | $ui = new calendar_uiviews($query); |
93 | - if(method_exists($ui, $states['view'])) |
|
93 | + if (method_exists($ui, $states['view'])) |
|
94 | 94 | { |
95 | 95 | ob_start(); |
96 | 96 | $ui->$states['view'](); |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | // compile list of unique cal_id's, as iCal should contain whole series, not recurrences |
113 | 113 | // calendar_ical->exportVCal needs to read events again, to get them in server-time |
114 | 114 | $ids = array(); |
115 | - foreach($events as $event) |
|
115 | + foreach ($events as $event) |
|
116 | 116 | { |
117 | 117 | $id = is_array($event) ? $event['id'] : $event; |
118 | 118 | if (($id = (int)$id)) $ids[$id] = $id; |
119 | 119 | } |
120 | 120 | |
121 | - $ical =& $boical->exportVCal($ids,'2.0','PUBLISH',false); |
|
121 | + $ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH', false); |
|
122 | 122 | fwrite($_stream, $ical); |
123 | 123 | } |
124 | 124 |
@@ -47,18 +47,18 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @var locktime in seconds |
49 | 49 | */ |
50 | - var $locktime_default=1; |
|
50 | + var $locktime_default = 1; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Constructor |
54 | 54 | */ |
55 | 55 | function __construct() |
56 | 56 | { |
57 | - parent::__construct(true); // call the parent's constructor |
|
57 | + parent::__construct(true); // call the parent's constructor |
|
58 | 58 | |
59 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
59 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
60 | 60 | { |
61 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
61 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function &default_add_event() |
71 | 71 | { |
72 | - $extra_participants = $_GET['participants'] ? explode(',',$_GET['participants']) : array(); |
|
72 | + $extra_participants = $_GET['participants'] ? explode(',', $_GET['participants']) : array(); |
|
73 | 73 | |
74 | 74 | // if participant is a contact, add its link title as title |
75 | - foreach($extra_participants as $uid) |
|
75 | + foreach ($extra_participants as $uid) |
|
76 | 76 | { |
77 | 77 | if ($uid[0] == 'c') |
78 | 78 | { |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
95 | - !$this->bo->check_perms(EGW_ACL_ADD,0,$owner)) |
|
95 | + !$this->bo->check_perms(EGW_ACL_ADD, 0, $owner)) |
|
96 | 96 | { |
97 | 97 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
98 | 98 | { |
99 | 99 | // if we come from ressources we don't need any users selected in calendar |
100 | 100 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
101 | 101 | { |
102 | - foreach(explode(',',$owner) as $uid) |
|
102 | + foreach (explode(',', $owner) as $uid) |
|
103 | 103 | { |
104 | 104 | // only add users or a single ressource, not all ressources displayed by a category |
105 | 105 | if (is_numeric($uid) || $owner == $uid) |
@@ -117,48 +117,48 @@ discard block |
||
117 | 117 | $extra_participants[] = $owner; |
118 | 118 | |
119 | 119 | $start = $this->bo->date2ts(array( |
120 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
121 | - 'hour' => (int) (isset($_GET['hour']) && (int) $_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
122 | - 'minute' => (int) $_GET['minute'], |
|
120 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
121 | + 'hour' => (int)(isset($_GET['hour']) && (int)$_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
122 | + 'minute' => (int)$_GET['minute'], |
|
123 | 123 | )); |
124 | 124 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
125 | 125 | |
126 | 126 | $participant_types['u'] = $participant_types = $participants = array(); |
127 | - foreach($extra_participants as $uid) |
|
127 | + foreach ($extra_participants as $uid) |
|
128 | 128 | { |
129 | - if (isset($participants[$uid])) continue; // already included |
|
129 | + if (isset($participants[$uid])) continue; // already included |
|
130 | 130 | |
131 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
131 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
132 | 132 | |
133 | 133 | if (is_numeric($uid)) |
134 | 134 | { |
135 | 135 | $participants[$uid] = $participant_types['u'][$uid] = |
136 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
137 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
136 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
137 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
138 | 138 | } |
139 | 139 | elseif (is_array($this->bo->resources[$uid[0]])) |
140 | 140 | { |
141 | 141 | // if contact is a user, use the user instead (as the GUI) |
142 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
142 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
143 | 143 | { |
144 | 144 | $uid = $account_id; |
145 | 145 | $participants[$uid] = $participant_types['u'][$uid] = |
146 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
147 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
146 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
147 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | $res_data = $this->bo->resources[$uid[0]]; |
151 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
152 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
151 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
152 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
153 | 153 | { |
154 | 154 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
155 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
155 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | 159 | if (!$participants) // if all participants got removed, include current user |
160 | 160 | { |
161 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
161 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
162 | 162 | } |
163 | 163 | $alarms = array(); |
164 | 164 | // if default alarm set in prefs --> add it |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | if ((string)$this->cal_prefs['default-alarm'] !== '') |
167 | 167 | { |
168 | 168 | $offset = 60 * $this->cal_prefs['default-alarm']; |
169 | - $alarms[1] = array( |
|
169 | + $alarms[1] = array( |
|
170 | 170 | 'default' => 1, |
171 | - 'offset' => $offset , |
|
171 | + 'offset' => $offset, |
|
172 | 172 | 'time' => $start - $offset, |
173 | 173 | 'all' => false, |
174 | 174 | 'owner' => $owner, |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | 'participants' => $participants, |
181 | 181 | 'owner' => $owner, |
182 | 182 | 'start' => $start, |
183 | - 'end' => $start + (int) $this->bo->cal_prefs['defaultlength']*60, |
|
183 | + 'end' => $start + (int)$this->bo->cal_prefs['defaultlength'] * 60, |
|
184 | 184 | 'tzid' => $this->bo->common_prefs['tz'], |
185 | - 'priority' => 2, // normal |
|
185 | + 'priority' => 2, // normal |
|
186 | 186 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
187 | 187 | 'alarm' => $alarms, |
188 | 188 | 'recur_exception' => array(), |
@@ -200,29 +200,29 @@ discard block |
||
200 | 200 | { |
201 | 201 | if (!is_array($content)) // redirect from etemplate, if POST empty |
202 | 202 | { |
203 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
203 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
204 | 204 | } |
205 | 205 | // clear notification errors |
206 | 206 | notifications::errors(true); |
207 | 207 | $messages = null; |
208 | 208 | $msg_permission_denied_added = false; |
209 | 209 | list($button) = @each($content['button']); |
210 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
210 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
211 | 211 | unset($content['button']); unset($content['action']); |
212 | 212 | |
213 | 213 | $view = $content['view']; |
214 | 214 | if ($button == 'ical') |
215 | 215 | { |
216 | - $msg = $this->export($content['id'],true); |
|
216 | + $msg = $this->export($content['id'], true); |
|
217 | 217 | } |
218 | 218 | // delete a recur-exception |
219 | 219 | if ($content['recur_exception']['delete_exception']) |
220 | 220 | { |
221 | 221 | list($date) = each($content['recur_exception']['delete_exception']); |
222 | 222 | // eT2 converts time to |
223 | - if (!is_numeric($date)) $date = egw_time::to (str_replace('Z','', $date), 'ts'); |
|
223 | + if (!is_numeric($date)) $date = egw_time::to(str_replace('Z', '', $date), 'ts'); |
|
224 | 224 | unset($content['recur_exception']['delete_exception']); |
225 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
225 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
226 | 226 | { |
227 | 227 | // propagate the exception to a single event |
228 | 228 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
233 | 233 | $exception['uid'] = common::generate_uid('calendar', $id); |
234 | 234 | $exception['reference'] = $exception['recurrence'] = 0; |
235 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
235 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
236 | 236 | break; |
237 | 237 | } |
238 | 238 | unset($content['recur_exception'][$key]); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
273 | 273 | if ((string)$def_alarm === '') |
274 | 274 | { |
275 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
275 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
276 | 276 | } |
277 | 277 | else |
278 | 278 | { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | unset($event['alarm']['delete_alarm']); |
287 | 287 | unset($event['duration']); |
288 | 288 | |
289 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
289 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
290 | 290 | { |
291 | 291 | // no conversation necessary, event is already in the right format |
292 | 292 | } |
@@ -306,16 +306,16 @@ discard block |
||
306 | 306 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
307 | 307 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
308 | 308 | { |
309 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
309 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
310 | 310 | } |
311 | 311 | if (isset($content['participants'])) |
312 | 312 | { |
313 | 313 | |
314 | 314 | $event['participants'] = $event['participant_types'] = array(); |
315 | 315 | |
316 | - foreach($content['participants'] as $key => $data) |
|
316 | + foreach ($content['participants'] as $key => $data) |
|
317 | 317 | { |
318 | - switch($key) |
|
318 | + switch ($key) |
|
319 | 319 | { |
320 | 320 | case 'delete': // handled in default |
321 | 321 | case 'quantity': // handled in new_resource |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") in the search field |
329 | 329 | $matches = array(); |
330 | 330 | if (($email = $content['participants']['resource']['search']) && |
331 | - (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$email,$matches))) |
|
331 | + (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $email, $matches))) |
|
332 | 332 | { |
333 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
333 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
334 | 334 | // check if email belongs to account or contact --> prefer them over just emails (if we are allowed to invite him) |
335 | - if (($data = $GLOBALS['egw']->accounts->name2id($matches[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
335 | + if (($data = $GLOBALS['egw']->accounts->name2id($matches[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
336 | 336 | { |
337 | 337 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
338 | 338 | } |
339 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
339 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
340 | 340 | 'email' => $matches[2], |
341 | 341 | 'email_home' => $matches[2], |
342 | - ),true,'','','',false,'OR'))) |
|
342 | + ), true, '', '', '', false, 'OR'))) |
|
343 | 343 | { |
344 | 344 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
345 | 345 | } |
@@ -357,8 +357,8 @@ discard block |
||
357 | 357 | case 'resource': |
358 | 358 | if (is_array($data)) // if $data['current'] is NOT set --> $app=='' |
359 | 359 | { |
360 | - list($app,$id) = explode(':',$data['current']); |
|
361 | - if(!$app && !$id) |
|
360 | + list($app, $id) = explode(':', $data['current']); |
|
361 | + if (!$app && !$id) |
|
362 | 362 | { |
363 | 363 | $app = $data['app']; |
364 | 364 | $id = $data['id']; |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | } |
367 | 367 | else |
368 | 368 | { |
369 | - list($app,$id) = explode(':',$data); |
|
369 | + list($app, $id) = explode(':', $data); |
|
370 | 370 | } |
371 | - foreach($this->bo->resources as $type => $data) |
|
371 | + foreach ($this->bo->resources as $type => $data) |
|
372 | 372 | { |
373 | 373 | if ($data['app'] == $app) break; |
374 | 374 | } |
@@ -378,19 +378,19 @@ discard block |
||
378 | 378 | $data = $id; |
379 | 379 | } |
380 | 380 | // check if new entry is no account (or contact entry of an account) |
381 | - elseif ($app != 'addressbook' || !($data = $GLOBALS['egw']->accounts->name2id($id,'person_id')) || !$this->bo->check_acl_invite($data)) |
|
381 | + elseif ($app != 'addressbook' || !($data = $GLOBALS['egw']->accounts->name2id($id, 'person_id')) || !$this->bo->check_acl_invite($data)) |
|
382 | 382 | { |
383 | 383 | if ($uid && $id) |
384 | 384 | { |
385 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
385 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
386 | 386 | if ($status) |
387 | 387 | { |
388 | 388 | $res_info = $this->bo->resource_info($uid); |
389 | 389 | // todo check real availability = maximum - already booked quantity |
390 | 390 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
391 | 391 | { |
392 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
393 | - foreach(array('quantity','resource','role') as $n) |
|
392 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
393 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
394 | 394 | { |
395 | 395 | $event['participants'][$n] = $content['participants'][$n]; |
396 | 396 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | else |
399 | 399 | { |
400 | 400 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
401 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
401 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
402 | 402 | } |
403 | 403 | } |
404 | - elseif(!$msg_permission_denied_added) |
|
404 | + elseif (!$msg_permission_denied_added) |
|
405 | 405 | { |
406 | 406 | $msg .= lang('Permission denied!'); |
407 | 407 | $msg_permission_denied_added = true; |
@@ -416,14 +416,14 @@ discard block |
||
416 | 416 | } |
417 | 417 | // fall-through for accounts entered as contact |
418 | 418 | case 'account': |
419 | - foreach(is_array($data) ? $data : explode(',',$data) as $uid) |
|
419 | + foreach (is_array($data) ? $data : explode(',', $data) as $uid) |
|
420 | 420 | { |
421 | 421 | if ($uid && $this->bo->check_acl_invite($uid)) |
422 | 422 | { |
423 | 423 | $event['participants'][$uid] = $event['participant_types']['u'][$uid] = |
424 | - calendar_so::combine_status($uid == $this->bo->user ? 'A' : 'U',1,$content['participants']['role']); |
|
424 | + calendar_so::combine_status($uid == $this->bo->user ? 'A' : 'U', 1, $content['participants']['role']); |
|
425 | 425 | } |
426 | - elseif($uid && !$msg_permission_denied_added) |
|
426 | + elseif ($uid && !$msg_permission_denied_added) |
|
427 | 427 | { |
428 | 428 | $msg .= lang('Permission denied!'); |
429 | 429 | $msg_permission_denied_added = true; |
@@ -432,14 +432,14 @@ discard block |
||
432 | 432 | break; |
433 | 433 | |
434 | 434 | default: // existing participant row |
435 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
436 | - foreach(array('uid','status','quantity','role') as $name) |
|
435 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
436 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
437 | 437 | { |
438 | 438 | $$name = $data[$name]; |
439 | 439 | } |
440 | 440 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
441 | 441 | { |
442 | - $uid = false; // entry has been deleted |
|
442 | + $uid = false; // entry has been deleted |
|
443 | 443 | } |
444 | 444 | elseif ($uid) |
445 | 445 | { |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | else |
452 | 452 | { |
453 | - $id = substr($uid,1); |
|
453 | + $id = substr($uid, 1); |
|
454 | 454 | $type = $uid[0]; |
455 | 455 | } |
456 | 456 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
459 | 459 | $quantity = $role = null; |
460 | 460 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
461 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
461 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
462 | 462 | { |
463 | 463 | // refreshing the calendar-view with the changed participant-status |
464 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
464 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
465 | 465 | { |
466 | 466 | $msg = lang('Status for all future scheduled days changed'); |
467 | 467 | } |
468 | 468 | else |
469 | 469 | { |
470 | - if(isset($content['edit_single'])) |
|
470 | + if (isset($content['edit_single'])) |
|
471 | 471 | { |
472 | 472 | $msg = lang('Status for this particular day changed'); |
473 | 473 | // prevent accidentally creating a real exception afterwards |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | if ($status == 'R' && $event['alarm']) |
489 | 489 | { |
490 | 490 | // remove from bo->set_status deleted alarms of rejected users from UI too |
491 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
491 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
492 | 492 | { |
493 | 493 | if ((string)$alarm['owner'] === (string)$uid) |
494 | 494 | { |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | if ($uid && $status != 'G') |
502 | 502 | { |
503 | 503 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
504 | - calendar_so::combine_status($status,$quantity,$role); |
|
504 | + calendar_so::combine_status($status, $quantity, $role); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | break; |
@@ -520,26 +520,26 @@ discard block |
||
520 | 520 | 'tabs' => $content['tabs'], |
521 | 521 | 'template' => $content['template'], |
522 | 522 | ); |
523 | - $noerror=true; |
|
523 | + $noerror = true; |
|
524 | 524 | |
525 | 525 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
526 | 526 | |
527 | 527 | $ignore_conflicts = $status_reset_to_unknown = false; |
528 | 528 | |
529 | - switch((string)$button) |
|
529 | + switch ((string)$button) |
|
530 | 530 | { |
531 | 531 | case 'ignore': |
532 | 532 | $ignore_conflicts = true; |
533 | - $button = $event['button_was']; // save or apply |
|
533 | + $button = $event['button_was']; // save or apply |
|
534 | 534 | unset($event['button_was']); |
535 | 535 | break; |
536 | 536 | |
537 | 537 | } |
538 | 538 | |
539 | - switch((string)$button) |
|
539 | + switch ((string)$button) |
|
540 | 540 | { |
541 | 541 | case 'exception': // create an exception in a recuring event |
542 | - $msg = $this->_create_exception($event,$preserv); |
|
542 | + $msg = $this->_create_exception($event, $preserv); |
|
543 | 543 | break; |
544 | 544 | |
545 | 545 | case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
@@ -550,29 +550,29 @@ discard block |
||
550 | 550 | unset($event['recurrence']); |
551 | 551 | unset($preserv['recurrence']); |
552 | 552 | unset($event['recur_exception']); |
553 | - unset($event['edit_single']); // in case it has been set |
|
553 | + unset($event['edit_single']); // in case it has been set |
|
554 | 554 | unset($event['modified']); |
555 | 555 | unset($event['modifier']); |
556 | 556 | unset($event['caldav_name']); |
557 | - $event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD,0,$this->owner) ? $this->user : $this->owner; |
|
557 | + $event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD, 0, $this->owner) ? $this->user : $this->owner; |
|
558 | 558 | |
559 | 559 | // Clear participant stati |
560 | - foreach($event['participant_types'] as $type => &$participants) |
|
560 | + foreach ($event['participant_types'] as $type => &$participants) |
|
561 | 561 | { |
562 | - foreach($participants as $id => &$response) |
|
562 | + foreach ($participants as $id => &$response) |
|
563 | 563 | { |
564 | - if($type == 'u' && $id == $event['owner']) continue; |
|
564 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
565 | 565 | calendar_so::split_status($response, $quantity, $role); |
566 | 566 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
567 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
568 | - $response = calendar_so::combine_status($status,$quantity,$role); |
|
567 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
568 | + $response = calendar_so::combine_status($status, $quantity, $role); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | 572 | // Copy alarms |
573 | 573 | if (is_array($event['alarm'])) |
574 | 574 | { |
575 | - foreach($event['alarm'] as $n => &$alarm) |
|
575 | + foreach ($event['alarm'] as $n => &$alarm) |
|
576 | 576 | { |
577 | 577 | unset($alarm['id']); |
578 | 578 | unset($alarm['cal_id']); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | // Get links to be copied |
583 | 583 | // With no ID, $content['link_to']['to_id'] is used |
584 | 584 | $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
585 | - foreach(egw_link::get_links('calendar', $content['id']) as $link) |
|
585 | + foreach (egw_link::get_links('calendar', $content['id']) as $link) |
|
586 | 586 | { |
587 | 587 | if ($link['app'] != egw_link::VFS_APPNAME) |
588 | 588 | { |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | case 'print': |
609 | 609 | case 'apply': |
610 | 610 | case 'infolog': |
611 | - if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event)) |
|
611 | + if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT, $event)) |
|
612 | 612 | { |
613 | 613 | $msg = lang('Permission denied'); |
614 | 614 | $button = ''; |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | $button = ''; |
627 | 627 | break; |
628 | 628 | } |
629 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
629 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
630 | 630 | { |
631 | 631 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
632 | 632 | $button = ''; |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | $event['reference'] = $event['id']; |
657 | 657 | $event['recurrence'] = $content['edit_single']; |
658 | 658 | unset($event['id']); |
659 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
659 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
660 | 660 | if (!is_array($conflicts) && $conflicts) |
661 | 661 | { |
662 | 662 | // now we need to add the original start as recur-execption to the series |
663 | 663 | $recur_event = $this->bo->read($event['reference']); |
664 | 664 | $recur_event['recur_exception'][] = $content['edit_single']; |
665 | 665 | // check if we need to move the alarms, because they are next on that exception |
666 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
666 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
667 | 667 | { |
668 | 668 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
669 | 669 | { |
@@ -679,11 +679,11 @@ discard block |
||
679 | 679 | } |
680 | 680 | } |
681 | 681 | } |
682 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
683 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
684 | - $this->bo->update($recur_event,true); // no conflict check here |
|
682 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
683 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
684 | + $this->bo->update($recur_event, true); // no conflict check here |
|
685 | 685 | unset($recur_event); |
686 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
686 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
687 | 687 | unset($preserv['edit_single']); |
688 | 688 | } |
689 | 689 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | if ($event['start'] != $old_event['start'] || |
704 | 704 | $event['whole_day'] != $old_event['whole_day']) |
705 | 705 | { |
706 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
706 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
707 | 707 | { |
708 | 708 | $msg = lang("Error: You can't shift a series from the past!"); |
709 | 709 | $noerror = false; |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | { |
727 | 727 | $event['end'] = $event['start'] + $content['duration']; |
728 | 728 | } |
729 | - elseif($event['end'] < $event['start']) |
|
729 | + elseif ($event['end'] < $event['start']) |
|
730 | 730 | { |
731 | 731 | $event['end'] = $event['start'] + $event['end'] - $actual_date; |
732 | 732 | } |
@@ -767,14 +767,14 @@ discard block |
||
767 | 767 | ($last = $occurrence)); |
768 | 768 | $last->setTime(0, 0, 0); |
769 | 769 | $old_event['recur_enddate'] = egw_time::to($last, 'ts'); |
770 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$content['no_notifications'])) |
|
770 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $content['no_notifications'])) |
|
771 | 771 | { |
772 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
773 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
774 | - htmlspecialchars(egw::link('/index.php',array( |
|
772 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
773 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
774 | + htmlspecialchars(egw::link('/index.php', array( |
|
775 | 775 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
776 | 776 | 'cal_id' => $content['id'], |
777 | - ))).'">','</a>'); |
|
777 | + ))).'">', '</a>'); |
|
778 | 778 | $noerror = false; |
779 | 779 | $event = $orig_event; |
780 | 780 | break; |
@@ -790,13 +790,13 @@ discard block |
||
790 | 790 | $event['whole_day'] != $old_event['whole_day']) |
791 | 791 | { |
792 | 792 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
793 | - foreach((array)$event['participants'] as $uid => $status) |
|
793 | + foreach ((array)$event['participants'] as $uid => $status) |
|
794 | 794 | { |
795 | 795 | $q = $r = null; |
796 | - calendar_so::split_status($status,$q,$r); |
|
796 | + calendar_so::split_status($status, $q, $r); |
|
797 | 797 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
798 | 798 | { |
799 | - $preferences = CreateObject('phpgwapi.preferences',$uid); |
|
799 | + $preferences = CreateObject('phpgwapi.preferences', $uid); |
|
800 | 800 | $part_prefs = $preferences->read_repository(); |
801 | 801 | switch ($part_prefs['calendar']['reset_stati']) |
802 | 802 | { |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | if ($sameday) break; |
807 | 807 | default: |
808 | 808 | $status_reset_to_unknown = true; |
809 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
809 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
810 | 810 | // todo: report reset status to user |
811 | 811 | } |
812 | 812 | } |
@@ -816,27 +816,27 @@ discard block |
||
816 | 816 | } |
817 | 817 | } |
818 | 818 | } |
819 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
819 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
820 | 820 | unset($event['ignore']); |
821 | 821 | } |
822 | 822 | if (is_array($conflicts)) |
823 | 823 | { |
824 | - $event['button_was'] = $button; // remember for ignore |
|
825 | - return $this->conflicts($event,$conflicts,$preserv); |
|
824 | + $event['button_was'] = $button; // remember for ignore |
|
825 | + return $this->conflicts($event, $conflicts, $preserv); |
|
826 | 826 | } |
827 | 827 | // check if there are messages from update, eg. removed participants or categories because of missing rights |
828 | 828 | if ($messages) |
829 | 829 | { |
830 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
830 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
831 | 831 | } |
832 | 832 | if ($conflicts === 0) |
833 | 833 | { |
834 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
835 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
836 | - htmlspecialchars(egw::link('/index.php',array( |
|
834 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
835 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
836 | + htmlspecialchars(egw::link('/index.php', array( |
|
837 | 837 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
838 | 838 | 'cal_id' => $content['id'], |
839 | - ))).'">','</a>'); |
|
839 | + ))).'">', '</a>'); |
|
840 | 840 | $noerror = false; |
841 | 841 | } |
842 | 842 | elseif ($conflicts > 0) |
@@ -857,19 +857,19 @@ discard block |
||
857 | 857 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
858 | 858 | if ($alarm['time'] < $this->bo->now_su) |
859 | 859 | { |
860 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
860 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
861 | 861 | { |
862 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
862 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
863 | 863 | } |
864 | 864 | else |
865 | 865 | { |
866 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
866 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
870 | 870 | elseif ($event_time < $event['start']) |
871 | 871 | { |
872 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
872 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
873 | 873 | } |
874 | 874 | if ($alarm) |
875 | 875 | { |
@@ -878,9 +878,9 @@ discard block |
||
878 | 878 | } |
879 | 879 | } |
880 | 880 | // attach all future exceptions to the new series |
881 | - $events =& $this->bo->search(array( |
|
881 | + $events = & $this->bo->search(array( |
|
882 | 882 | 'query' => array('cal_uid' => $old_event['uid']), |
883 | - 'filter' => 'owner', // return all possible entries |
|
883 | + 'filter' => 'owner', // return all possible entries |
|
884 | 884 | 'daywise' => false, |
885 | 885 | 'date_format' => 'ts', |
886 | 886 | )); |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | $exception['recurrence'] += $offset; |
892 | 892 | $exception['reference'] = $event['id']; |
893 | 893 | $exception['uid'] = $event['uid']; |
894 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
894 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | } |
@@ -899,24 +899,24 @@ discard block |
||
899 | 899 | $message = lang('Event saved'); |
900 | 900 | if ($status_reset_to_unknown) |
901 | 901 | { |
902 | - foreach((array)$event['participants'] as $uid => $status) |
|
902 | + foreach ((array)$event['participants'] as $uid => $status) |
|
903 | 903 | { |
904 | 904 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
905 | 905 | { |
906 | - calendar_so::split_status($status,$q,$r); |
|
907 | - $status = calendar_so::combine_status('U',$q,$r); |
|
906 | + calendar_so::split_status($status, $q, $r); |
|
907 | + $status = calendar_so::combine_status('U', $q, $r); |
|
908 | 908 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
909 | 909 | } |
910 | 910 | } |
911 | 911 | $message .= lang(', stati of participants reset'); |
912 | 912 | } |
913 | 913 | |
914 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
914 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
915 | 915 | egw_framework::refresh_opener($msg, 'calendar', $event['id']); |
916 | 916 | // writing links for new entry, existing ones are handled by the widget itself |
917 | 917 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
918 | 918 | { |
919 | - egw_link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
919 | + egw_link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
920 | 920 | } |
921 | 921 | } |
922 | 922 | else |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | break; |
927 | 927 | |
928 | 928 | case 'cancel': |
929 | - if($content['cancel_needs_refresh']) |
|
929 | + if ($content['cancel_needs_refresh']) |
|
930 | 930 | { |
931 | 931 | egw_framework::refresh_opener($msg, 'calendar'); |
932 | 932 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | { |
965 | 965 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
966 | 966 | } |
967 | - if ($this->bo->check_perms(EGW_ACL_EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
967 | + if ($this->bo->check_perms(EGW_ACL_EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
968 | 968 | { |
969 | 969 | $alarm = array( |
970 | 970 | 'offset' => $offset, |
@@ -978,13 +978,13 @@ discard block |
||
978 | 978 | } |
979 | 979 | elseif ($event['id']) // save the alarm immediatly |
980 | 980 | { |
981 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
981 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
982 | 982 | { |
983 | 983 | $alarm['id'] = $alarm_id; |
984 | 984 | $event['alarm'][$alarm_id] = $alarm; |
985 | 985 | |
986 | 986 | $msg = lang('Alarm added'); |
987 | - egw_framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
987 | + egw_framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
988 | 988 | } |
989 | 989 | else |
990 | 990 | { |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | } |
994 | 994 | else |
995 | 995 | { |
996 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
996 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
997 | 997 | $event['alarm'][$alarm['id']] = $alarm; |
998 | 998 | } |
999 | 999 | } |
@@ -1008,22 +1008,22 @@ discard block |
||
1008 | 1008 | { |
1009 | 1009 | $msg .= ($msg ? "\n" : '').implode("\n", $notification_errors); |
1010 | 1010 | } |
1011 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
1011 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
1012 | 1012 | { |
1013 | 1013 | if ($content['lock_token']) // remove an existing lock |
1014 | 1014 | { |
1015 | - egw_vfs::unlock(egw_vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
1015 | + egw_vfs::unlock(egw_vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
1016 | 1016 | } |
1017 | 1017 | if ($content['no_popup']) |
1018 | 1018 | { |
1019 | - egw::redirect_link('/index.php',array( |
|
1019 | + egw::redirect_link('/index.php', array( |
|
1020 | 1020 | 'menuaction' => 'calendar.calendar_uiviews.index', |
1021 | 1021 | 'msg' => $msg, |
1022 | 1022 | )); |
1023 | 1023 | } |
1024 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1024 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1025 | 1025 | { |
1026 | - egw_framework::refresh_opener($msg,'calendar'); |
|
1026 | + egw_framework::refresh_opener($msg, 'calendar'); |
|
1027 | 1027 | } |
1028 | 1028 | else |
1029 | 1029 | { |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | common::egw_exit(); |
1034 | 1034 | } |
1035 | 1035 | unset($event['no_notifications']); |
1036 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1036 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | /** |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | * @param array &$preserv |
1046 | 1046 | * @return string message that exception was created |
1047 | 1047 | */ |
1048 | - function _create_exception(&$event,&$preserv) |
|
1048 | + function _create_exception(&$event, &$preserv) |
|
1049 | 1049 | { |
1050 | 1050 | // In some cases where the user makes the first day an exception, actual_date may be missing |
1051 | 1051 | $preserv['actual_date'] = $preserv['acutal_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1055,17 +1055,17 @@ discard block |
||
1055 | 1055 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
1056 | 1056 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
1057 | 1057 | $event['recur_type'] = MCAL_RECUR_NONE; |
1058 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
1058 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
1059 | 1059 | { |
1060 | 1060 | unset($event[$name]); |
1061 | 1061 | } |
1062 | 1062 | // add all alarms as new alarms to execption |
1063 | 1063 | $event['alarm'] = array_values((array)$event['alarm']); |
1064 | - foreach($event['alarm'] as &$alarm) |
|
1064 | + foreach ($event['alarm'] as &$alarm) |
|
1065 | 1065 | { |
1066 | 1066 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
1067 | 1067 | } |
1068 | - if($this->bo->check_perms(EGW_ACL_EDIT,$event)) |
|
1068 | + if ($this->bo->check_perms(EGW_ACL_EDIT, $event)) |
|
1069 | 1069 | { |
1070 | 1070 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
1071 | 1071 | } |
@@ -1092,14 +1092,14 @@ discard block |
||
1092 | 1092 | { |
1093 | 1093 | $msg = false; |
1094 | 1094 | |
1095 | - if(!$as_of_date ) |
|
1095 | + if (!$as_of_date) |
|
1096 | 1096 | { |
1097 | 1097 | $as_of_date = time(); |
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | //error_log(__METHOD__ . egw_time::to($old_event['start']) . ' -> '. egw_time::to($event['start']) . ' as of ' . egw_time::to($as_of_date)); |
1101 | 1101 | |
1102 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1102 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1103 | 1103 | { |
1104 | 1104 | $msg = lang("Error: You can't shift a series from the past!"); |
1105 | 1105 | $noerror = false; |
@@ -1113,11 +1113,11 @@ discard block |
||
1113 | 1113 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
1114 | 1114 | |
1115 | 1115 | // base start-date of new series on actual / clicked date |
1116 | - $event['start'] = $as_of_date ; |
|
1116 | + $event['start'] = $as_of_date; |
|
1117 | 1117 | |
1118 | - if (egw_time::to($old_event['start'],'Ymd') < egw_time::to($as_of_date,'Ymd') || |
|
1118 | + if (egw_time::to($old_event['start'], 'Ymd') < egw_time::to($as_of_date, 'Ymd') || |
|
1119 | 1119 | // Adjust for requested date in the past |
1120 | - egw_time::to($as_of_date,'ts') < time() |
|
1120 | + egw_time::to($as_of_date, 'ts') < time() |
|
1121 | 1121 | ) |
1122 | 1122 | { |
1123 | 1123 | |
@@ -1137,17 +1137,17 @@ discard block |
||
1137 | 1137 | $rriter->next_no_exception(); |
1138 | 1138 | $occurrence = $rriter->current(); |
1139 | 1139 | } |
1140 | - while ($rriter->valid() && ( |
|
1140 | + while ($rriter->valid() && ( |
|
1141 | 1141 | egw_time::to($occurrence, 'ts') <= time() || |
1142 | - egw_time::to($occurrence, 'Ymd') < egw_time::to($as_of_date,'Ymd') |
|
1142 | + egw_time::to($occurrence, 'Ymd') < egw_time::to($as_of_date, 'Ymd') |
|
1143 | 1143 | ) && ($last = $occurrence)); |
1144 | 1144 | |
1145 | 1145 | |
1146 | 1146 | // Make sure as_of_date is still valid, may have to move forward |
1147 | - if(egw_time::to($as_of_date,'ts') < egw_time::to($last,'ts') || |
|
1147 | + if (egw_time::to($as_of_date, 'ts') < egw_time::to($last, 'ts') || |
|
1148 | 1148 | egw_time::to($as_of_date, 'Ymd') == egw_time::to($last, 'Ymd')) |
1149 | 1149 | { |
1150 | - $event['start'] = egw_time::to($rriter->current(),'ts') + $offset; |
|
1150 | + $event['start'] = egw_time::to($rriter->current(), 'ts') + $offset; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | //error_log(__METHOD__ ." Series should end at " . egw_time::to($last) . " New series starts at " . egw_time::to($event['start'])); |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | { |
1156 | 1156 | $event['end'] = $event['start'] + $duration; |
1157 | 1157 | } |
1158 | - elseif($event['end'] < $event['start']) |
|
1158 | + elseif ($event['end'] < $event['start']) |
|
1159 | 1159 | { |
1160 | 1160 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
1161 | 1161 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | $event['participants'] = $old_event['participants']; |
1165 | 1165 | foreach ($old_event['recur_exception'] as $key => $exdate) |
1166 | 1166 | { |
1167 | - if ($exdate > egw_time::to($last,'ts')) |
|
1167 | + if ($exdate > egw_time::to($last, 'ts')) |
|
1168 | 1168 | { |
1169 | 1169 | //error_log("Moved exception on " . egw_time::to($exdate)); |
1170 | 1170 | unset($old_event['recur_exception'][$key]); |
@@ -1178,18 +1178,18 @@ discard block |
||
1178 | 1178 | } |
1179 | 1179 | $last->setTime(0, 0, 0); |
1180 | 1180 | $old_event['recur_enddate'] = egw_time::to($last, 'ts'); |
1181 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
1181 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
1182 | 1182 | { |
1183 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1184 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
1185 | - htmlspecialchars(egw::link('/index.php',array( |
|
1183 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1184 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
1185 | + htmlspecialchars(egw::link('/index.php', array( |
|
1186 | 1186 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1187 | 1187 | 'cal_id' => $content['id'], |
1188 | - ))).'">','</a>'); |
|
1188 | + ))).'">', '</a>'); |
|
1189 | 1189 | $event = $orig_event; |
1190 | 1190 | } |
1191 | 1191 | } |
1192 | - $event['start'] = egw_time::to($event['start'],'ts'); |
|
1192 | + $event['start'] = egw_time::to($event['start'], 'ts'); |
|
1193 | 1193 | return $msg; |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1200,11 +1200,11 @@ discard block |
||
1200 | 1200 | * @param boolean $added |
1201 | 1201 | * @return string javascript window.open command |
1202 | 1202 | */ |
1203 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
1203 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
1204 | 1204 | { |
1205 | 1205 | $to = array(); |
1206 | 1206 | |
1207 | - foreach($event['participants'] as $uid => $status) |
|
1207 | + foreach ($event['participants'] as $uid => $status) |
|
1208 | 1208 | { |
1209 | 1209 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
1210 | 1210 | if (empty($status)) continue; |
@@ -1213,35 +1213,35 @@ discard block |
||
1213 | 1213 | |
1214 | 1214 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
1215 | 1215 | { |
1216 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
1216 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
1217 | 1217 | |
1218 | 1218 | $lid = $firstname = $lastname = null; |
1219 | - $GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname); |
|
1219 | + $GLOBALS['egw']->accounts->get_account_name($status['uid'], $lid, $firstname, $lastname); |
|
1220 | 1220 | |
1221 | 1221 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
1222 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
1222 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
1223 | 1223 | //error_log(__METHOD__.__LINE__.array2string($to)); |
1224 | 1224 | } |
1225 | 1225 | elseif ($uid < 0) |
1226 | 1226 | { |
1227 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
1227 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
1228 | 1228 | { |
1229 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
1229 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
1230 | 1230 | |
1231 | - $GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname); |
|
1231 | + $GLOBALS['egw']->accounts->get_account_name($uid, $lid, $firstname, $lastname); |
|
1232 | 1232 | |
1233 | 1233 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
1234 | 1234 | // dont add groupmembers if they already rejected the event, or are the current user |
1235 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1235 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1236 | 1236 | //error_log(__METHOD__.__LINE__.array2string($to)); |
1237 | 1237 | } |
1238 | 1238 | } |
1239 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1239 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1240 | 1240 | { |
1241 | 1241 | $to[] = $info['email']; |
1242 | 1242 | //error_log(__METHOD__.__LINE__.array2string($to)); |
1243 | 1243 | } |
1244 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
1244 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
1245 | 1245 | { |
1246 | 1246 | $to[] = $info['email']; |
1247 | 1247 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | // prefer event description over standard notification text |
1251 | 1251 | if (empty($event['description'])) |
1252 | 1252 | { |
1253 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1253 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1254 | 1254 | } |
1255 | 1255 | else |
1256 | 1256 | { |
@@ -1265,12 +1265,12 @@ discard block |
||
1265 | 1265 | $boical = new calendar_ical(); |
1266 | 1266 | // we need to pass $event[id] so iCal class reads event again, |
1267 | 1267 | // as event is in user TZ, but iCal class expects server TZ! |
1268 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
1268 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
1269 | 1269 | |
1270 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
1271 | - if(($f = fopen($ics_file,'w'))) |
|
1270 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
1271 | + if (($f = fopen($ics_file, 'w'))) |
|
1272 | 1272 | { |
1273 | - fwrite($f,$ics); |
|
1273 | + fwrite($f, $ics); |
|
1274 | 1274 | fclose($f); |
1275 | 1275 | } |
1276 | 1276 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | 'preset[body]' => $body, |
1283 | 1283 | 'preset[name]' => 'event.ics', |
1284 | 1284 | 'preset[file]' => $ics_file, |
1285 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
1285 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
1286 | 1286 | 'preset[size]' => filesize($ics_file), |
1287 | 1287 | ); |
1288 | 1288 | if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | * @param mixed $link_to_id ='' from or for the link-widget |
1339 | 1339 | * @param string $msg_type =null default automatic detect, if it contains "error" |
1340 | 1340 | */ |
1341 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
1341 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
1342 | 1342 | { |
1343 | 1343 | $sel_options = array( |
1344 | 1344 | 'recur_type' => &$this->bo->recur_types, |
@@ -1362,8 +1362,8 @@ discard block |
||
1362 | 1362 | 'no_popup' => isset($_GET['no_popup']), |
1363 | 1363 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
1364 | 1364 | ); |
1365 | - $cal_id = (int) $_GET['cal_id']; |
|
1366 | - if($_GET['action']) |
|
1365 | + $cal_id = (int)$_GET['cal_id']; |
|
1366 | + if ($_GET['action']) |
|
1367 | 1367 | { |
1368 | 1368 | $event = $this->bo->read($cal_id); |
1369 | 1369 | $event['action'] = $_GET['action']; |
@@ -1381,14 +1381,14 @@ discard block |
||
1381 | 1381 | { |
1382 | 1382 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
1383 | 1383 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
1384 | - $event =& $this->default_add_event(); |
|
1384 | + $event = & $this->default_add_event(); |
|
1385 | 1385 | } |
1386 | 1386 | if (!empty($_GET['ical_data']) && |
1387 | 1387 | !($_GET['ical'] = egw_link::get_data($_GET['ical_data']))) |
1388 | 1388 | { |
1389 | 1389 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
1390 | 1390 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
1391 | - $event =& $this->default_add_event(); |
|
1391 | + $event = & $this->default_add_event(); |
|
1392 | 1392 | } |
1393 | 1393 | if (!empty($_GET['ical'])) |
1394 | 1394 | { |
@@ -1397,14 +1397,14 @@ discard block |
||
1397 | 1397 | { |
1398 | 1398 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
1399 | 1399 | $msg = lang('Error: importing the iCal'); |
1400 | - $event =& $this->default_add_event(); |
|
1400 | + $event = & $this->default_add_event(); |
|
1401 | 1401 | } |
1402 | 1402 | else |
1403 | 1403 | { |
1404 | 1404 | if (count($events) > 1) |
1405 | 1405 | { |
1406 | 1406 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
1407 | - $msg_type = 'notice'; // no not hide automatic |
|
1407 | + $msg_type = 'notice'; // no not hide automatic |
|
1408 | 1408 | } |
1409 | 1409 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
1410 | 1410 | $this->bo->db2data($events, 'ts'); |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | else |
1418 | 1418 | { |
1419 | 1419 | $event['participant_types'] = array(); |
1420 | - foreach($event['participants'] as $uid => $status) |
|
1420 | + foreach ($event['participants'] as $uid => $status) |
|
1421 | 1421 | { |
1422 | 1422 | $user_type = $user_id = null; |
1423 | 1423 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1438,15 +1438,15 @@ discard block |
||
1438 | 1438 | } |
1439 | 1439 | else |
1440 | 1440 | { |
1441 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
1441 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
1442 | 1442 | common::egw_exit(); |
1443 | 1443 | } |
1444 | 1444 | } |
1445 | - $event =& $this->default_add_event(); |
|
1445 | + $event = & $this->default_add_event(); |
|
1446 | 1446 | } |
1447 | 1447 | else |
1448 | 1448 | { |
1449 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1449 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1450 | 1450 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1451 | 1451 | { |
1452 | 1452 | if (empty($event['whole_day'])) |
@@ -1459,10 +1459,10 @@ discard block |
||
1459 | 1459 | $date->setUser(); |
1460 | 1460 | } |
1461 | 1461 | $event = $this->bo->read($cal_id, $date, true); |
1462 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1462 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1463 | 1463 | if ($_GET['exception']) |
1464 | 1464 | { |
1465 | - $msg = $this->_create_exception($event,$preserv); |
|
1465 | + $msg = $this->_create_exception($event, $preserv); |
|
1466 | 1466 | } |
1467 | 1467 | else |
1468 | 1468 | { |
@@ -1471,8 +1471,8 @@ discard block |
||
1471 | 1471 | } |
1472 | 1472 | } |
1473 | 1473 | // set new start and end if given by $_GET |
1474 | - if(isset($_GET['start'])) { $event['start'] = $_GET['start']; } |
|
1475 | - if(isset($_GET['end'])) { $event['end'] = $_GET['end']; } |
|
1474 | + if (isset($_GET['start'])) { $event['start'] = $_GET['start']; } |
|
1475 | + if (isset($_GET['end'])) { $event['end'] = $_GET['end']; } |
|
1476 | 1476 | // check if the event is the whole day |
1477 | 1477 | $start = $this->bo->date2array($event['start']); |
1478 | 1478 | $end = $this->bo->date2array($event['end']); |
@@ -1482,30 +1482,30 @@ discard block |
||
1482 | 1482 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
1483 | 1483 | { |
1484 | 1484 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
1485 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1485 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1486 | 1486 | { |
1487 | 1487 | $link_id = $link_ids[$n]; |
1488 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
1488 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
1489 | 1489 | { |
1490 | 1490 | continue; |
1491 | 1491 | } |
1492 | - if(!$n) |
|
1492 | + if (!$n) |
|
1493 | 1493 | { |
1494 | - $event['title'] = egw_link::title($link_app,$link_id); |
|
1494 | + $event['title'] = egw_link::title($link_app, $link_id); |
|
1495 | 1495 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
1496 | - if (($set = $GLOBALS['egw']->hooks->single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
1496 | + if (($set = $GLOBALS['egw']->hooks->single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
1497 | 1497 | { |
1498 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
1498 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
1499 | 1499 | { |
1500 | - if (($l_id=$set['link_id'][$i])) egw_link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1500 | + if (($l_id = $set['link_id'][$i])) egw_link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
1501 | 1501 | } |
1502 | 1502 | unset($set['link_app']); |
1503 | 1503 | unset($set['link_id']); |
1504 | 1504 | |
1505 | - $event = array_merge($event,$set); |
|
1505 | + $event = array_merge($event, $set); |
|
1506 | 1506 | } |
1507 | 1507 | } |
1508 | - egw_link::link('calendar',$link_to_id,$link_app,$link_id); |
|
1508 | + egw_link::link('calendar', $link_to_id, $link_app, $link_id); |
|
1509 | 1509 | } |
1510 | 1510 | } |
1511 | 1511 | } |
@@ -1515,44 +1515,44 @@ discard block |
||
1515 | 1515 | { |
1516 | 1516 | $etpl->read($preserv['template'] = 'calendar.edit'); |
1517 | 1517 | } |
1518 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event); |
|
1518 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT, $event); |
|
1519 | 1519 | //echo "view=$view, event="; _debug_array($event); |
1520 | 1520 | // shared locking of entries to edit |
1521 | 1521 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
1522 | 1522 | { |
1523 | - $lock_path = egw_vfs::app_entry_lock_path('calendar',$event['id']); |
|
1523 | + $lock_path = egw_vfs::app_entry_lock_path('calendar', $event['id']); |
|
1524 | 1524 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1525 | 1525 | |
1526 | 1526 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
1527 | 1527 | { |
1528 | - egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
1528 | + egw_vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
1529 | 1529 | } |
1530 | 1530 | if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
1531 | 1531 | { |
1532 | 1532 | $msg .= ' '.lang('This entry is currently opened by %1!', |
1533 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
1533 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
1534 | 1534 | common::grab_owner_name($lock_uid) : $lock['owner'])); |
1535 | 1535 | } |
1536 | - elseif($lock) |
|
1536 | + elseif ($lock) |
|
1537 | 1537 | { |
1538 | 1538 | $preserv['lock_token'] = $lock['token']; |
1539 | 1539 | } |
1540 | - elseif(egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
1540 | + elseif (egw_vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
1541 | 1541 | { |
1542 | 1542 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
1543 | 1543 | } |
1544 | 1544 | else |
1545 | 1545 | { |
1546 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1546 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1547 | 1547 | $view = true; |
1548 | 1548 | } |
1549 | 1549 | } |
1550 | - $content = array_merge($event,array( |
|
1550 | + $content = array_merge($event, array( |
|
1551 | 1551 | 'link_to' => array( |
1552 | 1552 | 'to_id' => $link_to_id, |
1553 | 1553 | 'to_app' => 'calendar', |
1554 | 1554 | ), |
1555 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1555 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1556 | 1556 | 'tabs' => $preserv['tabs'], |
1557 | 1557 | 'view' => $view, |
1558 | 1558 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1564,11 +1564,11 @@ discard block |
||
1564 | 1564 | $row = 3; |
1565 | 1565 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
1566 | 1566 | // preserve some ui elements, if set eg. under error-conditions |
1567 | - foreach(array('quantity','resource','role') as $n) |
|
1567 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
1568 | 1568 | { |
1569 | 1569 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
1570 | 1570 | } |
1571 | - foreach($event['participant_types'] as $type => $participants) |
|
1571 | + foreach ($event['participant_types'] as $type => $participants) |
|
1572 | 1572 | { |
1573 | 1573 | $name = 'accounts'; |
1574 | 1574 | if (isset($this->bo->resources[$type])) |
@@ -1577,17 +1577,17 @@ discard block |
||
1577 | 1577 | } |
1578 | 1578 | // sort participants (in there group/app) by title |
1579 | 1579 | uksort($participants, array($this, 'uid_title_cmp')); |
1580 | - foreach($participants as $id => $status) |
|
1580 | + foreach ($participants as $id => $status) |
|
1581 | 1581 | { |
1582 | 1582 | $uid = $type == 'u' ? $id : $type.$id; |
1583 | 1583 | $quantity = $role = null; |
1584 | - calendar_so::split_status($status,$quantity,$role); |
|
1584 | + calendar_so::split_status($status, $quantity, $role); |
|
1585 | 1585 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1586 | 1586 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
1587 | 1587 | 'uid' => $uid, |
1588 | 1588 | 'status' => $status, |
1589 | 1589 | 'old_status' => $status, |
1590 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1590 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1591 | 1591 | 'role' => $role, |
1592 | 1592 | ); |
1593 | 1593 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1596,33 +1596,33 @@ discard block |
||
1596 | 1596 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
1597 | 1597 | } |
1598 | 1598 | // allow third party apps to use categories for roles |
1599 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
1599 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
1600 | 1600 | { |
1601 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
1601 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
1602 | 1602 | } |
1603 | 1603 | else |
1604 | 1604 | { |
1605 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
1605 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
1606 | 1606 | } |
1607 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
1607 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
1608 | 1608 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
1609 | 1609 | |
1610 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
1610 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
1611 | 1611 | $readonlys['participants'][$row]['status'] = $no_status; |
1612 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event)) |
|
1612 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT, $event)) |
|
1613 | 1613 | $readonlys['participants']['delete'][$uid] = true; |
1614 | 1614 | // todo: make the participants available as links with email as title |
1615 | 1615 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
1616 | 1616 | // enumerate group-invitations, so people can accept/reject them |
1617 | 1617 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
1618 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
1618 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
1619 | 1619 | { |
1620 | 1620 | $sel_options['status']['G'] = lang('Select one'); |
1621 | 1621 | // sort members by title |
1622 | 1622 | usort($members, array($this, 'uid_title_cmp')); |
1623 | - foreach($members as $member) |
|
1623 | + foreach ($members as $member) |
|
1624 | 1624 | { |
1625 | - if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ,0,$member)) |
|
1625 | + if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ, 0, $member)) |
|
1626 | 1626 | { |
1627 | 1627 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1628 | 1628 | 'app' => 'Group invitation', |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | ); |
1632 | 1632 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
1633 | 1633 | // read access is enough to invite participants, but you need edit rights to change status |
1634 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(EGW_ACL_EDIT,0,$member); |
|
1634 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(EGW_ACL_EDIT, 0, $member); |
|
1635 | 1635 | $content['participants'][$row++]['title'] = common::grab_owner_name($member); |
1636 | 1636 | } |
1637 | 1637 | } |
@@ -1639,16 +1639,16 @@ discard block |
||
1639 | 1639 | } |
1640 | 1640 | // resouces / apps we shedule, atm. resources and addressbook |
1641 | 1641 | $content['participants']['cal_resources'] = ''; |
1642 | - foreach($this->bo->resources as $data) |
|
1642 | + foreach ($this->bo->resources as $data) |
|
1643 | 1643 | { |
1644 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1644 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1645 | 1645 | $content['participants']['cal_resources'] .= ','.$data['app']; |
1646 | 1646 | } |
1647 | 1647 | // adding extra content for the resource link-entry widget to |
1648 | 1648 | // * select resources or addressbook as a default selection on the app selectbox based on prefs |
1649 | 1649 | $content['participants']['resource']['app'] = $this->cal_prefs['defaultresource_sel']; |
1650 | 1650 | // * get informations from the event on the ajax callback |
1651 | - if (in_array($content['participants']['resource']['app'],array('resources_conflict','resources_without_conflict'))) |
|
1651 | + if (in_array($content['participants']['resource']['app'], array('resources_conflict', 'resources_without_conflict'))) |
|
1652 | 1652 | { |
1653 | 1653 | // fix real app string |
1654 | 1654 | $content['participants']['resource']['app'] = 'resources'; |
@@ -1660,36 +1660,36 @@ discard block |
||
1660 | 1660 | } |
1661 | 1661 | } |
1662 | 1662 | $content['participants']['status_date'] = $preserv['actual_date']; |
1663 | - $preserved = array_merge($preserv,$content); |
|
1663 | + $preserved = array_merge($preserv, $content); |
|
1664 | 1664 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
1665 | 1665 | if ($event['alarm']) |
1666 | 1666 | { |
1667 | 1667 | // makes keys of the alarm-array starting with 1 |
1668 | 1668 | $content['alarm'] = array(false); |
1669 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
1669 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
1670 | 1670 | { |
1671 | - if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ,0,$alarm['owner'])) |
|
1671 | + if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ, 0, $alarm['owner'])) |
|
1672 | 1672 | { |
1673 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1673 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1674 | 1674 | } |
1675 | - $alarm['all'] = (int) $alarm['all']; |
|
1675 | + $alarm['all'] = (int)$alarm['all']; |
|
1676 | 1676 | $after = false; |
1677 | - if($alarm['offset'] < 0) |
|
1677 | + if ($alarm['offset'] < 0) |
|
1678 | 1678 | { |
1679 | 1679 | $after = true; |
1680 | 1680 | $alarm['offset'] = -1 * $alarm['offset']; |
1681 | 1681 | } |
1682 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
1683 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
1684 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
1682 | + $days = (int)($alarm['offset'] / DAY_s); |
|
1683 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
1684 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
1685 | 1685 | $label = array(); |
1686 | 1686 | if ($days) $label[] = $days.' '.lang('days'); |
1687 | 1687 | if ($hours) $label[] = $hours.' '.lang('hours'); |
1688 | 1688 | if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
1689 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
1689 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
1690 | 1690 | $content['alarm'][] = $alarm; |
1691 | 1691 | |
1692 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
1692 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
1693 | 1693 | } |
1694 | 1694 | if (count($content['alarm']) == 1) |
1695 | 1695 | { |
@@ -1704,20 +1704,20 @@ discard block |
||
1704 | 1704 | |
1705 | 1705 | if ($view) |
1706 | 1706 | { |
1707 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1707 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1708 | 1708 | $readonlys['button[cancel]'] = $readonlys['action'] = |
1709 | 1709 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
1710 | 1710 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
1711 | 1711 | |
1712 | 1712 | $content['participants']['no_add'] = true; |
1713 | 1713 | |
1714 | - if(!$event['whole_day']) |
|
1714 | + if (!$event['whole_day']) |
|
1715 | 1715 | { |
1716 | 1716 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
1717 | 1717 | } |
1718 | 1718 | |
1719 | 1719 | // respect category permissions |
1720 | - if(!empty($event['category'])) |
|
1720 | + if (!empty($event['category'])) |
|
1721 | 1721 | { |
1722 | 1722 | $content['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']); |
1723 | 1723 | } |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | |
1729 | 1729 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1730 | 1730 | { |
1731 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1731 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1732 | 1732 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
1733 | 1733 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
1734 | 1734 | } |
@@ -1753,13 +1753,13 @@ discard block |
||
1753 | 1753 | { |
1754 | 1754 | $readonlys['action'] = true; |
1755 | 1755 | } |
1756 | - if (!($readonlys['button[exception]'] = !$this->bo->check_perms(EGW_ACL_EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
|
1756 | + if (!($readonlys['button[exception]'] = !$this->bo->check_perms(EGW_ACL_EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate']))) |
|
1757 | 1757 | { |
1758 | 1758 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
1759 | 1759 | } |
1760 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(EGW_ACL_DELETE,$event); |
|
1760 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(EGW_ACL_DELETE, $event); |
|
1761 | 1761 | |
1762 | - if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1762 | + if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT, $event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1763 | 1763 | { |
1764 | 1764 | $sel_options['owner'][0] = lang('All participants'); |
1765 | 1765 | } |
@@ -1767,25 +1767,25 @@ discard block |
||
1767 | 1767 | { |
1768 | 1768 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
1769 | 1769 | } |
1770 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
1770 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
1771 | 1771 | { |
1772 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(EGW_ACL_EDIT,0,$uid)) |
|
1772 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(EGW_ACL_EDIT, 0, $uid)) |
|
1773 | 1773 | { |
1774 | 1774 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
1775 | 1775 | } |
1776 | 1776 | } |
1777 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1777 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1778 | 1778 | if (!$event['id']) |
1779 | 1779 | { |
1780 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
1780 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
1781 | 1781 | } |
1782 | 1782 | if ($preserved['no_popup']) |
1783 | 1783 | { |
1784 | - $etpl->set_cell_attribute('button[cancel]','onclick',''); |
|
1784 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', ''); |
|
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | // Allow admins to restore deleted events |
1788 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
1788 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
1789 | 1789 | { |
1790 | 1790 | $content['deleted'] = $preserved['deleted'] = null; |
1791 | 1791 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1801,7 +1801,7 @@ discard block |
||
1801 | 1801 | //echo "preserv="; _debug_array($preserved); |
1802 | 1802 | //echo "readonlys="; _debug_array($readonlys); |
1803 | 1803 | //echo "sel_options="; _debug_array($sel_options); |
1804 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
1804 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
1805 | 1805 | . (!$event['id'] ? lang('Add') |
1806 | 1806 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
1807 | 1807 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1817,15 +1817,15 @@ discard block |
||
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
1820 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1820 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1821 | 1821 | { |
1822 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1822 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1823 | 1823 | $content['button']['save'] = true; |
1824 | - $this->process_edit(array_merge($content,$preserved)); |
|
1824 | + $this->process_edit(array_merge($content, $preserved)); |
|
1825 | 1825 | } |
1826 | 1826 | else |
1827 | 1827 | { |
1828 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
1828 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
1829 | 1829 | } |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1835,14 +1835,14 @@ discard block |
||
1835 | 1835 | * @param int $id |
1836 | 1836 | * @param string $token |
1837 | 1837 | */ |
1838 | - function ajax_unlock($id,$token) |
|
1838 | + function ajax_unlock($id, $token) |
|
1839 | 1839 | { |
1840 | - $lock_path = egw_vfs::app_entry_lock_path('calendar',$id); |
|
1840 | + $lock_path = egw_vfs::app_entry_lock_path('calendar', $id); |
|
1841 | 1841 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1842 | 1842 | |
1843 | 1843 | if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
1844 | 1844 | { |
1845 | - egw_vfs::unlock($lock_path,$token,false); |
|
1845 | + egw_vfs::unlock($lock_path, $token, false); |
|
1846 | 1846 | } |
1847 | 1847 | } |
1848 | 1848 | |
@@ -1854,17 +1854,17 @@ discard block |
||
1854 | 1854 | * are called by new mail-app; and we intend to use the stuff passed on by session |
1855 | 1855 | * @param string $msg = null |
1856 | 1856 | */ |
1857 | - function meeting(array $event=null, $msg=null) |
|
1857 | + function meeting(array $event = null, $msg = null) |
|
1858 | 1858 | { |
1859 | 1859 | $user = $GLOBALS['egw_info']['user']['account_id']; |
1860 | 1860 | $readonlys['button[apply]'] = true; |
1861 | - $_usesession=!is_array($event); |
|
1861 | + $_usesession = !is_array($event); |
|
1862 | 1862 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
1863 | 1863 | //are called by new mail-app; and we intend to use the stuff passed on by session |
1864 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
1864 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
1865 | 1865 | { |
1866 | - $event=null; // set to null |
|
1867 | - $_usesession=true; // trigger session read |
|
1866 | + $event = null; // set to null |
|
1867 | + $_usesession = true; // trigger session read |
|
1868 | 1868 | } |
1869 | 1869 | if (!is_array($event)) |
1870 | 1870 | { |
@@ -1893,7 +1893,7 @@ discard block |
||
1893 | 1893 | |
1894 | 1894 | if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted']) |
1895 | 1895 | { |
1896 | - switch(strtolower($ical_method)) |
|
1896 | + switch (strtolower($ical_method)) |
|
1897 | 1897 | { |
1898 | 1898 | case 'reply': |
1899 | 1899 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -1947,19 +1947,19 @@ discard block |
||
1947 | 1947 | } |
1948 | 1948 | else // event not in calendar |
1949 | 1949 | { |
1950 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
1950 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
1951 | 1951 | } |
1952 | 1952 | $event['participant_types'] = array(); |
1953 | - foreach($event['participants'] as $uid => $status) |
|
1953 | + foreach ($event['participants'] as $uid => $status) |
|
1954 | 1954 | { |
1955 | 1955 | $user_type = $user_id = null; |
1956 | 1956 | calendar_so::split_user($uid, $user_type, $user_id); |
1957 | 1957 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
1958 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
1958 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
1959 | 1959 | } |
1960 | 1960 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
1961 | 1961 | $event['recure'] = $this->bo->recure2string($event); |
1962 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
1962 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
1963 | 1963 | |
1964 | 1964 | // ignore events in the past (for recurring events check enddate!) |
1965 | 1965 | if ($this->bo->date2ts($event['start']) < $this->bo->now_su && |
@@ -1979,23 +1979,23 @@ discard block |
||
1979 | 1979 | // clear notification errors |
1980 | 1980 | notifications::errors(true); |
1981 | 1981 | |
1982 | - switch($button) |
|
1982 | + switch ($button) |
|
1983 | 1983 | { |
1984 | 1984 | case 'reject': |
1985 | 1985 | if (!$event['id']) |
1986 | 1986 | { |
1987 | 1987 | // send reply to organizer |
1988 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
1989 | - break; // no need to store rejected event |
|
1988 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
1989 | + break; // no need to store rejected event |
|
1990 | 1990 | } |
1991 | 1991 | // fall-through |
1992 | 1992 | case 'accept': |
1993 | 1993 | case 'tentativ': |
1994 | - $status = strtoupper($button[0]); // A, R or T |
|
1994 | + $status = strtoupper($button[0]); // A, R or T |
|
1995 | 1995 | if (!$event['id']) |
1996 | 1996 | { |
1997 | 1997 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
1998 | - if (isset($event['owner']) && !$this->bo->check_perms(EGW_ACL_ADD,0,$event['owner'])) |
|
1998 | + if (isset($event['owner']) && !$this->bo->check_perms(EGW_ACL_ADD, 0, $event['owner'])) |
|
1999 | 1999 | { |
2000 | 2000 | // --> make organize a participant with role chair and current user the owner |
2001 | 2001 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2003,7 +2003,7 @@ discard block |
||
2003 | 2003 | $event['owner'] = $this->user; |
2004 | 2004 | } |
2005 | 2005 | // store event without notifications! |
2006 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2006 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2007 | 2007 | { |
2008 | 2008 | $msg[] = lang('Event saved'); |
2009 | 2009 | } |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | egw_framework::message(implode("\n", (array)$msg)); |
2042 | 2042 | $readonlys['button[edit]'] = !$event['id']; |
2043 | 2043 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
2044 | - switch(strtolower($ical_method)) |
|
2044 | + switch (strtolower($ical_method)) |
|
2045 | 2045 | { |
2046 | 2046 | case 'reply': |
2047 | 2047 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2065,37 +2065,37 @@ discard block |
||
2065 | 2065 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
2066 | 2066 | * @param array $preserv data to preserv |
2067 | 2067 | */ |
2068 | - function conflicts($event,$conflicts,$preserv) |
|
2068 | + function conflicts($event, $conflicts, $preserv) |
|
2069 | 2069 | { |
2070 | - $etpl = CreateObject('etemplate.etemplate_new','calendar.conflicts'); |
|
2070 | + $etpl = CreateObject('etemplate.etemplate_new', 'calendar.conflicts'); |
|
2071 | 2071 | $allConflicts = array(); |
2072 | 2072 | |
2073 | - foreach($conflicts as $k => $conflict) |
|
2073 | + foreach ($conflicts as $k => $conflict) |
|
2074 | 2074 | { |
2075 | - $is_readable = $this->bo->check_perms(EGW_ACL_READ,$conflict); |
|
2075 | + $is_readable = $this->bo->check_perms(EGW_ACL_READ, $conflict); |
|
2076 | 2076 | |
2077 | 2077 | $conflicts[$k] += array( |
2078 | 2078 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
2079 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
2080 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
2081 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
2082 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
2083 | - ),true,true)), // show group invitations too |
|
2079 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
2080 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
2081 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
2082 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
2083 | + ), true, true)), // show group invitations too |
|
2084 | 2084 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
2085 | 2085 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
2086 | 2086 | ); |
2087 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
2087 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
2088 | 2088 | } |
2089 | 2089 | $content = $event + array( |
2090 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2090 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2091 | 2091 | ); |
2092 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
2092 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
2093 | 2093 | $resources_config = config::read('resources'); |
2094 | 2094 | $readonlys = array(); |
2095 | 2095 | |
2096 | 2096 | foreach (array_keys($allConflicts) as $pId) |
2097 | 2097 | { |
2098 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
2098 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
2099 | 2099 | { |
2100 | 2100 | |
2101 | 2101 | switch ($resources_config['ignoreconflicts']) |
@@ -2115,7 +2115,7 @@ discard block |
||
2115 | 2115 | } |
2116 | 2116 | } |
2117 | 2117 | } |
2118 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
2118 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
2119 | 2119 | } |
2120 | 2120 | |
2121 | 2121 | /** |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
2134 | 2134 | |
2135 | 2135 | // convert start/end date-time values to timestamps |
2136 | - foreach(array('start', 'end') as $name) |
|
2136 | + foreach (array('start', 'end') as $name) |
|
2137 | 2137 | { |
2138 | 2138 | if (!empty($edit_content[$name])) |
2139 | 2139 | { |
@@ -2163,7 +2163,7 @@ discard block |
||
2163 | 2163 | 'recur_type' => $edit_content['recur_type'], |
2164 | 2164 | 'participants' => array(), |
2165 | 2165 | ); |
2166 | - foreach($edit_content['participants'] as $key => $data) |
|
2166 | + foreach ($edit_content['participants'] as $key => $data) |
|
2167 | 2167 | { |
2168 | 2168 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
2169 | 2169 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2178,21 +2178,21 @@ discard block |
||
2178 | 2178 | // default search parameters |
2179 | 2179 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
2180 | 2180 | $content['end_time'] = $this->cal_prefs['workdayends']; |
2181 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
2181 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
2182 | 2182 | { |
2183 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2183 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2184 | 2184 | } |
2185 | 2185 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
2186 | 2186 | |
2187 | 2187 | $content['search_window'] = 7 * DAY_s; |
2188 | 2188 | |
2189 | 2189 | // store content in session |
2190 | - egw_cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
2190 | + egw_cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
2191 | 2191 | |
2192 | 2192 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
2193 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
2193 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
2194 | 2194 | |
2195 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
2195 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
2196 | 2196 | |
2197 | 2197 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
2198 | 2198 | |
@@ -2215,26 +2215,26 @@ discard block |
||
2215 | 2215 | { |
2216 | 2216 | $etpl = new etemplate_new('calendar.freetimesearch'); |
2217 | 2217 | $sel_options['search_window'] = array( |
2218 | - 7*DAY_s => lang('one week'), |
|
2219 | - 14*DAY_s => lang('two weeks'), |
|
2220 | - 31*DAY_s => lang('one month'), |
|
2221 | - 92*DAY_s => lang('three month'), |
|
2222 | - 365*DAY_s => lang('one year'), |
|
2218 | + 7 * DAY_s => lang('one week'), |
|
2219 | + 14 * DAY_s => lang('two weeks'), |
|
2220 | + 31 * DAY_s => lang('one month'), |
|
2221 | + 92 * DAY_s => lang('three month'), |
|
2222 | + 365 * DAY_s => lang('one year'), |
|
2223 | 2223 | ); |
2224 | 2224 | if (!is_array($content)) |
2225 | 2225 | { |
2226 | 2226 | // get content from session (and delete it immediatly) |
2227 | - $content = egw_cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2228 | - egw_cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2227 | + $content = egw_cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2228 | + egw_cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2229 | 2229 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
2230 | 2230 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
2231 | 2231 | $sTime = $content['start_time']; |
2232 | 2232 | $eTime = $content['end_time']; |
2233 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
2234 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
2233 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
2234 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
2235 | 2235 | |
2236 | 2236 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
2237 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
2237 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
2238 | 2238 | { |
2239 | 2239 | if ($window > $content['duration']) |
2240 | 2240 | { |
@@ -2261,19 +2261,19 @@ discard block |
||
2261 | 2261 | { |
2262 | 2262 | $content['msg'] .= lang('Only the initial date of that recuring event is checked!'); |
2263 | 2263 | } |
2264 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
2265 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
2264 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
2265 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
2266 | 2266 | |
2267 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
2267 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
2268 | 2268 | |
2269 | 2269 | $sel_options['duration'] = $this->durations; |
2270 | 2270 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
2271 | 2271 | |
2272 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
2272 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
2273 | 2273 | 'participants' => $content['participants'], |
2274 | 2274 | 'cal_id' => $content['cal_id'], |
2275 | 2275 | 'recur_type' => $content['recur_type'], |
2276 | - ),2); |
|
2276 | + ), 2); |
|
2277 | 2277 | } |
2278 | 2278 | |
2279 | 2279 | /** |
@@ -2286,15 +2286,15 @@ discard block |
||
2286 | 2286 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
2287 | 2287 | * @return array of free time-slots: array with start and end values |
2288 | 2288 | */ |
2289 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
2289 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
2290 | 2290 | { |
2291 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2291 | + if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id); |
|
2292 | 2292 | |
2293 | 2293 | $busy = $this->bo->search(array( |
2294 | 2294 | 'start' => $start, |
2295 | 2295 | 'end' => $end, |
2296 | 2296 | 'users' => $participants, |
2297 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2297 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2298 | 2298 | )); |
2299 | 2299 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
2300 | 2300 | 'start' => $end, |
@@ -2303,15 +2303,15 @@ discard block |
||
2303 | 2303 | $ft_start = $start; |
2304 | 2304 | $freetime = array(); |
2305 | 2305 | $n = 0; |
2306 | - foreach($busy as $event) |
|
2306 | + foreach ($busy as $event) |
|
2307 | 2307 | { |
2308 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2308 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2309 | 2309 | |
2310 | 2310 | if ($event['non_blocking']) continue; // ignore non_blocking events |
2311 | 2311 | |
2312 | 2312 | // check if from all wanted participants at least one has a not rejected status in found event |
2313 | 2313 | $non_rejected_found = false; |
2314 | - foreach($participants as $uid) |
|
2314 | + foreach ($participants as $uid) |
|
2315 | 2315 | { |
2316 | 2316 | if ($event['participants'][$uid] == 'R') continue; |
2317 | 2317 | |
@@ -2327,10 +2327,10 @@ discard block |
||
2327 | 2327 | |
2328 | 2328 | if ($this->debug) |
2329 | 2329 | { |
2330 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
2330 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
2331 | 2331 | echo "event[title]=$event[title]<br>\n"; |
2332 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
2333 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
2332 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
2333 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
2334 | 2334 | } |
2335 | 2335 | // $events ends before our actual position ==> ignore it |
2336 | 2336 | if ($event['end'] < $ft_start) |
@@ -2354,11 +2354,11 @@ discard block |
||
2354 | 2354 | 'start' => $ft_start, |
2355 | 2355 | 'end' => $ft_end, |
2356 | 2356 | ); |
2357 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2357 | + if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n"; |
|
2358 | 2358 | } |
2359 | 2359 | $ft_start = $event['end']; |
2360 | 2360 | } |
2361 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2361 | + if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime); |
|
2362 | 2362 | |
2363 | 2363 | return $freetime; |
2364 | 2364 | } |
@@ -2378,46 +2378,46 @@ discard block |
||
2378 | 2378 | */ |
2379 | 2379 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
2380 | 2380 | { |
2381 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2381 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time); |
|
2382 | 2382 | |
2383 | 2383 | $freetime_daywise = array(); |
2384 | 2384 | if (!is_array($sel_options)) $sel_options = array(); |
2385 | 2385 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
2386 | 2386 | |
2387 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
2388 | - $end_time = (int) $_end_time; |
|
2387 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
2388 | + $end_time = (int)$_end_time; |
|
2389 | 2389 | |
2390 | 2390 | // ignore the end_time, if duration would never fit |
2391 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
2391 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
2392 | 2392 | { |
2393 | 2393 | $end_time = 0; |
2394 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2394 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time); |
|
2395 | 2395 | } |
2396 | 2396 | $n = 0; |
2397 | - foreach($freetime as $ft) |
|
2397 | + foreach ($freetime as $ft) |
|
2398 | 2398 | { |
2399 | 2399 | $adaybegin = $this->bo->date2array($ft['start']); |
2400 | 2400 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
2401 | 2401 | unset($adaybegin['raw']); |
2402 | 2402 | $daybegin = $this->bo->date2ts($adaybegin); |
2403 | 2403 | |
2404 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
2404 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
2405 | 2405 | { |
2406 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
2407 | - $mcal_dow = pow(2,$dow); |
|
2408 | - if (!($weekdays & $mcal_dow)) |
|
2406 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
2407 | + $mcal_dow = pow(2, $dow); |
|
2408 | + if (!($weekdays&$mcal_dow)) |
|
2409 | 2409 | { |
2410 | 2410 | //echo "wrong day of week $dow<br>\n"; |
2411 | - continue; // wrong day of week |
|
2411 | + continue; // wrong day of week |
|
2412 | 2412 | } |
2413 | 2413 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
2414 | 2414 | |
2415 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
2415 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
2416 | 2416 | { |
2417 | - $start = $daybegin + $start_time*HOUR_s; |
|
2417 | + $start = $daybegin + $start_time * HOUR_s; |
|
2418 | 2418 | } |
2419 | 2419 | // if end_time given use it, else the original slot's end |
2420 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
2420 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
2421 | 2421 | if ($end > $ft['end']) $end = $ft['end']; |
2422 | 2422 | |
2423 | 2423 | // slot to small for duration |
@@ -2431,11 +2431,11 @@ discard block |
||
2431 | 2431 | 'end' => $end, |
2432 | 2432 | ); |
2433 | 2433 | $times = array(); |
2434 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
2434 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
2435 | 2435 | { |
2436 | 2436 | $e = $s + $duration; |
2437 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
2438 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
2437 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
2438 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
2439 | 2439 | } |
2440 | 2440 | $sel_options[$n.'start'] = $times; |
2441 | 2441 | } |
@@ -2450,13 +2450,13 @@ discard block |
||
2450 | 2450 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
2451 | 2451 | * @return string error-msg if $return_error |
2452 | 2452 | */ |
2453 | - function export($content=0,$return_error=false) |
|
2453 | + function export($content = 0, $return_error = false) |
|
2454 | 2454 | { |
2455 | 2455 | $boical = new calendar_ical(); |
2456 | 2456 | #error_log(__METHOD__.print_r($content,true)); |
2457 | 2457 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
2458 | 2458 | { |
2459 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
2459 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
2460 | 2460 | { |
2461 | 2461 | $msg = lang('Permission denied'); |
2462 | 2462 | |
@@ -2464,20 +2464,20 @@ discard block |
||
2464 | 2464 | } |
2465 | 2465 | else |
2466 | 2466 | { |
2467 | - html::content_header('event.ics','text/calendar',bytes($ical)); |
|
2467 | + html::content_header('event.ics', 'text/calendar', bytes($ical)); |
|
2468 | 2468 | echo $ical; |
2469 | 2469 | common::egw_exit(); |
2470 | 2470 | } |
2471 | 2471 | } |
2472 | 2472 | if (is_array($content)) |
2473 | 2473 | { |
2474 | - $events =& $this->bo->search(array( |
|
2474 | + $events = & $this->bo->search(array( |
|
2475 | 2475 | 'start' => $content['start'], |
2476 | 2476 | 'end' => $content['end'], |
2477 | 2477 | 'enum_recuring' => false, |
2478 | 2478 | 'daywise' => false, |
2479 | 2479 | 'owner' => $this->owner, |
2480 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
2480 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
2481 | 2481 | )); |
2482 | 2482 | if (!$events) |
2483 | 2483 | { |
@@ -2485,8 +2485,8 @@ discard block |
||
2485 | 2485 | } |
2486 | 2486 | else |
2487 | 2487 | { |
2488 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
2489 | - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
2488 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
2489 | + html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
2490 | 2490 | echo $ical; |
2491 | 2491 | common::egw_exit(); |
2492 | 2492 | } |
@@ -2502,9 +2502,9 @@ discard block |
||
2502 | 2502 | } |
2503 | 2503 | $content['msg'] = $msg; |
2504 | 2504 | |
2505 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
2505 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
2506 | 2506 | $etpl = new etemplate_new('calendar.export'); |
2507 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
2507 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | /** |
@@ -2512,25 +2512,25 @@ discard block |
||
2512 | 2512 | * |
2513 | 2513 | * @param array $content submitted content from etempalte::exec |
2514 | 2514 | */ |
2515 | - function import($content=null) |
|
2515 | + function import($content = null) |
|
2516 | 2516 | { |
2517 | 2517 | if (is_array($content)) |
2518 | 2518 | { |
2519 | 2519 | if (is_array($content['ical_file']) && is_uploaded_file($content['ical_file']['tmp_name'])) |
2520 | 2520 | { |
2521 | - @set_time_limit(0); // try switching execution time limit off |
|
2521 | + @set_time_limit(0); // try switching execution time limit off |
|
2522 | 2522 | $start = microtime(true); |
2523 | 2523 | |
2524 | 2524 | $calendar_ical = new calendar_ical; |
2525 | 2525 | $calendar_ical->setSupportedFields('file', ''); |
2526 | - if (!$calendar_ical->importVCal($f=fopen($content['ical_file']['tmp_name'],'r'))) |
|
2526 | + if (!$calendar_ical->importVCal($f = fopen($content['ical_file']['tmp_name'], 'r'))) |
|
2527 | 2527 | { |
2528 | 2528 | $msg = lang('Error: importing the iCal'); |
2529 | 2529 | } |
2530 | 2530 | else |
2531 | 2531 | { |
2532 | 2532 | $msg = lang('iCal successful imported').' '.lang('(%1 events in %2 seconds)', |
2533 | - $calendar_ical->events_imported,number_format(microtime(true)-$start,1)); |
|
2533 | + $calendar_ical->events_imported, number_format(microtime(true) - $start, 1)); |
|
2534 | 2534 | } |
2535 | 2535 | if ($f) fclose($f); |
2536 | 2536 | } |
@@ -2539,7 +2539,7 @@ discard block |
||
2539 | 2539 | $msg = lang('You need to select an iCal file first'); |
2540 | 2540 | } |
2541 | 2541 | } |
2542 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Import'); |
|
2542 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Import'); |
|
2543 | 2543 | $etpl = new etemplate_new('calendar.import'); |
2544 | 2544 | |
2545 | 2545 | $etpl->exec('calendar.calendar_uiforms.import', array( |
@@ -2552,7 +2552,7 @@ discard block |
||
2552 | 2552 | * |
2553 | 2553 | * @param array $_content |
2554 | 2554 | */ |
2555 | - function cat_acl(array $_content=null) |
|
2555 | + function cat_acl(array $_content = null) |
|
2556 | 2556 | { |
2557 | 2557 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
2558 | 2558 | { |
@@ -2564,15 +2564,15 @@ discard block |
||
2564 | 2564 | unset($_content['button']); |
2565 | 2565 | if ($button != 'cancel') // store changed acl |
2566 | 2566 | { |
2567 | - foreach($_content as $data) |
|
2567 | + foreach ($_content as $data) |
|
2568 | 2568 | { |
2569 | 2569 | if (!($cat_id = $data['cat_id'])) continue; |
2570 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
2570 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
2571 | 2571 | { |
2572 | 2572 | $rights = 0; |
2573 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2574 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2575 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2573 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2574 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2575 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
2576 | 2576 | } |
2577 | 2577 | } |
2578 | 2578 | } |
@@ -2584,20 +2584,20 @@ discard block |
||
2584 | 2584 | ), 'admin'); |
2585 | 2585 | } |
2586 | 2586 | } |
2587 | - $content= $preserv = array(); |
|
2587 | + $content = $preserv = array(); |
|
2588 | 2588 | $n = 1; |
2589 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2589 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2590 | 2590 | { |
2591 | - $cat_id = substr($Lcat_id,1); |
|
2591 | + $cat_id = substr($Lcat_id, 1); |
|
2592 | 2592 | $row = array( |
2593 | 2593 | 'cat_id' => $cat_id, |
2594 | 2594 | 'add' => array(), |
2595 | 2595 | 'status' => array(), |
2596 | 2596 | ); |
2597 | - foreach($data as $account_id => $rights) |
|
2597 | + foreach ($data as $account_id => $rights) |
|
2598 | 2598 | { |
2599 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2600 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2599 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2600 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2601 | 2601 | } |
2602 | 2602 | $content[$n] = $row; |
2603 | 2603 | $preserv[$n] = array( |
@@ -2612,7 +2612,7 @@ discard block |
||
2612 | 2612 | |
2613 | 2613 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
2614 | 2614 | $tmp = new etemplate_new('calendar.cat_acl'); |
2615 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
2615 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
2616 | 2616 | } |
2617 | 2617 | |
2618 | 2618 | /** |
@@ -2662,18 +2662,18 @@ discard block |
||
2662 | 2662 | |
2663 | 2663 | |
2664 | 2664 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
2665 | - if($content['recur_type'] || $content['recurrence']) |
|
2665 | + if ($content['recur_type'] || $content['recurrence']) |
|
2666 | 2666 | { |
2667 | 2667 | $content['history']['filter'] = array( |
2668 | 2668 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
2669 | - history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
2670 | - history_old_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
2669 | + history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
2670 | + history_old_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
2671 | 2671 | ); |
2672 | 2672 | } |
2673 | 2673 | |
2674 | 2674 | // Translate labels |
2675 | 2675 | $tracking = new calendar_tracking(); |
2676 | - foreach($tracking->field2label as $field => $label) |
|
2676 | + foreach ($tracking->field2label as $field => $label) |
|
2677 | 2677 | { |
2678 | 2678 | $sel_options[$status][$field] = lang($label); |
2679 | 2679 | } |
@@ -2690,20 +2690,20 @@ discard block |
||
2690 | 2690 | * @param string $durationT the duration to support resizable calendar event |
2691 | 2691 | * @return string XML response if no error occurs |
2692 | 2692 | */ |
2693 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null) |
|
2693 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null) |
|
2694 | 2694 | { |
2695 | 2695 | // we do not allow dragging into another users calendar ATM |
2696 | - if(!$calendarOwner == $targetOwner) |
|
2696 | + if (!$calendarOwner == $targetOwner) |
|
2697 | 2697 | { |
2698 | 2698 | return false; |
2699 | 2699 | } |
2700 | 2700 | |
2701 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
2701 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
2702 | 2702 | |
2703 | - $old_event=$event=$this->bo->read($eventId); |
|
2703 | + $old_event = $event = $this->bo->read($eventId); |
|
2704 | 2704 | if (!$durationT) |
2705 | 2705 | { |
2706 | - $duration=$event['end']-$event['start']; |
|
2706 | + $duration = $event['end'] - $event['start']; |
|
2707 | 2707 | } |
2708 | 2708 | else |
2709 | 2709 | { |
@@ -2712,13 +2712,13 @@ discard block |
||
2712 | 2712 | |
2713 | 2713 | $event['start'] = $this->bo->date2ts($targetDateTime); |
2714 | 2714 | |
2715 | - $event['end'] = $event['start']+$duration; |
|
2715 | + $event['end'] = $event['start'] + $duration; |
|
2716 | 2716 | |
2717 | 2717 | if ($event['recur_type'] != MCAL_RECUR_NONE && $date) |
2718 | 2718 | { |
2719 | 2719 | // calculate offset against clicked recurrance, |
2720 | 2720 | // depending on which is smaller |
2721 | - $offset = egw_time::to($targetDateTime,'ts') - egw_time::to($date,'ts'); |
|
2721 | + $offset = egw_time::to($targetDateTime, 'ts') - egw_time::to($date, 'ts'); |
|
2722 | 2722 | $event['start'] = $old_event['start'] + $offset; |
2723 | 2723 | $event['duration'] = $duration; |
2724 | 2724 | |
@@ -2728,13 +2728,13 @@ discard block |
||
2728 | 2728 | } |
2729 | 2729 | $status_reset_to_unknown = false; |
2730 | 2730 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
2731 | - foreach((array)$event['participants'] as $uid => $status) |
|
2731 | + foreach ((array)$event['participants'] as $uid => $status) |
|
2732 | 2732 | { |
2733 | 2733 | $q = $r = null; |
2734 | - calendar_so::split_status($status,$q,$r); |
|
2734 | + calendar_so::split_status($status, $q, $r); |
|
2735 | 2735 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
2736 | 2736 | { |
2737 | - $preferences = CreateObject('phpgwapi.preferences',$uid); |
|
2737 | + $preferences = CreateObject('phpgwapi.preferences', $uid); |
|
2738 | 2738 | $part_prefs = $preferences->read_repository(); |
2739 | 2739 | switch ($part_prefs['calendar']['reset_stati']) |
2740 | 2740 | { |
@@ -2744,18 +2744,18 @@ discard block |
||
2744 | 2744 | if ($sameday) break; |
2745 | 2745 | default: |
2746 | 2746 | $status_reset_to_unknown = true; |
2747 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
2747 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
2748 | 2748 | // todo: report reset status to user |
2749 | 2749 | } |
2750 | 2750 | } |
2751 | 2751 | } |
2752 | 2752 | |
2753 | - $conflicts=$this->bo->update($event); |
|
2753 | + $conflicts = $this->bo->update($event); |
|
2754 | 2754 | |
2755 | 2755 | $response = egw_json_response::get(); |
2756 | - if(!is_array($conflicts)) |
|
2756 | + if (!is_array($conflicts)) |
|
2757 | 2757 | { |
2758 | - $response->redirect(egw::link('/index.php',array( |
|
2758 | + $response->redirect(egw::link('/index.php', array( |
|
2759 | 2759 | 'menuaction' => $this->view_menuaction, |
2760 | 2760 | ))); |
2761 | 2761 | } |
@@ -2769,16 +2769,16 @@ discard block |
||
2769 | 2769 | .'&end='.$event['end'] |
2770 | 2770 | .'&non_interactive=true' |
2771 | 2771 | .'&cancel_needs_refresh=true', |
2772 | - '',750,410); |
|
2772 | + '', 750, 410); |
|
2773 | 2773 | } |
2774 | 2774 | if ($status_reset_to_unknown) |
2775 | 2775 | { |
2776 | - foreach((array)$event['participants'] as $uid => $status) |
|
2776 | + foreach ((array)$event['participants'] as $uid => $status) |
|
2777 | 2777 | { |
2778 | 2778 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
2779 | 2779 | { |
2780 | - calendar_so::split_status($status,$q,$r); |
|
2781 | - $status = calendar_so::combine_status('U',$q,$r); |
|
2780 | + calendar_so::split_status($status, $q, $r); |
|
2781 | + $status = calendar_so::combine_status('U', $q, $r); |
|
2782 | 2782 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
2783 | 2783 | } |
2784 | 2784 | } |
@@ -2796,35 +2796,35 @@ discard block |
||
2796 | 2796 | // Arbitrarily limited to 50 / resource |
2797 | 2797 | $options = array('start' => 0, 'num_rows' => 50); |
2798 | 2798 | $results = array(); |
2799 | - if($query) |
|
2799 | + if ($query) |
|
2800 | 2800 | { |
2801 | - $resources = array_merge(array('' => $this->bo->resources['']),$this->bo->resources); |
|
2802 | - foreach($resources as $type => $data) |
|
2801 | + $resources = array_merge(array('' => $this->bo->resources['']), $this->bo->resources); |
|
2802 | + foreach ($resources as $type => $data) |
|
2803 | 2803 | { |
2804 | 2804 | $mapped = array(); |
2805 | 2805 | $_results = array(); |
2806 | 2806 | |
2807 | 2807 | // Handle accounts seperately |
2808 | - if($type == '') |
|
2808 | + if ($type == '') |
|
2809 | 2809 | { |
2810 | 2810 | $list = array('accounts', 'owngroups'); |
2811 | - foreach($list as $a_type) |
|
2811 | + foreach ($list as $a_type) |
|
2812 | 2812 | { |
2813 | 2813 | $account_options = $options + array('account_type' => $a_type); |
2814 | - $_results += accounts::link_query('',$account_options); |
|
2814 | + $_results += accounts::link_query('', $account_options); |
|
2815 | 2815 | } |
2816 | 2816 | $_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar')); |
2817 | 2817 | } |
2818 | 2818 | else if ($data['app'] && egw_link::get_registry($data['app'], 'query')) |
2819 | 2819 | { |
2820 | - $_results = egw_link::query($data['app'], $query,$options); |
|
2820 | + $_results = egw_link::query($data['app'], $query, $options); |
|
2821 | 2821 | } |
2822 | - if(!$_results) continue; |
|
2822 | + if (!$_results) continue; |
|
2823 | 2823 | $_results = array_unique($_results); |
2824 | 2824 | |
2825 | - foreach($_results as $id => $title) |
|
2825 | + foreach ($_results as $id => $title) |
|
2826 | 2826 | { |
2827 | - if($id && $title) |
|
2827 | + if ($id && $title) |
|
2828 | 2828 | { |
2829 | 2829 | // Magicsuggest uses id, not value. |
2830 | 2830 | $value = array( |
@@ -2833,14 +2833,14 @@ discard block |
||
2833 | 2833 | 'label' => $title, |
2834 | 2834 | 'app' => lang($data['app']) |
2835 | 2835 | ); |
2836 | - if(is_array($value['label'])) |
|
2836 | + if (is_array($value['label'])) |
|
2837 | 2837 | { |
2838 | 2838 | $value = array_merge($value, $value['label']); |
2839 | 2839 | } |
2840 | 2840 | $mapped[] = $value; |
2841 | 2841 | } |
2842 | 2842 | } |
2843 | - if(count($mapped)) |
|
2843 | + if (count($mapped)) |
|
2844 | 2844 | { |
2845 | 2845 | $results = array_merge($results, $mapped); |
2846 | 2846 | } |
@@ -2860,13 +2860,13 @@ discard block |
||
2860 | 2860 | * @param array $mailContent = null mail content |
2861 | 2861 | * @return array |
2862 | 2862 | */ |
2863 | - function mail_import(array $mailContent=null) |
|
2863 | + function mail_import(array $mailContent = null) |
|
2864 | 2864 | { |
2865 | 2865 | // It would get called from compose as a popup with egw_data |
2866 | 2866 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
2867 | 2867 | { |
2868 | 2868 | // get raw mail data |
2869 | - egw_link::get_data ($_GET['egw_data']); |
|
2869 | + egw_link::get_data($_GET['egw_data']); |
|
2870 | 2870 | return false; |
2871 | 2871 | } |
2872 | 2872 | |
@@ -2876,7 +2876,7 @@ discard block |
||
2876 | 2876 | $AB = new addressbook_bo(); |
2877 | 2877 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
2878 | 2878 | |
2879 | - $participants[0] = array ( |
|
2879 | + $participants[0] = array( |
|
2880 | 2880 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
2881 | 2881 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
2882 | 2882 | 'status' => 'A', |
@@ -2884,23 +2884,23 @@ discard block |
||
2884 | 2884 | 'app' => 'User', |
2885 | 2885 | 'role' => 'REQ-PARTICIPANT' |
2886 | 2886 | ); |
2887 | - foreach($mailContent['addresses'] as $address) |
|
2887 | + foreach ($mailContent['addresses'] as $address) |
|
2888 | 2888 | { |
2889 | 2889 | // Get available contacts from the email |
2890 | 2890 | $contacts = $AB->search(array( |
2891 | 2891 | 'email' => $address['email'], |
2892 | 2892 | 'email_home' => $address['email'] |
2893 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
2893 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
2894 | 2894 | if (is_array($contacts)) |
2895 | 2895 | { |
2896 | - foreach($contacts as $account) |
|
2896 | + foreach ($contacts as $account) |
|
2897 | 2897 | { |
2898 | 2898 | $accounts[] = $account['account_id']; |
2899 | 2899 | } |
2900 | 2900 | } |
2901 | 2901 | else |
2902 | 2902 | { |
2903 | - $participants []= array ( |
|
2903 | + $participants [] = array( |
|
2904 | 2904 | 'app' => 'email', |
2905 | 2905 | 'uid' => 'e'.$address['email'], |
2906 | 2906 | 'status' => 'U', |
@@ -2908,7 +2908,7 @@ discard block |
||
2908 | 2908 | ); |
2909 | 2909 | } |
2910 | 2910 | } |
2911 | - $participants = array_merge($participants , array( |
|
2911 | + $participants = array_merge($participants, array( |
|
2912 | 2912 | "account" => $accounts, |
2913 | 2913 | "role" => "REQ-PARTICIPANT", |
2914 | 2914 | "add" => "pressed" |
@@ -2932,14 +2932,14 @@ discard block |
||
2932 | 2932 | { |
2933 | 2933 | foreach ($mailContent['attachments'] as $attachment) |
2934 | 2934 | { |
2935 | - if($attachment['egw_data']) |
|
2935 | + if ($attachment['egw_data']) |
|
2936 | 2936 | { |
2937 | - egw_link::link('calendar',$event['link_to']['to_id'],egw_link::DATA_APPNAME, $attachment); |
|
2937 | + egw_link::link('calendar', $event['link_to']['to_id'], egw_link::DATA_APPNAME, $attachment); |
|
2938 | 2938 | } |
2939 | - else if(is_readable($attachment['tmp_name']) || |
|
2939 | + else if (is_readable($attachment['tmp_name']) || |
|
2940 | 2940 | (egw_vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
2941 | 2941 | { |
2942 | - egw_link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
2942 | + egw_link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
2943 | 2943 | } |
2944 | 2944 | } |
2945 | 2945 | } |
@@ -61,39 +61,39 @@ discard block |
||
61 | 61 | * @var array $priority_egw2ical conversion of the priority egw => ical |
62 | 62 | */ |
63 | 63 | var $priority_egw2ical = array( |
64 | - 0 => 0, // undefined |
|
65 | - 1 => 9, // low |
|
66 | - 2 => 5, // normal |
|
67 | - 3 => 1, // high |
|
64 | + 0 => 0, // undefined |
|
65 | + 1 => 9, // low |
|
66 | + 2 => 5, // normal |
|
67 | + 3 => 1, // high |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @var array $priority_ical2egw conversion of the priority ical => egw |
72 | 72 | */ |
73 | 73 | var $priority_ical2egw = array( |
74 | - 0 => 0, // undefined |
|
75 | - 9 => 1, 8 => 1, 7 => 1, 6 => 1, // low |
|
76 | - 5 => 2, // normal |
|
77 | - 4 => 3, 3 => 3, 2 => 3, 1 => 3, // high |
|
74 | + 0 => 0, // undefined |
|
75 | + 9 => 1, 8 => 1, 7 => 1, 6 => 1, // low |
|
76 | + 5 => 2, // normal |
|
77 | + 4 => 3, 3 => 3, 2 => 3, 1 => 3, // high |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * @var array $priority_egw2funambol conversion of the priority egw => funambol |
82 | 82 | */ |
83 | 83 | var $priority_egw2funambol = array( |
84 | - 0 => 1, // undefined (mapped to normal since undefined does not exist) |
|
85 | - 1 => 0, // low |
|
86 | - 2 => 1, // normal |
|
87 | - 3 => 2, // high |
|
84 | + 0 => 1, // undefined (mapped to normal since undefined does not exist) |
|
85 | + 1 => 0, // low |
|
86 | + 2 => 1, // normal |
|
87 | + 3 => 2, // high |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @var array $priority_funambol2egw conversion of the priority funambol => egw |
92 | 92 | */ |
93 | 93 | var $priority_funambol2egw = array( |
94 | - 0 => 1, // low |
|
95 | - 1 => 2, // normal |
|
96 | - 2 => 3, // high |
|
94 | + 0 => 1, // low |
|
95 | + 1 => 2, // normal |
|
96 | + 2 => 3, // high |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @var boolean |
164 | 164 | */ |
165 | 165 | var $log = false; |
166 | - var $logfile="/tmp/log-vcal"; |
|
166 | + var $logfile = "/tmp/log-vcal"; |
|
167 | 167 | |
168 | 168 | |
169 | 169 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY |
195 | 195 | * @return string|boolean string with iCal or false on error (e.g. no permission to read the event) |
196 | 196 | */ |
197 | - function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0) |
|
197 | + function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0) |
|
198 | 198 | { |
199 | 199 | if ($this->log) |
200 | 200 | { |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | |
226 | 226 | if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
227 | 227 | |
228 | - if ($this->productManufacturer == '' ) |
|
228 | + if ($this->productManufacturer == '') |
|
229 | 229 | { // syncevolution is broken |
230 | 230 | $version = '2.0'; |
231 | 231 | } |
232 | 232 | |
233 | 233 | $vcal = new Horde_Icalendar; |
234 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
234 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
235 | 235 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
236 | 236 | $vcal->setAttribute('VERSION', $version); |
237 | 237 | if ($method) $vcal->setAttribute('METHOD', $method); |
@@ -261,15 +261,15 @@ discard block |
||
261 | 261 | if ($this->log) |
262 | 262 | { |
263 | 263 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
264 | - '() User does not have the permission to read event ' . $event['id']. "\n", |
|
265 | - 3,$this->logfile); |
|
264 | + '() User does not have the permission to read event '.$event['id']."\n", |
|
265 | + 3, $this->logfile); |
|
266 | 266 | } |
267 | 267 | return -1; // Permission denied |
268 | 268 | } |
269 | 269 | } |
270 | 270 | else |
271 | 271 | { |
272 | - $retval = false; // Entry does not exist |
|
272 | + $retval = false; // Entry does not exist |
|
273 | 273 | if ($this->log) |
274 | 274 | { |
275 | 275 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | if ($this->log) |
284 | 284 | { |
285 | 285 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
286 | - '() export event UID: ' . $event['uid'] . ".\n", |
|
286 | + '() export event UID: '.$event['uid'].".\n", |
|
287 | 287 | 3, $this->logfile); |
288 | 288 | } |
289 | 289 | |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | if ($this->log) |
309 | 309 | { |
310 | 310 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
311 | - '(' . $event['id']. ',' . $recurrence . ")\n" . |
|
312 | - array2string($event)."\n",3,$this->logfile); |
|
311 | + '('.$event['id'].','.$recurrence.")\n". |
|
312 | + array2string($event)."\n", 3, $this->logfile); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($recurrence) |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | { |
331 | 331 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
332 | 332 | "(, $recurrence) Gratuitous pseudo exception, skipped ...\n", |
333 | - 3,$this->logfile); |
|
333 | + 3, $this->logfile); |
|
334 | 334 | } |
335 | 335 | continue; // unsupported status only exception |
336 | 336 | } |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | $days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule'); |
341 | 341 | if ($this->log) |
342 | 342 | { |
343 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
344 | - array2string($days)."\n",3,$this->logfile); |
|
343 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
344 | + array2string($days)."\n", 3, $this->logfile); |
|
345 | 345 | } |
346 | 346 | $recurrence = $days[$recurrence]; // use remote representation |
347 | 347 | } |
348 | 348 | // force single event |
349 | - foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name) |
|
349 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name) |
|
350 | 350 | { |
351 | 351 | unset($event[$name]); |
352 | 352 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | // check if tzid of event (not only recuring ones) is already added to export |
357 | - if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added)) |
|
357 | + if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added)) |
|
358 | 358 | { |
359 | 359 | // check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz) |
360 | 360 | if (calendar_timezones::add_vtimezone($vcal, $tzid) || |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | { |
373 | 373 | // Append UID to DESCRIPTION |
374 | 374 | if (!preg_match('/\[UID:.+\]/m', $event['description'])) { |
375 | - $event['description'] .= "\n[UID:" . $event['uid'] . "]"; |
|
375 | + $event['description'] .= "\n[UID:".$event['uid']."]"; |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
@@ -393,14 +393,14 @@ discard block |
||
393 | 393 | $exceptions = array(); |
394 | 394 | |
395 | 395 | // dont use "virtual" exceptions created by participant status for GroupDAV or file export |
396 | - if (!in_array($this->productManufacturer,array('file','groupdav'))) |
|
396 | + if (!in_array($this->productManufacturer, array('file', 'groupdav'))) |
|
397 | 397 | { |
398 | 398 | $filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule'; |
399 | 399 | $exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter); |
400 | 400 | if ($this->log) |
401 | 401 | { |
402 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" . |
|
403 | - array2string($exceptions)."\n",3,$this->logfile); |
|
402 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n". |
|
403 | + array2string($exceptions)."\n", 3, $this->logfile); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | elseif (is_array($event['recur_exception'])) |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | if ($this->log) |
418 | 418 | { |
419 | 419 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
420 | - '(' . $event['id'] . ") [$icalFieldName] not supported\n", |
|
421 | - 3,$this->logfile); |
|
420 | + '('.$event['id'].") [$icalFieldName] not supported\n", |
|
421 | + 3, $this->logfile); |
|
422 | 422 | } |
423 | 423 | continue; |
424 | 424 | } |
@@ -435,23 +435,23 @@ discard block |
||
435 | 435 | |
436 | 436 | if (!($info = $this->resource_info($uid))) continue; |
437 | 437 | |
438 | - if (in_array($status, array('X','E'))) continue; // dont include deleted participants |
|
438 | + if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants |
|
439 | 439 | |
440 | 440 | if ($this->log) |
441 | 441 | { |
442 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
443 | - '()attendee:' . array2string($info) ."\n",3,$this->logfile); |
|
442 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
443 | + '()attendee:'.array2string($info)."\n", 3, $this->logfile); |
|
444 | 444 | } |
445 | 445 | $participantCN = str_replace(array('\\', ',', ';', ':'), |
446 | 446 | array('\\\\', '\\,', '\\;', '\\:'), |
447 | 447 | trim(empty($info['cn']) ? $info['name'] : $info['cn'])); |
448 | 448 | if ($version == '1.0') |
449 | 449 | { |
450 | - $participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>')); |
|
450 | + $participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>')); |
|
451 | 451 | } |
452 | 452 | else |
453 | 453 | { |
454 | - $participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email']; |
|
454 | + $participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email']; |
|
455 | 455 | } |
456 | 456 | // RSVP={TRUE|FALSE} // resonse expected, not set in eGW => status=U |
457 | 457 | $rsvp = $status == 'U' ? 'TRUE' : 'FALSE'; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | ($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members)) |
480 | 480 | { |
481 | 481 | $user = $this->resource_info($this->user); |
482 | - $attributes['ATTENDEE'][] = 'mailto:' . $user['email']; |
|
482 | + $attributes['ATTENDEE'][] = 'mailto:'.$user['email']; |
|
483 | 483 | $parameters['ATTENDEE'][] = array( |
484 | 484 | 'CN' => $user['name'], |
485 | 485 | 'ROLE' => 'REQ-PARTICIPANT', |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | if (!empty($rsvp)) $options['RSVP'] = $rsvp; |
522 | 522 | if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email']) |
523 | 523 | { |
524 | - $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
|
524 | + $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
|
525 | 525 | } |
526 | 526 | if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; |
527 | 527 | if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | break; |
532 | 532 | |
533 | 533 | case 'CLASS': |
534 | - if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
534 | + if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
535 | 535 | $attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE'; |
536 | 536 | // Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!) |
537 | 537 | if (!$event['public'] && $this->productManufacturer == 'groupdav') |
@@ -543,16 +543,16 @@ discard block |
||
543 | 543 | case 'ORGANIZER': |
544 | 544 | if (!$organizerURL) |
545 | 545 | { |
546 | - $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
547 | - . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
548 | - $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
546 | + $organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname') |
|
547 | + . ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"'; |
|
548 | + $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email'); |
|
549 | 549 | if ($version == '1.0') |
550 | 550 | { |
551 | - $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
551 | + $organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>')); |
|
552 | 552 | } |
553 | 553 | else |
554 | 554 | { |
555 | - $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
555 | + $organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail; |
|
556 | 556 | } |
557 | 557 | $organizerUID = $event['owner']; |
558 | 558 | if (!isset($event['participants'][$event['owner']])) |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | case 'DTSTART': |
586 | 586 | if (empty($event['whole_day'])) |
587 | 587 | { |
588 | - $attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']); |
|
588 | + $attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']); |
|
589 | 589 | } |
590 | 590 | break; |
591 | 591 | |
@@ -596,27 +596,27 @@ discard block |
||
596 | 596 | if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400) |
597 | 597 | $attributes['duration'] = $event['end'] - $event['start']; |
598 | 598 | else |
599 | - $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
599 | + $attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']); |
|
600 | 600 | } |
601 | 601 | else |
602 | 602 | { |
603 | 603 | // write start + end of whole day events as dates |
604 | - $event['end-nextday'] = $event['end'] + 12*3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 |
|
605 | - foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t) |
|
604 | + $event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 |
|
605 | + foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t) |
|
606 | 606 | { |
607 | - $time = new egw_time($event[$f],egw_time::$server_timezone); |
|
608 | - $arr = egw_time::to($time,'array'); |
|
609 | - $vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']), |
|
607 | + $time = new egw_time($event[$f], egw_time::$server_timezone); |
|
608 | + $arr = egw_time::to($time, 'array'); |
|
609 | + $vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']), |
|
610 | 610 | array('VALUE' => 'DATE')); |
611 | 611 | } |
612 | 612 | unset($attributes['DTSTART']); |
613 | 613 | // Outlook does NOT care about type of DTSTART/END, only setting X-MICROSOFT-CDO-ALLDAYEVENT is used to determine an event is a whole-day event |
614 | - $vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE'); |
|
614 | + $vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE'); |
|
615 | 615 | } |
616 | 616 | break; |
617 | 617 | |
618 | 618 | case 'RRULE': |
619 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
619 | + if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
620 | 620 | $rriter = calendar_rrule::event2rrule($event, false, $tzid); |
621 | 621 | $rrule = $rriter->generate_rrule($version); |
622 | 622 | if ($event['recur_enddate']) |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | { |
636 | 636 | if ($event['recur_enddate'] && $tzid) |
637 | 637 | { |
638 | - $rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid); |
|
638 | + $rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid); |
|
639 | 639 | } |
640 | 640 | $attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL']; |
641 | 641 | } |
642 | 642 | else // $version == '2.0' |
643 | 643 | { |
644 | 644 | $attributes['RRULE'] = ''; |
645 | - foreach($rrule as $n => $v) |
|
645 | + foreach ($rrule as $n => $v) |
|
646 | 646 | { |
647 | - $attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v; |
|
647 | + $attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | break; |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | { |
660 | 660 | // current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here |
661 | 661 | // Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID |
662 | - $event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']); |
|
662 | + $event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']); |
|
663 | 663 | } |
664 | 664 | } |
665 | 665 | else |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | // use 'DATE' instead of 'DATE-TIME' on whole day events |
668 | 668 | foreach ($event['recur_exception'] as $id => $timestamp) |
669 | 669 | { |
670 | - $time = new egw_time($timestamp,egw_time::$server_timezone); |
|
670 | + $time = new egw_time($timestamp, egw_time::$server_timezone); |
|
671 | 671 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
672 | - $arr = egw_time::to($time,'array'); |
|
672 | + $arr = egw_time::to($time, 'array'); |
|
673 | 673 | $days[$id] = array( |
674 | 674 | 'year' => $arr['year'], |
675 | 675 | 'month' => $arr['month'], |
@@ -684,21 +684,21 @@ discard block |
||
684 | 684 | break; |
685 | 685 | |
686 | 686 | case 'PRIORITY': |
687 | - if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
687 | + if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
688 | 688 | if ($this->productManufacturer == 'funambol' && |
689 | 689 | (strpos($this->productName, 'outlook') !== false |
690 | 690 | || strpos($this->productName, 'pocket pc') !== false)) |
691 | 691 | { |
692 | - $attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']]; |
|
692 | + $attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']]; |
|
693 | 693 | } |
694 | 694 | else |
695 | 695 | { |
696 | - $attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']]; |
|
696 | + $attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']]; |
|
697 | 697 | } |
698 | 698 | break; |
699 | 699 | |
700 | 700 | case 'TRANSP': |
701 | - if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
701 | + if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
702 | 702 | if ($version == '1.0') |
703 | 703 | { |
704 | 704 | $attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0); |
@@ -737,13 +737,13 @@ discard block |
||
737 | 737 | // We handle a pseudo exception |
738 | 738 | if (empty($event['whole_day'])) |
739 | 739 | { |
740 | - $attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]); |
|
740 | + $attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]); |
|
741 | 741 | } |
742 | 742 | else |
743 | 743 | { |
744 | - $time = new egw_time($recur_date,egw_time::$server_timezone); |
|
744 | + $time = new egw_time($recur_date, egw_time::$server_timezone); |
|
745 | 745 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
746 | - $arr = egw_time::to($time,'array'); |
|
746 | + $arr = egw_time::to($time, 'array'); |
|
747 | 747 | $vevent->setAttribute($icalFieldName, array( |
748 | 748 | 'year' => $arr['year'], |
749 | 749 | 'month' => $arr['month'], |
@@ -755,17 +755,17 @@ discard block |
||
755 | 755 | elseif ($event['recurrence'] && $event['reference']) |
756 | 756 | { |
757 | 757 | // $event['reference'] is a calendar_id, not a timestamp |
758 | - if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
758 | + if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
759 | 759 | |
760 | 760 | if (empty($revent['whole_day'])) |
761 | 761 | { |
762 | - $attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]); |
|
762 | + $attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]); |
|
763 | 763 | } |
764 | 764 | else |
765 | 765 | { |
766 | - $time = new egw_time($event['recurrence'],egw_time::$server_timezone); |
|
766 | + $time = new egw_time($event['recurrence'], egw_time::$server_timezone); |
|
767 | 767 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
768 | - $arr = egw_time::to($time,'array'); |
|
768 | + $arr = egw_time::to($time, 'array'); |
|
769 | 769 | $vevent->setAttribute($icalFieldName, array( |
770 | 770 | 'year' => $arr['year'], |
771 | 771 | 'month' => $arr['month'], |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | $noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate']; |
790 | 790 | if ($this->log && $size > 0) |
791 | 791 | { |
792 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
793 | - "() $icalFieldName Size: $size, NoTruncate: " . |
|
794 | - ($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile); |
|
792 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
793 | + "() $icalFieldName Size: $size, NoTruncate: ". |
|
794 | + ($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile); |
|
795 | 795 | } |
796 | 796 | //Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " . |
797 | 797 | // ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | { |
810 | 810 | if ($this->log) |
811 | 811 | { |
812 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
813 | - "() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile); |
|
812 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
813 | + "() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile); |
|
814 | 814 | } |
815 | 815 | //Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size", |
816 | 816 | // __FILE__, __LINE__, PEAR_LOG_WARNING); |
@@ -820,8 +820,8 @@ discard block |
||
820 | 820 | $value = substr($value, 0, $size - 1); |
821 | 821 | if ($this->log) |
822 | 822 | { |
823 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
824 | - "() $icalFieldName truncated to maximum size $size\n",3,$this->logfile); |
|
823 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
824 | + "() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile); |
|
825 | 825 | } |
826 | 826 | //Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size", |
827 | 827 | // __FILE__, __LINE__, PEAR_LOG_INFO); |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | // for CalDAV add all X-Properties previously parsed |
837 | 837 | if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file') |
838 | 838 | { |
839 | - foreach($event as $name => $value) |
|
839 | + foreach ($event as $name => $value) |
|
840 | 840 | { |
841 | 841 | if (substr($name, 0, 2) == '##') |
842 | 842 | { |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | $values['AALARM']['repeat count'] = ''; |
909 | 909 | $values['AALARM']['display text'] = $description; |
910 | 910 | } |
911 | - $attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']); |
|
912 | - $attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']); |
|
911 | + $attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']); |
|
912 | + $attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']); |
|
913 | 913 | // lets take only the first alarm |
914 | 914 | break; |
915 | 915 | } |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $alarmData['offset'] = false; |
947 | 947 | } |
948 | 948 | |
949 | - $valarm = Horde_Icalendar::newComponent('VALARM',$vevent); |
|
949 | + $valarm = Horde_Icalendar::newComponent('VALARM', $vevent); |
|
950 | 950 | if ($alarmData['offset'] !== false) |
951 | 951 | { |
952 | 952 | $valarm->setAttribute('TRIGGER', -$alarmData['offset'], |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | else |
956 | 956 | { |
957 | 957 | $params = array('VALUE' => 'DATE-TIME'); |
958 | - $value = self::getDateTime($alarmData['time'],$tzid,$params); |
|
958 | + $value = self::getDateTime($alarmData['time'], $tzid, $params); |
|
959 | 959 | $valarm->setAttribute('TRIGGER', $value, $params); |
960 | 960 | } |
961 | 961 | if (!empty($alarmData['uid'])) |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | // set evtl. existing attributes set by iCal clients not used by EGroupware |
967 | 967 | if (isset($alarmData['attrs'])) |
968 | 968 | { |
969 | - foreach($alarmData['attrs'] as $attr => $data) |
|
969 | + foreach ($alarmData['attrs'] as $attr => $data) |
|
970 | 970 | { |
971 | 971 | $valarm->setAttribute($attr, $data['value'], $data['params']); |
972 | 972 | } |
@@ -974,11 +974,11 @@ discard block |
||
974 | 974 | // set default ACTION and DESCRIPTION, if not set by a client |
975 | 975 | if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION'])) |
976 | 976 | { |
977 | - $valarm->setAttribute('ACTION','DISPLAY'); |
|
977 | + $valarm->setAttribute('ACTION', 'DISPLAY'); |
|
978 | 978 | } |
979 | 979 | if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION'])) |
980 | 980 | { |
981 | - $valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description); |
|
981 | + $valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description); |
|
982 | 982 | } |
983 | 983 | $vevent->addComponent($valarm); |
984 | 984 | } |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | foreach ($attributes as $key => $value) |
988 | 988 | { |
989 | - foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) |
|
989 | + foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData) |
|
990 | 990 | { |
991 | - $valueData = translation::convert($valueData,translation::charset(),$charset); |
|
992 | - $paramData = (array) translation::convert(is_array($value) ? |
|
991 | + $valueData = translation::convert($valueData, translation::charset(), $charset); |
|
992 | + $paramData = (array)translation::convert(is_array($value) ? |
|
993 | 993 | $parameters[$key][$valueID] : $parameters[$key], |
994 | - translation::charset(),$charset); |
|
995 | - $valuesData = (array) translation::convert($values[$key], |
|
996 | - translation::charset(),$charset); |
|
997 | - $content = $valueData . implode(';', $valuesData); |
|
994 | + translation::charset(), $charset); |
|
995 | + $valuesData = (array)translation::convert($values[$key], |
|
996 | + translation::charset(), $charset); |
|
997 | + $content = $valueData.implode(';', $valuesData); |
|
998 | 998 | |
999 | 999 | if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) || |
1000 | 1000 | ($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN'])))) |
@@ -1044,10 +1044,10 @@ discard block |
||
1044 | 1044 | $retval = $events_exported ? $vcal->exportvCalendar() : false; |
1045 | 1045 | if ($this->log) |
1046 | 1046 | { |
1047 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
1048 | - "() '$this->productManufacturer','$this->productName'\n",3,$this->logfile); |
|
1049 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
1050 | - "()\n".array2string($retval)."\n",3,$this->logfile); |
|
1047 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
1048 | + "() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile); |
|
1049 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
1050 | + "()\n".array2string($retval)."\n", 3, $this->logfile); |
|
1051 | 1051 | } |
1052 | 1052 | return $retval; |
1053 | 1053 | } |
@@ -1060,15 +1060,15 @@ discard block |
||
1060 | 1060 | * @param array &$params=null parameter array to set TZID |
1061 | 1061 | * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid |
1062 | 1062 | */ |
1063 | - static function getDateTime($time,$tzid,array &$params=null) |
|
1063 | + static function getDateTime($time, $tzid, array &$params = null) |
|
1064 | 1064 | { |
1065 | 1065 | if (empty($tzid) || $tzid == 'UTC') |
1066 | 1066 | { |
1067 | - return egw_time::to($time,'ts'); |
|
1067 | + return egw_time::to($time, 'ts'); |
|
1068 | 1068 | } |
1069 | - if (!is_a($time,'DateTime')) |
|
1069 | + if (!is_a($time, 'DateTime')) |
|
1070 | 1070 | { |
1071 | - $time = new egw_time($time,egw_time::$server_timezone); |
|
1071 | + $time = new egw_time($time, egw_time::$server_timezone); |
|
1072 | 1072 | } |
1073 | 1073 | if (!isset(self::$tz_cache[$tzid])) |
1074 | 1074 | { |
@@ -1103,11 +1103,11 @@ discard block |
||
1103 | 1103 | * @param string $caldav_name=null name from CalDAV client or null (to use default) |
1104 | 1104 | * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden" |
1105 | 1105 | */ |
1106 | - function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false) |
|
1106 | + function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false) |
|
1107 | 1107 | { |
1108 | 1108 | //error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)"); |
1109 | 1109 | $this->events_imported = 0; |
1110 | - $replace = $delete_exceptions= false; |
|
1110 | + $replace = $delete_exceptions = false; |
|
1111 | 1111 | |
1112 | 1112 | if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
1113 | 1113 | |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | { |
1116 | 1116 | return false; |
1117 | 1117 | } |
1118 | - if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
1118 | + if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
1119 | 1119 | |
1120 | 1120 | if ($cal_id > 0) |
1121 | 1121 | { |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | { |
1124 | 1124 | $replace = $recur_date == 0; |
1125 | 1125 | $events[0]['id'] = $cal_id; |
1126 | - if (!is_null($etag)) $events[0]['etag'] = (int) $etag; |
|
1126 | + if (!is_null($etag)) $events[0]['etag'] = (int)$etag; |
|
1127 | 1127 | if ($recur_date) $events[0]['recurrence'] = $recur_date; |
1128 | 1128 | } |
1129 | 1129 | elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) && |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | { |
1176 | 1176 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1177 | 1177 | ."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n" |
1178 | - . array2string($event)."\n",3,$this->logfile); |
|
1178 | + . array2string($event)."\n", 3, $this->logfile); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | $updated_id = false; |
@@ -1198,14 +1198,14 @@ discard block |
||
1198 | 1198 | { |
1199 | 1199 | if ($delete_exceptions) |
1200 | 1200 | { |
1201 | - $this->delete($id,0,false,$skip_notification); |
|
1201 | + $this->delete($id, 0, false, $skip_notification); |
|
1202 | 1202 | } |
1203 | 1203 | else |
1204 | 1204 | { |
1205 | 1205 | if (!($exception = $this->read($id))) continue; |
1206 | 1206 | $exception['uid'] = common::generate_uid('calendar', $id); |
1207 | 1207 | $exception['reference'] = $exception['recurrence'] = 0; |
1208 | - $this->update($exception, true,true,false,true,$msg,$skip_notification); |
|
1208 | + $this->update($exception, true, true, false, true, $msg, $skip_notification); |
|
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | } |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | { |
1223 | 1223 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1224 | 1224 | . "(UPDATE Event)\n" |
1225 | - . array2string($event_info['stored_event'])."\n",3,$this->logfile); |
|
1225 | + . array2string($event_info['stored_event'])."\n", 3, $this->logfile); |
|
1226 | 1226 | } |
1227 | 1227 | if (empty($event['uid'])) |
1228 | 1228 | { |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | if ($this->log) |
1245 | 1245 | { |
1246 | 1246 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1247 | - "() Restore status for $uid\n",3,$this->logfile); |
|
1247 | + "() Restore status for $uid\n", 3, $this->logfile); |
|
1248 | 1248 | } |
1249 | 1249 | $event['participants'][$uid] = $event_info['stored_event']['participants'][$uid]; |
1250 | 1250 | } |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | if ($this->log) |
1269 | 1269 | { |
1270 | 1270 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1271 | - "()[MERGE]\n",3,$this->logfile); |
|
1271 | + "()[MERGE]\n", 3, $this->logfile); |
|
1272 | 1272 | } |
1273 | 1273 | // overwrite with server data for merge |
1274 | 1274 | foreach ($event_info['stored_event'] as $key => $value) |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | else |
1299 | 1299 | { |
1300 | 1300 | // no merge |
1301 | - if(!isset($this->supportedFields['category']) || !isset($event['category'])) |
|
1301 | + if (!isset($this->supportedFields['category']) || !isset($event['category'])) |
|
1302 | 1302 | { |
1303 | 1303 | $event['category'] = $event_info['stored_event']['category']; |
1304 | 1304 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | if ($this->log) |
1311 | 1311 | { |
1312 | 1312 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1313 | - "() No participants\n",3,$this->logfile); |
|
1313 | + "() No participants\n", 3, $this->logfile); |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | // If this is an updated meeting, and the client doesn't support |
@@ -1329,7 +1329,7 @@ discard block |
||
1329 | 1329 | if ($this->log) |
1330 | 1330 | { |
1331 | 1331 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1332 | - "() Restore resource $uid to status $status\n",3,$this->logfile); |
|
1332 | + "() Restore resource $uid to status $status\n", 3, $this->logfile); |
|
1333 | 1333 | } |
1334 | 1334 | // Add it back in |
1335 | 1335 | $event['participants'][$uid] = $status; |
@@ -1417,8 +1417,7 @@ discard block |
||
1417 | 1417 | } |
1418 | 1418 | // for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U') |
1419 | 1419 | $event['participants'][$user] = calendar_so::combine_status( |
1420 | - $user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : |
|
1421 | - ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1))); |
|
1420 | + $user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1))); |
|
1422 | 1421 | } |
1423 | 1422 | } |
1424 | 1423 | // check if an owner is set and the current user has add rights |
@@ -1483,9 +1482,9 @@ discard block |
||
1483 | 1482 | |
1484 | 1483 | if ($this->log) |
1485 | 1484 | { |
1486 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '(' |
|
1487 | - . $event_info['type'] . ")\n" |
|
1488 | - . array2string($event)."\n",3,$this->logfile); |
|
1485 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'(' |
|
1486 | + . $event_info['type'].")\n" |
|
1487 | + . array2string($event)."\n", 3, $this->logfile); |
|
1489 | 1488 | } |
1490 | 1489 | |
1491 | 1490 | // Android (any maybe others) delete recurrences by setting STATUS: CANCELLED |
@@ -1493,10 +1492,10 @@ discard block |
||
1493 | 1492 | if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) && |
1494 | 1493 | $event['status'] == 'CANCELLED') |
1495 | 1494 | { |
1496 | - if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification)) |
|
1495 | + if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification)) |
|
1497 | 1496 | { |
1498 | 1497 | // delete fails (because no rights), reject recurrence |
1499 | - $this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification); |
|
1498 | + $this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification); |
|
1500 | 1499 | } |
1501 | 1500 | continue; |
1502 | 1501 | } |
@@ -1508,7 +1507,7 @@ discard block |
||
1508 | 1507 | if ($this->log) |
1509 | 1508 | { |
1510 | 1509 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1511 | - "(): event SINGLE\n",3,$this->logfile); |
|
1510 | + "(): event SINGLE\n", 3, $this->logfile); |
|
1512 | 1511 | } |
1513 | 1512 | |
1514 | 1513 | // update the event |
@@ -1518,7 +1517,7 @@ discard block |
||
1518 | 1517 | $event['reference'] = 0; |
1519 | 1518 | $event_to_store = $event; // prevent $event from being changed by the update method |
1520 | 1519 | $this->server2usertime($event_to_store); |
1521 | - $updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
1520 | + $updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
1522 | 1521 | unset($event_to_store); |
1523 | 1522 | } |
1524 | 1523 | break; |
@@ -1527,7 +1526,7 @@ discard block |
||
1527 | 1526 | if ($this->log) |
1528 | 1527 | { |
1529 | 1528 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1530 | - "(): event SERIES-MASTER\n",3,$this->logfile); |
|
1529 | + "(): event SERIES-MASTER\n", 3, $this->logfile); |
|
1531 | 1530 | } |
1532 | 1531 | |
1533 | 1532 | // remove all known pseudo exceptions and update the event |
@@ -1537,8 +1536,8 @@ discard block |
||
1537 | 1536 | $days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter); |
1538 | 1537 | if ($this->log) |
1539 | 1538 | { |
1540 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" . |
|
1541 | - array2string($days)."\n",3,$this->logfile); |
|
1539 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n". |
|
1540 | + array2string($days)."\n", 3, $this->logfile); |
|
1542 | 1541 | } |
1543 | 1542 | if (is_array($days)) |
1544 | 1543 | { |
@@ -1556,7 +1555,7 @@ discard block |
||
1556 | 1555 | |
1557 | 1556 | $event_to_store = $event; // prevent $event from being changed by the update method |
1558 | 1557 | $this->server2usertime($event_to_store); |
1559 | - $updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
1558 | + $updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
1560 | 1559 | unset($event_to_store); |
1561 | 1560 | } |
1562 | 1561 | break; |
@@ -1566,7 +1565,7 @@ discard block |
||
1566 | 1565 | if ($this->log) |
1567 | 1566 | { |
1568 | 1567 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1569 | - "(): event SERIES-EXCEPTION\n",3,$this->logfile); |
|
1568 | + "(): event SERIES-EXCEPTION\n", 3, $this->logfile); |
|
1570 | 1569 | } |
1571 | 1570 | |
1572 | 1571 | // update event |
@@ -1622,13 +1621,13 @@ discard block |
||
1622 | 1621 | $event['owner'] = $event_info['master_event']['owner']; |
1623 | 1622 | $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method |
1624 | 1623 | $this->server2usertime($event_to_store); |
1625 | - $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
1624 | + $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
1626 | 1625 | unset($event_to_store); |
1627 | 1626 | } |
1628 | 1627 | |
1629 | 1628 | $event_to_store = $event; // prevent $event from being changed by update method |
1630 | 1629 | $this->server2usertime($event_to_store); |
1631 | - $updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
1630 | + $updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
1632 | 1631 | unset($event_to_store); |
1633 | 1632 | } |
1634 | 1633 | break; |
@@ -1637,7 +1636,7 @@ discard block |
||
1637 | 1636 | if ($this->log) |
1638 | 1637 | { |
1639 | 1638 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1640 | - "(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile); |
|
1639 | + "(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile); |
|
1641 | 1640 | } |
1642 | 1641 | //Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION', |
1643 | 1642 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -1658,7 +1657,7 @@ discard block |
||
1658 | 1657 | // save the series master with the adjusted exceptions |
1659 | 1658 | $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method |
1660 | 1659 | $this->server2usertime($event_to_store); |
1661 | - $updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification); |
|
1660 | + $updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification); |
|
1662 | 1661 | unset($event_to_store); |
1663 | 1662 | } |
1664 | 1663 | |
@@ -1685,13 +1684,13 @@ discard block |
||
1685 | 1684 | if ($event_info['acl_edit']) |
1686 | 1685 | { |
1687 | 1686 | // update all participants if we have the right to do that |
1688 | - $this->update_status($event, $event_info['stored_event'],0,$skip_notification); |
|
1687 | + $this->update_status($event, $event_info['stored_event'], 0, $skip_notification); |
|
1689 | 1688 | } |
1690 | 1689 | elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user])) |
1691 | 1690 | { |
1692 | 1691 | // update the users status only |
1693 | 1692 | $this->set_status($event_info['stored_event']['id'], $this->user, |
1694 | - ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification); |
|
1693 | + ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification); |
|
1695 | 1694 | } |
1696 | 1695 | } |
1697 | 1696 | break; |
@@ -1703,13 +1702,13 @@ discard block |
||
1703 | 1702 | if ($event_info['acl_edit']) |
1704 | 1703 | { |
1705 | 1704 | // update all participants if we have the right to do that |
1706 | - $this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification); |
|
1705 | + $this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification); |
|
1707 | 1706 | } |
1708 | 1707 | elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user])) |
1709 | 1708 | { |
1710 | 1709 | // update the users status only |
1711 | 1710 | $this->set_status($event_info['master_event']['id'], $this->user, |
1712 | - ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification); |
|
1711 | + ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification); |
|
1713 | 1712 | } |
1714 | 1713 | } |
1715 | 1714 | break; |
@@ -1726,7 +1725,7 @@ discard block |
||
1726 | 1725 | break; |
1727 | 1726 | |
1728 | 1727 | case 'SERIES-PSEUDO-EXCEPTION': |
1729 | - $return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false; |
|
1728 | + $return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false; |
|
1730 | 1729 | break; |
1731 | 1730 | |
1732 | 1731 | case 'SERIES-EXCEPTION-PROPAGATE': |
@@ -1739,7 +1738,7 @@ discard block |
||
1739 | 1738 | { |
1740 | 1739 | // we did not have sufficient rights to propagate the status only exception to a real one |
1741 | 1740 | // we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched |
1742 | - $return_id = $event_info['master_event']['id'] . ':' . $event['recurrence']; |
|
1741 | + $return_id = $event_info['master_event']['id'].':'.$event['recurrence']; |
|
1743 | 1742 | } |
1744 | 1743 | break; |
1745 | 1744 | } |
@@ -1753,8 +1752,8 @@ discard block |
||
1753 | 1752 | if ($this->log) |
1754 | 1753 | { |
1755 | 1754 | $event_info['stored_event'] = $this->read($event_info['stored_event']['id']); |
1756 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" . |
|
1757 | - array2string($event_info['stored_event'])."\n",3,$this->logfile); |
|
1755 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n". |
|
1756 | + array2string($event_info['stored_event'])."\n", 3, $this->logfile); |
|
1758 | 1757 | } |
1759 | 1758 | } |
1760 | 1759 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
@@ -1774,10 +1773,10 @@ discard block |
||
1774 | 1773 | { |
1775 | 1774 | if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
1776 | 1775 | $modified = 0; |
1777 | - foreach($event['alarm'] as &$alarm) |
|
1776 | + foreach ($event['alarm'] as &$alarm) |
|
1778 | 1777 | { |
1779 | 1778 | // check if alarm is already stored or from other users |
1780 | - foreach($old_alarms as $id => $old_alarm) |
|
1779 | + foreach ($old_alarms as $id => $old_alarm) |
|
1781 | 1780 | { |
1782 | 1781 | // not current users alarm --> ignore |
1783 | 1782 | if (!$old_alarm['all'] && $old_alarm['owner'] != $user) |
@@ -1814,7 +1813,7 @@ discard block |
||
1814 | 1813 | } |
1815 | 1814 | } |
1816 | 1815 | // remove all old alarms left from current user |
1817 | - foreach($old_alarms as $id => $old_alarm) |
|
1816 | + foreach ($old_alarms as $id => $old_alarm) |
|
1818 | 1817 | { |
1819 | 1818 | // not current users alarm --> ignore |
1820 | 1819 | if (!$old_alarm['all'] && $old_alarm['owner'] != $user) |
@@ -1837,7 +1836,7 @@ discard block |
||
1837 | 1836 | * @param string $what ='value' |
1838 | 1837 | * @return mixed |
1839 | 1838 | */ |
1840 | - static function _get_attribute($components,$name,$what='value') |
|
1839 | + static function _get_attribute($components, $name, $what = 'value') |
|
1841 | 1840 | { |
1842 | 1841 | foreach ($components as $attribute) |
1843 | 1842 | { |
@@ -1872,7 +1871,7 @@ discard block |
||
1872 | 1871 | case 'DURATION': |
1873 | 1872 | if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END') |
1874 | 1873 | { |
1875 | - $alarm['offset'] = $duration -$vattr['value']; |
|
1874 | + $alarm['offset'] = $duration - $vattr['value']; |
|
1876 | 1875 | } |
1877 | 1876 | elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START') |
1878 | 1877 | { |
@@ -1888,7 +1887,7 @@ discard block |
||
1888 | 1887 | $alarm['time'] = $vattr['value']; |
1889 | 1888 | break; |
1890 | 1889 | default: |
1891 | - error_log('VALARM/TRIGGER: unsupported value type:' . $vtype); |
|
1890 | + error_log('VALARM/TRIGGER: unsupported value type:'.$vtype); |
|
1892 | 1891 | } |
1893 | 1892 | break; |
1894 | 1893 | |
@@ -1913,9 +1912,9 @@ discard block |
||
1913 | 1912 | return 0; |
1914 | 1913 | } |
1915 | 1914 | |
1916 | - function setSupportedFields($_productManufacturer='', $_productName='') |
|
1915 | + function setSupportedFields($_productManufacturer = '', $_productName = '') |
|
1917 | 1916 | { |
1918 | - $state =& $_SESSION['SyncML.state']; |
|
1917 | + $state = & $_SESSION['SyncML.state']; |
|
1919 | 1918 | if (isset($state)) |
1920 | 1919 | { |
1921 | 1920 | $deviceInfo = $state->getClientDeviceInfo(); |
@@ -2212,10 +2211,10 @@ discard block |
||
2212 | 2211 | if ($this->log) |
2213 | 2212 | { |
2214 | 2213 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2215 | - '(' . $this->productManufacturer . |
|
2216 | - ', '. $this->productName .', ' . |
|
2217 | - ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) . |
|
2218 | - ', ' . $this->calendarOwner . ")\n" , 3, $this->logfile); |
|
2214 | + '('.$this->productManufacturer. |
|
2215 | + ', '.$this->productName.', '. |
|
2216 | + ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()). |
|
2217 | + ', '.$this->calendarOwner.")\n", 3, $this->logfile); |
|
2219 | 2218 | } |
2220 | 2219 | |
2221 | 2220 | //Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', ' |
@@ -2233,12 +2232,12 @@ discard block |
||
2233 | 2232 | * utf-8 for new format, iso-8859-1 for old format. |
2234 | 2233 | * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure |
2235 | 2234 | */ |
2236 | - function icaltoegw($_vcalData, $principalURL='', $charset=null) |
|
2235 | + function icaltoegw($_vcalData, $principalURL = '', $charset = null) |
|
2237 | 2236 | { |
2238 | 2237 | if ($this->log) |
2239 | 2238 | { |
2240 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" . |
|
2241 | - array2string($_vcalData)."\n",3,$this->logfile); |
|
2239 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n". |
|
2240 | + array2string($_vcalData)."\n", 3, $this->logfile); |
|
2242 | 2241 | } |
2243 | 2242 | |
2244 | 2243 | if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
@@ -2246,7 +2245,7 @@ discard block |
||
2246 | 2245 | // we use egw_ical_iterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0]) |
2247 | 2246 | if (is_resource($_vcalData)) |
2248 | 2247 | { |
2249 | - return new egw_ical_iterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($this->tzid,$principalURL)); |
|
2248 | + return new egw_ical_iterator($_vcalData, 'VCALENDAR', $charset, array($this, '_ical2egw_callback'), array($this->tzid, $principalURL)); |
|
2250 | 2249 | } |
2251 | 2250 | |
2252 | 2251 | if ($this->tzid) |
@@ -2271,14 +2270,14 @@ discard block |
||
2271 | 2270 | if ($this->log) |
2272 | 2271 | { |
2273 | 2272 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2274 | - "(): No vCalendar Container found!\n",3,$this->logfile); |
|
2273 | + "(): No vCalendar Container found!\n", 3, $this->logfile); |
|
2275 | 2274 | } |
2276 | 2275 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
2277 | 2276 | return false; |
2278 | 2277 | } |
2279 | 2278 | foreach ($vcal->getComponents() as $component) |
2280 | 2279 | { |
2281 | - if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal))) |
|
2280 | + if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal))) |
|
2282 | 2281 | { |
2283 | 2282 | $events[] = $event; |
2284 | 2283 | } |
@@ -2297,13 +2296,13 @@ discard block |
||
2297 | 2296 | * @param Horde_Icalendar $container =null container to access attributes on container |
2298 | 2297 | * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent |
2299 | 2298 | */ |
2300 | - function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null) |
|
2299 | + function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null) |
|
2301 | 2300 | { |
2302 | 2301 | //unset($component->_container); _debug_array($component); |
2303 | 2302 | |
2304 | 2303 | if ($this->log) |
2305 | 2304 | { |
2306 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile); |
|
2305 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile); |
|
2307 | 2306 | } |
2308 | 2307 | |
2309 | 2308 | if (!is_a($component, 'Horde_Icalendar_Vevent') || |
@@ -2352,16 +2351,16 @@ discard block |
||
2352 | 2351 | * @param Horde_Icalendar $container =null container to access attributes on container |
2353 | 2352 | * @return array|boolean event on success, false on failure |
2354 | 2353 | */ |
2355 | - function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null) |
|
2354 | + function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null) |
|
2356 | 2355 | { |
2357 | - unset($principalURL); // not longer used, but required in function signature |
|
2356 | + unset($principalURL); // not longer used, but required in function signature |
|
2358 | 2357 | |
2359 | 2358 | if ($check_component && !is_a($component, $check_component)) |
2360 | 2359 | { |
2361 | 2360 | if ($this->log) |
2362 | 2361 | { |
2363 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' . |
|
2364 | - get_class($component)." found\n",3,$this->logfile); |
|
2362 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'. |
|
2363 | + get_class($component)." found\n", 3, $this->logfile); |
|
2365 | 2364 | } |
2366 | 2365 | return false; |
2367 | 2366 | } |
@@ -2377,11 +2376,11 @@ discard block |
||
2377 | 2376 | |
2378 | 2377 | $isDate = false; |
2379 | 2378 | $event = array(); |
2380 | - $alarms = array(); |
|
2381 | - $vcardData = array( |
|
2379 | + $alarms = array(); |
|
2380 | + $vcardData = array( |
|
2382 | 2381 | 'recur_type' => MCAL_RECUR_NONE, |
2383 | 2382 | 'recur_exception' => array(), |
2384 | - 'priority' => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal |
|
2383 | + 'priority' => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal |
|
2385 | 2384 | ); |
2386 | 2385 | // we need to parse DTSTART, DTEND or DURATION (in that order!) first |
2387 | 2386 | foreach (array_merge( |
@@ -2398,7 +2397,7 @@ discard block |
||
2398 | 2397 | $isDate = true; |
2399 | 2398 | } |
2400 | 2399 | $dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']); |
2401 | - $vcardData['start'] = $dtstart_ts; |
|
2400 | + $vcardData['start'] = $dtstart_ts; |
|
2402 | 2401 | |
2403 | 2402 | if ($this->tzid) |
2404 | 2403 | { |
@@ -2421,18 +2420,18 @@ discard block |
||
2421 | 2420 | } |
2422 | 2421 | else |
2423 | 2422 | { |
2424 | - error_log(__METHOD__ . '() unknown TZID=' |
|
2425 | - . $attributes['params']['TZID'] . ', defaulting to timezone "' |
|
2426 | - . date_default_timezone_get() . '".'.array2string($tz)); |
|
2427 | - $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
2423 | + error_log(__METHOD__.'() unknown TZID=' |
|
2424 | + . $attributes['params']['TZID'].', defaulting to timezone "' |
|
2425 | + . date_default_timezone_get().'".'.array2string($tz)); |
|
2426 | + $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
2428 | 2427 | } |
2429 | 2428 | } |
2430 | - catch(Exception $e) |
|
2429 | + catch (Exception $e) |
|
2431 | 2430 | { |
2432 | - error_log(__METHOD__ . '() unknown TZID=' |
|
2433 | - . $attributes['params']['TZID'] . ', defaulting to timezone "' |
|
2434 | - . date_default_timezone_get() . '".'.$e->getMessage()); |
|
2435 | - $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
2431 | + error_log(__METHOD__.'() unknown TZID=' |
|
2432 | + . $attributes['params']['TZID'].', defaulting to timezone "' |
|
2433 | + . date_default_timezone_get().'".'.$e->getMessage()); |
|
2434 | + $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
2436 | 2435 | } |
2437 | 2436 | } |
2438 | 2437 | else |
@@ -2447,11 +2446,11 @@ discard block |
||
2447 | 2446 | |
2448 | 2447 | case 'DTEND': |
2449 | 2448 | $dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']); |
2450 | - if (date('H:i:s',$dtend_ts) == '00:00:00') |
|
2449 | + if (date('H:i:s', $dtend_ts) == '00:00:00') |
|
2451 | 2450 | { |
2452 | 2451 | $dtend_ts -= 1; |
2453 | 2452 | } |
2454 | - $vcardData['end'] = $dtend_ts; |
|
2453 | + $vcardData['end'] = $dtend_ts; |
|
2455 | 2454 | break; |
2456 | 2455 | |
2457 | 2456 | case 'DURATION': // clients can use DTSTART+DURATION, instead of DTSTART+DTEND |
@@ -2471,7 +2470,7 @@ discard block |
||
2471 | 2470 | if ($this->log) |
2472 | 2471 | { |
2473 | 2472 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2474 | - . "() DTSTART missing!\n",3,$this->logfile); |
|
2473 | + . "() DTSTART missing!\n", 3, $this->logfile); |
|
2475 | 2474 | } |
2476 | 2475 | return false; // not a valid entry |
2477 | 2476 | } |
@@ -2483,7 +2482,7 @@ discard block |
||
2483 | 2482 | case 'X-MICROSOFT-CDO-ALLDAYEVENT': |
2484 | 2483 | if (isset($supportedFields['whole_day'])) |
2485 | 2484 | { |
2486 | - $event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true); |
|
2485 | + $event['whole_day'] = (isset($attributes['value']) ? strtoupper($attributes['value']) == 'TRUE' : true); |
|
2487 | 2486 | } |
2488 | 2487 | break; |
2489 | 2488 | case 'AALARM': |
@@ -2513,32 +2512,32 @@ discard block |
||
2513 | 2512 | $vcardData['recurrence'] = $attributes['value']; |
2514 | 2513 | break; |
2515 | 2514 | case 'LOCATION': |
2516 | - $vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']); |
|
2515 | + $vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']); |
|
2517 | 2516 | break; |
2518 | 2517 | case 'RRULE': |
2519 | 2518 | $recurence = $attributes['value']; |
2520 | 2519 | $vcardData['recur_interval'] = 1; |
2521 | - $type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0]; |
|
2520 | + $type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0]; |
|
2522 | 2521 | // vCard 2.0 values for all types |
2523 | - if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches)) |
|
2522 | + if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches)) |
|
2524 | 2523 | { |
2525 | 2524 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]); |
2526 | 2525 | // If it couldn't be parsed, treat it as not set |
2527 | - if(is_string($vcardData['recur_enddate'])) |
|
2526 | + if (is_string($vcardData['recur_enddate'])) |
|
2528 | 2527 | { |
2529 | 2528 | unset($vcardData['recur_enddate']); |
2530 | 2529 | } |
2531 | 2530 | } |
2532 | - elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches)) |
|
2531 | + elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches)) |
|
2533 | 2532 | { |
2534 | 2533 | $vcardData['recur_count'] = (int)$matches[1]; |
2535 | 2534 | } |
2536 | - if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches)) |
|
2535 | + if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches)) |
|
2537 | 2536 | { |
2538 | - $vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1; |
|
2537 | + $vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1; |
|
2539 | 2538 | } |
2540 | 2539 | $vcardData['recur_data'] = 0; |
2541 | - switch($type) |
|
2540 | + switch ($type) |
|
2542 | 2541 | { |
2543 | 2542 | case 'D': // 1.0 |
2544 | 2543 | $recurenceMatches = null; |
@@ -2562,20 +2561,20 @@ discard block |
||
2562 | 2561 | case 'W': |
2563 | 2562 | case 'WEEKLY': |
2564 | 2563 | $days = array(); |
2565 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
2564 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches)) // 1.0 |
|
2566 | 2565 | { |
2567 | 2566 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2568 | 2567 | if (empty($recurenceMatches[2])) |
2569 | 2568 | { |
2570 | - $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
|
2569 | + $days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2)); |
|
2571 | 2570 | } |
2572 | 2571 | else |
2573 | 2572 | { |
2574 | - $days = explode(' ',trim($recurenceMatches[2])); |
|
2573 | + $days = explode(' ', trim($recurenceMatches[2])); |
|
2575 | 2574 | } |
2576 | 2575 | |
2577 | 2576 | $repeatMatches = null; |
2578 | - if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
|
2577 | + if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches)) |
|
2579 | 2578 | { |
2580 | 2579 | if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
2581 | 2580 | } |
@@ -2586,21 +2585,21 @@ discard block |
||
2586 | 2585 | |
2587 | 2586 | $recur_days = $this->recur_days_1_0; |
2588 | 2587 | } |
2589 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
2588 | + elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches)) // 2.0 |
|
2590 | 2589 | { |
2591 | - $days = explode(',',$recurenceMatches[1]); |
|
2590 | + $days = explode(',', $recurenceMatches[1]); |
|
2592 | 2591 | $recur_days = $this->recur_days; |
2593 | 2592 | } |
2594 | 2593 | else // no day given, use the day of dtstart |
2595 | 2594 | { |
2596 | - $vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']); |
|
2595 | + $vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']); |
|
2597 | 2596 | $vcardData['recur_type'] = MCAL_RECUR_WEEKLY; |
2598 | 2597 | } |
2599 | 2598 | if ($days) |
2600 | 2599 | { |
2601 | 2600 | foreach ($recur_days as $id => $day) |
2602 | 2601 | { |
2603 | - if (in_array(strtoupper(substr($day,0,2)),$days)) |
|
2602 | + if (in_array(strtoupper(substr($day, 0, 2)), $days)) |
|
2604 | 2603 | { |
2605 | 2604 | $vcardData['recur_data'] |= $id; |
2606 | 2605 | } |
@@ -2616,17 +2615,17 @@ discard block |
||
2616 | 2615 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2617 | 2616 | $vcardData['recur_count'] = $recurenceMatches[2]; |
2618 | 2617 | } |
2619 | - elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches)) |
|
2618 | + elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches)) |
|
2620 | 2619 | { |
2621 | 2620 | $vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY; |
2622 | 2621 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2623 | 2622 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
2624 | 2623 | } |
2625 | - elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches)) |
|
2624 | + elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches)) |
|
2626 | 2625 | { |
2627 | 2626 | $vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY; |
2628 | 2627 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2629 | - if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches)) |
|
2628 | + if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches)) |
|
2630 | 2629 | { |
2631 | 2630 | $vcardData['recur_count'] = $recurenceMatches[1]; |
2632 | 2631 | } |
@@ -2643,7 +2642,7 @@ discard block |
||
2643 | 2642 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2644 | 2643 | $vcardData['recur_count'] = $recurenceMatches[2]; |
2645 | 2644 | } |
2646 | - elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches)) |
|
2645 | + elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches)) |
|
2647 | 2646 | { |
2648 | 2647 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2649 | 2648 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
@@ -2657,11 +2656,11 @@ discard block |
||
2657 | 2656 | } |
2658 | 2657 | // handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL |
2659 | 2658 | $vcardData['recur_interval'] = $vcardData['recur_interval'] ? |
2660 | - 12*$vcardData['recur_interval'] : 12; |
|
2659 | + 12 * $vcardData['recur_interval'] : 12; |
|
2661 | 2660 | // fall-through |
2662 | 2661 | case 'MONTHLY': |
2663 | 2662 | // does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART |
2664 | - $vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ? |
|
2663 | + $vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ? |
|
2665 | 2664 | MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY; |
2666 | 2665 | break; |
2667 | 2666 | } |
@@ -2717,11 +2716,11 @@ discard block |
||
2717 | 2716 | (strpos($this->productName, 'outlook') !== false |
2718 | 2717 | || strpos($this->productName, 'pocket pc') !== false)) |
2719 | 2718 | { |
2720 | - $vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']]; |
|
2719 | + $vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']]; |
|
2721 | 2720 | } |
2722 | 2721 | else |
2723 | 2722 | { |
2724 | - $vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']]; |
|
2723 | + $vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']]; |
|
2725 | 2724 | } |
2726 | 2725 | break; |
2727 | 2726 | case 'CATEGORIES': |
@@ -2735,10 +2734,10 @@ discard block |
||
2735 | 2734 | } |
2736 | 2735 | break; |
2737 | 2736 | case 'ORGANIZER': |
2738 | - $event['organizer'] = $attributes['value']; // no egw field, but needed in AS |
|
2739 | - if (strtolower(substr($event['organizer'],0,7)) == 'mailto:') |
|
2737 | + $event['organizer'] = $attributes['value']; // no egw field, but needed in AS |
|
2738 | + if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:') |
|
2740 | 2739 | { |
2741 | - $event['organizer'] = substr($event['organizer'],7); |
|
2740 | + $event['organizer'] = substr($event['organizer'], 7); |
|
2742 | 2741 | } |
2743 | 2742 | if (!empty($attributes['params']['CN'])) |
2744 | 2743 | { |
@@ -2775,19 +2774,19 @@ discard block |
||
2775 | 2774 | } |
2776 | 2775 | // try parsing email and cn from attendee |
2777 | 2776 | elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i', |
2778 | - $attributes['value'],$matches)) |
|
2777 | + $attributes['value'], $matches)) |
|
2779 | 2778 | { |
2780 | 2779 | $email = $matches[1] ? $matches[1] : $matches[3]; |
2781 | - $cn = isset($matches[2]) ? $matches[2]: ''; |
|
2780 | + $cn = isset($matches[2]) ? $matches[2] : ''; |
|
2782 | 2781 | } |
2783 | 2782 | elseif (!empty($attributes['value']) && |
2784 | 2783 | preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i', |
2785 | - $attributes['value'],$matches)) |
|
2784 | + $attributes['value'], $matches)) |
|
2786 | 2785 | { |
2787 | 2786 | $cn = $matches[1]; |
2788 | 2787 | $email = $matches[2]; |
2789 | 2788 | } |
2790 | - elseif (strpos($attributes['value'],'@') !== false) |
|
2789 | + elseif (strpos($attributes['value'], '@') !== false) |
|
2791 | 2790 | { |
2792 | 2791 | $email = $attributes['value']; |
2793 | 2792 | } |
@@ -2804,7 +2803,7 @@ discard block |
||
2804 | 2803 | if ($this->log) |
2805 | 2804 | { |
2806 | 2805 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2807 | - . "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile); |
|
2806 | + . "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile); |
|
2808 | 2807 | } |
2809 | 2808 | } |
2810 | 2809 | elseif ($attributes['value'] == 'Unknown') |
@@ -2822,7 +2821,7 @@ discard block |
||
2822 | 2821 | if ($this->log) |
2823 | 2822 | { |
2824 | 2823 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2825 | - . "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile); |
|
2824 | + . "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile); |
|
2826 | 2825 | } |
2827 | 2826 | } |
2828 | 2827 | if (!$uid) |
@@ -2839,9 +2838,9 @@ discard block |
||
2839 | 2838 | $cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'), |
2840 | 2839 | array(',', ';', ':', '\\'), |
2841 | 2840 | $attributes['params']['CN']); |
2842 | - if ($cn[0] == '"' && substr($cn,-1) == '"') |
|
2841 | + if ($cn[0] == '"' && substr($cn, -1) == '"') |
|
2843 | 2842 | { |
2844 | - $cn = substr($cn,1,-1); |
|
2843 | + $cn = substr($cn, 1, -1); |
|
2845 | 2844 | } |
2846 | 2845 | // not searching for $cn, as match can be not unique or without an email address |
2847 | 2846 | // --> notification will fail, better store just as email |
@@ -2850,19 +2849,19 @@ discard block |
||
2850 | 2849 | if ($this->log) |
2851 | 2850 | { |
2852 | 2851 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2853 | - . "() Search participant: '$cn', '$email'\n",3,$this->logfile); |
|
2852 | + . "() Search participant: '$cn', '$email'\n", 3, $this->logfile); |
|
2854 | 2853 | } |
2855 | 2854 | |
2856 | 2855 | //elseif (//$attributes['params']['CUTYPE'] == 'GROUP' |
2857 | - if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches)) |
|
2856 | + if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches)) |
|
2858 | 2857 | { |
2859 | 2858 | // we found a group |
2860 | 2859 | if ($this->log) |
2861 | 2860 | { |
2862 | 2861 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2863 | - . "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile); |
|
2862 | + . "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile); |
|
2864 | 2863 | } |
2865 | - if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g'))) |
|
2864 | + if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g'))) |
|
2866 | 2865 | { |
2867 | 2866 | //Horde::logMessage("vevent2egw: group participant $uid", |
2868 | 2867 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -2876,7 +2875,7 @@ discard block |
||
2876 | 2875 | //Horde::logMessage("vevent2egw: set status to " . $status, |
2877 | 2876 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
2878 | 2877 | $vcardData['participants'][$this->user] = |
2879 | - calendar_so::combine_status($status,$quantity,$role); |
|
2878 | + calendar_so::combine_status($status, $quantity, $role); |
|
2880 | 2879 | } |
2881 | 2880 | } |
2882 | 2881 | $status = 'U'; // keep the group |
@@ -2885,36 +2884,36 @@ discard block |
||
2885 | 2884 | } |
2886 | 2885 | elseif (empty($searcharray)) |
2887 | 2886 | { |
2888 | - continue; // participants without email AND CN --> ignore it |
|
2887 | + continue; // participants without email AND CN --> ignore it |
|
2889 | 2888 | } |
2890 | 2889 | elseif ((list($data) = $this->addressbook->search($searcharray, |
2891 | - array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
2890 | + array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
2892 | 2891 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
2893 | - '','',false,'OR'))) |
|
2892 | + '', '', false, 'OR'))) |
|
2894 | 2893 | { |
2895 | 2894 | // found an addressbook entry |
2896 | 2895 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
2897 | 2896 | if ($this->log) |
2898 | 2897 | { |
2899 | 2898 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2900 | - . "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile); |
|
2899 | + . "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile); |
|
2901 | 2900 | } |
2902 | 2901 | } |
2903 | 2902 | else |
2904 | 2903 | { |
2905 | 2904 | if (!$email) |
2906 | 2905 | { |
2907 | - $email = '[email protected]'; // set dummy email to store the CN |
|
2906 | + $email = '[email protected]'; // set dummy email to store the CN |
|
2908 | 2907 | } |
2909 | - $uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email); |
|
2908 | + $uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email); |
|
2910 | 2909 | if ($this->log) |
2911 | 2910 | { |
2912 | 2911 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2913 | - . "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile); |
|
2912 | + . "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile); |
|
2914 | 2913 | } |
2915 | 2914 | } |
2916 | 2915 | } |
2917 | - switch($attributes['name']) |
|
2916 | + switch ($attributes['name']) |
|
2918 | 2917 | { |
2919 | 2918 | case 'ATTENDEE': |
2920 | 2919 | if (!isset($attributes['params']['ROLE']) && |
@@ -2928,7 +2927,7 @@ discard block |
||
2928 | 2927 | // keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role |
2929 | 2928 | // as this is currently the only way to store an external organizer and send him iMip responses |
2930 | 2929 | $q = $r = null; |
2931 | - if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) && |
|
2930 | + if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) && |
|
2932 | 2931 | calendar_so::split_status($s, $q, $r) && $r == 'CHAIR') |
2933 | 2932 | { |
2934 | 2933 | $role = 'CHAIR'; |
@@ -2942,7 +2941,7 @@ discard block |
||
2942 | 2941 | if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR') |
2943 | 2942 | $component->getAttribute('ORGANIZER'); |
2944 | 2943 | } |
2945 | - catch(Horde_Icalendar_Exception $e) |
|
2944 | + catch (Horde_Icalendar_Exception $e) |
|
2946 | 2945 | { |
2947 | 2946 | // we can store the ORGANIZER as event owner |
2948 | 2947 | $event['owner'] = $uid; |
@@ -2998,7 +2997,7 @@ discard block |
||
2998 | 2997 | break; |
2999 | 2998 | |
3000 | 2999 | case 'ATTACH': |
3001 | - if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
3000 | + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
3002 | 3001 | // fall throught to store external attachment url |
3003 | 3002 | default: // X- attribute or other by EGroupware unsupported property |
3004 | 3003 | //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); |
@@ -3056,7 +3055,7 @@ discard block |
||
3056 | 3055 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
3057 | 3056 | { |
3058 | 3057 | $event['reference'] = 0; |
3059 | - foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r) |
|
3058 | + foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r) |
|
3060 | 3059 | { |
3061 | 3060 | if (isset($vcardData[$r])) |
3062 | 3061 | { |
@@ -3079,12 +3078,12 @@ discard block |
||
3079 | 3078 | // reset recure_enddate to 00:00:00 on the last day |
3080 | 3079 | $rriter = calendar_rrule::event2rrule($event, false); |
3081 | 3080 | $last = $rriter->normalize_enddate(); |
3082 | - if(!is_object($last)) |
|
3081 | + if (!is_object($last)) |
|
3083 | 3082 | { |
3084 | - if($this->log) |
|
3083 | + if ($this->log) |
|
3085 | 3084 | { |
3086 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
3087 | - " Unable to determine recurrence end date. \n".array2string($event),3, $this->logfile); |
|
3085 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
3086 | + " Unable to determine recurrence end date. \n".array2string($event), 3, $this->logfile); |
|
3088 | 3087 | } |
3089 | 3088 | return false; |
3090 | 3089 | } |
@@ -3093,16 +3092,16 @@ discard block |
||
3093 | 3092 | $event['recur_enddate'] = egw_time::to($last, 'server'); |
3094 | 3093 | } |
3095 | 3094 | // translate COUNT into an enddate, as we only store enddates |
3096 | - elseif($event['recur_count']) |
|
3095 | + elseif ($event['recur_count']) |
|
3097 | 3096 | { |
3098 | 3097 | $rriter = calendar_rrule::event2rrule($event, false); |
3099 | 3098 | $last = $rriter->count2date($event['recur_count']); |
3100 | - if(!is_object($last)) |
|
3099 | + if (!is_object($last)) |
|
3101 | 3100 | { |
3102 | - if($this->log) |
|
3101 | + if ($this->log) |
|
3103 | 3102 | { |
3104 | 3103 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__, |
3105 | - " Unable to determine recurrence end date. \n".array2string($event),3, $this->logfile); |
|
3104 | + " Unable to determine recurrence end date. \n".array2string($event), 3, $this->logfile); |
|
3106 | 3105 | } |
3107 | 3106 | return false; |
3108 | 3107 | } |
@@ -3116,7 +3115,7 @@ discard block |
||
3116 | 3115 | if ($this->productManufacturer == 'groupdav' && $container && |
3117 | 3116 | ($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS'))) |
3118 | 3117 | { |
3119 | - $event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC'); |
|
3118 | + $event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC'); |
|
3120 | 3119 | } |
3121 | 3120 | //error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public'])); |
3122 | 3121 | } |
@@ -3137,15 +3136,15 @@ discard block |
||
3137 | 3136 | |
3138 | 3137 | if ($this->log) |
3139 | 3138 | { |
3140 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
3141 | - array2string($event)."\n",3,$this->logfile); |
|
3139 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
3140 | + array2string($event)."\n", 3, $this->logfile); |
|
3142 | 3141 | } |
3143 | 3142 | //Horde::logMessage("vevent2egw:\n" . print_r($event, true), |
3144 | 3143 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
3145 | 3144 | return $event; |
3146 | 3145 | } |
3147 | 3146 | |
3148 | - function search($_vcalData, $contentID=null, $relax=false, $charset=null) |
|
3147 | + function search($_vcalData, $contentID = null, $relax = false, $charset = null) |
|
3149 | 3148 | { |
3150 | 3149 | if (($events = $this->icaltoegw($_vcalData, $charset))) |
3151 | 3150 | { |
@@ -3166,8 +3165,8 @@ discard block |
||
3166 | 3165 | } |
3167 | 3166 | if ($this->log) |
3168 | 3167 | { |
3169 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" . |
|
3170 | - array2string($events)."\n",3,$this->logfile); |
|
3168 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n". |
|
3169 | + array2string($events)."\n", 3, $this->logfile); |
|
3171 | 3170 | } |
3172 | 3171 | } |
3173 | 3172 | return array(); |
@@ -3185,23 +3184,23 @@ discard block |
||
3185 | 3184 | * @param array $extra =null extra attributes to add |
3186 | 3185 | * X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy |
3187 | 3186 | */ |
3188 | - function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
|
3187 | + function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null) |
|
3189 | 3188 | { |
3190 | - if (!$start) $start = time(); // default now |
|
3191 | - if (!$end) $end = time() + 100*DAY_s; // default next 100 days |
|
3189 | + if (!$start) $start = time(); // default now |
|
3190 | + if (!$end) $end = time() + 100 * DAY_s; // default next 100 days |
|
3192 | 3191 | |
3193 | 3192 | $vcal = new Horde_Icalendar; |
3194 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
3193 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
3195 | 3194 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
3196 | - $vcal->setAttribute('VERSION','2.0'); |
|
3197 | - $vcal->setAttribute('METHOD',$method); |
|
3195 | + $vcal->setAttribute('VERSION', '2.0'); |
|
3196 | + $vcal->setAttribute('METHOD', $method); |
|
3198 | 3197 | |
3199 | - $vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal); |
|
3198 | + $vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal); |
|
3200 | 3199 | |
3201 | 3200 | $attributes = array( |
3202 | 3201 | 'DTSTAMP' => time(), |
3203 | - 'DTSTART' => $this->date2ts($start,true), // true = server-time |
|
3204 | - 'DTEND' => $this->date2ts($end,true), // true = server-time |
|
3202 | + 'DTSTART' => $this->date2ts($start, true), // true = server-time |
|
3203 | + 'DTEND' => $this->date2ts($end, true), // true = server-time |
|
3205 | 3204 | ); |
3206 | 3205 | if (!$utc) |
3207 | 3206 | { |
@@ -3212,9 +3211,9 @@ discard block |
||
3212 | 3211 | } |
3213 | 3212 | if (is_null($extra)) $extra = array( |
3214 | 3213 | 'URL' => $this->freebusy_url($user), |
3215 | - 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'), |
|
3214 | + 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'), |
|
3216 | 3215 | ); |
3217 | - foreach($attributes+$extra as $attr => $value) |
|
3216 | + foreach ($attributes + $extra as $attr => $value) |
|
3218 | 3217 | { |
3219 | 3218 | $vfreebusy->setAttribute($attr, $value); |
3220 | 3219 | } |
@@ -3237,16 +3236,16 @@ discard block |
||
3237 | 3236 | |
3238 | 3237 | if ($utc) |
3239 | 3238 | { |
3240 | - $vfreebusy->setAttribute('FREEBUSY',array(array( |
|
3239 | + $vfreebusy->setAttribute('FREEBUSY', array(array( |
|
3241 | 3240 | 'start' => $event['start'], |
3242 | 3241 | 'end' => $event['end'], |
3243 | 3242 | )), array('FBTYPE' => $fbtype)); |
3244 | 3243 | } |
3245 | 3244 | else |
3246 | 3245 | { |
3247 | - $vfreebusy->setAttribute('FREEBUSY',array(array( |
|
3248 | - 'start' => date('Ymd\THis',$event['start']), |
|
3249 | - 'end' => date('Ymd\THis',$event['end']), |
|
3246 | + $vfreebusy->setAttribute('FREEBUSY', array(array( |
|
3247 | + 'start' => date('Ymd\THis', $event['start']), |
|
3248 | + 'end' => date('Ymd\THis', $event['end']), |
|
3250 | 3249 | )), array('FBTYPE' => $fbtype)); |
3251 | 3250 | } |
3252 | 3251 | } |
@@ -15,40 +15,40 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * some necessary defines used by the calendar |
17 | 17 | */ |
18 | -if(!extension_loaded('mcal')) |
|
18 | +if (!extension_loaded('mcal')) |
|
19 | 19 | { |
20 | - define('MCAL_RECUR_NONE',0); |
|
21 | - define('MCAL_RECUR_DAILY',1); |
|
22 | - define('MCAL_RECUR_WEEKLY',2); |
|
23 | - define('MCAL_RECUR_MONTHLY_MDAY',3); |
|
24 | - define('MCAL_RECUR_MONTHLY_WDAY',4); |
|
25 | - define('MCAL_RECUR_YEARLY',5); |
|
26 | - define('MCAL_RECUR_SECONDLY',6); |
|
27 | - define('MCAL_RECUR_MINUTELY',7); |
|
28 | - define('MCAL_RECUR_HOURLY',8); |
|
29 | - |
|
30 | - define('MCAL_M_SUNDAY',1); |
|
31 | - define('MCAL_M_MONDAY',2); |
|
32 | - define('MCAL_M_TUESDAY',4); |
|
33 | - define('MCAL_M_WEDNESDAY',8); |
|
34 | - define('MCAL_M_THURSDAY',16); |
|
35 | - define('MCAL_M_FRIDAY',32); |
|
36 | - define('MCAL_M_SATURDAY',64); |
|
37 | - |
|
38 | - define('MCAL_M_WEEKDAYS',62); |
|
39 | - define('MCAL_M_WEEKEND',65); |
|
40 | - define('MCAL_M_ALLDAYS',127); |
|
20 | + define('MCAL_RECUR_NONE', 0); |
|
21 | + define('MCAL_RECUR_DAILY', 1); |
|
22 | + define('MCAL_RECUR_WEEKLY', 2); |
|
23 | + define('MCAL_RECUR_MONTHLY_MDAY', 3); |
|
24 | + define('MCAL_RECUR_MONTHLY_WDAY', 4); |
|
25 | + define('MCAL_RECUR_YEARLY', 5); |
|
26 | + define('MCAL_RECUR_SECONDLY', 6); |
|
27 | + define('MCAL_RECUR_MINUTELY', 7); |
|
28 | + define('MCAL_RECUR_HOURLY', 8); |
|
29 | + |
|
30 | + define('MCAL_M_SUNDAY', 1); |
|
31 | + define('MCAL_M_MONDAY', 2); |
|
32 | + define('MCAL_M_TUESDAY', 4); |
|
33 | + define('MCAL_M_WEDNESDAY', 8); |
|
34 | + define('MCAL_M_THURSDAY', 16); |
|
35 | + define('MCAL_M_FRIDAY', 32); |
|
36 | + define('MCAL_M_SATURDAY', 64); |
|
37 | + |
|
38 | + define('MCAL_M_WEEKDAYS', 62); |
|
39 | + define('MCAL_M_WEEKEND', 65); |
|
40 | + define('MCAL_M_ALLDAYS', 127); |
|
41 | 41 | } |
42 | 42 | |
43 | -define('REJECTED',0); |
|
44 | -define('NO_RESPONSE',1); |
|
45 | -define('TENTATIVE',2); |
|
46 | -define('ACCEPTED',3); |
|
47 | -define('DELEGATED',4); |
|
43 | +define('REJECTED', 0); |
|
44 | +define('NO_RESPONSE', 1); |
|
45 | +define('TENTATIVE', 2); |
|
46 | +define('ACCEPTED', 3); |
|
47 | +define('DELEGATED', 4); |
|
48 | 48 | |
49 | -define('HOUR_s',60*60); |
|
50 | -define('DAY_s',24*HOUR_s); |
|
51 | -define('WEEK_s',7*DAY_s); |
|
49 | +define('HOUR_s', 60 * 60); |
|
50 | +define('DAY_s', 24 * HOUR_s); |
|
51 | +define('WEEK_s', 7 * DAY_s); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Class to store all calendar data (storage object) |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * name of the main calendar table and prefix for all other calendar tables |
97 | 97 | */ |
98 | 98 | var $cal_table = 'egw_cal'; |
99 | - var $extra_table,$repeats_table,$user_table,$dates_table,$all_tables; |
|
99 | + var $extra_table, $repeats_table, $user_table, $dates_table, $all_tables; |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * reference to global db-object |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $this->db = $GLOBALS['egw']->db; |
133 | 133 | |
134 | 134 | $this->all_tables = array($this->cal_table); |
135 | - foreach(array('extra','repeats','user','dates') as $name) |
|
135 | + foreach (array('extra', 'repeats', 'user', 'dates') as $name) |
|
136 | 136 | { |
137 | 137 | $vname = $name.'_table'; |
138 | 138 | $this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name; |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | * @param boolean $deleted =false |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - protected function cal_range_view($start, $end, array $_where=null, $deleted=false) |
|
151 | + protected function cal_range_view($start, $end, array $_where = null, $deleted = false) |
|
152 | 152 | { |
153 | 153 | if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) // using view without start-date is slower! |
154 | 154 | { |
155 | - return $this->cal_table; // no need / use for a view |
|
155 | + return $this->cal_table; // no need / use for a view |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $where = array(); |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | * @param boolean $deleted =false |
179 | 179 | * @return string |
180 | 180 | */ |
181 | - protected function dates_range_view($start, $end, array $_where=null, $deleted=false) |
|
181 | + protected function dates_range_view($start, $end, array $_where = null, $deleted = false) |
|
182 | 182 | { |
183 | 183 | if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) // using view without start- AND end-date is slower! |
184 | 184 | { |
185 | - return $this->dates_table; // no need / use for a view |
|
185 | + return $this->dates_table; // no need / use for a view |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $where = array(); |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
228 | 228 | * @return array of events |
229 | 229 | */ |
230 | - function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null) |
|
230 | + function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null) |
|
231 | 231 | { |
232 | - error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
|
232 | + error_log(__METHOD__.'('.($start ? date('Y-m-d H:i', $start) : '').','.($end ? date('Y-m-d H:i', $end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
|
233 | 233 | $start_time = microtime(true); |
234 | 234 | // not everything is supported by now |
235 | 235 | if (!$start || !$end || is_string($params['query']) || |
236 | 236 | //in_array($filter,array('owner','deleted')) || |
237 | - $params['enum_recuring']===false) |
|
237 | + $params['enum_recuring'] === false) |
|
238 | 238 | { |
239 | 239 | throw new egw_exception_assertion_failed("Unsupported value for parameters!"); |
240 | 240 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | { |
262 | 262 | // fix $users to also prefix system users and groups (with 'u') |
263 | 263 | if (!is_array($users)) $users = $users ? (array)$users : array(); |
264 | - foreach($users as &$uid) |
|
264 | + foreach ($users as &$uid) |
|
265 | 265 | { |
266 | 266 | $user_type = $user_id = null; |
267 | 267 | self::split_user($uid, $user_type, $user_id, true); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | if ($params['order']) // only order if requested |
284 | 284 | { |
285 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
285 | + if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
286 | 286 | $sql .= "\nORDER BY ".$params['order']; |
287 | 287 | } |
288 | 288 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | $offset = 0; |
292 | 292 | $num_rows = -1; |
293 | 293 | } |
294 | - $events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
|
295 | - error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3)); |
|
294 | + $events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
|
295 | + error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3)); |
|
296 | 296 | return $events; |
297 | 297 | } |
298 | 298 | |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | * @param int $recur_date =0 if set read the next recurrence at or after the timestamp, default 0 = read the initital one |
306 | 306 | * @return array|boolean array with cal_id => event array pairs or false if entry not found |
307 | 307 | */ |
308 | - function read($ids,$recur_date=0) |
|
308 | + function read($ids, $recur_date = 0) |
|
309 | 309 | { |
310 | 310 | //error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace()); |
311 | 311 | $cols = self::get_columns('calendar', $this->cal_table); |
312 | 312 | $cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); |
313 | - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols); |
|
313 | + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols); |
|
314 | 314 | $join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id"; |
315 | 315 | |
316 | 316 | $where = array(); |
@@ -320,23 +320,23 @@ discard block |
||
320 | 320 | $where['cal_uid'] = $ids; |
321 | 321 | $where['cal_reference'] = 0; |
322 | 322 | } |
323 | - elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) // one or more cal_id's |
|
323 | + elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids)) // one or more cal_id's |
|
324 | 324 | { |
325 | 325 | $where['cal_id'] = $ids; |
326 | 326 | } |
327 | 327 | else // array with column => value pairs |
328 | 328 | { |
329 | 329 | $where = $ids; |
330 | - unset($ids); // otherwise users get not read! |
|
330 | + unset($ids); // otherwise users get not read! |
|
331 | 331 | } |
332 | 332 | if (isset($where['cal_id'])) // prevent non-unique column-name cal_id |
333 | 333 | { |
334 | - $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array( |
|
334 | + $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array( |
|
335 | 335 | 'cal_id' => $where['cal_id'], |
336 | 336 | )); |
337 | 337 | unset($where['cal_id']); |
338 | 338 | } |
339 | - if ((int) $recur_date) |
|
339 | + if ((int)$recur_date) |
|
340 | 340 | { |
341 | 341 | $where[] = 'cal_start >= '.(int)$recur_date; |
342 | 342 | $group_by = 'GROUP BY '.$cols; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | $cols .= ',range_end AS recur_enddate'; |
351 | 351 | |
352 | - $events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date); |
|
352 | + $events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date); |
|
353 | 353 | |
354 | 354 | return $events ? $events : false; |
355 | 355 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @param int $recur_date =0 |
362 | 362 | * @return array |
363 | 363 | */ |
364 | - protected function &get_events($rs, $recur_date=0) |
|
364 | + protected function &get_events($rs, $recur_date = 0) |
|
365 | 365 | { |
366 | 366 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
367 | 367 | { |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | $events = array(); |
376 | - foreach($rs as $row) |
|
376 | + foreach ($rs as $row) |
|
377 | 377 | { |
378 | 378 | if (!$row['recur_type']) |
379 | 379 | { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | unset($row['recur_enddate']); |
382 | 382 | } |
383 | 383 | $row['recur_exception'] = $row['alarm'] = array(); |
384 | - $events[$row['cal_id']] = egw_db::strip_array_keys($row,'cal_'); |
|
384 | + $events[$row['cal_id']] = egw_db::strip_array_keys($row, 'cal_'); |
|
385 | 385 | } |
386 | 386 | if (!$events) return $events; |
387 | 387 | |
@@ -393,26 +393,26 @@ discard block |
||
393 | 393 | if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length) |
394 | 394 | { |
395 | 395 | // event (without uid), not strong enough uid => create new uid |
396 | - $event['uid'] = common::generate_uid('calendar',$event['id']); |
|
396 | + $event['uid'] = common::generate_uid('calendar', $event['id']); |
|
397 | 397 | $this->db->update($this->cal_table, array('cal_uid' => $event['uid']), |
398 | - array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar'); |
|
398 | + array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar'); |
|
399 | 399 | } |
400 | 400 | if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE) |
401 | 401 | { |
402 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
402 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
403 | 403 | 'cal_id' => $ids, |
404 | 404 | 'recur_exception' => true, |
405 | 405 | ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row) |
406 | 406 | { |
407 | 407 | $events[$row['cal_id']]['recur_exception'][] = $row['cal_start']; |
408 | 408 | } |
409 | - break; // as above select read all exceptions (and I dont think too short uid problem still exists) |
|
409 | + break; // as above select read all exceptions (and I dont think too short uid problem still exists) |
|
410 | 410 | } |
411 | 411 | // make sure we fetch only real exceptions (deleted occurrences of a series should not show up) |
412 | - if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE)) |
|
412 | + if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE)) |
|
413 | 413 | { |
414 | 414 | //_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']); |
415 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
415 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
416 | 416 | 'cal_id' => $event['id'], |
417 | 417 | 'cal_start' => $event['start'], |
418 | 418 | 'recur_exception' => true, |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | 'cal_deleted' => NULL |
429 | 429 | ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn()) |
430 | 430 | { |
431 | - $e = $this->read($event['id'],$event['start']+1); |
|
431 | + $e = $this->read($event['id'], $event['start'] + 1); |
|
432 | 432 | $event = $e[$event['id']]; |
433 | 433 | break; |
434 | 434 | } |
@@ -450,21 +450,21 @@ discard block |
||
450 | 450 | if ($recur_date) |
451 | 451 | { |
452 | 452 | // also remember recur_date, maybe we need it later, duno now |
453 | - $recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']); |
|
453 | + $recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']); |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | 457 | // participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0 |
458 | 458 | // sorting by cal_recur_date ASC makes sure recurence status always overwrites series status |
459 | - foreach($this->db->select($this->user_table,'*',array( |
|
459 | + foreach ($this->db->select($this->user_table, '*', array( |
|
460 | 460 | 'cal_id' => $ids, |
461 | 461 | 'cal_recur_date' => $recur_date, |
462 | 462 | "cal_status NOT IN ('X','E')", |
463 | - ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) // DESC puts users before resources and contacts |
|
463 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT, 'calendar') as $row) // DESC puts users before resources and contacts |
|
464 | 464 | { |
465 | 465 | // combine all participant data in uid and status values |
466 | 466 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
467 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
467 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
468 | 468 | |
469 | 469 | $events[$row['cal_id']]['participants'][$uid] = $status; |
470 | 470 | $events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | // custom fields |
476 | - foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row) |
|
476 | + foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
477 | 477 | { |
478 | 478 | $events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value']; |
479 | 479 | } |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | // alarms |
482 | 482 | if (is_array($ids)) |
483 | 483 | { |
484 | - foreach($this->read_alarms((array)$ids) as $cal_id => $alarms) |
|
484 | + foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms) |
|
485 | 485 | { |
486 | 486 | $events[$cal_id]['alarm'] = $alarms; |
487 | 487 | } |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
511 | 511 | * @return int maximum modification timestamp |
512 | 512 | */ |
513 | - function get_ctag($users, $owner_too=false,$master_only=false) |
|
513 | + function get_ctag($users, $owner_too = false, $master_only = false) |
|
514 | 514 | { |
515 | - static $ctags = array(); // some per-request caching |
|
515 | + static $ctags = array(); // some per-request caching |
|
516 | 516 | static $last_request = null; |
517 | - if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME) |
|
517 | + if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME) |
|
518 | 518 | { |
519 | 519 | $ctags = array(); |
520 | 520 | $last_request = time(); |
@@ -523,13 +523,13 @@ discard block |
||
523 | 523 | if (isset($ctags[$signature])) return $ctags[$signature]; |
524 | 524 | |
525 | 525 | $types = array(); |
526 | - foreach((array)$users as $uid) |
|
526 | + foreach ((array)$users as $uid) |
|
527 | 527 | { |
528 | 528 | $type = $id = null; |
529 | 529 | self::split_user($uid, $type, $id, true); |
530 | 530 | $types[$type][] = $id; |
531 | 531 | } |
532 | - foreach($types as $type => $ids) |
|
532 | + foreach ($types as $type => $ids) |
|
533 | 533 | { |
534 | 534 | $where = array( |
535 | 535 | 'cal_user_type' => $type, |
@@ -551,17 +551,17 @@ discard block |
||
551 | 551 | if ($owner_too) |
552 | 552 | { |
553 | 553 | // owner can only by users, no groups or resources |
554 | - foreach($users as $key => $user) |
|
554 | + foreach ($users as $key => $user) |
|
555 | 555 | { |
556 | 556 | if (!($user > 0)) unset($users[$key]); |
557 | 557 | } |
558 | 558 | $where = $this->db->expression($this->user_table, '(', $where, ' OR '). |
559 | 559 | $this->db->expression($this->cal_table, array( |
560 | 560 | 'cal_owner' => $users, |
561 | - ),')'); |
|
561 | + ), ')'); |
|
562 | 562 | } |
563 | - return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)', |
|
564 | - $where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn(); |
|
563 | + return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)', |
|
564 | + $where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn(); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query |
574 | 574 | * @return Iterator as egw_db::select |
575 | 575 | */ |
576 | - function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
|
576 | + function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
|
577 | 577 | { |
578 | 578 | if (!is_array($cols)) $cols = explode(',', $cols); |
579 | 579 | |
@@ -599,12 +599,12 @@ discard block |
||
599 | 599 | if ($cat_id) |
600 | 600 | { |
601 | 601 | $cats = $GLOBALS['egw']->categories->return_all_children($cat_id); |
602 | - array_walk($cats,create_function('&$val,$key','$val = (int) $val;')); |
|
603 | - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; |
|
604 | - $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); |
|
605 | - foreach($cats as $cat) |
|
602 | + array_walk($cats, create_function('&$val,$key', '$val = (int) $val;')); |
|
603 | + if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0]; |
|
604 | + $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id)); |
|
605 | + foreach ($cats as $cat) |
|
606 | 606 | { |
607 | - $sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%'); |
|
607 | + $sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%'); |
|
608 | 608 | } |
609 | 609 | $sql .= ') '; |
610 | 610 | } |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | * @param array $where =array() array to add filters too |
620 | 620 | * @return array |
621 | 621 | */ |
622 | - protected function status_filter($filter, $enum_recuring=true, array $where=array()) |
|
622 | + protected function status_filter($filter, $enum_recuring = true, array $where = array()) |
|
623 | 623 | { |
624 | - if($filter != 'deleted' && $filter != 'everything') |
|
624 | + if ($filter != 'deleted' && $filter != 'everything') |
|
625 | 625 | { |
626 | 626 | $where[] = 'cal_deleted IS NULL'; |
627 | 627 | } |
628 | - switch($filter) |
|
628 | + switch ($filter) |
|
629 | 629 | { |
630 | 630 | case 'everything': // no filter at all |
631 | 631 | break; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
700 | 700 | * @return Iterator|array of events |
701 | 701 | */ |
702 | - function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null) |
|
702 | + function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null) |
|
703 | 703 | { |
704 | 704 | //error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
705 | 705 | |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | { |
723 | 723 | $all_cols = self::get_columns('calendar', $this->cal_table); |
724 | 724 | $all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); |
725 | - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
725 | + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',', $all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
726 | 726 | } |
727 | 727 | $where = array(); |
728 | 728 | if (is_array($params['query'])) |
@@ -731,19 +731,19 @@ discard block |
||
731 | 731 | } |
732 | 732 | elseif ($params['query']) |
733 | 733 | { |
734 | - foreach(array('cal_title','cal_description','cal_location') as $col) |
|
734 | + foreach (array('cal_title', 'cal_description', 'cal_location') as $col) |
|
735 | 735 | { |
736 | 736 | $to_or[] = $col.' '.$this->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%'); |
737 | 737 | } |
738 | - $where[] = '('.implode(' OR ',$to_or).')'; |
|
738 | + $where[] = '('.implode(' OR ', $to_or).')'; |
|
739 | 739 | |
740 | 740 | // Searching - restrict private to own or private grant |
741 | 741 | if (!isset($params['private_grants'])) |
742 | 742 | { |
743 | 743 | $params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], EGW_ACL_PRIVATE, 'calendar'); |
744 | - $params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user |
|
744 | + $params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user |
|
745 | 745 | } |
746 | - $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')'; |
|
746 | + $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')'; |
|
747 | 747 | $where[] = $private_filter; |
748 | 748 | } |
749 | 749 | if (!empty($params['sql_filter'])) |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | { |
753 | 753 | $where[] = $params['sql_filter']; |
754 | 754 | } |
755 | - elseif(is_array($params['sql_filter'])) |
|
755 | + elseif (is_array($params['sql_filter'])) |
|
756 | 756 | { |
757 | 757 | $where = array_merge($where, $params['sql_filter']); |
758 | 758 | } |
@@ -760,11 +760,11 @@ discard block |
||
760 | 760 | if ($users) |
761 | 761 | { |
762 | 762 | $users_by_type = array(); |
763 | - foreach((array)$users as $user) |
|
763 | + foreach ((array)$users as $user) |
|
764 | 764 | { |
765 | 765 | if (is_numeric($user)) |
766 | 766 | { |
767 | - $users_by_type['u'][] = (int) $user; |
|
767 | + $users_by_type['u'][] = (int)$user; |
|
768 | 768 | } |
769 | 769 | else |
770 | 770 | { |
@@ -776,45 +776,45 @@ discard block |
||
776 | 776 | $to_or = $user_or = array(); |
777 | 777 | $owner_or = null; |
778 | 778 | $useUnionQuery = $this->db->capabilities['distinct_on_text'] && $this->db->capabilities['union']; |
779 | - $table_def = $this->db->get_table_definitions('calendar',$this->user_table); |
|
780 | - foreach($users_by_type as $type => $ids) |
|
779 | + $table_def = $this->db->get_table_definitions('calendar', $this->user_table); |
|
780 | + foreach ($users_by_type as $type => $ids) |
|
781 | 781 | { |
782 | 782 | // when we are able to use Union Querys, we do not OR our query, we save the needed parts for later construction of the union |
783 | 783 | if ($useUnionQuery) |
784 | 784 | { |
785 | - $user_or[] = $this->db->expression($table_def,$this->user_table.'.',array( |
|
785 | + $user_or[] = $this->db->expression($table_def, $this->user_table.'.', array( |
|
786 | 786 | 'cal_user_type' => $type, |
787 | - ),' AND '.$this->user_table.'.',array( |
|
787 | + ), ' AND '.$this->user_table.'.', array( |
|
788 | 788 | 'cal_user_id' => $ids, |
789 | 789 | )); |
790 | 790 | if ($type == 'u' && $filter == 'owner') |
791 | 791 | { |
792 | - $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); |
|
792 | + $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
|
793 | 793 | // only users can be owners, no need to add groups |
794 | 794 | $user_ids = array(); |
795 | - foreach($ids as $user_id) |
|
795 | + foreach ($ids as $user_id) |
|
796 | 796 | { |
797 | 797 | if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id; |
798 | 798 | } |
799 | - $owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids)); |
|
799 | + $owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids)); |
|
800 | 800 | } |
801 | 801 | } |
802 | 802 | else |
803 | 803 | { |
804 | - $to_or[] = $this->db->expression($table_def,$this->user_table.'.',array( |
|
804 | + $to_or[] = $this->db->expression($table_def, $this->user_table.'.', array( |
|
805 | 805 | 'cal_user_type' => $type, |
806 | - ),' AND '.$this->user_table.'.',array( |
|
806 | + ), ' AND '.$this->user_table.'.', array( |
|
807 | 807 | 'cal_user_id' => $ids, |
808 | 808 | )); |
809 | 809 | if ($type == 'u' && $filter == 'owner') |
810 | 810 | { |
811 | - $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); |
|
812 | - $to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids)); |
|
811 | + $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
|
812 | + $to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids)); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | } |
816 | 816 | // this is only used, when we cannot use UNIONS |
817 | - if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; |
|
817 | + if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')'; |
|
818 | 818 | |
819 | 819 | $where = $this->status_filter($filter, $params['enum_recuring'], $where); |
820 | 820 | } |
@@ -833,15 +833,15 @@ discard block |
||
833 | 833 | $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; |
834 | 834 | } |
835 | 835 | } |
836 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
836 | + if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
837 | 837 | |
838 | 838 | // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! |
839 | 839 | if (!$params['enum_recuring']) |
840 | 840 | { |
841 | 841 | $where[] = "$this->user_table.cal_recur_date=0"; |
842 | - $cols = str_replace(array('cal_start','cal_end'),array('range_start AS cal_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'),$cols); |
|
842 | + $cols = str_replace(array('cal_start', 'cal_end'), array('range_start AS cal_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'), $cols); |
|
843 | 843 | // in case cal_start is used in a query, eg. calendar_ical::find_event |
844 | - $where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
|
844 | + $where = str_replace(array('cal_start', 'cal_end'), array('range_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
|
845 | 845 | $params['order'] = str_replace('cal_start', 'range_start', $params['order']); |
846 | 846 | if ($end) $where[] = (int)$end.' > range_start'; |
847 | 847 | } |
@@ -853,14 +853,13 @@ discard block |
||
853 | 853 | " ON $this->cal_table.cal_id=rejected_by_user.cal_id". |
854 | 854 | " AND rejected_by_user.cal_user_type='u'". |
855 | 855 | " AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user). |
856 | - " AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : |
|
857 | - '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)'); |
|
856 | + " AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)'); |
|
858 | 857 | $or_required = array( |
859 | 858 | 'rejected_by_user.cal_status IS NULL', |
860 | 859 | "rejected_by_user.cal_status NOT IN ('R','X')", |
861 | 860 | ); |
862 | 861 | if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
863 | - $where[] = '('.implode(' OR ',$or_required).')'; |
|
862 | + $where[] = '('.implode(' OR ', $or_required).')'; |
|
864 | 863 | } |
865 | 864 | // using a time-range and deleted attribute limited view instead of full table |
866 | 865 | $cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted'); |
@@ -872,7 +871,7 @@ discard block |
||
872 | 871 | // dates table join only needed to enum recuring events, we use a time-range limited view here too |
873 | 872 | if ($params['enum_recuring']) |
874 | 873 | { |
875 | - $join = "JOIN ".$this->dates_table. // using dates_table direct seems quicker then an other view |
|
874 | + $join = "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view |
|
876 | 875 | //$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted'). |
877 | 876 | " ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$join; |
878 | 877 | } |
@@ -899,29 +898,29 @@ discard block |
||
899 | 898 | // as replace the OR by construction of a suitable UNION for performance reasons |
900 | 899 | if ($owner_or || $user_or) |
901 | 900 | { |
902 | - foreach($user_or as $user_sql) |
|
901 | + foreach ($user_or as $user_sql) |
|
903 | 902 | { |
904 | 903 | $selects[] = $select; |
905 | - $selects[count($selects)-1]['where'][] = $user_sql; |
|
904 | + $selects[count($selects) - 1]['where'][] = $user_sql; |
|
906 | 905 | if ($params['enum_recuring']) |
907 | 906 | { |
908 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
907 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
909 | 908 | $selects[] = $select; |
910 | - $selects[count($selects)-1]['where'][] = $user_sql; |
|
911 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
909 | + $selects[count($selects) - 1]['where'][] = $user_sql; |
|
910 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
912 | 911 | } |
913 | 912 | } |
914 | 913 | // if the query is to be filtered by owner we need to add more selects for the union |
915 | 914 | if ($owner_or) |
916 | 915 | { |
917 | 916 | $selects[] = $select; |
918 | - $selects[count($selects)-1]['where'][] = $owner_or; |
|
917 | + $selects[count($selects) - 1]['where'][] = $owner_or; |
|
919 | 918 | if ($params['enum_recuring']) |
920 | 919 | { |
921 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
920 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
922 | 921 | $selects[] = $select; |
923 | - $selects[count($selects)-1]['where'][] = $owner_or; |
|
924 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
922 | + $selects[count($selects) - 1]['where'][] = $owner_or; |
|
923 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
925 | 924 | } |
926 | 925 | } |
927 | 926 | } |
@@ -931,34 +930,34 @@ discard block |
||
931 | 930 | $selects[] = $select; |
932 | 931 | if ($params['enum_recuring']) |
933 | 932 | { |
934 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
933 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
935 | 934 | $selects[] = $select; |
936 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
935 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
937 | 936 | } |
938 | 937 | } |
939 | 938 | if (is_numeric($offset) && !$params['no_total']) // get the total too |
940 | 939 | { |
941 | 940 | $save_selects = $selects; |
942 | 941 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
943 | - foreach(array_keys($selects) as $key) |
|
942 | + foreach (array_keys($selects) as $key) |
|
944 | 943 | { |
945 | 944 | $selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date"; |
946 | 945 | if (!$params['enum_recuring']) |
947 | 946 | { |
948 | - $selects[$key]['cols'] = str_replace(array('cal_start','cal_end'), |
|
949 | - array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); |
|
947 | + $selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'), |
|
948 | + array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']); |
|
950 | 949 | } |
951 | 950 | } |
952 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
951 | + if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
953 | 952 | |
954 | - $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); |
|
953 | + $this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows(); |
|
955 | 954 | |
956 | 955 | // restore original cols / selects |
957 | 956 | $selects = $save_selects; unset($save_selects); |
958 | 957 | } |
959 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
958 | + if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
960 | 959 | |
961 | - $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
|
960 | + $rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows); |
|
962 | 961 | } |
963 | 962 | else // MsSQL oder MySQL 3.23 |
964 | 963 | { |
@@ -981,27 +980,27 @@ discard block |
||
981 | 980 | $selects[0]['cols'] = "$this->cal_table.cal_id,cal_start"; |
982 | 981 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
983 | 982 | { |
984 | - self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
983 | + self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
985 | 984 | } |
986 | 985 | $this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows(); |
987 | 986 | $selects = $save_selects; |
988 | 987 | } |
989 | 988 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
990 | 989 | { |
991 | - self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
990 | + self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
992 | 991 | } |
993 | - $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
|
992 | + $rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows); |
|
994 | 993 | } |
995 | 994 | //error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql); |
996 | 995 | |
997 | 996 | if (isset($params['cols'])) |
998 | 997 | { |
999 | - return $rs; // if colums are specified we return the recordset / iterator |
|
998 | + return $rs; // if colums are specified we return the recordset / iterator |
|
1000 | 999 | } |
1001 | 1000 | // Todo: return $this->get_events($rs); |
1002 | 1001 | |
1003 | 1002 | $events = $ids = $recur_dates = $recur_ids = array(); |
1004 | - foreach($rs as $row) |
|
1003 | + foreach ($rs as $row) |
|
1005 | 1004 | { |
1006 | 1005 | $id = $row['cal_id']; |
1007 | 1006 | if (is_numeric($id)) $ids[] = $id; |
@@ -1013,9 +1012,9 @@ discard block |
||
1013 | 1012 | } |
1014 | 1013 | if ($row['participants']) |
1015 | 1014 | { |
1016 | - $row['participants'] = explode(',',$row['participants']); |
|
1015 | + $row['participants'] = explode(',', $row['participants']); |
|
1017 | 1016 | $row['participants'] = array_combine($row['participants'], |
1018 | - array_fill(0,count($row['participants']),'')); |
|
1017 | + array_fill(0, count($row['participants']), '')); |
|
1019 | 1018 | } |
1020 | 1019 | else |
1021 | 1020 | { |
@@ -1024,9 +1023,9 @@ discard block |
||
1024 | 1023 | $row['recur_exception'] = $row['alarm'] = array(); |
1025 | 1024 | |
1026 | 1025 | // compile a list of recurrences per cal_id |
1027 | - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
1026 | + if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
1028 | 1027 | |
1029 | - $events[$id] = egw_db::strip_array_keys($row,'cal_'); |
|
1028 | + $events[$id] = egw_db::strip_array_keys($row, 'cal_'); |
|
1030 | 1029 | } |
1031 | 1030 | //_debug_array($events); |
1032 | 1031 | if (count($ids)) |
@@ -1036,26 +1035,26 @@ discard block |
||
1036 | 1035 | // now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date) |
1037 | 1036 | // This will always read the first entry of each recuring event too, we eliminate it later |
1038 | 1037 | $recur_dates[] = 0; |
1039 | - $utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")". |
|
1038 | + $utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")". |
|
1040 | 1039 | ($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid "; |
1041 | 1040 | //$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates "; |
1042 | - foreach($this->db->select($utcal_id_view,'*',array( |
|
1041 | + foreach ($this->db->select($utcal_id_view, '*', array( |
|
1043 | 1042 | //'cal_id' => array_unique($ids), |
1044 | 1043 | 'cal_recur_date' => $recur_dates, |
1045 | - ),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='', |
|
1046 | - $this->db->get_table_definitions('calendar',$this->user_table)) as $row) // DESC puts users before resources and contacts |
|
1044 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', $num_rows, $join = '', |
|
1045 | + $this->db->get_table_definitions('calendar', $this->user_table)) as $row) // DESC puts users before resources and contacts |
|
1047 | 1046 | { |
1048 | 1047 | $id = $row['cal_id']; |
1049 | 1048 | if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date']; |
1050 | 1049 | |
1051 | 1050 | // combine all participant data in uid and status values |
1052 | 1051 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
1053 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
1052 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
1054 | 1053 | |
1055 | 1054 | // set accept/reject/tentative of series for all recurrences |
1056 | 1055 | if (!$row['cal_recur_date']) |
1057 | 1056 | { |
1058 | - foreach((array)$recur_ids[$row['cal_id']] as $i) |
|
1057 | + foreach ((array)$recur_ids[$row['cal_id']] as $i) |
|
1059 | 1058 | { |
1060 | 1059 | if (isset($events[$i]) && !isset($events[$i]['participants'][$uid])) |
1061 | 1060 | { |
@@ -1070,16 +1069,16 @@ discard block |
||
1070 | 1069 | // query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...) |
1071 | 1070 | if (!$params['enum_recuring'] || !$params['daywise']) |
1072 | 1071 | { |
1073 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
1072 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
1074 | 1073 | 'cal_id' => $ids, |
1075 | 1074 | 'recur_exception' => true, |
1076 | 1075 | ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row) |
1077 | 1076 | { |
1078 | 1077 | // for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start |
1079 | 1078 | // find master, which is first recurrence |
1080 | - if (!isset($events[$id=$row['cal_id']])) |
|
1079 | + if (!isset($events[$id = $row['cal_id']])) |
|
1081 | 1080 | { |
1082 | - foreach($events as $id => $event) |
|
1081 | + foreach ($events as $id => $event) |
|
1083 | 1082 | { |
1084 | 1083 | if ($event['id'] == $row['cal_id']) break; |
1085 | 1084 | } |
@@ -1092,10 +1091,10 @@ discard block |
||
1092 | 1091 | { |
1093 | 1092 | $where = array('cal_id' => $ids); |
1094 | 1093 | if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; |
1095 | - foreach($this->db->select($this->extra_table,'*',$where, |
|
1096 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
1094 | + foreach ($this->db->select($this->extra_table, '*', $where, |
|
1095 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
1097 | 1096 | { |
1098 | - foreach((array)$recur_ids[$row['cal_id']] as $id) |
|
1097 | + foreach ((array)$recur_ids[$row['cal_id']] as $id) |
|
1099 | 1098 | { |
1100 | 1099 | if (isset($events[$id])) |
1101 | 1100 | { |
@@ -1105,9 +1104,9 @@ discard block |
||
1105 | 1104 | } |
1106 | 1105 | } |
1107 | 1106 | // alarms |
1108 | - foreach($this->read_alarms($ids) as $cal_id => $alarms) |
|
1107 | + foreach ($this->read_alarms($ids) as $cal_id => $alarms) |
|
1109 | 1108 | { |
1110 | - foreach($alarms as $id => $alarm) |
|
1109 | + foreach ($alarms as $id => $alarm) |
|
1111 | 1110 | { |
1112 | 1111 | $event_start = $alarm['time'] + $alarm['offset']; |
1113 | 1112 | |
@@ -1144,16 +1143,16 @@ discard block |
||
1144 | 1143 | * @param $query |
1145 | 1144 | * @param $users_raw as passed to calendar_bo::search (no members and memberships added) |
1146 | 1145 | */ |
1147 | - private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw) |
|
1146 | + private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw) |
|
1148 | 1147 | { |
1149 | - if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) || |
|
1150 | - !in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home'))) |
|
1148 | + if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) || |
|
1149 | + !in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home'))) |
|
1151 | 1150 | { |
1152 | - return; // disable integration for GroupDAV, SyncML, ... |
|
1151 | + return; // disable integration for GroupDAV, SyncML, ... |
|
1153 | 1152 | } |
1154 | 1153 | self::$integration_data = $GLOBALS['egw']->hooks->process(array( |
1155 | 1154 | 'location' => 'calendar_search_union', |
1156 | - 'cols' => $selects[0]['cols'], // cols to return |
|
1155 | + 'cols' => $selects[0]['cols'], // cols to return |
|
1157 | 1156 | 'start' => $start, |
1158 | 1157 | 'end' => $end, |
1159 | 1158 | 'users' => $users, |
@@ -1162,12 +1161,12 @@ discard block |
||
1162 | 1161 | 'filter'=> $filter, |
1163 | 1162 | 'query' => $query, |
1164 | 1163 | )); |
1165 | - foreach(self::$integration_data as $data) |
|
1164 | + foreach (self::$integration_data as $data) |
|
1166 | 1165 | { |
1167 | 1166 | if (is_array($data['selects'])) |
1168 | 1167 | { |
1169 | 1168 | //echo $app; _debug_array($data); |
1170 | - $selects = array_merge($selects,$data['selects']); |
|
1169 | + $selects = array_merge($selects, $data['selects']); |
|
1171 | 1170 | } |
1172 | 1171 | } |
1173 | 1172 | } |
@@ -1192,35 +1191,35 @@ discard block |
||
1192 | 1191 | * @param string $required_app ='calendar' |
1193 | 1192 | * @return string cols for union query to match ones supplied in $required |
1194 | 1193 | */ |
1195 | - public static function union_cols(array $app_cols,$required,$required_app='calendar') |
|
1194 | + public static function union_cols(array $app_cols, $required, $required_app = 'calendar') |
|
1196 | 1195 | { |
1197 | 1196 | // remove evtl. used DISTINCT, we currently dont need it |
1198 | - if (($distinct = substr($required,0,9) == 'DISTINCT ')) |
|
1197 | + if (($distinct = substr($required, 0, 9) == 'DISTINCT ')) |
|
1199 | 1198 | { |
1200 | - $required = substr($required,9); |
|
1199 | + $required = substr($required, 9); |
|
1201 | 1200 | } |
1202 | 1201 | $return_cols = array(); |
1203 | - foreach(is_array($required) ? $required : explode(',',$required) as $cols) |
|
1202 | + foreach (is_array($required) ? $required : explode(',', $required) as $cols) |
|
1204 | 1203 | { |
1205 | 1204 | $matches = null; |
1206 | - if (substr($cols,-2) == '.*') |
|
1205 | + if (substr($cols, -2) == '.*') |
|
1207 | 1206 | { |
1208 | - $cols = self::get_columns($required_app,substr($cols,0,-2)); |
|
1207 | + $cols = self::get_columns($required_app, substr($cols, 0, -2)); |
|
1209 | 1208 | } |
1210 | 1209 | // remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)" |
1211 | 1210 | elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches)) |
1212 | 1211 | { |
1213 | 1212 | $cols = $matches[1]; |
1214 | 1213 | } |
1215 | - elseif (strpos($cols,' AS ') !== false) |
|
1214 | + elseif (strpos($cols, ' AS ') !== false) |
|
1216 | 1215 | { |
1217 | - list(,$cols) = explode(' AS ',$cols); |
|
1216 | + list(,$cols) = explode(' AS ', $cols); |
|
1218 | 1217 | } |
1219 | - foreach((array)$cols as $col) |
|
1218 | + foreach ((array)$cols as $col) |
|
1220 | 1219 | { |
1221 | - if (substr($col,0,7) == 'egw_cal') // remove table name |
|
1220 | + if (substr($col, 0, 7) == 'egw_cal') // remove table name |
|
1222 | 1221 | { |
1223 | - $col = preg_replace('/^egw_cal[a-z_]*\./','',$col); |
|
1222 | + $col = preg_replace('/^egw_cal[a-z_]*\./', '', $col); |
|
1224 | 1223 | } |
1225 | 1224 | if (isset($app_cols[$col])) |
1226 | 1225 | { |
@@ -1233,7 +1232,7 @@ discard block |
||
1233 | 1232 | } |
1234 | 1233 | } |
1235 | 1234 | //error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols))); |
1236 | - return implode(',',$return_cols); |
|
1235 | + return implode(',', $return_cols); |
|
1237 | 1236 | } |
1238 | 1237 | |
1239 | 1238 | /** |
@@ -1243,21 +1242,21 @@ discard block |
||
1243 | 1242 | * @param string $table |
1244 | 1243 | * @return array of column names |
1245 | 1244 | */ |
1246 | - static private function get_columns($app,$table) |
|
1245 | + static private function get_columns($app, $table) |
|
1247 | 1246 | { |
1248 | 1247 | if ($table != 'egw_cal') |
1249 | 1248 | { |
1250 | - $table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table); |
|
1249 | + $table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table); |
|
1251 | 1250 | $cols = array_keys($table_def['fd']); |
1252 | 1251 | } |
1253 | 1252 | else |
1254 | 1253 | { |
1255 | 1254 | // special handling for egw_cal, as old databases have a different column order!!! |
1256 | - $cols =& egw_cache::getSession(__CLASS__,$table); |
|
1255 | + $cols = & egw_cache::getSession(__CLASS__, $table); |
|
1257 | 1256 | |
1258 | 1257 | if (is_null($cols)) |
1259 | 1258 | { |
1260 | - $meta = $GLOBALS['egw']->db->metadata($table,true); |
|
1259 | + $meta = $GLOBALS['egw']->db->metadata($table, true); |
|
1261 | 1260 | $cols = array_keys($meta['meta']); |
1262 | 1261 | } |
1263 | 1262 | } |
@@ -1310,12 +1309,12 @@ discard block |
||
1310 | 1309 | * @param int &$etag etag=null etag to check or null, on return new etag |
1311 | 1310 | * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise |
1312 | 1311 | */ |
1313 | - function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null) |
|
1312 | + function save($event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null) |
|
1314 | 1313 | { |
1315 | 1314 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
1316 | 1315 | { |
1317 | 1316 | $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; |
1318 | - if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
1317 | + if (empty($minimum_uid_length) || $minimum_uid_length <= 1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
1319 | 1318 | } |
1320 | 1319 | else |
1321 | 1320 | { |
@@ -1326,7 +1325,7 @@ discard block |
||
1326 | 1325 | |
1327 | 1326 | //error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace()); |
1328 | 1327 | |
1329 | - $cal_id = (int) $event['id']; |
|
1328 | + $cal_id = (int)$event['id']; |
|
1330 | 1329 | unset($event['id']); |
1331 | 1330 | $set_recurrences = !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE; |
1332 | 1331 | |
@@ -1354,9 +1353,9 @@ discard block |
||
1354 | 1353 | } |
1355 | 1354 | |
1356 | 1355 | // add colum prefix 'cal_' if there's not already a 'recur_' prefix |
1357 | - foreach($event as $col => $val) |
|
1356 | + foreach ($event as $col => $val) |
|
1358 | 1357 | { |
1359 | - if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name') |
|
1358 | + if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name') |
|
1360 | 1359 | { |
1361 | 1360 | $event['cal_'.$col] = $val; |
1362 | 1361 | unset($event[$col]); |
@@ -1366,13 +1365,12 @@ discard block |
||
1366 | 1365 | if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start']; |
1367 | 1366 | if (isset($event['cal_end'])) |
1368 | 1367 | { |
1369 | - $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : |
|
1370 | - ($event['recur_enddate'] ? $event['recur_enddate'] : null); |
|
1368 | + $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null); |
|
1371 | 1369 | } |
1372 | 1370 | // ensure that we find mathing entries later on |
1373 | 1371 | if (!is_array($event['cal_category'])) |
1374 | 1372 | { |
1375 | - $categories = array_unique(explode(',',$event['cal_category'])); |
|
1373 | + $categories = array_unique(explode(',', $event['cal_category'])); |
|
1376 | 1374 | sort($categories); |
1377 | 1375 | } |
1378 | 1376 | else |
@@ -1381,7 +1379,7 @@ discard block |
||
1381 | 1379 | } |
1382 | 1380 | sort($categories, SORT_NUMERIC); |
1383 | 1381 | |
1384 | - $event['cal_category'] = implode(',',$categories); |
|
1382 | + $event['cal_category'] = implode(',', $categories); |
|
1385 | 1383 | |
1386 | 1384 | // make sure recurring events never reference to an other recurrent event |
1387 | 1385 | if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0; |
@@ -1399,18 +1397,18 @@ discard block |
||
1399 | 1397 | // read only timezone id, to check if it is changed |
1400 | 1398 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1401 | 1399 | { |
1402 | - $old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn(); |
|
1400 | + $old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn(); |
|
1403 | 1401 | } |
1404 | 1402 | if (!is_null($etag)) $where['cal_etag'] = $etag; |
1405 | 1403 | |
1406 | 1404 | unset($event['cal_etag']); |
1407 | - $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
|
1405 | + $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
|
1408 | 1406 | |
1409 | - $this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar'); |
|
1407 | + $this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar'); |
|
1410 | 1408 | |
1411 | 1409 | if (!is_null($etag) && $this->db->affected_rows() < 1) |
1412 | 1410 | { |
1413 | - return 0; // wrong etag, someone else updated the entry |
|
1411 | + return 0; // wrong etag, someone else updated the entry |
|
1414 | 1412 | } |
1415 | 1413 | if (!is_null($etag)) ++$etag; |
1416 | 1414 | } |
@@ -1419,10 +1417,10 @@ discard block |
||
1419 | 1417 | // new event |
1420 | 1418 | if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
1421 | 1419 | |
1422 | - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
1420 | + if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
1423 | 1421 | |
1424 | - $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); |
|
1425 | - if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id'))) |
|
1422 | + $this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar'); |
|
1423 | + if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id'))) |
|
1426 | 1424 | { |
1427 | 1425 | return false; |
1428 | 1426 | } |
@@ -1432,7 +1430,7 @@ discard block |
||
1432 | 1430 | // event without uid or not strong enough uid |
1433 | 1431 | if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length) |
1434 | 1432 | { |
1435 | - $update['cal_uid'] = $event['cal_uid'] = common::generate_uid('calendar',$cal_id); |
|
1433 | + $update['cal_uid'] = $event['cal_uid'] = common::generate_uid('calendar', $cal_id); |
|
1436 | 1434 | } |
1437 | 1435 | // set caldav_name, if not given by caller |
1438 | 1436 | if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>=')) |
@@ -1441,37 +1439,37 @@ discard block |
||
1441 | 1439 | } |
1442 | 1440 | if ($update) |
1443 | 1441 | { |
1444 | - $this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar'); |
|
1442 | + $this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar'); |
|
1445 | 1443 | } |
1446 | 1444 | |
1447 | 1445 | if ($event['recur_type'] == MCAL_RECUR_NONE) |
1448 | 1446 | { |
1449 | - $this->db->delete($this->dates_table,array( |
|
1447 | + $this->db->delete($this->dates_table, array( |
|
1450 | 1448 | 'cal_id' => $cal_id), |
1451 | - __LINE__,__FILE__,'calendar'); |
|
1449 | + __LINE__, __FILE__, 'calendar'); |
|
1452 | 1450 | |
1453 | 1451 | // delete all user-records, with recur-date != 0 |
1454 | - $this->db->delete($this->user_table,array( |
|
1452 | + $this->db->delete($this->user_table, array( |
|
1455 | 1453 | 'cal_id' => $cal_id, 'cal_recur_date != 0'), |
1456 | - __LINE__,__FILE__,'calendar'); |
|
1454 | + __LINE__, __FILE__, 'calendar'); |
|
1457 | 1455 | |
1458 | - $this->db->delete($this->repeats_table,array( |
|
1456 | + $this->db->delete($this->repeats_table, array( |
|
1459 | 1457 | 'cal_id' => $cal_id), |
1460 | - __LINE__,__FILE__,'calendar'); |
|
1458 | + __LINE__, __FILE__, 'calendar'); |
|
1461 | 1459 | |
1462 | 1460 | // add exception marker to master, so participants added to exceptions *only* get found |
1463 | 1461 | if ($event['cal_reference']) |
1464 | 1462 | { |
1465 | 1463 | $master_participants = array(); |
1466 | - foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( |
|
1464 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( |
|
1467 | 1465 | 'cal_id' => $event['cal_reference'], |
1468 | 1466 | 'cal_recur_date' => 0, |
1469 | - "cal_status != 'X'", // deleted need to be replaced with exception marker too |
|
1467 | + "cal_status != 'X'", // deleted need to be replaced with exception marker too |
|
1470 | 1468 | ), __LINE__, __FILE__, 'calendar') as $row) |
1471 | 1469 | { |
1472 | 1470 | $master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
1473 | 1471 | } |
1474 | - foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid) |
|
1472 | + foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid) |
|
1475 | 1473 | { |
1476 | 1474 | $user_type = $user_id = null; |
1477 | 1475 | self::split_user($uid, $user_type, $user_id, true); |
@@ -1490,10 +1488,10 @@ discard block |
||
1490 | 1488 | else // write information about recuring event, if recur_type is present in the array |
1491 | 1489 | { |
1492 | 1490 | // fetch information about the currently saved (old) event |
1493 | - $old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
1494 | - $old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min; |
|
1491 | + $old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
1492 | + $old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min; |
|
1495 | 1493 | $old_exceptions = array(); |
1496 | - foreach($this->db->select($this->dates_table, 'cal_start', array( |
|
1494 | + foreach ($this->db->select($this->dates_table, 'cal_start', array( |
|
1497 | 1495 | 'cal_id' => $cal_id, |
1498 | 1496 | 'recur_exception' => true |
1499 | 1497 | ), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row) |
@@ -1512,8 +1510,8 @@ discard block |
||
1512 | 1510 | 'cal_recur_date' => 0, |
1513 | 1511 | ); |
1514 | 1512 | $old_participants = array(); |
1515 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where, |
|
1516 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
1513 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where, |
|
1514 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
1517 | 1515 | { |
1518 | 1516 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
1519 | 1517 | $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
@@ -1523,7 +1521,7 @@ discard block |
||
1523 | 1521 | // re-check: did so much recurrence data change that we have to rebuild it from scratch? |
1524 | 1522 | if (!$set_recurrences) |
1525 | 1523 | { |
1526 | - $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) || |
|
1524 | + $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) || |
|
1527 | 1525 | $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
1528 | 1526 | (int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id; |
1529 | 1527 | } |
@@ -1532,22 +1530,22 @@ discard block |
||
1532 | 1530 | { |
1533 | 1531 | // too much recurrence data has changed, we have to do a rebuild from scratch |
1534 | 1532 | // delete all, but the lowest dates record |
1535 | - $this->db->delete($this->dates_table,array( |
|
1533 | + $this->db->delete($this->dates_table, array( |
|
1536 | 1534 | 'cal_id' => $cal_id, |
1537 | 1535 | 'cal_start > '.(int)$old_min, |
1538 | - ),__LINE__,__FILE__,'calendar'); |
|
1536 | + ), __LINE__, __FILE__, 'calendar'); |
|
1539 | 1537 | |
1540 | 1538 | // delete all user-records, with recur-date != 0 |
1541 | - $this->db->delete($this->user_table,array( |
|
1539 | + $this->db->delete($this->user_table, array( |
|
1542 | 1540 | 'cal_id' => $cal_id, |
1543 | 1541 | 'cal_recur_date != 0', |
1544 | - ),__LINE__,__FILE__,'calendar'); |
|
1542 | + ), __LINE__, __FILE__, 'calendar'); |
|
1545 | 1543 | } |
1546 | 1544 | else |
1547 | 1545 | { |
1548 | 1546 | // we adjust some possibly changed recurrences manually |
1549 | 1547 | // deleted exceptions: re-insert recurrences into the user and dates table |
1550 | - if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception']))) |
|
1548 | + if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception']))) |
|
1551 | 1549 | { |
1552 | 1550 | if (isset($event['cal_participants'])) |
1553 | 1551 | { |
@@ -1558,7 +1556,7 @@ discard block |
||
1558 | 1556 | // use old default |
1559 | 1557 | $participants = $old_participants; |
1560 | 1558 | } |
1561 | - foreach($deleted_exceptions as $id => $deleted_exception) |
|
1559 | + foreach ($deleted_exceptions as $id => $deleted_exception) |
|
1562 | 1560 | { |
1563 | 1561 | // rebuild participants for the re-inserted recurrence |
1564 | 1562 | $this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants); |
@@ -1566,24 +1564,24 @@ discard block |
||
1566 | 1564 | } |
1567 | 1565 | |
1568 | 1566 | // check if recurrence enddate was adjusted |
1569 | - if(isset($event['recur_enddate'])) |
|
1567 | + if (isset($event['recur_enddate'])) |
|
1570 | 1568 | { |
1571 | 1569 | // recurrences need to be truncated |
1572 | - if((int)$event['recur_enddate'] > 0 && |
|
1570 | + if ((int)$event['recur_enddate'] > 0 && |
|
1573 | 1571 | ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) |
1574 | 1572 | ) |
1575 | 1573 | { |
1576 | - $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
|
1577 | - $this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
|
1574 | + $this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar'); |
|
1575 | + $this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar'); |
|
1578 | 1576 | } |
1579 | 1577 | |
1580 | 1578 | // recurrences need to be expanded |
1581 | - if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
|
1579 | + if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
|
1582 | 1580 | || ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate']) |
1583 | 1581 | ) |
1584 | 1582 | { |
1585 | 1583 | $set_recurrences = true; |
1586 | - $set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s); |
|
1584 | + $set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s); |
|
1587 | 1585 | } |
1588 | 1586 | //error_log(__METHOD__."() event[recur_enddate]=$event[recur_enddate], old_repeats[recur_enddate]=$old_repeats[recur_enddate] --> set_recurrences=".array2string($set_recurrences).", set_recurrences_start=$set_recurrences_start"); |
1589 | 1587 | } |
@@ -1592,9 +1590,9 @@ discard block |
||
1592 | 1590 | if (count($event['recur_exception'])) |
1593 | 1591 | { |
1594 | 1592 | // added and existing exceptions: delete the execeptions from the user table, it could be the first time |
1595 | - $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar'); |
|
1593 | + $this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar'); |
|
1596 | 1594 | // update recur_exception flag based on current exceptions |
1597 | - $this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array( |
|
1595 | + $this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array( |
|
1598 | 1596 | 'cal_start' => $event['recur_exception'], |
1599 | 1597 | )), array( |
1600 | 1598 | 'cal_id' => $cal_id, |
@@ -1603,25 +1601,25 @@ discard block |
||
1603 | 1601 | } |
1604 | 1602 | |
1605 | 1603 | // write the repeats table |
1606 | - unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table |
|
1607 | - $this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar'); |
|
1604 | + unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table |
|
1605 | + $this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar'); |
|
1608 | 1606 | } |
1609 | 1607 | // update start- and endtime if present in the event-array, evtl. we need to move all recurrences |
1610 | 1608 | if (isset($event['cal_start']) && isset($event['cal_end'])) |
1611 | 1609 | { |
1612 | - $this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min + $old_duration); |
|
1610 | + $this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration); |
|
1613 | 1611 | } |
1614 | 1612 | // update participants if present in the event-array |
1615 | 1613 | if (isset($event['cal_participants'])) |
1616 | 1614 | { |
1617 | - $this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since); |
|
1615 | + $this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since); |
|
1618 | 1616 | } |
1619 | 1617 | // Custom fields |
1620 | - foreach($event as $name => $value) |
|
1618 | + foreach ($event as $name => $value) |
|
1621 | 1619 | { |
1622 | 1620 | if ($name[0] == '#') |
1623 | 1621 | { |
1624 | - if (is_array($value) && array_key_exists('id',$value)) |
|
1622 | + if (is_array($value) && array_key_exists('id', $value)) |
|
1625 | 1623 | { |
1626 | 1624 | //error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace()); |
1627 | 1625 | $value = $value['id']; |
@@ -1629,19 +1627,19 @@ discard block |
||
1629 | 1627 | } |
1630 | 1628 | if ($value) |
1631 | 1629 | { |
1632 | - $this->db->insert($this->extra_table,array( |
|
1633 | - 'cal_extra_value' => is_array($value) ? implode(',',$value) : $value, |
|
1634 | - ),array( |
|
1630 | + $this->db->insert($this->extra_table, array( |
|
1631 | + 'cal_extra_value' => is_array($value) ? implode(',', $value) : $value, |
|
1632 | + ), array( |
|
1635 | 1633 | 'cal_id' => $cal_id, |
1636 | - 'cal_extra_name' => substr($name,1), |
|
1637 | - ),__LINE__,__FILE__,'calendar'); |
|
1634 | + 'cal_extra_name' => substr($name, 1), |
|
1635 | + ), __LINE__, __FILE__, 'calendar'); |
|
1638 | 1636 | } |
1639 | 1637 | else |
1640 | 1638 | { |
1641 | - $this->db->delete($this->extra_table,array( |
|
1639 | + $this->db->delete($this->extra_table, array( |
|
1642 | 1640 | 'cal_id' => $cal_id, |
1643 | - 'cal_extra_name' => substr($name,1), |
|
1644 | - ),__LINE__,__FILE__,'calendar'); |
|
1641 | + 'cal_extra_name' => substr($name, 1), |
|
1642 | + ), __LINE__, __FILE__, 'calendar'); |
|
1645 | 1643 | } |
1646 | 1644 | } |
1647 | 1645 | } |
@@ -1652,9 +1650,9 @@ discard block |
||
1652 | 1650 | { |
1653 | 1651 | if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0) |
1654 | 1652 | { |
1655 | - unset($alarm['id']); // unset the temporary id to add the alarm |
|
1653 | + unset($alarm['id']); // unset the temporary id to add the alarm |
|
1656 | 1654 | } |
1657 | - if(!isset($alarm['offset'])) |
|
1655 | + if (!isset($alarm['offset'])) |
|
1658 | 1656 | { |
1659 | 1657 | $alarm['offset'] = $event['cal_start'] - $alarm['time']; |
1660 | 1658 | } |
@@ -1665,14 +1663,14 @@ discard block |
||
1665 | 1663 | |
1666 | 1664 | if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm)) |
1667 | 1665 | { |
1668 | - continue; // pgoerzen: don't add alarm in the past |
|
1666 | + continue; // pgoerzen: don't add alarm in the past |
|
1669 | 1667 | } |
1670 | - $this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway |
|
1668 | + $this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway |
|
1671 | 1669 | } |
1672 | 1670 | } |
1673 | 1671 | if (is_null($etag)) |
1674 | 1672 | { |
1675 | - $etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
1673 | + $etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
1676 | 1674 | } |
1677 | 1675 | |
1678 | 1676 | // if event is an exception: update modified of master, to force etag, ctag and sync-token change |
@@ -1692,7 +1690,7 @@ discard block |
||
1692 | 1690 | * are dealing with, default is now. |
1693 | 1691 | * @return boolean true if alarm could be shifted, false if not |
1694 | 1692 | */ |
1695 | - public static function shift_alarm(array $_event, array &$alarm, $timestamp=null) |
|
1693 | + public static function shift_alarm(array $_event, array &$alarm, $timestamp = null) |
|
1696 | 1694 | { |
1697 | 1695 | if ($_event['recur_type'] == MCAL_RECUR_NONE) |
1698 | 1696 | { |
@@ -1703,7 +1701,7 @@ discard block |
||
1703 | 1701 | $rrule = calendar_rrule::event2rrule($event, false); |
1704 | 1702 | foreach ($rrule as $time) |
1705 | 1703 | { |
1706 | - if ($start < ($ts = egw_time::to($time,'server'))) |
|
1704 | + if ($start < ($ts = egw_time::to($time, 'server'))) |
|
1707 | 1705 | { |
1708 | 1706 | $alarm['time'] = $ts - $alarm['offset']; |
1709 | 1707 | return true; |
@@ -1724,34 +1722,34 @@ discard block |
||
1724 | 1722 | * @todo Recalculate recurrences, if timezone changes |
1725 | 1723 | * @return int|boolean number of moved recurrences or false on error |
1726 | 1724 | */ |
1727 | - function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0) |
|
1725 | + function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0) |
|
1728 | 1726 | { |
1729 | 1727 | //echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n"; |
1730 | 1728 | |
1731 | - if (!(int) $cal_id) return false; |
|
1729 | + if (!(int)$cal_id) return false; |
|
1732 | 1730 | |
1733 | 1731 | if (!$old_start) |
1734 | 1732 | { |
1735 | - if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
1736 | - array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch(); |
|
1733 | + if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
1734 | + array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch(); |
|
1737 | 1735 | // if no recurrence found, create one with the new dates |
1738 | 1736 | if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end']) |
1739 | 1737 | { |
1740 | - $this->db->insert($this->dates_table,array( |
|
1738 | + $this->db->insert($this->dates_table, array( |
|
1741 | 1739 | 'cal_id' => $cal_id, |
1742 | 1740 | 'cal_start' => $start, |
1743 | 1741 | 'cal_end' => $end, |
1744 | - ),false,__LINE__,__FILE__,'calendar'); |
|
1742 | + ), false, __LINE__, __FILE__, 'calendar'); |
|
1745 | 1743 | |
1746 | 1744 | return 1; |
1747 | 1745 | } |
1748 | - $move_start = (int) ($start-$row['cal_start']); |
|
1749 | - $move_end = (int) ($end-$row['cal_end']); |
|
1746 | + $move_start = (int)($start - $row['cal_start']); |
|
1747 | + $move_end = (int)($end - $row['cal_end']); |
|
1750 | 1748 | } |
1751 | 1749 | else |
1752 | 1750 | { |
1753 | - $move_start = (int) ($start-$old_start); |
|
1754 | - $move_end = (int) ($end-$old_end); |
|
1751 | + $move_start = (int)($start - $old_start); |
|
1752 | + $move_end = (int)($end - $old_end); |
|
1755 | 1753 | } |
1756 | 1754 | $where = 'cal_id='.(int)$cal_id; |
1757 | 1755 | |
@@ -1759,13 +1757,13 @@ discard block |
||
1759 | 1757 | { |
1760 | 1758 | // move the recur-date of the participants |
1761 | 1759 | $this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
1762 | - ((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__); |
|
1760 | + ((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__); |
|
1763 | 1761 | } |
1764 | 1762 | if ($move_start || $move_end) |
1765 | 1763 | { |
1766 | 1764 | // move the event and it's recurrences |
1767 | 1765 | $this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
1768 | - ((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__); |
|
1766 | + ((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__); |
|
1769 | 1767 | } |
1770 | 1768 | return $this->db->affected_rows(); |
1771 | 1769 | } |
@@ -1784,8 +1782,7 @@ discard block |
||
1784 | 1782 | } |
1785 | 1783 | if (is_array($attendee)) |
1786 | 1784 | { |
1787 | - $email = !empty($attendee['email']) ? $user_attendee['email'] : |
|
1788 | - (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']); |
|
1785 | + $email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']); |
|
1789 | 1786 | $attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email; |
1790 | 1787 | } |
1791 | 1788 | return $attendee; |
@@ -1798,11 +1795,11 @@ discard block |
||
1798 | 1795 | * @param string|array $attendee attendee information: email, json or array with attr cn and url |
1799 | 1796 | * @return string|int combined id |
1800 | 1797 | */ |
1801 | - static function combine_user($user_type, $user_id, $attendee=null) |
|
1798 | + static function combine_user($user_type, $user_id, $attendee = null) |
|
1802 | 1799 | { |
1803 | 1800 | if (!$user_type || $user_type == 'u') |
1804 | 1801 | { |
1805 | - return (int) $user_id; |
|
1802 | + return (int)$user_id; |
|
1806 | 1803 | } |
1807 | 1804 | if ($user_type == 'e' && $attendee) |
1808 | 1805 | { |
@@ -1822,12 +1819,12 @@ discard block |
||
1822 | 1819 | * @param string|int &$user_id id |
1823 | 1820 | * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e" |
1824 | 1821 | */ |
1825 | - static function split_user($uid, &$user_type, &$user_id, $md5_email=false) |
|
1822 | + static function split_user($uid, &$user_type, &$user_id, $md5_email = false) |
|
1826 | 1823 | { |
1827 | 1824 | if (is_numeric($uid)) |
1828 | 1825 | { |
1829 | 1826 | $user_type = 'u'; |
1830 | - $user_id = (int) $uid; |
|
1827 | + $user_id = (int)$uid; |
|
1831 | 1828 | } |
1832 | 1829 | // create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>") |
1833 | 1830 | elseif ($md5_email && $uid[0] == 'e') |
@@ -1841,7 +1838,7 @@ discard block |
||
1841 | 1838 | else |
1842 | 1839 | { |
1843 | 1840 | $user_type = $uid[0]; |
1844 | - $user_id = substr($uid,1); |
|
1841 | + $user_id = substr($uid, 1); |
|
1845 | 1842 | } |
1846 | 1843 | } |
1847 | 1844 | |
@@ -1853,7 +1850,7 @@ discard block |
||
1853 | 1850 | * @param string $role ='REQ-PARTICIPANT' |
1854 | 1851 | * @return string |
1855 | 1852 | */ |
1856 | - static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT') |
|
1853 | + static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT') |
|
1857 | 1854 | { |
1858 | 1855 | if ((int)$quantity > 1) $status .= (int)$quantity; |
1859 | 1856 | if ($role != 'REQ-PARTICIPANT') $status .= $role; |
@@ -1869,13 +1866,13 @@ discard block |
||
1869 | 1866 | * @param string &$role=null only O: role |
1870 | 1867 | * @return string status U, T, A or R, same as $status parameter on return |
1871 | 1868 | */ |
1872 | - static function split_status(&$status,&$quantity=null,&$role=null) |
|
1869 | + static function split_status(&$status, &$quantity = null, &$role = null) |
|
1873 | 1870 | { |
1874 | 1871 | $quantity = 1; |
1875 | 1872 | $role = 'REQ-PARTICIPANT'; |
1876 | 1873 | //error_log(__METHOD__.__LINE__.array2string($status)); |
1877 | 1874 | $matches = null; |
1878 | - if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches)) |
|
1875 | + if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches)) |
|
1879 | 1876 | { |
1880 | 1877 | if ((int)$matches[1] > 0) $quantity = (int)$matches[1]; |
1881 | 1878 | if ($matches[2]) $role = $matches[2]; |
@@ -1902,14 +1899,14 @@ discard block |
||
1902 | 1899 | * true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants) |
1903 | 1900 | * @return int|boolean number of updated recurrences or false on error |
1904 | 1901 | */ |
1905 | - function participants($cal_id,$participants,$change_since=0,$add_only=false) |
|
1902 | + function participants($cal_id, $participants, $change_since = 0, $add_only = false) |
|
1906 | 1903 | { |
1907 | 1904 | //error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only"); |
1908 | 1905 | |
1909 | 1906 | $recurrences = array(); |
1910 | 1907 | |
1911 | 1908 | // remove group-invitations, they are NOT stored in the db |
1912 | - foreach($participants as $uid => $status) |
|
1909 | + foreach ($participants as $uid => $status) |
|
1913 | 1910 | { |
1914 | 1911 | if ($status[0] == 'G') |
1915 | 1912 | { |
@@ -1918,7 +1915,7 @@ discard block |
||
1918 | 1915 | } |
1919 | 1916 | $where = array('cal_id' => $cal_id); |
1920 | 1917 | |
1921 | - if ((int) $change_since) |
|
1918 | + if ((int)$change_since) |
|
1922 | 1919 | { |
1923 | 1920 | $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')'; |
1924 | 1921 | } |
@@ -1926,31 +1923,31 @@ discard block |
||
1926 | 1923 | if ($change_since !== false) |
1927 | 1924 | { |
1928 | 1925 | // find all existing recurrences |
1929 | - foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row) |
|
1926 | + foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
1930 | 1927 | { |
1931 | 1928 | $recurrences[] = $row['cal_recur_date']; |
1932 | 1929 | } |
1933 | 1930 | |
1934 | 1931 | // update existing entries |
1935 | - $existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar'); |
|
1932 | + $existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar'); |
|
1936 | 1933 | |
1937 | 1934 | // create a full list of participants which already exist in the db |
1938 | 1935 | // with status, quantity and role of the earliest recurence |
1939 | 1936 | $old_participants = array(); |
1940 | - foreach($existing_entries as $row) |
|
1937 | + foreach ($existing_entries as $row) |
|
1941 | 1938 | { |
1942 | 1939 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
1943 | 1940 | if ($row['cal_recur_date'] || !isset($old_participants[$uid])) |
1944 | 1941 | { |
1945 | - $old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
1942 | + $old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
1946 | 1943 | } |
1947 | 1944 | } |
1948 | 1945 | |
1949 | 1946 | // tag participants which should be deleted |
1950 | - if($add_only === false) |
|
1947 | + if ($add_only === false) |
|
1951 | 1948 | { |
1952 | 1949 | $deleted = array(); |
1953 | - foreach($existing_entries as $row) |
|
1950 | + foreach ($existing_entries as $row) |
|
1954 | 1951 | { |
1955 | 1952 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
1956 | 1953 | // delete not longer set participants |
@@ -1963,7 +1960,7 @@ discard block |
||
1963 | 1960 | |
1964 | 1961 | // only keep added OR status (incl. quantity!) changed participants for further steps |
1965 | 1962 | // we do not touch unchanged (!) existing ones |
1966 | - foreach($participants as $uid => $status) |
|
1963 | + foreach ($participants as $uid => $status) |
|
1967 | 1964 | { |
1968 | 1965 | if ($old_participants[$uid] === $status) |
1969 | 1966 | { |
@@ -1975,46 +1972,46 @@ discard block |
||
1975 | 1972 | if ($add_only === false && count($deleted)) |
1976 | 1973 | { |
1977 | 1974 | $to_or = array(); |
1978 | - $table_def = $this->db->get_table_definitions('calendar',$this->user_table); |
|
1979 | - foreach($deleted as $type => $ids) |
|
1975 | + $table_def = $this->db->get_table_definitions('calendar', $this->user_table); |
|
1976 | + foreach ($deleted as $type => $ids) |
|
1980 | 1977 | { |
1981 | - $to_or[] = $this->db->expression($table_def,array( |
|
1978 | + $to_or[] = $this->db->expression($table_def, array( |
|
1982 | 1979 | 'cal_user_type' => $type, |
1983 | 1980 | 'cal_user_id' => $ids, |
1984 | 1981 | )); |
1985 | 1982 | } |
1986 | - $where[] = '('.implode(' OR ',$to_or).')'; |
|
1987 | - $where[] = "cal_status!='E'"; // do NOT delete exception marker |
|
1988 | - $this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar'); |
|
1983 | + $where[] = '('.implode(' OR ', $to_or).')'; |
|
1984 | + $where[] = "cal_status!='E'"; // do NOT delete exception marker |
|
1985 | + $this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar'); |
|
1989 | 1986 | } |
1990 | 1987 | } |
1991 | 1988 | |
1992 | 1989 | if (count($participants)) // participants which need to be added |
1993 | 1990 | { |
1994 | - if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
1991 | + if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
1995 | 1992 | |
1996 | 1993 | $delete_deleted = array(); |
1997 | 1994 | |
1998 | 1995 | // update participants |
1999 | - foreach($participants as $uid => $status) |
|
1996 | + foreach ($participants as $uid => $status) |
|
2000 | 1997 | { |
2001 | 1998 | $type = $id = $quantity = $role = null; |
2002 | 1999 | self::split_user($uid, $type, $id, true); |
2003 | - self::split_status($status,$quantity,$role); |
|
2000 | + self::split_status($status, $quantity, $role); |
|
2004 | 2001 | $set = array( |
2005 | 2002 | 'cal_status' => $status, |
2006 | 2003 | 'cal_quantity' => $quantity, |
2007 | 2004 | 'cal_role' => $role, |
2008 | 2005 | 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, |
2009 | 2006 | ); |
2010 | - foreach($recurrences as $recur_date) |
|
2007 | + foreach ($recurrences as $recur_date) |
|
2011 | 2008 | { |
2012 | - $this->db->insert($this->user_table,$set,array( |
|
2009 | + $this->db->insert($this->user_table, $set, array( |
|
2013 | 2010 | 'cal_id' => $cal_id, |
2014 | 2011 | 'cal_recur_date' => $recur_date, |
2015 | 2012 | 'cal_user_type' => $type, |
2016 | 2013 | 'cal_user_id' => $id, |
2017 | - ),__LINE__,__FILE__,'calendar'); |
|
2014 | + ), __LINE__, __FILE__, 'calendar'); |
|
2018 | 2015 | } |
2019 | 2016 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
2020 | 2017 | if ($uid < 0) |
@@ -2024,13 +2021,13 @@ discard block |
||
2024 | 2021 | } |
2025 | 2022 | if ($delete_deleted) |
2026 | 2023 | { |
2027 | - $this->db->delete($this->user_table, $where=array( |
|
2024 | + $this->db->delete($this->user_table, $where = array( |
|
2028 | 2025 | 'cal_id' => $cal_id, |
2029 | 2026 | 'cal_recur_date' => $recurrences, |
2030 | 2027 | 'cal_user_type' => 'u', |
2031 | 2028 | 'cal_user_id' => array_unique($delete_deleted), |
2032 | 2029 | 'cal_status' => 'X', |
2033 | - ),__LINE__,__FILE__,'calendar'); |
|
2030 | + ), __LINE__, __FILE__, 'calendar'); |
|
2034 | 2031 | //error_log(__METHOD__."($cal_id, ".array2string($participants).", since=$change_since, add_only=$add_only) db->delete('$this->user_table', ".array2string($where).") affected ".$this->db->affected_rows().' rows'); |
2035 | 2032 | } |
2036 | 2033 | } |
@@ -2049,7 +2046,7 @@ discard block |
||
2049 | 2046 | * @param string $attendee =null extra attendee information to set for all types (incl. accounts!) |
2050 | 2047 | * @return int number of changed recurrences |
2051 | 2048 | */ |
2052 | - function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null) |
|
2049 | + function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null) |
|
2053 | 2050 | { |
2054 | 2051 | static $status_code_short = array( |
2055 | 2052 | REJECTED => 'R', |
@@ -2074,7 +2071,7 @@ discard block |
||
2074 | 2071 | 'cal_user_type' => $user_type, |
2075 | 2072 | 'cal_user_id' => $user_id_md5, |
2076 | 2073 | ); |
2077 | - if ((int) $recur_date) |
|
2074 | + if ((int)$recur_date) |
|
2078 | 2075 | { |
2079 | 2076 | $where['cal_recur_date'] = $recur_date; |
2080 | 2077 | } |
@@ -2085,7 +2082,7 @@ discard block |
||
2085 | 2082 | |
2086 | 2083 | if ($status == 'G') // remove group invitations, as we dont store them in the db |
2087 | 2084 | { |
2088 | - $this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar'); |
|
2085 | + $this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar'); |
|
2089 | 2086 | $ret = $this->db->affected_rows(); |
2090 | 2087 | } |
2091 | 2088 | else |
@@ -2093,7 +2090,7 @@ discard block |
||
2093 | 2090 | $set = array('cal_status' => $status); |
2094 | 2091 | if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
2095 | 2092 | if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role; |
2096 | - $this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar'); |
|
2093 | + $this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar'); |
|
2097 | 2094 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
2098 | 2095 | if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0) |
2099 | 2096 | { |
@@ -2106,7 +2103,7 @@ discard block |
||
2106 | 2103 | // update modified and modifier in main table |
2107 | 2104 | if ($ret) |
2108 | 2105 | { |
2109 | - $this->updateModified($cal_id, true); // true = update series master too |
|
2106 | + $this->updateModified($cal_id, true); // true = update series master too |
|
2110 | 2107 | } |
2111 | 2108 | //error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret"); |
2112 | 2109 | return $ret; |
@@ -2121,7 +2118,7 @@ discard block |
||
2121 | 2118 | * @param array $participants uid => status pairs |
2122 | 2119 | * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception) |
2123 | 2120 | */ |
2124 | - function recurrence($cal_id,$start,$end,$participants,$exception=null) |
|
2121 | + function recurrence($cal_id, $start, $end, $participants, $exception = null) |
|
2125 | 2122 | { |
2126 | 2123 | //error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception)); |
2127 | 2124 | $update = array('cal_end' => $end); |
@@ -2130,7 +2127,7 @@ discard block |
||
2130 | 2127 | $this->db->insert($this->dates_table, $update, array( |
2131 | 2128 | 'cal_id' => $cal_id, |
2132 | 2129 | 'cal_start' => $start, |
2133 | - ),__LINE__,__FILE__,'calendar'); |
|
2130 | + ), __LINE__, __FILE__, 'calendar'); |
|
2134 | 2131 | |
2135 | 2132 | if (!is_array($participants)) |
2136 | 2133 | { |
@@ -2138,26 +2135,26 @@ discard block |
||
2138 | 2135 | } |
2139 | 2136 | if ($exception !== true) |
2140 | 2137 | { |
2141 | - foreach($participants as $uid => $status) |
|
2138 | + foreach ($participants as $uid => $status) |
|
2142 | 2139 | { |
2143 | - if ($status == 'G') continue; // dont save group-invitations |
|
2140 | + if ($status == 'G') continue; // dont save group-invitations |
|
2144 | 2141 | |
2145 | 2142 | $type = ''; |
2146 | 2143 | $id = null; |
2147 | 2144 | self::split_user($uid, $type, $id, true); |
2148 | 2145 | $quantity = $role = null; |
2149 | - self::split_status($status,$quantity,$role); |
|
2150 | - $this->db->insert($this->user_table,array( |
|
2146 | + self::split_status($status, $quantity, $role); |
|
2147 | + $this->db->insert($this->user_table, array( |
|
2151 | 2148 | 'cal_status' => $status, |
2152 | 2149 | 'cal_quantity' => $quantity, |
2153 | 2150 | 'cal_role' => $role, |
2154 | 2151 | 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, |
2155 | - ),array( |
|
2152 | + ), array( |
|
2156 | 2153 | 'cal_id' => $cal_id, |
2157 | 2154 | 'cal_recur_date' => $start, |
2158 | 2155 | 'cal_user_type' => $type, |
2159 | 2156 | 'cal_user_id' => $id, |
2160 | - ),__LINE__,__FILE__,'calendar'); |
|
2157 | + ), __LINE__, __FILE__, 'calendar'); |
|
2161 | 2158 | } |
2162 | 2159 | } |
2163 | 2160 | } |
@@ -2171,7 +2168,7 @@ discard block |
||
2171 | 2168 | function unfinished_recuring($time) |
2172 | 2169 | { |
2173 | 2170 | $ids = array(); |
2174 | - foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start", |
|
2171 | + foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start", |
|
2175 | 2172 | '(range_end IS NULL OR range_end > '.(int)$time.')', |
2176 | 2173 | __LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0, |
2177 | 2174 | " JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id". |
@@ -2197,9 +2194,9 @@ discard block |
||
2197 | 2194 | // update timestamp of series master, updates own timestamp too, which does not hurt ;-) |
2198 | 2195 | $this->updateModified($cal_id, true); |
2199 | 2196 | |
2200 | - foreach($this->all_tables as $table) |
|
2197 | + foreach ($this->all_tables as $table) |
|
2201 | 2198 | { |
2202 | - $this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar'); |
|
2199 | + $this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar'); |
|
2203 | 2200 | } |
2204 | 2201 | } |
2205 | 2202 | |
@@ -2215,19 +2212,19 @@ discard block |
||
2215 | 2212 | function purge($date) |
2216 | 2213 | { |
2217 | 2214 | // with new range_end we simple delete all with range_end < $date (range_end NULL is never returned) |
2218 | - foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2215 | + foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2219 | 2216 | { |
2220 | 2217 | //echo __METHOD__." About to delete".$row['cal_id']."\r\n"; |
2221 | - foreach($this->all_tables as $table) |
|
2218 | + foreach ($this->all_tables as $table) |
|
2222 | 2219 | { |
2223 | 2220 | $this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar'); |
2224 | 2221 | } |
2225 | 2222 | // handle sync |
2226 | - $this->db->update('egw_api_content_history',array( |
|
2223 | + $this->db->update('egw_api_content_history', array( |
|
2227 | 2224 | 'sync_deleted' => time(), |
2228 | - ),array( |
|
2225 | + ), array( |
|
2229 | 2226 | 'sync_appname' => 'calendar', |
2230 | - 'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)! |
|
2227 | + 'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)! |
|
2231 | 2228 | ), __LINE__, __FILE__); |
2232 | 2229 | // handle links |
2233 | 2230 | egw_link::unlink('', 'calendar', $row['cal_id']); |
@@ -2250,23 +2247,23 @@ discard block |
||
2250 | 2247 | * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id |
2251 | 2248 | * @return array of (cal_id => array of) alarms with alarm-id as key |
2252 | 2249 | */ |
2253 | - function read_alarms($cal_id, $update_cache=null) |
|
2250 | + function read_alarms($cal_id, $update_cache = null) |
|
2254 | 2251 | { |
2255 | 2252 | if (!isset(self::$alarm_cache) && is_array($cal_id)) |
2256 | 2253 | { |
2257 | 2254 | self::$alarm_cache = array(); |
2258 | 2255 | if (($jobs = $this->async->read('cal:%'))) |
2259 | 2256 | { |
2260 | - foreach($jobs as $id => $job) |
|
2257 | + foreach ($jobs as $id => $job) |
|
2261 | 2258 | { |
2262 | - $alarm = $job['data']; // text, enabled |
|
2259 | + $alarm = $job['data']; // text, enabled |
|
2263 | 2260 | $alarm['id'] = $id; |
2264 | 2261 | $alarm['time'] = $job['next']; |
2265 | 2262 | |
2266 | 2263 | self::$alarm_cache[$alarm['cal_id']][$id] = $alarm; |
2267 | 2264 | } |
2268 | 2265 | } |
2269 | - unset($update_cache); // just done |
|
2266 | + unset($update_cache); // just done |
|
2270 | 2267 | } |
2271 | 2268 | $alarms = array(); |
2272 | 2269 | |
@@ -2274,13 +2271,13 @@ discard block |
||
2274 | 2271 | { |
2275 | 2272 | if (isset($update_cache)) |
2276 | 2273 | { |
2277 | - foreach((array)$cal_id as $id) |
|
2274 | + foreach ((array)$cal_id as $id) |
|
2278 | 2275 | { |
2279 | 2276 | if ($update_cache === false) |
2280 | 2277 | { |
2281 | 2278 | unset(self::$alarm_cache[$cal_id]); |
2282 | 2279 | } |
2283 | - elseif($update_cache === true) |
|
2280 | + elseif ($update_cache === true) |
|
2284 | 2281 | { |
2285 | 2282 | self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id); |
2286 | 2283 | } |
@@ -2292,7 +2289,7 @@ discard block |
||
2292 | 2289 | } |
2293 | 2290 | else |
2294 | 2291 | { |
2295 | - foreach($cal_id as $id) |
|
2292 | + foreach ($cal_id as $id) |
|
2296 | 2293 | { |
2297 | 2294 | $alarms[$id] = (array)self::$alarm_cache[$id]; |
2298 | 2295 | } |
@@ -2307,9 +2304,9 @@ discard block |
||
2307 | 2304 | { |
2308 | 2305 | if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%'))) |
2309 | 2306 | { |
2310 | - foreach($jobs as $id => $job) |
|
2307 | + foreach ($jobs as $id => $job) |
|
2311 | 2308 | { |
2312 | - $alarm = $job['data']; // text, enabled |
|
2309 | + $alarm = $job['data']; // text, enabled |
|
2313 | 2310 | $alarm['id'] = $id; |
2314 | 2311 | $alarm['time'] = $job['next']; |
2315 | 2312 | |
@@ -2332,8 +2329,8 @@ discard block |
||
2332 | 2329 | { |
2333 | 2330 | return False; |
2334 | 2331 | } |
2335 | - list($alarm_id,$job) = each($jobs); |
|
2336 | - $alarm = $job['data']; // text, enabled |
|
2332 | + list($alarm_id, $job) = each($jobs); |
|
2333 | + $alarm = $job['data']; // text, enabled |
|
2337 | 2334 | $alarm['id'] = $alarm_id; |
2338 | 2335 | $alarm['time'] = $job['next']; |
2339 | 2336 | |
@@ -2349,12 +2346,12 @@ discard block |
||
2349 | 2346 | * @param boolean $update_modified =true call update modified, default true |
2350 | 2347 | * @return string id of the alarm |
2351 | 2348 | */ |
2352 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
2349 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
2353 | 2350 | { |
2354 | 2351 | //error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace()); |
2355 | 2352 | if (!($id = $alarm['id'])) |
2356 | 2353 | { |
2357 | - $alarms = $this->read_alarms($cal_id); // find a free alarm# |
|
2354 | + $alarms = $this->read_alarms($cal_id); // find a free alarm# |
|
2358 | 2355 | $n = count($alarms); |
2359 | 2356 | do |
2360 | 2357 | { |
@@ -2367,12 +2364,12 @@ discard block |
||
2367 | 2364 | { |
2368 | 2365 | $this->async->cancel_timer($id); |
2369 | 2366 | } |
2370 | - $alarm['cal_id'] = $cal_id; // we need the back-reference |
|
2367 | + $alarm['cal_id'] = $cal_id; // we need the back-reference |
|
2371 | 2368 | // add an alarm uid, if none is given |
2372 | 2369 | if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid; |
2373 | 2370 | //error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace()); |
2374 | 2371 | // allways store job with the alarm owner as job-owner to get eg. the correct from address |
2375 | - if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner'])) |
|
2372 | + if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner'])) |
|
2376 | 2373 | { |
2377 | 2374 | return False; |
2378 | 2375 | } |
@@ -2399,7 +2396,7 @@ discard block |
||
2399 | 2396 | //error_log(__METHOD__."($cal_id) ".function_backtrace()); |
2400 | 2397 | if (($alarms = $this->read_alarms($cal_id))) |
2401 | 2398 | { |
2402 | - foreach(array_keys($alarms) as $id) |
|
2399 | + foreach (array_keys($alarms) as $id) |
|
2403 | 2400 | { |
2404 | 2401 | $this->async->cancel_timer($id); |
2405 | 2402 | } |
@@ -2419,7 +2416,7 @@ discard block |
||
2419 | 2416 | { |
2420 | 2417 | //error_log(__METHOD__."('$id') ".function_backtrace()); |
2421 | 2418 | // update the modification information of the related event |
2422 | - list(,$cal_id) = explode(':',$id); |
|
2419 | + list(,$cal_id) = explode(':', $id); |
|
2423 | 2420 | if ($cal_id) |
2424 | 2421 | { |
2425 | 2422 | $this->updateModified($cal_id, true); |
@@ -2438,7 +2435,7 @@ discard block |
||
2438 | 2435 | * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it |
2439 | 2436 | * @param int $new_user =null |
2440 | 2437 | */ |
2441 | - function deleteaccount($old_user, $new_user=null) |
|
2438 | + function deleteaccount($old_user, $new_user = null) |
|
2442 | 2439 | { |
2443 | 2440 | if (is_array($old_user)) |
2444 | 2441 | { |
@@ -2449,52 +2446,52 @@ discard block |
||
2449 | 2446 | { |
2450 | 2447 | $user_type = ''; |
2451 | 2448 | $user_id = null; |
2452 | - self::split_user($old_user,$user_type,$user_id); |
|
2449 | + self::split_user($old_user, $user_type, $user_id); |
|
2453 | 2450 | |
2454 | 2451 | if ($user_type == 'u') // only accounts can be owners of events |
2455 | 2452 | { |
2456 | - foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row) |
|
2453 | + foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2457 | 2454 | { |
2458 | 2455 | $this->delete($row['cal_id']); |
2459 | 2456 | } |
2460 | 2457 | } |
2461 | - $this->db->delete($this->user_table,array( |
|
2458 | + $this->db->delete($this->user_table, array( |
|
2462 | 2459 | 'cal_user_type' => $user_type, |
2463 | 2460 | 'cal_user_id' => $user_id, |
2464 | - ),__LINE__,__FILE__,'calendar'); |
|
2461 | + ), __LINE__, __FILE__, 'calendar'); |
|
2465 | 2462 | |
2466 | 2463 | // delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner) |
2467 | - foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
2468 | - False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
|
2464 | + foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__, |
|
2465 | + False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
|
2469 | 2466 | { |
2470 | 2467 | $this->delete($row['cal_id']); |
2471 | 2468 | } |
2472 | 2469 | } |
2473 | 2470 | else |
2474 | 2471 | { |
2475 | - $this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar'); |
|
2472 | + $this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar'); |
|
2476 | 2473 | // delete participation of old user, if new user is already a participant |
2477 | 2474 | $ids = array(); |
2478 | - foreach($this->db->select($this->user_table,'cal_id',array( // MySQL does NOT allow to run this as delete! |
|
2475 | + foreach ($this->db->select($this->user_table, 'cal_id', array( // MySQL does NOT allow to run this as delete! |
|
2479 | 2476 | 'cal_user_type' => 'u', |
2480 | 2477 | 'cal_user_id' => $old_user, |
2481 | 2478 | "cal_id IN (SELECT cal_id FROM $this->user_table other WHERE other.cal_id=cal_id AND other.cal_user_id=".$this->db->quote($new_user)." AND cal_user_type='u')", |
2482 | - ),__LINE__,__FILE__,false,'','calendar') as $row) |
|
2479 | + ), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2483 | 2480 | { |
2484 | 2481 | $ids[] = $row['cal_id']; |
2485 | 2482 | } |
2486 | - if ($ids) $this->db->delete($this->user_table,array( |
|
2483 | + if ($ids) $this->db->delete($this->user_table, array( |
|
2487 | 2484 | 'cal_user_type' => 'u', |
2488 | 2485 | 'cal_user_id' => $old_user, |
2489 | 2486 | 'cal_id' => $ids, |
2490 | - ),__LINE__,__FILE__,'calendar'); |
|
2487 | + ), __LINE__, __FILE__, 'calendar'); |
|
2491 | 2488 | // now change participant in the rest to contain new user instead of old user |
2492 | - $this->db->update($this->user_table,array( |
|
2489 | + $this->db->update($this->user_table, array( |
|
2493 | 2490 | 'cal_user_id' => $new_user, |
2494 | - ),array( |
|
2491 | + ), array( |
|
2495 | 2492 | 'cal_user_type' => 'u', |
2496 | 2493 | 'cal_user_id' => $old_user, |
2497 | - ),__LINE__,__FILE__,'calendar'); |
|
2494 | + ), __LINE__, __FILE__, 'calendar'); |
|
2498 | 2495 | } |
2499 | 2496 | } |
2500 | 2497 | |
@@ -2508,18 +2505,18 @@ discard block |
||
2508 | 2505 | * |
2509 | 2506 | * @return array recur_date => status pairs (index 0 => main status) |
2510 | 2507 | */ |
2511 | - function get_recurrences($cal_id, $uid=null, $start=0, $end=0) |
|
2508 | + function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0) |
|
2512 | 2509 | { |
2513 | 2510 | $participant_status = array(); |
2514 | 2511 | $where = array('cal_id' => $cal_id); |
2515 | - if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
2516 | - if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
2512 | + if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')'; |
|
2513 | + if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')'; |
|
2517 | 2514 | if ($start != 0 && $end != 0) |
2518 | 2515 | { |
2519 | - $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
|
2520 | - ' AND cal_recur_date <= ' . (int)$end . '))'; |
|
2516 | + $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start. |
|
2517 | + ' AND cal_recur_date <= '.(int)$end.'))'; |
|
2521 | 2518 | } |
2522 | - foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row) |
|
2519 | + foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2523 | 2520 | { |
2524 | 2521 | // inititalize the array |
2525 | 2522 | $participant_status[$row['cal_recur_date']] = null; |
@@ -2533,17 +2530,17 @@ discard block |
||
2533 | 2530 | 'cal_user_type' => $user_type ? $user_type : 'u', |
2534 | 2531 | 'cal_user_id' => $user_id, |
2535 | 2532 | ); |
2536 | - if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
2537 | - if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
2533 | + if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')'; |
|
2534 | + if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')'; |
|
2538 | 2535 | if ($start != 0 && $end != 0) |
2539 | 2536 | { |
2540 | - $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
|
2541 | - ' AND cal_recur_date <= ' . (int)$end . '))'; |
|
2537 | + $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start. |
|
2538 | + ' AND cal_recur_date <= '.(int)$end.'))'; |
|
2542 | 2539 | } |
2543 | - foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2, |
|
2544 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
2540 | + foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2, |
|
2541 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2545 | 2542 | { |
2546 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
2543 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
2547 | 2544 | $participant_status[$row['cal_recur_date']] = $status; |
2548 | 2545 | } |
2549 | 2546 | return $participant_status; |
@@ -2592,8 +2589,8 @@ discard block |
||
2592 | 2589 | 'cal_uid' => $uid, |
2593 | 2590 | ); |
2594 | 2591 | $related = array(); |
2595 | - foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where, |
|
2596 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
2592 | + foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where, |
|
2593 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2597 | 2594 | { |
2598 | 2595 | if ($row['cal_reference'] != 0) |
2599 | 2596 | { |
@@ -2622,10 +2619,10 @@ discard block |
||
2622 | 2619 | * |
2623 | 2620 | * @return array Array of exception days (false for non-recurring events). |
2624 | 2621 | */ |
2625 | - function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all') |
|
2622 | + function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all') |
|
2626 | 2623 | { |
2627 | 2624 | if (!is_array($event)) return false; |
2628 | - $cal_id = (int) $event['id']; |
|
2625 | + $cal_id = (int)$event['id']; |
|
2629 | 2626 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2630 | 2627 | // "($cal_id, $tz_id, $filter): " . $event['tzid']); |
2631 | 2628 | if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false; |
@@ -2649,27 +2646,27 @@ discard block |
||
2649 | 2646 | while ($egw_rrule->valid()) |
2650 | 2647 | { |
2651 | 2648 | while ($egw_rrule->exceptions && |
2652 | - in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions)) |
|
2649 | + in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions)) |
|
2653 | 2650 | { |
2654 | - if (in_array($filter, array('map','tz_map','rrule','tz_rrule'))) |
|
2651 | + if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule'))) |
|
2655 | 2652 | { |
2656 | 2653 | // real exception |
2657 | - $locts = (int)egw_time::to($egw_rrule->current(),'server'); |
|
2654 | + $locts = (int)egw_time::to($egw_rrule->current(), 'server'); |
|
2658 | 2655 | if ($expand_all) |
2659 | 2656 | { |
2660 | - $remts = (int)egw_time::to($remote_rrule->current(),'server'); |
|
2657 | + $remts = (int)egw_time::to($remote_rrule->current(), 'server'); |
|
2661 | 2658 | if ($remote) |
2662 | 2659 | { |
2663 | - $days[$locts]= $remts; |
|
2660 | + $days[$locts] = $remts; |
|
2664 | 2661 | } |
2665 | 2662 | else |
2666 | 2663 | { |
2667 | - $days[$remts]= $locts; |
|
2664 | + $days[$remts] = $locts; |
|
2668 | 2665 | } |
2669 | 2666 | } |
2670 | 2667 | else |
2671 | 2668 | { |
2672 | - $days[$locts]= $locts; |
|
2669 | + $days[$locts] = $locts; |
|
2673 | 2670 | } |
2674 | 2671 | } |
2675 | 2672 | if ($expand_all) |
@@ -2680,14 +2677,14 @@ discard block |
||
2680 | 2677 | if (!$egw_rrule->valid()) return $days; |
2681 | 2678 | } |
2682 | 2679 | $day = $egw_rrule->current(); |
2683 | - $locts = (int)egw_time::to($day,'server'); |
|
2680 | + $locts = (int)egw_time::to($day, 'server'); |
|
2684 | 2681 | $tz_exception = ($filter == 'tz_rrule'); |
2685 | 2682 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2686 | 2683 | // '()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)"); |
2687 | 2684 | if ($expand_all) |
2688 | 2685 | { |
2689 | 2686 | $remote_day = $remote_rrule->current(); |
2690 | - $remts = (int)egw_time::to($remote_day,'server'); |
|
2687 | + $remts = (int)egw_time::to($remote_day, 'server'); |
|
2691 | 2688 | // error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2692 | 2689 | // '()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)"); |
2693 | 2690 | } |
@@ -2706,11 +2703,11 @@ discard block |
||
2706 | 2703 | // '() tz exception: ' . $day->format('Ymd\THis')); |
2707 | 2704 | if ($remote) |
2708 | 2705 | { |
2709 | - $days[$locts]= $remts; |
|
2706 | + $days[$locts] = $remts; |
|
2710 | 2707 | } |
2711 | 2708 | else |
2712 | 2709 | { |
2713 | - $days[$remts]= $locts; |
|
2710 | + $days[$remts] = $locts; |
|
2714 | 2711 | } |
2715 | 2712 | } |
2716 | 2713 | } |
@@ -2732,18 +2729,18 @@ discard block |
||
2732 | 2729 | { |
2733 | 2730 | if ($remote) |
2734 | 2731 | { |
2735 | - $days[$locts]= $remts; |
|
2732 | + $days[$locts] = $remts; |
|
2736 | 2733 | } |
2737 | 2734 | else |
2738 | 2735 | { |
2739 | - $days[$remts]= $locts; |
|
2736 | + $days[$remts] = $locts; |
|
2740 | 2737 | } |
2741 | 2738 | } |
2742 | 2739 | } |
2743 | 2740 | } |
2744 | 2741 | elseif ($filter != 'map') |
2745 | 2742 | { |
2746 | - $days[$locts]= $locts; |
|
2743 | + $days[$locts] = $locts; |
|
2747 | 2744 | } |
2748 | 2745 | } |
2749 | 2746 | elseif (($filter == 'map' || filter == 'tz_map') && |
@@ -2753,11 +2750,11 @@ discard block |
||
2753 | 2750 | if ($expand_all) |
2754 | 2751 | { |
2755 | 2752 | |
2756 | - $days[$remts]= $locts; |
|
2753 | + $days[$remts] = $locts; |
|
2757 | 2754 | } |
2758 | 2755 | else |
2759 | 2756 | { |
2760 | - $days[$locts]= $locts; |
|
2757 | + $days[$locts] = $locts; |
|
2761 | 2758 | } |
2762 | 2759 | } |
2763 | 2760 | } |
@@ -2781,9 +2778,9 @@ discard block |
||
2781 | 2778 | */ |
2782 | 2779 | function status_pseudo_exception($cal_id, $recur_date, $filter) |
2783 | 2780 | { |
2784 | - static $recurrence_zero=null; |
|
2785 | - static $cached_id=null; |
|
2786 | - static $user=null; |
|
2781 | + static $recurrence_zero = null; |
|
2782 | + static $cached_id = null; |
|
2783 | + static $user = null; |
|
2787 | 2784 | |
2788 | 2785 | if (!isset($cached_id) || $cached_id != $cal_id) |
2789 | 2786 | { |
@@ -2794,8 +2791,8 @@ discard block |
||
2794 | 2791 | 'cal_id' => $cal_id, |
2795 | 2792 | 'cal_recur_date' => 0, |
2796 | 2793 | ); |
2797 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where, |
|
2798 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
2794 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where, |
|
2795 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2799 | 2796 | { |
2800 | 2797 | switch ($row['cal_user_type']) |
2801 | 2798 | { |
@@ -2818,8 +2815,8 @@ discard block |
||
2818 | 2815 | 'cal_id' => $cal_id, |
2819 | 2816 | 'cal_recur_date' => $recur_date, |
2820 | 2817 | ); |
2821 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where, |
|
2822 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
2818 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where, |
|
2819 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
2823 | 2820 | { |
2824 | 2821 | switch ($row['cal_user_type']) |
2825 | 2822 | { |
@@ -2916,14 +2913,14 @@ discard block |
||
2916 | 2913 | } |
2917 | 2914 | $timezone = self::$tz_cache[$event['tzid']]; |
2918 | 2915 | } |
2919 | - $start_time = new egw_time($event['start'],egw_time::$server_timezone); |
|
2916 | + $start_time = new egw_time($event['start'], egw_time::$server_timezone); |
|
2920 | 2917 | $start_time->setTimezone($timezone); |
2921 | - $end_time = new egw_time($event['end'],egw_time::$server_timezone); |
|
2918 | + $end_time = new egw_time($event['end'], egw_time::$server_timezone); |
|
2922 | 2919 | $end_time->setTimezone($timezone); |
2923 | 2920 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2924 | 2921 | // '(): ' . $start . '-' . $end); |
2925 | - $start = egw_time::to($start_time,'array'); |
|
2926 | - $end = egw_time::to($end_time,'array'); |
|
2922 | + $start = egw_time::to($start_time, 'array'); |
|
2923 | + $end = egw_time::to($end_time, 'array'); |
|
2927 | 2924 | |
2928 | 2925 | |
2929 | 2926 | return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59; |
@@ -2937,7 +2934,7 @@ discard block |
||
2937 | 2934 | * |
2938 | 2935 | * @return DateTime |
2939 | 2936 | */ |
2940 | - function &startOfDay(egw_time $time, $tz_id=null) |
|
2937 | + function &startOfDay(egw_time $time, $tz_id = null) |
|
2941 | 2938 | { |
2942 | 2939 | if (empty($tz_id)) |
2943 | 2940 | { |
@@ -2962,14 +2959,14 @@ discard block |
||
2962 | 2959 | * @param int $time =null new timestamp, default current (server-)time |
2963 | 2960 | * @param int $modifier =null uid of the modifier, default current user |
2964 | 2961 | */ |
2965 | - function updateModified($id, $update_master=false, $time=null, $modifier=null) |
|
2962 | + function updateModified($id, $update_master = false, $time = null, $modifier = null) |
|
2966 | 2963 | { |
2967 | 2964 | if (is_null($time) || !$time) $time = time(); |
2968 | 2965 | if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id']; |
2969 | 2966 | |
2970 | 2967 | $this->db->update($this->cal_table, |
2971 | 2968 | array('cal_modified' => $time, 'cal_modifier' => $modifier), |
2972 | - array('cal_id' => $id), __LINE__,__FILE__, 'calendar'); |
|
2969 | + array('cal_id' => $id), __LINE__, __FILE__, 'calendar'); |
|
2973 | 2970 | |
2974 | 2971 | // if event is an exception: update modified of master, to force etag, ctag and sync-token change |
2975 | 2972 | if ($update_master) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | if ($year >= 1985 && $holiday['month'] == $cached_month && $day == $cached_day + 2 && $cached_observance_rule == True && $holiday['observance_rule'] == True) |
105 | 105 | { |
106 | - $pdow = $GLOBALS['egw']->datetime->day_of_week($year,$holiday['month'],$day-1); |
|
106 | + $pdow = $GLOBALS['egw']->datetime->day_of_week($year, $holiday['month'], $day - 1); |
|
107 | 107 | if ($pdow != 0) |
108 | 108 | { |
109 | 109 | $addcnt = count($holidays) + 1; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $holidays[$addcnt]['month'] = $holiday['month']; |
121 | 121 | $holidays[$addcnt]['occurence'] = 0; |
122 | 122 | $holidays[$addcnt]['dow'] = 0; |
123 | - $holidays[$addcnt]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$year); |
|
123 | + $holidays[$addcnt]['date'] = mktime(0, 0, 0, $holiday['month'], $day - 1, $year); |
|
124 | 124 | $holidays[$addcnt]['observance_rule'] = 0; |
125 | 125 | } |
126 | 126 | } |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | } |
136 | 136 | elseif ($holiday['observance_rule'] == True) |
137 | 137 | { |
138 | - $dow = $GLOBALS['egw']->datetime->day_of_week($year,$holiday['month'],$day); |
|
138 | + $dow = $GLOBALS['egw']->datetime->day_of_week($year, $holiday['month'], $day); |
|
139 | 139 | // This now calulates Observed holidays and creates a new entry for them. |
140 | - if($dow == 0) |
|
140 | + if ($dow == 0) |
|
141 | 141 | { |
142 | 142 | $addcnt = count($holidays) + 1; |
143 | 143 | $holidays[$addcnt]['locale'] = $holiday['locale']; |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | $holidays[$addcnt]['month'] = $holiday['month']; |
147 | 147 | $holidays[$addcnt]['occurence'] = $holiday['occurence']; |
148 | 148 | $holidays[$addcnt]['dow'] = $holiday['dow']; |
149 | - $holidays[$addcnt]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$year); |
|
149 | + $holidays[$addcnt]['date'] = mktime(0, 0, 0, $holiday['month'], $day + 1, $year); |
|
150 | 150 | $holidays[$addcnt]['observance_rule'] = 0; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - $date = mktime(0,0,0,$holiday['month'],$day,$year); |
|
154 | + $date = mktime(0, 0, 0, $holiday['month'], $day, $year); |
|
155 | 155 | |
156 | 156 | return $date; |
157 | 157 | } |