|
@@ -84,19 +84,19 @@ discard block |
|
|
block discarded – undo |
|
84
|
84
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
85
|
85
|
|
|
86
|
86
|
$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
|
87
|
|
- $cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P' |
|
|
87
|
+ $cals = $cals_pref ? explode(',', $cals_pref) : array('P'); // implicit default of 'P' |
|
88
|
88
|
$folderlist = array(); |
|
89
|
89
|
|
|
90
|
90
|
foreach ($this->calendar->list_cals() as $entry) |
|
91
|
91
|
{ |
|
92
|
92
|
$account_id = $entry['grantor']; |
|
93
|
|
- if (in_array('A',$cals) || in_array($account_id,$cals) || |
|
94
|
|
- $account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar! |
|
95
|
|
- $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals)) |
|
|
93
|
+ if (in_array('A', $cals) || in_array($account_id, $cals) || |
|
|
94
|
+ $account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar! |
|
|
95
|
+ $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals)) |
|
96
|
96
|
{ |
|
97
|
97
|
$folderlist[] = $f = array( |
|
98
|
|
- 'id' => $this->backend->createID('calendar',$account_id), |
|
99
|
|
- 'mod' => $GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'), |
|
|
98
|
+ 'id' => $this->backend->createID('calendar', $account_id), |
|
|
99
|
+ 'mod' => $GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'), |
|
100
|
100
|
'parent'=> '0', |
|
101
|
101
|
); |
|
102
|
102
|
} |
|
@@ -120,7 +120,7 @@ discard block |
|
|
block discarded – undo |
|
120
|
120
|
$folderObj = new SyncFolder(); |
|
121
|
121
|
$folderObj->serverid = $id; |
|
122
|
122
|
$folderObj->parentid = '0'; |
|
123
|
|
- $folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'); |
|
|
123
|
+ $folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'); |
|
124
|
124
|
if ($owner == $GLOBALS['egw_info']['user']['account_id']) |
|
125
|
125
|
{ |
|
126
|
126
|
$folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT; |
|
@@ -154,7 +154,7 @@ discard block |
|
|
block discarded – undo |
|
154
|
154
|
|
|
155
|
155
|
$stat = array( |
|
156
|
156
|
'id' => $id, |
|
157
|
|
- 'mod' => $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'), |
|
|
157
|
+ 'mod' => $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'), |
|
158
|
158
|
'parent' => '0', |
|
159
|
159
|
); |
|
160
|
160
|
//error_log(__METHOD__."('$id') folderObj=".array2string($stat)); |
|
@@ -178,19 +178,19 @@ discard block |
|
|
block discarded – undo |
|
178
|
178
|
* @param array $not_uids =null uids NOT to return for meeting requests |
|
179
|
179
|
* @return array |
|
180
|
180
|
*/ |
|
181
|
|
- function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
|
|
181
|
+ function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null) |
|
182
|
182
|
{ |
|
183
|
183
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
184
|
184
|
|
|
185
|
185
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)"); |
|
186
|
186
|
$type = $user = null; |
|
187
|
|
- $this->backend->splitID($id,$type,$user); |
|
|
187
|
+ $this->backend->splitID($id, $type, $user); |
|
188
|
188
|
|
|
189
|
|
- if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
|
189
|
+ if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences |
|
190
|
190
|
|
|
191
|
191
|
$filter = array( |
|
192
|
192
|
'users' => $user, |
|
193
|
|
- 'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences |
|
|
193
|
+ 'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences |
|
194
|
194
|
'enum_recuring' => false, |
|
195
|
195
|
'daywise' => false, |
|
196
|
196
|
'date_format' => 'server', |
|
@@ -199,13 +199,13 @@ discard block |
|
|
block discarded – undo |
|
199
|
199
|
'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default', |
|
200
|
200
|
// @todo return only etag relevant information (seems not to work ...) |
|
201
|
201
|
//'cols' => array('egw_cal.cal_id', 'cal_start', 'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'), |
|
202
|
|
- 'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions |
|
|
202
|
+ 'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions |
|
203
|
203
|
); |
|
204
|
204
|
|
|
205
|
205
|
$messagelist = array(); |
|
206
|
206
|
// reading events in chunks of 100, to keep memory down for huge calendars |
|
207
|
207
|
$num_rows = 100; |
|
208
|
|
- for($start=0; ($events = $this->calendar->search($filter+array( |
|
|
208
|
+ for ($start = 0; ($events = $this->calendar->search($filter + array( |
|
209
|
209
|
'offset' => $start, |
|
210
|
210
|
'num_rows' => $num_rows, |
|
211
|
211
|
))); $start += $num_rows) |
|
@@ -240,7 +240,7 @@ discard block |
|
|
block discarded – undo |
|
240
|
240
|
* @param int $cutoffdate =null |
|
241
|
241
|
* @return array |
|
242
|
242
|
*/ |
|
243
|
|
- function GetMeetingRequests(array $not_uids, $cutoffdate=NULL) |
|
|
243
|
+ function GetMeetingRequests(array $not_uids, $cutoffdate = NULL) |
|
244
|
244
|
{ |
|
245
|
245
|
unset($not_uids, $cutoffdate); |
|
246
|
246
|
return array(); |
|
@@ -266,7 +266,7 @@ discard block |
|
|
block discarded – undo |
|
266
|
266
|
*/ |
|
267
|
267
|
function StatMeetingRequest($id) |
|
268
|
268
|
{ |
|
269
|
|
- $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
|
269
|
+ $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
270
|
270
|
|
|
271
|
271
|
$ret = $this->StatMessage($folderid, abs($id)); |
|
272
|
272
|
$ret['id'] = $id; |
|
@@ -285,9 +285,9 @@ discard block |
|
|
block discarded – undo |
|
285
|
285
|
* @param bool $mimesupport |
|
286
|
286
|
* @return SyncMail |
|
287
|
287
|
*/ |
|
288
|
|
- function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
|
288
|
+ function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
289
|
289
|
{ |
|
290
|
|
- unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
|
|
290
|
+ unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
|
291
|
291
|
|
|
292
|
292
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
293
|
293
|
|
|
@@ -300,13 +300,13 @@ discard block |
|
|
block discarded – undo |
|
300
|
300
|
$message = new SyncMail(); |
|
301
|
301
|
$message->read = false; |
|
302
|
302
|
$message->subject = $event['title']; |
|
303
|
|
- $message->importance = 1; // 0=Low, 1=Normal, 2=High |
|
|
303
|
+ $message->importance = 1; // 0=Low, 1=Normal, 2=High |
|
304
|
304
|
$message->datereceived = $event['created']; |
|
305
|
305
|
$message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email']; |
|
306
|
|
- $message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'). |
|
307
|
|
- ' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>'; |
|
|
306
|
+ $message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname'). |
|
|
307
|
+ ' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>'; |
|
308
|
308
|
$message->internetcpid = 65001; |
|
309
|
|
- $message->contentclass="urn:content-classes:message"; |
|
|
309
|
+ $message->contentclass = "urn:content-classes:message"; |
|
310
|
310
|
|
|
311
|
311
|
$message->meetingrequest = self::meetingRequest($event); |
|
312
|
312
|
$message->messageclass = "IPM.Schedule.Meeting.Request"; |
|
@@ -321,7 +321,7 @@ discard block |
|
|
block discarded – undo |
|
321
|
321
|
else |
|
322
|
322
|
{ |
|
323
|
323
|
$message->airsyncbasebody = new SyncAirSyncBaseBody(); |
|
324
|
|
- $message->airsyncbasenativebodytype=1; |
|
|
324
|
+ $message->airsyncbasenativebodytype = 1; |
|
325
|
325
|
$this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody); |
|
326
|
326
|
} |
|
327
|
327
|
} |
|
@@ -358,12 +358,12 @@ discard block |
|
|
block discarded – undo |
|
358
|
358
|
$as_tz = TimezoneUtil::GetFullTZFromTZName($event['tzid']); |
|
359
|
359
|
$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz)); |
|
360
|
360
|
} |
|
361
|
|
- catch(Exception $e) { |
|
|
361
|
+ catch (Exception $e) { |
|
362
|
362
|
unset($e); |
|
363
|
363
|
// ignore exception, simply set no timezone, as it is optional |
|
364
|
364
|
} |
|
365
|
365
|
// copying timestamps (they are already read in servertime, so non tz conversation) |
|
366
|
|
- foreach(array( |
|
|
366
|
+ foreach (array( |
|
367
|
367
|
'start' => 'starttime', |
|
368
|
368
|
'end' => 'endtime', |
|
369
|
369
|
'created' => 'dtstamp', |
|
@@ -373,10 +373,10 @@ discard block |
|
|
block discarded – undo |
|
373
|
373
|
} |
|
374
|
374
|
if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
|
375
|
375
|
{ |
|
376
|
|
- ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
|
376
|
+ ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
377
|
377
|
} |
|
378
|
378
|
// copying strings |
|
379
|
|
- foreach(array( |
|
|
379
|
+ foreach (array( |
|
380
|
380
|
'title' => 'subject', |
|
381
|
381
|
'location' => 'location', |
|
382
|
382
|
) as $key => $attr) |
|
@@ -385,16 +385,16 @@ discard block |
|
|
block discarded – undo |
|
385
|
385
|
} |
|
386
|
386
|
$message->organizer = $event['organizer']; |
|
387
|
387
|
|
|
388
|
|
- $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
|
388
|
+ $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
389
|
389
|
|
|
390
|
390
|
// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
|
391
|
391
|
$message->busystatus = $event['non_blocking'] ? 0 : 2; |
|
392
|
392
|
|
|
393
|
393
|
// ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ... |
|
394
|
|
- $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception |
|
|
394
|
+ $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception |
|
395
|
395
|
|
|
396
|
|
- $message->responserequested = 1; //0=No, 1=Yes |
|
397
|
|
- $message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed |
|
|
396
|
+ $message->responserequested = 1; //0=No, 1=Yes |
|
|
397
|
+ $message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed |
|
398
|
398
|
//$message->messagemeetingtype; // email2 |
|
399
|
399
|
|
|
400
|
400
|
// ToDo: alarme: Reminder |
|
@@ -440,14 +440,14 @@ discard block |
|
|
block discarded – undo |
|
440
|
440
|
// check if event already exist (invitation of or already imported by other user) |
|
441
|
441
|
if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server'))) |
|
442
|
442
|
{ |
|
443
|
|
- $event = $parsed_event; // create new event from external invitation |
|
|
443
|
+ $event = $parsed_event; // create new event from external invitation |
|
444
|
444
|
} |
|
445
|
|
- elseif(!isset($event['participants'][$uid])) |
|
|
445
|
+ elseif (!isset($event['participants'][$uid])) |
|
446
|
446
|
{ |
|
447
|
447
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event)); |
|
448
|
448
|
// maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ... |
|
449
|
449
|
} |
|
450
|
|
- elseif($event['deleted']) |
|
|
450
|
+ elseif ($event['deleted']) |
|
451
|
451
|
{ |
|
452
|
452
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false"); |
|
453
|
453
|
return false; |
|
@@ -470,7 +470,7 @@ discard block |
|
|
block discarded – undo |
|
470
|
470
|
else |
|
471
|
471
|
{ |
|
472
|
472
|
$event['participants'][$uid] = $status; |
|
473
|
|
- $ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS |
|
|
473
|
+ $ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS |
|
474
|
474
|
} |
|
475
|
475
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", '$folderid', $response) returning ".array2string($ret)); |
|
476
|
476
|
return $ret; |
|
@@ -482,10 +482,10 @@ discard block |
|
|
block discarded – undo |
|
482
|
482
|
* @var array |
|
483
|
483
|
*/ |
|
484
|
484
|
static $status2as = array( |
|
485
|
|
- 'U' => 0, // unknown |
|
486
|
|
- 'T' => 2, // tentative |
|
487
|
|
- 'A' => 3, // accepted |
|
488
|
|
- 'R' => 4, // decline |
|
|
485
|
+ 'U' => 0, // unknown |
|
|
486
|
+ 'T' => 2, // tentative |
|
|
487
|
+ 'A' => 3, // accepted |
|
|
488
|
+ 'R' => 4, // decline |
|
489
|
489
|
// 5 = not responded |
|
490
|
490
|
); |
|
491
|
491
|
/** |
|
@@ -494,9 +494,9 @@ discard block |
|
|
block discarded – undo |
|
494
|
494
|
* @var array |
|
495
|
495
|
*/ |
|
496
|
496
|
static $role2as = array( |
|
497
|
|
- 'REQ-PARTICIPANT' => 1, // required |
|
498
|
|
- 'CHAIR' => 1, // required |
|
499
|
|
- 'OPT-PARTICIPANT' => 2, // optional |
|
|
497
|
+ 'REQ-PARTICIPANT' => 1, // required |
|
|
498
|
+ 'CHAIR' => 1, // required |
|
|
499
|
+ 'OPT-PARTICIPANT' => 2, // optional |
|
500
|
500
|
'NON-PARTICIPANT' => 2, |
|
501
|
501
|
// 3 = ressource |
|
502
|
502
|
); |
|
@@ -508,8 +508,8 @@ discard block |
|
|
block discarded – undo |
|
508
|
508
|
static $recur_type2as = array( |
|
509
|
509
|
calendar_rrule::DAILY => 0, |
|
510
|
510
|
calendar_rrule::WEEKLY => 1, |
|
511
|
|
- calendar_rrule::MONTHLY_MDAY => 2, // monthly |
|
512
|
|
- calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day |
|
|
511
|
+ calendar_rrule::MONTHLY_MDAY => 2, // monthly |
|
|
512
|
+ calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day |
|
513
|
513
|
calendar_rrule::YEARLY => 5, |
|
514
|
514
|
// 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears) |
|
515
|
515
|
); |
|
@@ -536,7 +536,7 @@ discard block |
|
|
block discarded – undo |
|
536
|
536
|
*/ |
|
537
|
537
|
public function ChangeMessage($folderid, $_id, $message, $contentParameters) |
|
538
|
538
|
{ |
|
539
|
|
- unset($contentParameters); // unused, but required by function signature |
|
|
539
|
+ unset($contentParameters); // unused, but required by function signature |
|
540
|
540
|
|
|
541
|
541
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
542
|
542
|
|
|
@@ -546,7 +546,7 @@ discard block |
|
|
block discarded – undo |
|
546
|
546
|
|
|
547
|
547
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $_id, ".array2string($message).") type='$type', account=$account"); |
|
548
|
548
|
|
|
549
|
|
- list($id,$recur_date) = explode(':', $_id); |
|
|
549
|
+ list($id, $recur_date) = explode(':', $_id); |
|
550
|
550
|
|
|
551
|
551
|
if ($type != 'calendar' || $id && !($old_event = $this->calendar->read($id, $recur_date, false, 'server'))) |
|
552
|
552
|
{ |
|
@@ -559,21 +559,21 @@ discard block |
|
|
block discarded – undo |
|
559
|
559
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
|
560
|
560
|
//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
|
561
|
561
|
} |
|
562
|
|
- if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account)) |
|
|
562
|
+ if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0, $account)) |
|
563
|
563
|
{ |
|
564
|
564
|
// @todo: write in users calendar and make account only a participant |
|
565
|
565
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) no rights to add/edit event!"); |
|
566
|
566
|
//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
|
567
|
567
|
return false; |
|
568
|
568
|
} |
|
569
|
|
- if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
|
569
|
+ if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
570
|
570
|
|
|
571
|
571
|
$event = $this->message2event($message, $account, $old_event); |
|
572
|
572
|
|
|
573
|
573
|
// store event, ignore conflicts and skip notifications, as AS clients do their own notifications |
|
574
|
574
|
$skip_notification = false; |
|
575
|
575
|
if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
|
576
|
|
- $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send') |
|
|
576
|
+ $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'send') |
|
577
|
577
|
{ |
|
578
|
578
|
$skip_notification = true; // to avoid double notification from client AND Server |
|
579
|
579
|
} |
|
@@ -586,16 +586,16 @@ discard block |
|
|
block discarded – undo |
|
586
|
586
|
// store non-delete exceptions |
|
587
|
587
|
if ($message->exceptions) |
|
588
|
588
|
{ |
|
589
|
|
- foreach($message->exceptions as $exception) |
|
|
589
|
+ foreach ($message->exceptions as $exception) |
|
590
|
590
|
{ |
|
591
|
591
|
if (!$exception->deleted) |
|
592
|
592
|
{ |
|
593
|
593
|
$ex_event = $event; |
|
594
|
594
|
unset($ex_event['id']); |
|
595
|
595
|
unset($ex_event['etag']); |
|
596
|
|
- foreach(array_keys($ex_event) as $name) |
|
|
596
|
+ foreach (array_keys($ex_event) as $name) |
|
597
|
597
|
{ |
|
598
|
|
- if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
|
598
|
+ if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]); |
|
599
|
599
|
} |
|
600
|
600
|
$ex_event['recur_type'] = calendar_rrule::NONE; |
|
601
|
601
|
|
|
@@ -603,10 +603,10 @@ discard block |
|
|
block discarded – undo |
|
603
|
603
|
'user' => $account, |
|
604
|
604
|
'enum_recuring' => false, |
|
605
|
605
|
'daywise' => false, |
|
606
|
|
- 'filter' => 'owner', // return all possible entries |
|
|
606
|
+ 'filter' => 'owner', // return all possible entries |
|
607
|
607
|
'query' => array( |
|
608
|
608
|
'cal_uid' => $event['uid'], |
|
609
|
|
- 'cal_recurrence' => $exception->exceptionstarttime, // in servertime |
|
|
609
|
+ 'cal_recurrence' => $exception->exceptionstarttime, // in servertime |
|
610
|
610
|
), |
|
611
|
611
|
)))) |
|
612
|
612
|
{ |
|
@@ -618,7 +618,7 @@ discard block |
|
|
block discarded – undo |
|
618
|
618
|
$participants = $event['participants']; |
|
619
|
619
|
} |
|
620
|
620
|
$save_event = $this->message2event($exception, $account, $ex_event); |
|
621
|
|
- $save_event['participants'] = $participants; // not contained in $exception |
|
|
621
|
+ $save_event['participants'] = $participants; // not contained in $exception |
|
622
|
622
|
$save_event['reference'] = $event['id']; |
|
623
|
623
|
$save_event['recurrence'] = Api\DateTime::server2user($exception->exceptionstarttime); |
|
624
|
624
|
$ex_ok = $this->calendar->save($save_event); |
|
@@ -640,10 +640,10 @@ discard block |
|
|
block discarded – undo |
|
640
|
640
|
* @param array $event =array() |
|
641
|
641
|
* @return array |
|
642
|
642
|
*/ |
|
643
|
|
- private function message2event(SyncAppointment $message, $account, $event=array()) |
|
|
643
|
+ private function message2event(SyncAppointment $message, $account, $event = array()) |
|
644
|
644
|
{ |
|
645
|
645
|
// timestamps (created & modified are updated automatically) |
|
646
|
|
- foreach(array( |
|
|
646
|
+ foreach (array( |
|
647
|
647
|
'start' => 'starttime', |
|
648
|
648
|
'end' => 'endtime', |
|
649
|
649
|
) as $key => $attr) |
|
@@ -651,7 +651,7 @@ discard block |
|
|
block discarded – undo |
|
651
|
651
|
if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr); |
|
652
|
652
|
} |
|
653
|
653
|
// copying strings |
|
654
|
|
- foreach(array( |
|
|
654
|
+ foreach (array( |
|
655
|
655
|
'title' => 'subject', |
|
656
|
656
|
'uid' => 'uid', |
|
657
|
657
|
'location' => 'location', |
|
@@ -666,7 +666,7 @@ discard block |
|
|
block discarded – undo |
|
666
|
666
|
{ |
|
667
|
667
|
$event['description'] = $description; |
|
668
|
668
|
} |
|
669
|
|
- $event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential |
|
|
669
|
+ $event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential |
|
670
|
670
|
|
|
671
|
671
|
// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
|
672
|
672
|
if (isset($message->busystatus)) |
|
@@ -676,21 +676,21 @@ discard block |
|
|
block discarded – undo |
|
676
|
676
|
|
|
677
|
677
|
if (($event['whole_day'] = $message->alldayevent)) |
|
678
|
678
|
{ |
|
679
|
|
- if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
680
|
|
- $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
|
|
679
|
+ if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day |
|
|
680
|
+ $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
|
681
|
681
|
} |
|
682
|
682
|
|
|
683
|
683
|
$participants = array(); |
|
684
|
|
- foreach((array)$message->attendees as $attendee) |
|
|
684
|
+ foreach ((array)$message->attendees as $attendee) |
|
685
|
685
|
{ |
|
686
|
|
- if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
|
686
|
+ if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
687
|
687
|
|
|
688
|
688
|
$matches = null; |
|
689
|
|
- if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
|
|
689
|
+ if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches)) |
|
690
|
690
|
{ |
|
691
|
691
|
$uid = $matches[1]; |
|
692
|
692
|
} |
|
693
|
|
- elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email'))) |
|
|
693
|
+ elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email'))) |
|
694
|
694
|
{ |
|
695
|
695
|
$search = array( |
|
696
|
696
|
'email' => $attendee->email, |
|
@@ -700,13 +700,13 @@ discard block |
|
|
block discarded – undo |
|
700
|
700
|
// search addressbook for participant |
|
701
|
701
|
if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
702
|
702
|
if ((list($data) = $this->addressbook->search($search, |
|
703
|
|
- array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
|
703
|
+ array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
704
|
704
|
'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
|
705
|
|
- '','',false,'OR'))) |
|
|
705
|
+ '', '', false, 'OR'))) |
|
706
|
706
|
{ |
|
707
|
707
|
$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
|
708
|
708
|
} |
|
709
|
|
- elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
|
709
|
+ elseif ($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
710
|
710
|
{ |
|
711
|
711
|
$uid = 'e'.$attendee->email; |
|
712
|
712
|
} |
|
@@ -724,8 +724,8 @@ discard block |
|
|
block discarded – undo |
|
724
|
724
|
//ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
|
725
|
725
|
} |
|
726
|
726
|
// check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set |
|
727
|
|
- elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) || |
|
728
|
|
- (isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>'])))) |
|
|
727
|
+ elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) || |
|
|
728
|
+ (isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>'])))) |
|
729
|
729
|
{ |
|
730
|
730
|
$status = $event['participants'][$u]; |
|
731
|
731
|
calendar_so::split_status($status, $quantity, $role); |
|
@@ -738,9 +738,9 @@ discard block |
|
|
block discarded – undo |
|
738
|
738
|
$role = 'REQ-PARTICIPANT'; |
|
739
|
739
|
//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
|
740
|
740
|
} |
|
741
|
|
- if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
|
741
|
+ if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
742
|
742
|
|
|
743
|
|
- if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
|
|
743
|
+ if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as))) |
|
744
|
744
|
{ |
|
745
|
745
|
$status = $s; |
|
746
|
746
|
} |
|
@@ -750,29 +750,29 @@ discard block |
|
|
block discarded – undo |
|
750
|
750
|
$chair_set = true; |
|
751
|
751
|
} |
|
752
|
752
|
elseif (isset($attendee->attendeetype) && |
|
753
|
|
- !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
|
754
|
|
- ($r = array_search($attendee->attendeetype,self::$role2as)) && |
|
|
753
|
+ !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
|
|
754
|
+ ($r = array_search($attendee->attendeetype, self::$role2as)) && |
|
755
|
755
|
(int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
|
756
|
756
|
{ |
|
757
|
757
|
$role = $r; |
|
758
|
758
|
} |
|
759
|
759
|
//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
|
760
|
|
- $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
|
|
760
|
+ $participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role); |
|
761
|
761
|
} |
|
762
|
762
|
// if organizer is not already participant, add him as chair |
|
763
|
|
- if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid])) |
|
|
763
|
+ if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid])) |
|
764
|
764
|
{ |
|
765
|
765
|
$participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ? |
|
766
|
|
- 'A' : 'U',1,'CHAIR'); |
|
|
766
|
+ 'A' : 'U', 1, 'CHAIR'); |
|
767
|
767
|
$chair_set = true; |
|
768
|
768
|
} |
|
769
|
769
|
// preserve all resource types not account, contact or email (eg. resources) for existing events |
|
770
|
770
|
// $account is also preserved, as AS does not add him as participant! |
|
771
|
|
- foreach((array)$event['participant_types'] as $type => $parts) |
|
|
771
|
+ foreach ((array)$event['participant_types'] as $type => $parts) |
|
772
|
772
|
{ |
|
773
|
|
- if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
|
773
|
+ if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS |
|
774
|
774
|
|
|
775
|
|
- foreach($parts as $id => $status) |
|
|
775
|
+ foreach ($parts as $id => $status) |
|
776
|
776
|
{ |
|
777
|
777
|
// accounts are represented correctly, but the event owner which is no participant in AS |
|
778
|
778
|
if ($type == 'u' && $id != $account) continue; |
|
@@ -788,13 +788,13 @@ discard block |
|
|
block discarded – undo |
|
788
|
788
|
if (!$event['id'] || !$participants || !isset($participants[$account])) |
|
789
|
789
|
{ |
|
790
|
790
|
$participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ? |
|
791
|
|
- 'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
|
791
|
+ 'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
792
|
792
|
} |
|
793
|
793
|
$event['participants'] = $participants; |
|
794
|
794
|
|
|
795
|
795
|
if (isset($message->categories)) |
|
796
|
796
|
{ |
|
797
|
|
- $event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen')); |
|
|
797
|
+ $event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen')); |
|
798
|
798
|
} |
|
799
|
799
|
|
|
800
|
800
|
// check if event is recurring and import recur information (incl. timezone) |
|
@@ -804,8 +804,7 @@ discard block |
|
|
block discarded – undo |
|
804
|
804
|
{ |
|
805
|
805
|
$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
|
806
|
806
|
} |
|
807
|
|
- $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
|
808
|
|
- array_search($message->recurrence->type, self::$recur_type2as); |
|
|
807
|
+ $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as); |
|
809
|
808
|
$event['recur_interval'] = $message->recurrence->interval; |
|
810
|
809
|
|
|
811
|
810
|
switch ($event['recur_type']) |
|
@@ -814,7 +813,7 @@ discard block |
|
|
block discarded – undo |
|
814
|
813
|
// $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date |
|
815
|
814
|
// fall throught |
|
816
|
815
|
case calendar_rrule::WEEKLY: |
|
817
|
|
- $event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
|
816
|
+ $event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
818
|
817
|
break; |
|
819
|
818
|
case calendar_rrule::MONTHLY_MDAY: |
|
820
|
819
|
// $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date |
|
@@ -830,7 +829,7 @@ discard block |
|
|
block discarded – undo |
|
830
|
829
|
$event['recur_exceptions'] = array(); |
|
831
|
830
|
if ($message->exceptions) |
|
832
|
831
|
{ |
|
833
|
|
- foreach($message->exceptions as $exception) |
|
|
832
|
+ foreach ($message->exceptions as $exception) |
|
834
|
833
|
{ |
|
835
|
834
|
$event['recur_exception'][] = Api\DateTime::server2user($exception->exceptionstarttime); |
|
836
|
835
|
} |
|
@@ -840,7 +839,7 @@ discard block |
|
|
block discarded – undo |
|
840
|
839
|
{ |
|
841
|
840
|
// calculate enddate from occurences count, as we only support enddate |
|
842
|
841
|
$count = $message->recurrence->occurrences; |
|
843
|
|
- foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
|
842
|
+ foreach (calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
844
|
843
|
{ |
|
845
|
844
|
if (--$count <= 0) break; |
|
846
|
845
|
} |
|
@@ -850,11 +849,11 @@ discard block |
|
|
block discarded – undo |
|
850
|
849
|
// only import alarms in own calendar |
|
851
|
850
|
if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id']) |
|
852
|
851
|
{ |
|
853
|
|
- foreach((array)$event['alarm'] as $alarm) |
|
|
852
|
+ foreach ((array)$event['alarm'] as $alarm) |
|
854
|
853
|
{ |
|
855
|
|
- if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder) |
|
|
854
|
+ if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder) |
|
856
|
855
|
{ |
|
857
|
|
- $alarm = true; // alarm already exists --> do nothing |
|
|
856
|
+ $alarm = true; // alarm already exists --> do nothing |
|
858
|
857
|
break; |
|
859
|
858
|
} |
|
860
|
859
|
} |
|
@@ -863,16 +862,16 @@ discard block |
|
|
block discarded – undo |
|
863
|
862
|
// delete all earlier alarms of that user |
|
864
|
863
|
// user get's per AS only the earliest alarm, as AS only supports one alarm |
|
865
|
864
|
// --> if a later alarm is returned, user probably modifed an existing alarm |
|
866
|
|
- foreach((array)$event['alarm'] as $key => $alarm) |
|
|
865
|
+ foreach ((array)$event['alarm'] as $key => $alarm) |
|
867
|
866
|
{ |
|
868
|
|
- if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
|
|
867
|
+ if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder) |
|
869
|
868
|
{ |
|
870
|
869
|
unset($event['alarm'][$key]); |
|
871
|
870
|
} |
|
872
|
871
|
} |
|
873
|
872
|
$event['alarm'][] = $alarm = array( |
|
874
|
873
|
'owner' => $account, |
|
875
|
|
- 'offset' => 60*$message->reminder, |
|
|
874
|
+ 'offset' => 60 * $message->reminder, |
|
876
|
875
|
); |
|
877
|
876
|
} |
|
878
|
877
|
} |
|
@@ -946,7 +945,7 @@ discard block |
|
|
block discarded – undo |
|
946
|
945
|
*/ |
|
947
|
946
|
public function DeleteMessage($folderid, $id, $contentParameters) |
|
948
|
947
|
{ |
|
949
|
|
- unset($contentParameters); // not used, but required by function signature |
|
|
948
|
+ unset($contentParameters); // not used, but required by function signature |
|
950
|
949
|
|
|
951
|
950
|
if (!isset($this->caledar)) $this->calendar = new calendar_boupdate(); |
|
952
|
951
|
|
|
@@ -974,7 +973,7 @@ discard block |
|
|
block discarded – undo |
|
974
|
973
|
*/ |
|
975
|
974
|
function SetReadFlag($folderid, $id, $flags, $contentParameters) |
|
976
|
975
|
{ |
|
977
|
|
- unset($contentParameters); // not used, but required by function signature |
|
|
976
|
+ unset($contentParameters); // not used, but required by function signature |
|
978
|
977
|
|
|
979
|
978
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, ".array2string($flags)." NOT supported!"); |
|
980
|
979
|
return false; |
|
@@ -1008,7 +1007,7 @@ discard block |
|
|
block discarded – undo |
|
1008
|
1007
|
* @param string $class ='SyncAppointment' or 'SyncAppointmentException' |
|
1009
|
1008
|
* @return SyncAppointment|boolean false on error |
|
1010
|
1009
|
*/ |
|
1011
|
|
- public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment') |
|
|
1010
|
+ public function GetMessage($folderid, $id, $contentparameters, $class = 'SyncAppointment') |
|
1012
|
1011
|
{ |
|
1013
|
1012
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
1014
|
1013
|
//error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace()); |
|
@@ -1026,17 +1025,17 @@ discard block |
|
|
block discarded – undo |
|
1026
|
1025
|
} |
|
1027
|
1026
|
else |
|
1028
|
1027
|
{ |
|
1029
|
|
- list($id,$recur_date) = explode(':',$id); |
|
1030
|
|
- if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account))) |
|
|
1028
|
+ list($id, $recur_date) = explode(':', $id); |
|
|
1029
|
+ if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account))) |
|
1031
|
1030
|
{ |
|
1032
|
1031
|
error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false"); |
|
1033
|
1032
|
return false; |
|
1034
|
1033
|
} |
|
1035
|
1034
|
} |
|
1036
|
|
- ZLog::Write(LOGLEVEL_DEBUG, __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'])); |
|
1037
|
|
- foreach((array)$event['recur_exception'] as $ex) |
|
|
1035
|
+ ZLog::Write(LOGLEVEL_DEBUG, __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'])); |
|
|
1036
|
+ foreach ((array)$event['recur_exception'] as $ex) |
|
1038
|
1037
|
{ |
|
1039
|
|
- ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s',$ex)); |
|
|
1038
|
+ ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s', $ex)); |
|
1040
|
1039
|
} |
|
1041
|
1040
|
$message = new $class(); |
|
1042
|
1041
|
|
|
@@ -1047,17 +1046,17 @@ discard block |
|
|
block discarded – undo |
|
1047
|
1046
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.':'. array2string($as_tz )); |
|
1048
|
1047
|
// Using TimezoneUtil from zpush to transform from name to as_tz array |
|
1049
|
1048
|
$as_tz = TimezoneUtil::GetFullTZFromTZName($event['tzid']); |
|
1050
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' TimeZone:'.$event['tzid'].' transforms to:'. array2string($as_tz )); |
|
|
1049
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' TimeZone:'.$event['tzid'].' transforms to:'.array2string($as_tz)); |
|
1051
|
1050
|
$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz)); |
|
1052
|
1051
|
} |
|
1053
|
|
- catch(Exception $e) { |
|
|
1052
|
+ catch (Exception $e) { |
|
1054
|
1053
|
unset($e); |
|
1055
|
1054
|
// z-push (2.3 at least) requires a timezone for recurring events |
|
1056
|
1055
|
if ($event['recur_type']) $message->timezone = self::UTC_BLOB; |
|
1057
|
1056
|
} |
|
1058
|
1057
|
|
|
1059
|
1058
|
// copying timestamps (they are already read in servertime, so non tz conversation) |
|
1060
|
|
- foreach(array( |
|
|
1059
|
+ foreach (array( |
|
1061
|
1060
|
'start' => 'starttime', |
|
1062
|
1061
|
'end' => 'endtime', |
|
1063
|
1062
|
'created' => 'dtstamp', |
|
@@ -1068,10 +1067,10 @@ discard block |
|
|
block discarded – undo |
|
1068
|
1067
|
} |
|
1069
|
1068
|
if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
|
1070
|
1069
|
{ |
|
1071
|
|
- ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
|
1070
|
+ ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
1072
|
1071
|
} |
|
1073
|
1072
|
// copying strings |
|
1074
|
|
- foreach(array( |
|
|
1073
|
+ foreach (array( |
|
1075
|
1074
|
'title' => 'subject', |
|
1076
|
1075
|
'uid' => 'uid', |
|
1077
|
1076
|
'location' => 'location', |
|
@@ -1093,21 +1092,21 @@ discard block |
|
|
block discarded – undo |
|
1093
|
1092
|
{ |
|
1094
|
1093
|
ZLog::Write(LOGLEVEL_DEBUG, "airsyncbasebody!"); |
|
1095
|
1094
|
$message->asbody = new SyncBaseBody(); |
|
1096
|
|
- $message->nativebodytype=1; |
|
|
1095
|
+ $message->nativebodytype = 1; |
|
1097
|
1096
|
$this->backend->note2messagenote($event['description'], $bodypreference, $message->asbody); |
|
1098
|
1097
|
} |
|
1099
|
1098
|
} |
|
1100
|
|
- $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'); |
|
|
1099
|
+ $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname'); |
|
1101
|
1100
|
// at least iOS calendar crashes, if organizer has no email address (true = generate an email, if user has none) |
|
1102
|
1101
|
$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email', true); |
|
1103
|
1102
|
|
|
1104
|
|
- $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
|
1103
|
+ $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
1105
|
1104
|
|
|
1106
|
1105
|
// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
|
1107
|
1106
|
$message->busystatus = $event['non_blocking'] ? 0 : 2; |
|
1108
|
1107
|
|
|
1109
|
1108
|
$message->attendees = array(); |
|
1110
|
|
- foreach($event['participants'] as $uid => $status) |
|
|
1109
|
+ foreach ($event['participants'] as $uid => $status) |
|
1111
|
1110
|
{ |
|
1112
|
1111
|
// AS does NOT want calendar owner as participant |
|
1113
|
1112
|
if ($uid == $account) continue; |
|
@@ -1119,13 +1118,13 @@ discard block |
|
|
block discarded – undo |
|
1119
|
1118
|
$attendee->attendeetype = (int)self::$role2as[$role]; |
|
1120
|
1119
|
if (is_numeric($uid)) |
|
1121
|
1120
|
{ |
|
1122
|
|
- $attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname'); |
|
|
1121
|
+ $attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname'); |
|
1123
|
1122
|
$attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email', true); |
|
1124
|
1123
|
} |
|
1125
|
1124
|
else |
|
1126
|
1125
|
{ |
|
1127
|
1126
|
list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
|
1128
|
|
- ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
|
|
1127
|
+ ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false); |
|
1129
|
1128
|
|
|
1130
|
1129
|
if (!$info) continue; |
|
1131
|
1130
|
|
|
@@ -1143,7 +1142,7 @@ discard block |
|
|
block discarded – undo |
|
1143
|
1142
|
$message->organizeremail = $attendee->email; |
|
1144
|
1143
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
|
1145
|
1144
|
} |
|
1146
|
|
- if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
|
1145
|
+ if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
1147
|
1146
|
} |
|
1148
|
1147
|
// email must NOT be empty, but MAY be an arbitrary text |
|
1149
|
1148
|
if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
@@ -1151,7 +1150,7 @@ discard block |
|
|
block discarded – undo |
|
1151
|
1150
|
$message->attendees[] = $attendee; |
|
1152
|
1151
|
} |
|
1153
|
1152
|
$message->categories = array(); |
|
1154
|
|
- foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id) |
|
|
1153
|
+ foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id) |
|
1155
|
1154
|
{ |
|
1156
|
1155
|
$message->categories[] = Api\Categories::id2name($cat_id); |
|
1157
|
1156
|
} |
|
@@ -1160,25 +1159,25 @@ discard block |
|
|
block discarded – undo |
|
1160
|
1159
|
if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date) |
|
1161
|
1160
|
{ |
|
1162
|
1161
|
$message->recurrence = $recurrence = new SyncRecurrence(); |
|
1163
|
|
- $rrule = calendar_rrule::event2rrule($event,false); // false = timestamps in $event are servertime |
|
|
1162
|
+ $rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime |
|
1164
|
1163
|
$recurrence->type = (int)self::$recur_type2as[$rrule->type]; |
|
1165
|
1164
|
$recurrence->interval = $rrule->interval; |
|
1166
|
1165
|
switch ($rrule->type) |
|
1167
|
1166
|
{ |
|
1168
|
1167
|
case calendar_rrule::MONTHLY_WDAY: |
|
1169
|
1168
|
$recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ? |
|
1170
|
|
- $rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1 |
|
|
1169
|
+ $rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1 |
|
1171
|
1170
|
// fall throught |
|
1172
|
1171
|
case calendar_rrule::WEEKLY: |
|
1173
|
|
- $recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
|
1172
|
+ $recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
1174
|
1173
|
break; |
|
1175
|
1174
|
case calendar_rrule::MONTHLY_MDAY: |
|
1176
|
|
- $recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31 |
|
1177
|
|
- $rrule->monthly_bymonthday : 31; // not -1 for last day of month! |
|
|
1175
|
+ $recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31 |
|
|
1176
|
+ $rrule->monthly_bymonthday : 31; // not -1 for last day of month! |
|
1178
|
1177
|
break; |
|
1179
|
1178
|
case calendar_rrule::YEARLY: |
|
1180
|
|
- $recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31 |
|
1181
|
|
- $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
|
|
1179
|
+ $recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31 |
|
|
1180
|
+ $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
|
1182
|
1181
|
break; |
|
1183
|
1182
|
} |
|
1184
|
1183
|
if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
|
@@ -1194,9 +1193,9 @@ discard block |
|
|
block discarded – undo |
|
1194
|
1193
|
// search real / non-virtual exceptions |
|
1195
|
1194
|
if (!empty($event['uid'])) |
|
1196
|
1195
|
{ |
|
1197
|
|
- $ex_events =& $this->calendar->search(array( |
|
|
1196
|
+ $ex_events = & $this->calendar->search(array( |
|
1198
|
1197
|
'query' => array('cal_uid' => $event['uid']), |
|
1199
|
|
- 'filter' => 'owner', // return all possible entries |
|
|
1198
|
+ 'filter' => 'owner', // return all possible entries |
|
1200
|
1199
|
'daywise' => false, |
|
1201
|
1200
|
'date_format' => 'server', |
|
1202
|
1201
|
)); |
|
@@ -1205,36 +1204,36 @@ discard block |
|
|
block discarded – undo |
|
1205
|
1204
|
{ |
|
1206
|
1205
|
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
|
1207
|
1206
|
} |
|
1208
|
|
- if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
|
1207
|
+ if (count($ex_events) >= 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1209
|
1208
|
|
|
1210
|
1209
|
$message->exceptions = array(); |
|
1211
|
|
- foreach($ex_events as $ex_event) |
|
|
1210
|
+ foreach ($ex_events as $ex_event) |
|
1212
|
1211
|
{ |
|
1213
|
|
- if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
|
1212
|
+ if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
1214
|
1213
|
$exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException'); |
|
1215
|
1214
|
$exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
|
1216
|
|
- foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
|
|
1215
|
+ foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported) |
|
1217
|
1216
|
{ |
|
1218
|
|
- $exception->$not_supported = null; // not allowed in exceptions :-( |
|
|
1217
|
+ $exception->$not_supported = null; // not allowed in exceptions :-( |
|
1219
|
1218
|
} |
|
1220
|
1219
|
$exception->deleted = 0; |
|
1221
|
|
- if (($key = array_search($exception_time,$event['recur_exception'])) !== false) |
|
|
1220
|
+ if (($key = array_search($exception_time, $event['recur_exception'])) !== false) |
|
1222
|
1221
|
{ |
|
1223
|
1222
|
unset($event['recur_exception'][$key]); |
|
1224
|
1223
|
} |
|
1225
|
|
- ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception)); |
|
|
1224
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception)); |
|
1226
|
1225
|
$message->exceptions[] = $exception; |
|
1227
|
1226
|
} |
|
1228
|
1227
|
// add rest of exceptions as deleted |
|
1229
|
|
- foreach($event['recur_exception'] as $exception_time) |
|
|
1228
|
+ foreach ($event['recur_exception'] as $exception_time) |
|
1230
|
1229
|
{ |
|
1231
|
1230
|
if (!empty($exception_time)) |
|
1232
|
1231
|
{ |
|
1233
|
1232
|
if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
1234
|
|
- $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
|
|
1233
|
+ $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
|
1235
|
1234
|
$exception->deleted = 1; |
|
1236
|
1235
|
$exception->exceptionstarttime = $exception_time; |
|
1237
|
|
- ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception)); |
|
|
1236
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception)); |
|
1238
|
1237
|
$message->exceptions[] = $exception; |
|
1239
|
1238
|
} |
|
1240
|
1239
|
} |
|
@@ -1256,12 +1255,12 @@ discard block |
|
|
block discarded – undo |
|
1256
|
1255
|
// only return alarms if in own calendar |
|
1257
|
1256
|
if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm']) |
|
1258
|
1257
|
{ |
|
1259
|
|
- foreach($event['alarm'] as $alarm) |
|
|
1258
|
+ foreach ($event['alarm'] as $alarm) |
|
1260
|
1259
|
{ |
|
1261
|
1260
|
if ($alarm['all'] || $alarm['owner'] == $account) |
|
1262
|
1261
|
{ |
|
1263
|
|
- $message->reminder = $alarm['offset']/60; // is in minutes, not seconds as in EGw |
|
1264
|
|
- break; // AS supports only one alarm! (we use the next/earliest one) |
|
|
1262
|
+ $message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw |
|
|
1263
|
+ break; // AS supports only one alarm! (we use the next/earliest one) |
|
1265
|
1264
|
} |
|
1266
|
1265
|
} |
|
1267
|
1266
|
} |
|
@@ -1284,7 +1283,7 @@ discard block |
|
|
block discarded – undo |
|
1284
|
1283
|
*/ |
|
1285
|
1284
|
public function StatMessage($folderid, $id) |
|
1286
|
1285
|
{ |
|
1287
|
|
- unset($folderid); // not used ($id is unique), but required by function signature |
|
|
1286
|
+ unset($folderid); // not used ($id is unique), but required by function signature |
|
1288
|
1287
|
|
|
1289
|
1288
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
1290
|
1289
|
|
|
@@ -1295,7 +1294,7 @@ discard block |
|
|
block discarded – undo |
|
1295
|
1294
|
// error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
|
1296
|
1295
|
$backup = $this->calendar->debug; |
|
1297
|
1296
|
//$this->calendar->debug = 2; |
|
1298
|
|
- list($id) = explode(':',$id); |
|
|
1297
|
+ list($id) = explode(':', $id); |
|
1299
|
1298
|
$this->calendar->check_perms(calendar_bo::ACL_FREEBUSY, $id, 0, 'server'); |
|
1300
|
1299
|
$this->calendar->debug = $backup; |
|
1301
|
1300
|
} |
|
@@ -1329,7 +1328,7 @@ discard block |
|
|
block discarded – undo |
|
1329
|
1328
|
|
|
1330
|
1329
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
1331
|
1330
|
//$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
|
1332
|
|
- $syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
|
|
1331
|
+ $syncstate = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too |
|
1333
|
1332
|
// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
|
1334
|
1333
|
if ($syncstate == 0) $syncstate = 1; |
|
1335
|
1334
|
|
|
@@ -1409,8 +1408,8 @@ discard block |
|
|
block discarded – undo |
|
1409
|
1408
|
|
|
1410
|
1409
|
if ($tz === 'UTC') return $data; |
|
1411
|
1410
|
|
|
1412
|
|
- $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
|
1413
|
|
- if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
|
1411
|
+ $name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz; |
|
|
1412
|
+ if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component'); |
|
1414
|
1413
|
// parse ical timezone defintion |
|
1415
|
1414
|
$ical = self::ical2array($component); |
|
1416
|
1415
|
$standard = $ical['VTIMEZONE']['STANDARD']; |
|
@@ -1419,11 +1418,11 @@ discard block |
|
|
block discarded – undo |
|
1419
|
1418
|
if (!isset($standard)) |
|
1420
|
1419
|
{ |
|
1421
|
1420
|
$matches = null; |
|
1422
|
|
- if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches)) |
|
|
1421
|
+ if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches)) |
|
1423
|
1422
|
{ |
|
1424
|
1423
|
$standard = array( |
|
1425
|
|
- 'TZOFFSETTO' => sprintf('%s%02d00',$matches[1],$matches[2]), |
|
1426
|
|
- 'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]), |
|
|
1424
|
+ 'TZOFFSETTO' => sprintf('%s%02d00', $matches[1], $matches[2]), |
|
|
1425
|
+ 'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]), |
|
1427
|
1426
|
); |
|
1428
|
1427
|
unset($daylight); |
|
1429
|
1428
|
} |
|
@@ -1434,15 +1433,15 @@ discard block |
|
|
block discarded – undo |
|
1434
|
1433
|
} |
|
1435
|
1434
|
// get bias and dstbias from standard component, which is present in all tz's |
|
1436
|
1435
|
// (dstbias is relative to bias and almost always 60 or 0) |
|
1437
|
|
- $data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2)); |
|
1438
|
|
- $data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']); |
|
|
1436
|
+ $data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2)); |
|
|
1437
|
+ $data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']); |
|
1439
|
1438
|
|
|
1440
|
1439
|
// check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving |
|
1441
|
1440
|
if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE'])) |
|
1442
|
1441
|
{ |
|
1443
|
|
- foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp) |
|
|
1442
|
+ foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp) |
|
1444
|
1443
|
{ |
|
1445
|
|
- if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches)) |
|
|
1444
|
+ if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches)) |
|
1446
|
1445
|
{ |
|
1447
|
1446
|
$data[$prefix.'month'] = (int)$matches[2]; |
|
1448
|
1447
|
$data[$prefix.'week'] = (int)$matches[1]; |
|
@@ -1459,20 +1458,20 @@ discard block |
|
|
block discarded – undo |
|
1459
|
1458
|
$data[$prefix.'week'] = 5; |
|
1460
|
1459
|
if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
|
1461
|
1460
|
} |
|
1462
|
|
- static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
|
1463
|
|
- $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
|
|
1461
|
+ static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6); |
|
|
1462
|
+ $data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)]; |
|
1464
|
1463
|
} |
|
1465
|
|
- if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches)) |
|
|
1464
|
+ if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches)) |
|
1466
|
1465
|
{ |
|
1467
|
|
- $data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60; |
|
1468
|
|
- $data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60; |
|
1469
|
|
- $data[$prefix.'second'] = (int)substr($matches[1],4,2); |
|
|
1466
|
+ $data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60; |
|
|
1467
|
+ $data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60; |
|
|
1468
|
+ $data[$prefix.'second'] = (int)substr($matches[1], 4, 2); |
|
1470
|
1469
|
} |
|
1471
|
1470
|
} |
|
1472
|
1471
|
// for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute |
|
1473
|
1472
|
if ($data['dststartmonth'] > $data['dstendmonth']) |
|
1474
|
1473
|
{ |
|
1475
|
|
- $start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start; |
|
|
1474
|
+ $start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start; |
|
1476
|
1475
|
$end = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $end; |
|
1477
|
1476
|
} |
|
1478
|
1477
|
} |
|
@@ -1530,20 +1529,20 @@ discard block |
|
|
block discarded – undo |
|
1530
|
1529
|
* @param string|array $ical lines of ical file |
|
1531
|
1530
|
* @return array with parsed ical components |
|
1532
|
1531
|
*/ |
|
1533
|
|
- static public function ical2array(&$ical,$section=null) |
|
|
1532
|
+ static public function ical2array(&$ical, $section = null) |
|
1534
|
1533
|
{ |
|
1535
|
1534
|
$arr = array(); |
|
1536
|
1535
|
if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
|
1537
|
1536
|
while (($line = array_shift($ical))) |
|
1538
|
1537
|
{ |
|
1539
|
|
- list($name,$value) = explode(':',$line,2); |
|
|
1538
|
+ list($name, $value) = explode(':', $line, 2); |
|
1540
|
1539
|
if ($name == 'BEGIN') |
|
1541
|
1540
|
{ |
|
1542
|
|
- $arr[$value] = self::ical2array($ical,$value); |
|
|
1541
|
+ $arr[$value] = self::ical2array($ical, $value); |
|
1543
|
1542
|
} |
|
1544
|
|
- elseif($name == 'END') |
|
|
1543
|
+ elseif ($name == 'END') |
|
1545
|
1544
|
{ |
|
1546
|
|
- if ($section && $section==$value) return $arr; |
|
|
1545
|
+ if ($section && $section == $value) return $arr; |
|
1547
|
1546
|
break; |
|
1548
|
1547
|
} |
|
1549
|
1548
|
else |
|
@@ -1566,13 +1565,13 @@ discard block |
|
|
block discarded – undo |
|
1566
|
1565
|
*/ |
|
1567
|
1566
|
public static function as2tz(array $data) |
|
1568
|
1567
|
{ |
|
1569
|
|
- static $cache=null; // some caching withing the request |
|
|
1568
|
+ static $cache = null; // some caching withing the request |
|
1570
|
1569
|
|
|
1571
|
|
- unset($data['name']); // not used, but can stall the match |
|
|
1570
|
+ unset($data['name']); // not used, but can stall the match |
|
1572
|
1571
|
|
|
1573
|
1572
|
$key = serialize($data); |
|
1574
|
1573
|
|
|
1575
|
|
- for($n = 0; !isset($cache[$key]); ++$n) |
|
|
1574
|
+ for ($n = 0; !isset($cache[$key]); ++$n) |
|
1576
|
1575
|
{ |
|
1577
|
1576
|
if (!$n) // check users timezone first |
|
1578
|
1577
|
{ |
|
@@ -1591,7 +1590,7 @@ discard block |
|
|
block discarded – undo |
|
1591
|
1590
|
break; |
|
1592
|
1591
|
} |
|
1593
|
1592
|
} |
|
1594
|
|
- catch(Exception $e) { |
|
|
1593
|
+ catch (Exception $e) { |
|
1595
|
1594
|
unset($e); |
|
1596
|
1595
|
// simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component |
|
1597
|
1596
|
} |
|
@@ -1606,8 +1605,8 @@ discard block |
|
|
block discarded – undo |
|
1606
|
1605
|
*/ |
|
1607
|
1606
|
static public function _getTZFromSyncBlob($data) |
|
1608
|
1607
|
{ |
|
1609
|
|
- $tz = unpack( "lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" . |
|
1610
|
|
- "lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" . |
|
|
1608
|
+ $tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/". |
|
|
1609
|
+ "lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/". |
|
1611
|
1610
|
"ldstbias", $data); |
|
1612
|
1611
|
|
|
1613
|
1612
|
return $tz; |
|
@@ -1620,7 +1619,7 @@ discard block |
|
|
block discarded – undo |
|
1620
|
1619
|
*/ |
|
1621
|
1620
|
static public function _getSyncBlobFromTZ($tz) |
|
1622
|
1621
|
{ |
|
1623
|
|
- $packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l", |
|
|
1622
|
+ $packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l", |
|
1624
|
1623
|
$tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"], |
|
1625
|
1624
|
$tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"], |
|
1626
|
1625
|
$tz["dstbias"]); |
|
@@ -1644,7 +1643,7 @@ discard block |
|
|
block discarded – undo |
|
1644
|
1643
|
$account_id = $entry['grantor']; |
|
1645
|
1644
|
$cals[$account_id] = $entry['name']; |
|
1646
|
1645
|
} |
|
1647
|
|
- if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
|
1646
|
+ if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
1648
|
1647
|
} |
|
1649
|
1648
|
$cals['G'] = lang('Primary group'); |
|
1650
|
1649
|
$cals['A'] = lang('All'); |
|
@@ -1680,8 +1679,8 @@ discard block |
|
|
block discarded – undo |
|
1680
|
1679
|
) |
|
1681
|
1680
|
); |
|
1682
|
1681
|
require_once('../../header.inc.php'); |
|
1683
|
|
- ini_set('display_errors',1); |
|
1684
|
|
- error_reporting(E_ALL & ~E_NOTICE); |
|
|
1682
|
+ ini_set('display_errors', 1); |
|
|
1683
|
+ error_reporting(E_ALL&~E_NOTICE); |
|
1685
|
1684
|
|
|
1686
|
1685
|
echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n"; |
|
1687
|
1686
|
echo "<h3>Conversation of ActiveSync Timezone Blobs to TZID's</h3>\n"; |
|
@@ -1695,7 +1694,7 @@ discard block |
|
|
block discarded – undo |
|
1695
|
1694
|
</script>\n"; |
|
1696
|
1695
|
|
|
1697
|
1696
|
// TZID => AS timezone blobs reported by various devices |
|
1698
|
|
- foreach(array( |
|
|
1697
|
+ foreach (array( |
|
1699
|
1698
|
'Europe/Berlin' => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==', |
|
1700
|
1699
|
'Europe/Helsinki' => 'iP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAQAAAAAAAAAxP///w==', |
|
1701
|
1700
|
'Asia/Tokyo' => '5P3//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///w==', |
|
@@ -1709,7 +1708,7 @@ discard block |
|
|
block discarded – undo |
|
1709
|
1708
|
) as $tz => $sync_blob) |
|
1710
|
1709
|
{ |
|
1711
|
1710
|
// get as timezone data for a given timezone |
|
1712
|
|
- $ical = calendar_timezones::tz2id($tz,'component'); |
|
|
1711
|
+ $ical = calendar_timezones::tz2id($tz, 'component'); |
|
1713
|
1712
|
//echo "<pre>".print_r($ical,true)."</pre>\n"; |
|
1714
|
1713
|
$ical_tz = $ical; |
|
1715
|
1714
|
$ical_arr = calendar_zpush::ical2array($ical_tz); |
|
@@ -1728,22 +1727,22 @@ discard block |
|
|
block discarded – undo |
|
1728
|
1727
|
//echo array2string($matched); |
|
1729
|
1728
|
|
|
1730
|
1729
|
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"; |
|
1731
|
|
- foreach(array('dststart','dstend') as $prefix) |
|
|
1730
|
+ foreach (array('dststart', 'dstend') as $prefix) |
|
1732
|
1731
|
{ |
|
1733
|
1732
|
echo "<td>\n"; |
|
1734
|
|
- foreach(array($as_tz_org,$as_tz) as $n => $arr) |
|
|
1733
|
+ foreach (array($as_tz_org, $as_tz) as $n => $arr) |
|
1735
|
1734
|
{ |
|
1736
|
1735
|
$parts = array(); |
|
1737
|
|
- foreach(array('year','month','day','week','hour','minute','second') as $postfix) |
|
|
1736
|
+ foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix) |
|
1738
|
1737
|
{ |
|
1739
|
1738
|
$failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix]; |
|
1740
|
|
- $parts[] = ($failed?'<font color="red">':'').$arr[$prefix.$postfix].($failed?'</font>':''); |
|
|
1739
|
+ $parts[] = ($failed ? '<font color="red">' : '').$arr[$prefix.$postfix].($failed ? '</font>' : ''); |
|
1741
|
1740
|
} |
|
1742
|
|
- echo implode(' ', $parts).(!$n?'<br/>':''); |
|
|
1741
|
+ echo implode(' ', $parts).(!$n ? '<br/>' : ''); |
|
1743
|
1742
|
} |
|
1744
|
1743
|
echo "</td>\n"; |
|
1745
|
1744
|
} |
|
1746
|
|
- echo "<td> <br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n"; |
|
|
1745
|
+ echo "<td> <br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n"; |
|
1747
|
1746
|
} |
|
1748
|
1747
|
echo "</tbody></table>\n"; |
|
1749
|
1748
|
echo "</body></html>\n"; |