Test Failed
Branch master (bfd46a)
by Mike
03:05
created
mapi/mapi.util.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		// OR
224 224
 		[RES_OR,
225 225
 			[
226
-				[RES_AND,    // Normal items: itemEnd must be after viewStart, itemStart must be before viewEnd
226
+				[RES_AND, // Normal items: itemEnd must be after viewStart, itemStart must be before viewEnd
227 227
 					[
228 228
 						[RES_PROPERTY,
229 229
 							[RELOP => RELOP_GT,
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 					],
248 248
 				],
249 249
 			], // EXISTS OR
250
-		];        // global OR
250
+		]; // global OR
251 251
 
252 252
 	// Get requested properties, plus whatever we need
253 253
 	$proplist = [PR_ENTRYID, $properties["recurring"], $properties["recurring_data"], $properties["timezone_data"]];
Please login to merge, or discard this patch.
mapi/mapidefs.php 1 patch
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@  discard block
 block discarded – undo
16 16
 
17 17
 /* Object type */
18 18
 
19
-define('MAPI_STORE', 0x00000001);    /* Message Store */
20
-define('MAPI_ADDRBOOK', 0x00000002);    /* Address Book */
21
-define('MAPI_FOLDER', 0x00000003);    /* Folder */
22
-define('MAPI_ABCONT', 0x00000004);    /* Address Book Container */
23
-define('MAPI_MESSAGE', 0x00000005);    /* Message */
24
-define('MAPI_MAILUSER', 0x00000006);    /* Individual Recipient */
25
-define('MAPI_ATTACH', 0x00000007);    /* Attachment */
26
-define('MAPI_DISTLIST', 0x00000008);    /* Distribution List Recipient */
27
-define('MAPI_PROFSECT', 0x00000009);    /* Profile Section */
28
-define('MAPI_STATUS', 0x0000000A);    /* Status Object */
29
-define('MAPI_SESSION', 0x0000000B);    /* Session */
30
-define('MAPI_FORMINFO', 0x0000000C);    /* Form Information */
19
+define('MAPI_STORE', 0x00000001); /* Message Store */
20
+define('MAPI_ADDRBOOK', 0x00000002); /* Address Book */
21
+define('MAPI_FOLDER', 0x00000003); /* Folder */
22
+define('MAPI_ABCONT', 0x00000004); /* Address Book Container */
23
+define('MAPI_MESSAGE', 0x00000005); /* Message */
24
+define('MAPI_MAILUSER', 0x00000006); /* Individual Recipient */
25
+define('MAPI_ATTACH', 0x00000007); /* Attachment */
26
+define('MAPI_DISTLIST', 0x00000008); /* Distribution List Recipient */
27
+define('MAPI_PROFSECT', 0x00000009); /* Profile Section */
28
+define('MAPI_STATUS', 0x0000000A); /* Status Object */
29
+define('MAPI_SESSION', 0x0000000B); /* Session */
30
+define('MAPI_FORMINFO', 0x0000000C); /* Form Information */
31 31
 
32 32
 define('MV_FLAG', 0x1000);
33 33
 define('MV_INSTANCE', 0x2000);
34
-define('MVI_FLAG', MV_FLAG | MV_INSTANCE);
35
-
36
-define('PT_UNSPECIFIED', 0);    /* (Reserved for interface use) type doesn't matter to caller */
37
-define('PT_NULL', 1);    /* NULL property value */
38
-define('PT_I2', 2);    /* Signed 16-bit value */
39
-define('PT_LONG', 3);    /* Signed 32-bit value */
40
-define('PT_R4', 4);    /* 4-byte floating point */
41
-define('PT_DOUBLE', 5);    /* Floating point double */
42
-define('PT_CURRENCY', 6);    /* Signed 64-bit int (decimal w/    4 digits right of decimal pt) */
43
-define('PT_APPTIME', 7);    /* Application time */
44
-define('PT_ERROR', 10);    /* 32-bit error value */
45
-define('PT_BOOLEAN', 11);    /* 16-bit boolean (non-zero true) */
46
-define('PT_OBJECT', 13);    /* Embedded object in a property */
47
-define('PT_I8', 20);    /* 8-byte signed integer */
48
-define('PT_STRING8', 30);    /* Null terminated 8-bit character string */
49
-define('PT_UNICODE', 31);    /* Null terminated Unicode string */
50
-define('PT_SYSTIME', 64);    /* FILETIME 64-bit int w/ number of 100ns periods since Jan 1,1601 */
51
-define('PT_CLSID', 72);    /* OLE GUID */
52
-define('PT_BINARY', 258);   /* Uninterpreted (counted byte array) */
34
+define('MVI_FLAG', MV_FLAG|MV_INSTANCE);
35
+
36
+define('PT_UNSPECIFIED', 0); /* (Reserved for interface use) type doesn't matter to caller */
37
+define('PT_NULL', 1); /* NULL property value */
38
+define('PT_I2', 2); /* Signed 16-bit value */
39
+define('PT_LONG', 3); /* Signed 32-bit value */
40
+define('PT_R4', 4); /* 4-byte floating point */
41
+define('PT_DOUBLE', 5); /* Floating point double */
42
+define('PT_CURRENCY', 6); /* Signed 64-bit int (decimal w/    4 digits right of decimal pt) */
43
+define('PT_APPTIME', 7); /* Application time */
44
+define('PT_ERROR', 10); /* 32-bit error value */
45
+define('PT_BOOLEAN', 11); /* 16-bit boolean (non-zero true) */
46
+define('PT_OBJECT', 13); /* Embedded object in a property */
47
+define('PT_I8', 20); /* 8-byte signed integer */
48
+define('PT_STRING8', 30); /* Null terminated 8-bit character string */
49
+define('PT_UNICODE', 31); /* Null terminated Unicode string */
50
+define('PT_SYSTIME', 64); /* FILETIME 64-bit int w/ number of 100ns periods since Jan 1,1601 */
51
+define('PT_CLSID', 72); /* OLE GUID */
52
+define('PT_BINARY', 258); /* Uninterpreted (counted byte array) */
53 53
 /* Changes are likely to these numbers, and to their structures. */
54 54
 
55 55
 /* Alternate property type names for ease of use */
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 
62 62
 define('PT_TSTRING', PT_STRING8);
63 63
 
64
-define('PT_MV_I2', (MV_FLAG | PT_I2));
65
-define('PT_MV_LONG', (MV_FLAG | PT_LONG));
66
-define('PT_MV_R4', (MV_FLAG | PT_R4));
67
-define('PT_MV_DOUBLE', (MV_FLAG | PT_DOUBLE));
68
-define('PT_MV_CURRENCY', (MV_FLAG | PT_CURRENCY));
69
-define('PT_MV_APPTIME', (MV_FLAG | PT_APPTIME));
70
-define('PT_MV_SYSTIME', (MV_FLAG | PT_SYSTIME));
71
-define('PT_MV_STRING8', (MV_FLAG | PT_STRING8));
72
-define('PT_MV_BINARY', (MV_FLAG | PT_BINARY));
73
-define('PT_MV_UNICODE', (MV_FLAG | PT_UNICODE));
74
-define('PT_MV_CLSID', (MV_FLAG | PT_CLSID));
75
-define('PT_MV_I8', (MV_FLAG | PT_I8));
64
+define('PT_MV_I2', (MV_FLAG|PT_I2));
65
+define('PT_MV_LONG', (MV_FLAG|PT_LONG));
66
+define('PT_MV_R4', (MV_FLAG|PT_R4));
67
+define('PT_MV_DOUBLE', (MV_FLAG|PT_DOUBLE));
68
+define('PT_MV_CURRENCY', (MV_FLAG|PT_CURRENCY));
69
+define('PT_MV_APPTIME', (MV_FLAG|PT_APPTIME));
70
+define('PT_MV_SYSTIME', (MV_FLAG|PT_SYSTIME));
71
+define('PT_MV_STRING8', (MV_FLAG|PT_STRING8));
72
+define('PT_MV_BINARY', (MV_FLAG|PT_BINARY));
73
+define('PT_MV_UNICODE', (MV_FLAG|PT_UNICODE));
74
+define('PT_MV_CLSID', (MV_FLAG|PT_CLSID));
75
+define('PT_MV_I8', (MV_FLAG|PT_I8));
76 76
 
77 77
 define('PT_MV_TSTRING', PT_MV_STRING8);
78 78
 /* bit 0: set if descending, clear if ascending */
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 
191 191
 /* Values for PR_RESOURCE_TYPE, _METHODS, _FLAGS */
192 192
 
193
-define('MAPI_STORE_PROVIDER', 33);    /* Message Store */
194
-define('MAPI_AB', 34);    /* Address Book */
195
-define('MAPI_AB_PROVIDER', 35);    /* Address Book Provider */
196
-define('MAPI_TRANSPORT_PROVIDER', 36);    /* Transport Provider */
197
-define('MAPI_SPOOLER', 37);    /* Message Spooler */
198
-define('MAPI_PROFILE_PROVIDER', 38);    /* Profile Provider */
199
-define('MAPI_SUBSYSTEM', 39);    /* Overall Subsystem Status */
200
-define('MAPI_HOOK_PROVIDER', 40);    /* Spooler Hook */
193
+define('MAPI_STORE_PROVIDER', 33); /* Message Store */
194
+define('MAPI_AB', 34); /* Address Book */
195
+define('MAPI_AB_PROVIDER', 35); /* Address Book Provider */
196
+define('MAPI_TRANSPORT_PROVIDER', 36); /* Transport Provider */
197
+define('MAPI_SPOOLER', 37); /* Message Spooler */
198
+define('MAPI_PROFILE_PROVIDER', 38); /* Profile Provider */
199
+define('MAPI_SUBSYSTEM', 39); /* Overall Subsystem Status */
200
+define('MAPI_HOOK_PROVIDER', 40); /* Spooler Hook */
201 201
 define('STATUS_VALIDATE_STATE', 0x00000001);
202 202
 define('STATUS_SETTINGS_DIALOG', 0x00000002);
203 203
 define('STATUS_CHANGE_PASSWORD', 0x00000004);
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 define('MODRECIP_MODIFY', 0x00000004);
244 244
 define('MODRECIP_REMOVE', 0x00000008);
245 245
 
246
-define('MAPI_ORIG', 0);          /* Recipient is message originator */
247
-define('MAPI_TO', 1);          /* Recipient is a primary recipient */
248
-define('MAPI_CC', 2);          /* Recipient is a copy recipient */
249
-define('MAPI_BCC', 3);          /* Recipient is blind copy recipient */
246
+define('MAPI_ORIG', 0); /* Recipient is message originator */
247
+define('MAPI_TO', 1); /* Recipient is a primary recipient */
248
+define('MAPI_CC', 2); /* Recipient is a copy recipient */
249
+define('MAPI_BCC', 3); /* Recipient is blind copy recipient */
250 250
 
251 251
 /* IAttach Interface ------------------------------------------------------- */
252 252
 
@@ -438,28 +438,28 @@  discard block
 block discarded – undo
438 438
 define('BMR_NEZ', 0x00000001);
439 439
 
440 440
 /* array index values of restrictions -- same values are used in php-ext/main.cpp::PHPArraytoSRestriction() */
441
-define('VALUE', 0);        // propval
442
-define('RELOP', 1);        // compare method
443
-define('FUZZYLEVEL', 2);        // string search flags
444
-define('CB', 3);        // size restriction
445
-define('ULTYPE', 4);        // bit mask restriction type BMR_xxx
446
-define('ULMASK', 5);        // bitmask
447
-define('ULPROPTAG', 6);        // property
448
-define('ULPROPTAG1', 7);        // RES_COMPAREPROPS 1st property
449
-define('ULPROPTAG2', 8);        // RES_COMPAREPROPS 2nd property
450
-define('PROPS', 9);        // RES_COMMENT properties
451
-define('RESTRICTION', 10);        // RES_COMMENT and RES_SUBRESTRICTION restriction
441
+define('VALUE', 0); // propval
442
+define('RELOP', 1); // compare method
443
+define('FUZZYLEVEL', 2); // string search flags
444
+define('CB', 3); // size restriction
445
+define('ULTYPE', 4); // bit mask restriction type BMR_xxx
446
+define('ULMASK', 5); // bitmask
447
+define('ULPROPTAG', 6); // property
448
+define('ULPROPTAG1', 7); // RES_COMPAREPROPS 1st property
449
+define('ULPROPTAG2', 8); // RES_COMPAREPROPS 2nd property
450
+define('PROPS', 9); // RES_COMMENT properties
451
+define('RESTRICTION', 10); // RES_COMMENT and RES_SUBRESTRICTION restriction
452 452
 
453 453
 /* GUIDs for PR_MDB_PROVIDER */
454
-define("KOPANO_SERVICE_GUID", makeGuid("{3C253DCA-D227-443C-94FE-425FAB958C19}"));    // default store
455
-define("KOPANO_STORE_PUBLIC_GUID", makeGuid("{D47F4A09-D3BD-493C-B2FC-3C90BBCB48D4}"));    // public store
456
-define("KOPANO_STORE_DELEGATE_GUID", makeGuid("{7C7C1085-BC6D-4E53-9DAB-8A53F8DEF808}"));    // other store
457
-define("KOPANO_STORE_ARCHIVER_GUID", makeGuid("{BC8953AD-2E3F-4172-9404-896FF459870F}"));    // archive store
454
+define("KOPANO_SERVICE_GUID", makeGuid("{3C253DCA-D227-443C-94FE-425FAB958C19}")); // default store
455
+define("KOPANO_STORE_PUBLIC_GUID", makeGuid("{D47F4A09-D3BD-493C-B2FC-3C90BBCB48D4}")); // public store
456
+define("KOPANO_STORE_DELEGATE_GUID", makeGuid("{7C7C1085-BC6D-4E53-9DAB-8A53F8DEF808}")); // other store
457
+define("KOPANO_STORE_ARCHIVER_GUID", makeGuid("{BC8953AD-2E3F-4172-9404-896FF459870F}")); // archive store
458 458
 /* webapp depends on these yet */
459
-define("ZARAFA_SERVICE_GUID", makeGuid("{3C253DCA-D227-443C-94FE-425FAB958C19}"));    // default store
460
-define("ZARAFA_STORE_PUBLIC_GUID", makeGuid("{D47F4A09-D3BD-493C-B2FC-3C90BBCB48D4}"));    // public store
461
-define("ZARAFA_STORE_DELEGATE_GUID", makeGuid("{7C7C1085-BC6D-4E53-9DAB-8A53F8DEF808}"));    // other store
462
-define('ZARAFA_STORE_ARCHIVER_GUID', makeGuid("{BC8953AD-2E3F-4172-9404-896FF459870F}"));    // archive store
459
+define("ZARAFA_SERVICE_GUID", makeGuid("{3C253DCA-D227-443C-94FE-425FAB958C19}")); // default store
460
+define("ZARAFA_STORE_PUBLIC_GUID", makeGuid("{D47F4A09-D3BD-493C-B2FC-3C90BBCB48D4}")); // public store
461
+define("ZARAFA_STORE_DELEGATE_GUID", makeGuid("{7C7C1085-BC6D-4E53-9DAB-8A53F8DEF808}")); // other store
462
+define('ZARAFA_STORE_ARCHIVER_GUID', makeGuid("{BC8953AD-2E3F-4172-9404-896FF459870F}")); // archive store
463 463
 
464 464
 /* global profile section guid */
465 465
 define('pbGlobalProfileSectionGuid', makeGuid("{C8B0DB13-05AA-1A10-9BB0-00AA002FC45A}"));
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 // define('ecrightsContact'                       ,0x00000200);
488 488
 define('ecRightsFolderVisible', 0x00000400);
489 489
 
490
-define('ecRightsAll', ecRightsReadAny | ecRightsCreate | ecRightsEditOwned | ecRightsDeleteOwned | ecRightsEditAny | ecRightsDeleteAny | ecRightsCreateSubfolder | ecRightsFolderAccess | ecRightsFolderVisible);
491
-define('ecRightsFullControl', ecRightsReadAny | ecRightsCreate | ecRightsEditOwned | ecRightsDeleteOwned | ecRightsEditAny | ecRightsDeleteAny | ecRightsCreateSubfolder | ecRightsFolderVisible);
492
-define('ecRightsDefault', ecRightsNone | ecRightsFolderVisible);
493
-define('ecRightsDefaultPublic', ecRightsReadAny | ecRightsFolderVisible);
490
+define('ecRightsAll', ecRightsReadAny|ecRightsCreate|ecRightsEditOwned|ecRightsDeleteOwned|ecRightsEditAny|ecRightsDeleteAny|ecRightsCreateSubfolder|ecRightsFolderAccess|ecRightsFolderVisible);
491
+define('ecRightsFullControl', ecRightsReadAny|ecRightsCreate|ecRightsEditOwned|ecRightsDeleteOwned|ecRightsEditAny|ecRightsDeleteAny|ecRightsCreateSubfolder|ecRightsFolderVisible);
492
+define('ecRightsDefault', ecRightsNone|ecRightsFolderVisible);
493
+define('ecRightsDefaultPublic', ecRightsReadAny|ecRightsFolderVisible);
494 494
 define('ecRightsAdmin', 0x00001000);
495 495
 define('ecRightsAllMask', 0x000015FB);
496 496
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 define('ROW_ADD', 0x0001);
507 507
 define('ROW_MODIFY', 0x0002);
508 508
 define('ROW_REMOVE', 0x0004);
509
-define('ROW_EMPTY', (ROW_ADD | ROW_REMOVE));
509
+define('ROW_EMPTY', (ROW_ADD|ROW_REMOVE));
510 510
 
511 511
 // new property types
512 512
 define('PT_SRESTRICTION', 0x00FD);
@@ -576,11 +576,11 @@  discard block
 block discarded – undo
576 576
 define('SYNC_NO_FOREIGN_KEYS', 0x100);
577 577
 define('SYNC_LIMITED_IMESSAGE', 0x200);
578 578
 define('SYNC_CATCHUP', 0x400);
579
-define('SYNC_NEW_MESSAGE', 0x800);   // only applicable to ImportMessageChange()
580
-define('SYNC_MSG_SELECTIVE', 0x1000);  // Used internally.      Will reject if used by clients.
579
+define('SYNC_NEW_MESSAGE', 0x800); // only applicable to ImportMessageChange()
580
+define('SYNC_MSG_SELECTIVE', 0x1000); // Used internally.      Will reject if used by clients.
581 581
 define('SYNC_BEST_BODY', 0x2000);
582 582
 define('SYNC_IGNORE_SPECIFIED_ON_ASSOCIATED', 0x4000);
583
-define('SYNC_PROGRESS_MODE', 0x8000);  // AirMapi progress mode
583
+define('SYNC_PROGRESS_MODE', 0x8000); // AirMapi progress mode
584 584
 define('SYNC_FXRECOVERMODE', 0x10000);
585 585
 define('SYNC_DEFER_CONFIG', 0x20000);
586 586
 define('SYNC_FORCE_UNICODE', 0x40000); // Forces server to return Unicode properties
@@ -591,23 +591,23 @@  discard block
 block discarded – undo
591 591
 define('TBL_BATCH', 0x00000002); // Batch multiple table commands
592 592
 
593 593
 /* Flags for recipients in exceptions */
594
-define('recipSendable', 0x00000001);	// sendable attendee.
595
-define('recipOrganizer', 0x00000002);	// meeting organizer
596
-define('recipExceptionalResponse', 0x00000010);	// attendee gave a response for the exception
597
-define('recipExceptionalDeleted', 0x00000020);	// recipientRow exists, but it is treated as if the corresponding recipient is deleted from meeting
598
-define('recipOriginal', 0x00000100);	// recipient is an original Attendee
594
+define('recipSendable', 0x00000001); // sendable attendee.
595
+define('recipOrganizer', 0x00000002); // meeting organizer
596
+define('recipExceptionalResponse', 0x00000010); // attendee gave a response for the exception
597
+define('recipExceptionalDeleted', 0x00000020); // recipientRow exists, but it is treated as if the corresponding recipient is deleted from meeting
598
+define('recipOriginal', 0x00000100); // recipient is an original Attendee
599 599
 define('recipReserved', 0x00000200);
600 600
 
601 601
 /* Flags which indicates type of Meeting Object */
602
-define('mtgEmpty', 0x00000000);	// Unspecified.
603
-define('mtgRequest', 0x00000001);	// Initial meeting request.
604
-define('mtgFull', 0x00010000);	// Full update.
605
-define('mtgInfo', 0x00020000);	// Informational update.
606
-define('mtgOutOfDate', 0x00080000);	// A newer Meeting Request object or Meeting Update object was received after this one.
607
-define('mtgDelegatorCopy', 0x00100000);	// This is set on the delegator's copy when a delegate will handle meeting-related objects.
608
-
609
-define('MAPI_ONE_OFF_UNICODE', 0x8000);		// the flag that defines whether the embedded strings are Unicode in one off entryids.
610
-define('MAPI_ONE_OFF_NO_RICH_INFO', 0x0001);		// the flag that specifies whether the recipient gets TNEF or not.
602
+define('mtgEmpty', 0x00000000); // Unspecified.
603
+define('mtgRequest', 0x00000001); // Initial meeting request.
604
+define('mtgFull', 0x00010000); // Full update.
605
+define('mtgInfo', 0x00020000); // Informational update.
606
+define('mtgOutOfDate', 0x00080000); // A newer Meeting Request object or Meeting Update object was received after this one.
607
+define('mtgDelegatorCopy', 0x00100000); // This is set on the delegator's copy when a delegate will handle meeting-related objects.
608
+
609
+define('MAPI_ONE_OFF_UNICODE', 0x8000); // the flag that defines whether the embedded strings are Unicode in one off entryids.
610
+define('MAPI_ONE_OFF_NO_RICH_INFO', 0x0001); // the flag that specifies whether the recipient gets TNEF or not.
611 611
 
612 612
 /* Mask flags for mapi_msgstore_advise */
613 613
 define('fnevCriticalError', 0x00000001);
Please login to merge, or discard this patch.
mapi/class.mapiexception.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,37 +25,37 @@
 block discarded – undo
25 25
 			}
26 26
 
27 27
 			switch ($this->getCode()) {
28
-			case MAPI_E_NO_ACCESS:
29
-				return dgettext("kopano", "You have insufficient privileges to open this object.");
28
+				case MAPI_E_NO_ACCESS:
29
+					return dgettext("kopano", "You have insufficient privileges to open this object.");
30 30
 
31
-			case MAPI_E_LOGON_FAILED:
32
-			case MAPI_E_UNCONFIGURED:
33
-				return dgettext("kopano", "Logon Failed. Please check your username/password.");
31
+				case MAPI_E_LOGON_FAILED:
32
+				case MAPI_E_UNCONFIGURED:
33
+					return dgettext("kopano", "Logon Failed. Please check your username/password.");
34 34
 
35
-			case MAPI_E_NETWORK_ERROR:
36
-				return dgettext("kopano", "Can not connect to Kopano server.");
35
+				case MAPI_E_NETWORK_ERROR:
36
+					return dgettext("kopano", "Can not connect to Kopano server.");
37 37
 
38
-			case MAPI_E_UNKNOWN_ENTRYID:
39
-				return dgettext("kopano", "Can not open object with provided id.");
38
+				case MAPI_E_UNKNOWN_ENTRYID:
39
+					return dgettext("kopano", "Can not open object with provided id.");
40 40
 
41
-			case MAPI_E_NO_RECIPIENTS:
42
-				return dgettext("kopano", "There are no recipients in the message.");
41
+				case MAPI_E_NO_RECIPIENTS:
42
+					return dgettext("kopano", "There are no recipients in the message.");
43 43
 
44
-			case MAPI_E_NOT_FOUND:
45
-				return dgettext("kopano", "Can not find object.");
44
+				case MAPI_E_NOT_FOUND:
45
+					return dgettext("kopano", "Can not find object.");
46 46
 
47
-			case MAPI_E_INTERFACE_NOT_SUPPORTED:
48
-			case MAPI_E_INVALID_PARAMETER:
49
-			case MAPI_E_INVALID_ENTRYID:
50
-			case MAPI_E_INVALID_OBJECT:
51
-			case MAPI_E_TOO_COMPLEX:
52
-			case MAPI_E_CORRUPT_DATA:
53
-			case MAPI_E_END_OF_SESSION:
54
-			case MAPI_E_AMBIGUOUS_RECIP:
55
-			case MAPI_E_COLLISION:
56
-			case MAPI_E_UNCONFIGURED:
57
-			default:
58
-				return sprintf(dgettext("kopano", "Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode()));
47
+				case MAPI_E_INTERFACE_NOT_SUPPORTED:
48
+				case MAPI_E_INVALID_PARAMETER:
49
+				case MAPI_E_INVALID_ENTRYID:
50
+				case MAPI_E_INVALID_OBJECT:
51
+				case MAPI_E_TOO_COMPLEX:
52
+				case MAPI_E_CORRUPT_DATA:
53
+				case MAPI_E_END_OF_SESSION:
54
+				case MAPI_E_AMBIGUOUS_RECIP:
55
+				case MAPI_E_COLLISION:
56
+				case MAPI_E_UNCONFIGURED:
57
+				default:
58
+					return sprintf(dgettext("kopano", "Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode()));
59 59
 			}
60 60
 		}
61 61
 	}
Please login to merge, or discard this patch.
mapi/class.taskrequest.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 	* It is used to indicate the type of change that is being carried in the IPM.TaskRequest item (although this
23 23
 	* information seems redundant due to that information already being available in PR_MESSAGE_CLASS).
24 24
 	*/
25
-	define('tdmtNothing', 0);			// Value in IPM.Task items
26
-	define('tdmtTaskReq', 1);			// Assigner -> Assignee
27
-	define('tdmtTaskAcc', 2);			// Assignee -> Assigner
28
-	define('tdmtTaskDec', 3);			// Assignee -> Assigner
29
-	define('tdmtTaskUpd', 4);			// Assignee -> Assigner
30
-	define('tdmtTaskSELF', 5);			// Assigner -> Assigner (?)
25
+	define('tdmtNothing', 0); // Value in IPM.Task items
26
+	define('tdmtTaskReq', 1); // Assigner -> Assignee
27
+	define('tdmtTaskAcc', 2); // Assignee -> Assigner
28
+	define('tdmtTaskDec', 3); // Assignee -> Assigner
29
+	define('tdmtTaskUpd', 4); // Assignee -> Assigner
30
+	define('tdmtTaskSELF', 5); // Assigner -> Assigner (?)
31 31
 
32 32
 	/* The TaskHistory is used to show the last action on the task on both the assigner and the assignee's side.
33 33
 	*
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
 	* at the top of the task request in the format 'Accepted by <user> on 01-01-2010 11:00'.
36 36
 	*/
37 37
 	define('thNone', 0);
38
-	define('thAccepted', 1);			// Set by assignee
39
-	define('thDeclined', 2);			// Set by assignee
40
-	define('thUpdated', 3);				// Set by assignee
38
+	define('thAccepted', 1); // Set by assignee
39
+	define('thDeclined', 2); // Set by assignee
40
+	define('thUpdated', 3); // Set by assignee
41 41
 	define('thDueDateChanged', 4);
42
-	define('thAssigned', 5);			// Set by assigner
42
+	define('thAssigned', 5); // Set by assigner
43 43
 
44 44
 	/* The TaskState value is used to differentiate the version of a task in the assigner's folder and the version in the
45 45
 	* assignee's folder. The buttons shown depend on this and the 'taskaccepted' boolean (for the assignee)
46 46
 	*/
47
-	define('tdsNOM', 0);		// Got a response to a deleted task, and re-created the task for the assigner
48
-	define('tdsOWNNEW', 1);		// Not assigned
49
-	define('tdsOWN', 2);		// Assignee version
50
-	define('tdsACC', 3);		// Assigner version
51
-	define('tdsDEC', 4);		// Assigner version, but assignee declined
47
+	define('tdsNOM', 0); // Got a response to a deleted task, and re-created the task for the assigner
48
+	define('tdsOWNNEW', 1); // Not assigned
49
+	define('tdsOWN', 2); // Assignee version
50
+	define('tdsACC', 3); // Assigner version
51
+	define('tdsDEC', 4); // Assigner version, but assignee declined
52 52
 
53 53
 	/* The delegationstate is used for the assigner to indicate state
54 54
 	*/
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	/* The task ownership indicates the role of the current user relative to the task.
61 61
 	*/
62 62
 	define('olNewTask', 0);
63
-	define('olDelegatedTask', 1);	// Task has been assigned
64
-	define('olOwnTask', 2);			// Task owned
63
+	define('olDelegatedTask', 1); // Task has been assigned
64
+	define('olOwnTask', 2); // Task owned
65 65
 
66 66
 	/* taskmultrecips indicates whether the task request sent or received has multiple assignees or not.
67 67
 	*/
68 68
 	define('tmrNone', 0);
69
-	define('tmrSent', 1);		// Task has been sent to multiple assignee
70
-	define('tmrReceived', 2);	// Task Request received has multiple assignee
69
+	define('tmrSent', 1); // Task has been sent to multiple assignee
70
+	define('tmrReceived', 2); // Task Request received has multiple assignee
71 71
 
72 72
 	class TaskRequest {
73 73
 		// All recipient properties
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 			// Set properties on Task Request
266 266
 			mapi_setprops($this->message, [
267 267
 				$this->props['taskglobalobjid'] => $taskid, /* our new taskglobalobjid */
268
-				$this->props['taskstate'] => tdsACC, 		/* state for our outgoing request */
269
-				$this->props['taskmode'] => tdmtNothing, 	/* we're not sending a change */
270
-				$this->props['updatecount'] => 2,			/* version 2 (no idea) */
268
+				$this->props['taskstate'] => tdsACC, /* state for our outgoing request */
269
+				$this->props['taskmode'] => tdmtNothing, /* we're not sending a change */
270
+				$this->props['updatecount'] => 2, /* version 2 (no idea) */
271 271
 				$this->props['delegationstate'] => olTaskDelegationUnknown, /* no reply yet */
272 272
 				$this->props['ownership'] => olDelegatedTask, /* Task has been assigned */
273
-				$this->props['taskhistory'] => thAssigned,	/* Task has been assigned */
274
-				PR_ICON_INDEX => 1283,						/* Task request icon */
273
+				$this->props['taskhistory'] => thAssigned, /* Task has been assigned */
274
+				PR_ICON_INDEX => 1283, /* Task request icon */
275 275
 			]);
276 276
 			$this->setLastUser();
277 277
 			$this->setOwnerForAssignor();
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
 
285 285
 			// Make it a task request, and put it in sent items after it is sent
286 286
 			mapi_setprops($outgoing, [
287
-				PR_MESSAGE_CLASS => "IPM.TaskRequest", 		/* class is task request */
288
-				$this->props['taskstate'] => tdsOWNNEW, 	/* for the recipient the task is new */
289
-				$this->props['taskmode'] => tdmtTaskReq,	/* for the recipient, it is a request */
290
-				$this->props['updatecount'] => 1,			/* version 2 is in the attachment */
287
+				PR_MESSAGE_CLASS => "IPM.TaskRequest", /* class is task request */
288
+				$this->props['taskstate'] => tdsOWNNEW, /* for the recipient the task is new */
289
+				$this->props['taskmode'] => tdmtTaskReq, /* for the recipient, it is a request */
290
+				$this->props['updatecount'] => 1, /* version 2 is in the attachment */
291 291
 				PR_SUBJECT => $prefix . $messageprops[PR_SUBJECT],
292
-				PR_ICON_INDEX => 0xFFFFFFFF,				/* show assigned icon */
292
+				PR_ICON_INDEX => 0xFFFFFFFF, /* show assigned icon */
293 293
 			]);
294 294
 
295 295
 			// Set Body
296 296
 			$body = $this->getBody();
297
-			$stream = mapi_openproperty($outgoing, PR_BODY, IID_IStream, 0, MAPI_CREATE | MAPI_MODIFY);
297
+			$stream = mapi_openproperty($outgoing, PR_BODY, IID_IStream, 0, MAPI_CREATE|MAPI_MODIFY);
298 298
 			mapi_stream_setsize($stream, strlen($body));
299 299
 			mapi_stream_write($stream, $body);
300 300
 			mapi_stream_commit($stream);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			$attach = mapi_message_createattach($outgoing);
303 303
 			mapi_setprops($attach, [PR_ATTACH_METHOD => ATTACH_EMBEDDED_MSG, PR_DISPLAY_NAME => $messageprops[PR_SUBJECT]]);
304 304
 
305
-			$sub = mapi_attach_openproperty($attach, PR_ATTACH_DATA_OBJ, IID_IMessage, 0, MAPI_MODIFY | MAPI_CREATE);
305
+			$sub = mapi_attach_openproperty($attach, PR_ATTACH_DATA_OBJ, IID_IMessage, 0, MAPI_MODIFY|MAPI_CREATE);
306 306
 
307 307
 			mapi_copyto($this->message, [], [], $sub);
308 308
 			mapi_savechanges($sub);
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$this->updateTaskRequest();
405 405
 
406 406
 			// Set as accepted
407
-			mapi_setprops($this->message, [$this->props['taskhistory'] => thAccepted, $this->props['assignedtime'] => time(), $this->props['taskaccepted'] => true,  $this->props['delegationstate'] => olTaskNotDelegated]);
407
+			mapi_setprops($this->message, [$this->props['taskhistory'] => thAccepted, $this->props['assignedtime'] => time(), $this->props['taskaccepted'] => true, $this->props['delegationstate'] => olTaskNotDelegated]);
408 408
 
409 409
 			mapi_savechanges($this->message);
410 410
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 			$this->updateTaskRequest();
434 434
 
435 435
 			// Set as declined
436
-			mapi_setprops($this->message, [$this->props['taskhistory'] => thDeclined,  $this->props['delegationstate'] => olTaskDelegationDeclined]);
436
+			mapi_setprops($this->message, [$this->props['taskhistory'] => thDeclined, $this->props['delegationstate'] => olTaskDelegationDeclined]);
437 437
 
438 438
 			mapi_savechanges($this->message);
439 439
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 				$this->setRecipientsForResponse($outgoing, tdmtTaskUpd, true);
477 477
 				$body = $this->getBody();
478
-				$stream = mapi_openproperty($outgoing, PR_BODY, IID_IStream, 0, MAPI_CREATE | MAPI_MODIFY);
478
+				$stream = mapi_openproperty($outgoing, PR_BODY, IID_IStream, 0, MAPI_CREATE|MAPI_MODIFY);
479 479
 				mapi_stream_setsize($stream, strlen($body));
480 480
 				mapi_stream_write($stream, $body);
481 481
 				mapi_stream_commit($stream);
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 
601 601
 			$attach = mapi_message_createattach($outgoing);
602 602
 			mapi_setprops($attach, [PR_ATTACH_METHOD => ATTACH_EMBEDDED_MSG, PR_DISPLAY_NAME => $messageprops[PR_SUBJECT], PR_ATTACHMENT_HIDDEN => true]);
603
-			$sub = mapi_attach_openproperty($attach, PR_ATTACH_DATA_OBJ, IID_IMessage, 0, MAPI_CREATE | MAPI_MODIFY);
603
+			$sub = mapi_attach_openproperty($attach, PR_ATTACH_DATA_OBJ, IID_IMessage, 0, MAPI_CREATE|MAPI_MODIFY);
604 604
 
605 605
 			mapi_copyto($this->message, [], [PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS, PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_ENTRYID, PR_SENT_REPRESENTING_SEARCH_KEY], $outgoing);
606 606
 			mapi_copyto($this->message, [], [], $sub);
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 
629 629
 			// Set Body
630 630
 			$body = $this->getBody();
631
-			$stream = mapi_openproperty($outgoing, PR_BODY, IID_IStream, 0, MAPI_CREATE | MAPI_MODIFY);
631
+			$stream = mapi_openproperty($outgoing, PR_BODY, IID_IStream, 0, MAPI_CREATE|MAPI_MODIFY);
632 632
 			mapi_stream_setsize($stream, strlen($body));
633 633
 			mapi_stream_write($stream, $body);
634 634
 			mapi_stream_commit($stream);
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 				}
868 868
 
869 869
 				foreach ($recips as $recip) {
870
-					$recip[PR_RECIPIENT_TYPE] = MAPI_TO;	// Change recipient type to MAPI_TO
870
+					$recip[PR_RECIPIENT_TYPE] = MAPI_TO; // Change recipient type to MAPI_TO
871 871
 					mapi_message_modifyrecipients($outgoing, MODRECIP_ADD, [$recip]);
872 872
 				}
873 873
 
Please login to merge, or discard this patch.
mapi/class.baserecurrence.php 2 patches
Switch Indentation   +618 added lines, -618 removed lines patch added patch discarded remove patch
@@ -156,94 +156,94 @@  discard block
 block discarded – undo
156 156
 			$rdata = substr($rdata, 10);
157 157
 
158 158
 			switch ($data["rtype"]) {
159
-			case 0x0A:
160
-				// Daily
161
-				if (strlen($rdata) < 12) {
162
-					return $ret;
163
-				}
164
-				$data = unpack("Vunknown/Veveryn/Vregen", $rdata);
165
-				$ret["everyn"] = $data["everyn"];
166
-				$ret["regen"] = $data["regen"];
159
+				case 0x0A:
160
+					// Daily
161
+					if (strlen($rdata) < 12) {
162
+						return $ret;
163
+					}
164
+					$data = unpack("Vunknown/Veveryn/Vregen", $rdata);
165
+					$ret["everyn"] = $data["everyn"];
166
+					$ret["regen"] = $data["regen"];
167 167
 
168
-				switch ($ret["subtype"]) {
169
-				case 0:
170
-					$rdata = substr($rdata, 12);
171
-					break;
168
+					switch ($ret["subtype"]) {
169
+						case 0:
170
+							$rdata = substr($rdata, 12);
171
+							break;
172 172
 
173
-				case 1:
174
-					$rdata = substr($rdata, 16);
175
-					break;
176
-				}
173
+						case 1:
174
+							$rdata = substr($rdata, 16);
175
+							break;
176
+					}
177 177
 				break;
178 178
 
179
-			case 0x0B:
180
-				// Weekly
181
-				if (strlen($rdata) < 16) {
182
-					return $ret;
183
-				}
179
+				case 0x0B:
180
+					// Weekly
181
+					if (strlen($rdata) < 16) {
182
+						return $ret;
183
+					}
184 184
 
185
-				$data = unpack("Vconst1/Veveryn/Vregen", $rdata);
186
-				$rdata = substr($rdata, 12);
185
+					$data = unpack("Vconst1/Veveryn/Vregen", $rdata);
186
+					$rdata = substr($rdata, 12);
187 187
 
188
-				$ret["everyn"] = $data["everyn"];
189
-				$ret["regen"] = $data["regen"];
190
-				$ret["weekdays"] = 0;
188
+					$ret["everyn"] = $data["everyn"];
189
+					$ret["regen"] = $data["regen"];
190
+					$ret["weekdays"] = 0;
191 191
 
192
-				if ($data["regen"] == 0) {
193
-					$data = unpack("Vweekdays", $rdata);
194
-					$rdata = substr($rdata, 4);
195
-					$ret["weekdays"] = $data["weekdays"];
196
-				}
197
-				break;
192
+					if ($data["regen"] == 0) {
193
+						$data = unpack("Vweekdays", $rdata);
194
+						$rdata = substr($rdata, 4);
195
+						$ret["weekdays"] = $data["weekdays"];
196
+					}
197
+					break;
198 198
 
199
-			case 0x0C:
200
-				// Monthly
201
-				if (strlen($rdata) < 16) {
202
-					return $ret;
203
-				}
199
+				case 0x0C:
200
+					// Monthly
201
+					if (strlen($rdata) < 16) {
202
+						return $ret;
203
+					}
204 204
 
205
-				$data = unpack("Vconst1/Veveryn/Vregen/Vmonthday", $rdata);
206
-				$ret["everyn"] = $data["everyn"];
207
-				$ret["regen"] = $data["regen"];
208
-				if ($ret["subtype"] == 3) {
209
-					$ret["weekdays"] = $data["monthday"];
210
-				}
211
-				else {
212
-					$ret["monthday"] = $data["monthday"];
213
-				}
205
+					$data = unpack("Vconst1/Veveryn/Vregen/Vmonthday", $rdata);
206
+					$ret["everyn"] = $data["everyn"];
207
+					$ret["regen"] = $data["regen"];
208
+					if ($ret["subtype"] == 3) {
209
+						$ret["weekdays"] = $data["monthday"];
210
+					}
211
+					else {
212
+						$ret["monthday"] = $data["monthday"];
213
+					}
214 214
 
215
-				$rdata = substr($rdata, 16);
216
-				if ($ret["subtype"] == 3) {
217
-					$data = unpack("Vnday", $rdata);
218
-					$ret["nday"] = $data["nday"];
219
-					$rdata = substr($rdata, 4);
220
-				}
221
-				break;
215
+					$rdata = substr($rdata, 16);
216
+					if ($ret["subtype"] == 3) {
217
+						$data = unpack("Vnday", $rdata);
218
+						$ret["nday"] = $data["nday"];
219
+						$rdata = substr($rdata, 4);
220
+					}
221
+					break;
222 222
 
223
-			case 0x0D:
224
-				// Yearly
225
-				if (strlen($rdata) < 16) {
226
-					return $ret;
227
-				}
223
+				case 0x0D:
224
+					// Yearly
225
+					if (strlen($rdata) < 16) {
226
+						return $ret;
227
+					}
228 228
 
229
-				$data = unpack("Vmonth/Veveryn/Vregen/Vmonthday", $rdata);
230
-				$ret["month"] = $data["month"];
231
-				$ret["everyn"] = $data["everyn"];
232
-				$ret["regen"] = $data["regen"];
233
-				if ($ret["subtype"] == 3) {
234
-					$ret["weekdays"] = $data["monthday"];
235
-				}
236
-				else {
237
-					$ret["monthday"] = $data["monthday"];
238
-				}
229
+					$data = unpack("Vmonth/Veveryn/Vregen/Vmonthday", $rdata);
230
+					$ret["month"] = $data["month"];
231
+					$ret["everyn"] = $data["everyn"];
232
+					$ret["regen"] = $data["regen"];
233
+					if ($ret["subtype"] == 3) {
234
+						$ret["weekdays"] = $data["monthday"];
235
+					}
236
+					else {
237
+						$ret["monthday"] = $data["monthday"];
238
+					}
239 239
 
240
-				$rdata = substr($rdata, 16);
241
-				if ($ret["subtype"] == 3) {
242
-					$data = unpack("Vnday", $rdata);
243
-					$ret["nday"] = $data["nday"];
244
-					$rdata = substr($rdata, 4);
245
-				}
246
-				break;
240
+					$rdata = substr($rdata, 16);
241
+					if ($ret["subtype"] == 3) {
242
+						$data = unpack("Vnday", $rdata);
243
+						$ret["nday"] = $data["nday"];
244
+						$rdata = substr($rdata, 4);
245
+					}
246
+					break;
247 247
 			}
248 248
 
249 249
 			if (strlen($rdata) < 16) {
@@ -573,312 +573,312 @@  discard block
 block discarded – undo
573 573
 			$term = (int) $this->recur["type"];
574 574
 
575 575
 			switch ($term) {
576
-			case 0x0A:
577
-				// Daily
578
-				if (!isset($this->recur["everyn"])) {
579
-					return;
580
-				}
581
-
582
-				if ($this->recur["subtype"] == 1) {
583
-					// Daily every workday
584
-					$rdata .= pack("VVVV", (6 * 24 * 60), 1, 0, 0x3E);
585
-				}
586
-				else {
587
-					// Daily every N days (everyN in minutes)
588
-					$everyn = ((int) $this->recur["everyn"]) / 1440;
589
-					// Calc first occ
590
-					$firstocc = $this->unixDataToRecurData($this->recur["start"]) % ((int) $this->recur["everyn"]);
591
-					$rdata .= pack("VVV", $firstocc, (int) $this->recur["everyn"], $this->recur["regen"] ? 1 : 0);
592
-				}
593
-				break;
594
-
595
-			case 0x0B:
596
-				// Weekly
597
-				if (!isset($this->recur["everyn"])) {
598
-					return;
599
-				}
600
-				if (!$this->recur["regen"] && !isset($this->recur["weekdays"])) {
601
-					return;
602
-				}
603
-
604
-				// No need to calculate startdate if sliding flag was set.
605
-				if (!$this->recur['regen']) {
606
-					// Calculate start date of recurrence
607
-
608
-					// Find the first day that matches one of the weekdays selected
609
-					$daycount = 0;
610
-					$dayskip = -1;
611
-					for ($j = 0; $j < 7; ++$j) {
612
-						if (((int) $this->recur["weekdays"]) & (1 << (($dayofweek + $j) % 7))) {
613
-							if ($dayskip == -1) {
614
-								$dayskip = $j;
615
-							}
616
-							++$daycount;
617
-						}
576
+				case 0x0A:
577
+					// Daily
578
+					if (!isset($this->recur["everyn"])) {
579
+						return;
618 580
 					}
619 581
 
620
-					// $dayskip is the number of days to skip from the startdate until the first occurrence
621
-					// $daycount is the number of days per week that an occurrence occurs
622
-					$weekskip = 0;
623
-					if (($dayofweek < $weekstart && $dayskip > 0) || ($dayofweek + $dayskip) > 6) {
624
-						$weekskip = 1;
582
+					if ($this->recur["subtype"] == 1) {
583
+						// Daily every workday
584
+						$rdata .= pack("VVVV", (6 * 24 * 60), 1, 0, 0x3E);
625 585
 					}
626
-
627
-					// Check if the recurrence ends after a number of occurrences, in that case we must calculate the
628
-					// remaining occurrences based on the start of the recurrence.
629
-					if (((int) $this->recur["term"]) == 0x22) {
630
-						// $weekskip is the amount of weeks to skip from the startdate before the first occurrence
631
-						// $forwardcount is the maximum number of week occurrences we can go ahead after the first occurrence that
632
-						// is still inside the recurrence. We subtract one to make sure that the last week is never forwarded over
633
-						// (eg when numoccur = 2, and daycount = 1)
634
-						$forwardcount = floor((int) ($this->recur["numoccur"] - 1) / $daycount);
635
-
636
-						// $restocc is the number of occurrences left after $forwardcount whole weeks of occurrences, minus one
637
-						// for the occurrence on the first day
638
-						$restocc = ((int) $this->recur["numoccur"]) - ($forwardcount * $daycount) - 1;
639
-
640
-						// $forwardcount is now the number of weeks we can go forward and still be inside the recurrence
641
-						$forwardcount *= (int) $this->recur["everyn"];
586
+					else {
587
+						// Daily every N days (everyN in minutes)
588
+						$everyn = ((int) $this->recur["everyn"]) / 1440;
589
+						// Calc first occ
590
+						$firstocc = $this->unixDataToRecurData($this->recur["start"]) % ((int) $this->recur["everyn"]);
591
+						$rdata .= pack("VVV", $firstocc, (int) $this->recur["everyn"], $this->recur["regen"] ? 1 : 0);
642 592
 					}
593
+					break;
643 594
 
644
-					// The real start is start + dayskip + weekskip-1 (since dayskip will already bring us into the next week)
645
-					$this->recur["start"] = ((int) $this->recur["start"]) + ($dayskip * 24 * 60 * 60) + ($weekskip * (((int) $this->recur["everyn"]) - 1) * 7 * 24 * 60 * 60);
646
-				}
647
-
648
-				// Calc first occ
649
-				$firstocc = ($this->unixDataToRecurData($this->recur["start"])) % (((int) $this->recur["everyn"]) * 7 * 24 * 60);
650
-				$firstocc -= (((int) gmdate("w", (int) $this->recur["start"])) - 1) * 24 * 60;
651
-
652
-				if ($this->recur["regen"]) {
653
-					$rdata .= pack("VVV", $firstocc, (int) $this->recur["everyn"], 1);
654
-				}
655
-				else {
656
-					$rdata .= pack("VVVV", $firstocc, (int) $this->recur["everyn"], 0, (int) $this->recur["weekdays"]);
657
-				}
658
-				break;
659
-
660
-			case 0x0C:
661
-				// Monthly
662
-			case 0x0D:
663
-				// Yearly
664
-				if (!isset($this->recur["everyn"])) {
665
-					return;
666
-				}
667
-				if ($term == 0x0D /* yearly */ && !isset($this->recur["month"])) {
668
-					return;
669
-				}
670
-				if ($term == 0x0C /* monthly */) {
671
-					$everyn = (int) $this->recur["everyn"];
672
-				}
673
-				else {
674
-					$everyn = $this->recur["regen"] ? ((int) $this->recur["everyn"]) * 12 : 12;
675
-				}
676
-
677
-				// Get montday/month/year of original start
678
-				$curmonthday = gmdate("j", (int) $this->recur["start"]);
679
-				$curyear = gmdate("Y", (int) $this->recur["start"]);
680
-				$curmonth = gmdate("n", (int) $this->recur["start"]);
681
-
682
-				// Check if the recurrence ends after a number of occurrences, in that case we must calculate the
683
-				// remaining occurrences based on the start of the recurrence.
684
-				if (((int) $this->recur["term"]) == 0x22) {
685
-					// $forwardcount is the number of occurrences we can skip and still be inside the recurrence range (minus
686
-					// one to make sure there are always at least one occurrence left)
687
-					$forwardcount = ((((int) $this->recur["numoccur"]) - 1) * $everyn);
688
-				}
689
-
690
-				// Get month for yearly on D'th day of month M
691
-				if ($term == 0x0D /* yearly */) {
692
-					$selmonth = floor(((int) $this->recur["month"]) / (24 * 60 * 29)) + 1;
693
-				} // 1=jan, 2=feb, eg
694
-
695
-				switch ((int) $this->recur["subtype"]) {
696
-				// on D day of every M month
697
-				case 2:
698
-					if (!isset($this->recur["monthday"])) {
595
+				case 0x0B:
596
+					// Weekly
597
+					if (!isset($this->recur["everyn"])) {
598
+						return;
599
+					}
600
+					if (!$this->recur["regen"] && !isset($this->recur["weekdays"])) {
699 601
 						return;
700 602
 					}
701
-					// Recalc startdate
702
-					// Set on the right begin day
703
-					// Go the beginning of the month
704
-					$this->recur["start"] -= ($curmonthday - 1) * 24 * 60 * 60;
705
-					// Go the the correct month day
706
-					$this->recur["start"] += (((int) $this->recur["monthday"]) - 1) * 24 * 60 * 60;
707
-
708
-					// If the previous calculation gave us a start date *before* the original start date, then we need to skip to the next occurrence
709
-					if (($term == 0x0C /* monthly */ && ((int) $this->recur["monthday"]) < $curmonthday) ||
710
-						($term == 0x0D /* yearly */ && ($selmonth < $curmonth || ($selmonth == $curmonth && ((int) $this->recur["monthday"]) < $curmonthday)))) {
711
-						if ($term == 0x0D /* yearly */) {
712
-							$count = ($everyn - ($curmonth - $selmonth));
713
-						} // Yearly, go to next occurrence in 'everyn' months minus difference in first occurrence and original date
714
-						else {
715
-							$count = $everyn;
716
-						} // Monthly, go to next occurrence in 'everyn' months
717
-
718
-						// Forward by $count months. This is done by getting the number of days in that month and forwarding that many days
719
-						for ($i = 0; $i < $count; ++$i) {
720
-							$this->recur["start"] += $this->getMonthInSeconds($curyear, $curmonth);
721
-							if ($curmonth == 12) {
722
-								++$curyear;
723
-								$curmonth = 0;
603
+
604
+					// No need to calculate startdate if sliding flag was set.
605
+					if (!$this->recur['regen']) {
606
+						// Calculate start date of recurrence
607
+
608
+						// Find the first day that matches one of the weekdays selected
609
+						$daycount = 0;
610
+						$dayskip = -1;
611
+						for ($j = 0; $j < 7; ++$j) {
612
+							if (((int) $this->recur["weekdays"]) & (1 << (($dayofweek + $j) % 7))) {
613
+								if ($dayskip == -1) {
614
+									$dayskip = $j;
615
+								}
616
+								++$daycount;
724 617
 							}
725
-							++$curmonth;
726 618
 						}
727
-					}
728 619
 
729
-					// "start" is now pointing to the first occurrence, except that it will overshoot if the
730
-					// month in which it occurs has less days than specified as the day of the month. So 31st
731
-					// of each month will overshoot in february (29 days). We compensate for that by checking
732
-					// if the day of the month we got is wrong, and then back up to the last day of the previous
733
-					// month.
734
-					if (((int) $this->recur["monthday"]) >= 28 && ((int) $this->recur["monthday"]) <= 31 &&
735
-						gmdate("j", ((int) $this->recur["start"])) < ((int) $this->recur["monthday"])) {
736
-						$this->recur["start"] -= gmdate("j", ((int) $this->recur["start"])) * 24 * 60 * 60;
620
+						// $dayskip is the number of days to skip from the startdate until the first occurrence
621
+						// $daycount is the number of days per week that an occurrence occurs
622
+						$weekskip = 0;
623
+						if (($dayofweek < $weekstart && $dayskip > 0) || ($dayofweek + $dayskip) > 6) {
624
+							$weekskip = 1;
625
+						}
626
+
627
+						// Check if the recurrence ends after a number of occurrences, in that case we must calculate the
628
+						// remaining occurrences based on the start of the recurrence.
629
+						if (((int) $this->recur["term"]) == 0x22) {
630
+							// $weekskip is the amount of weeks to skip from the startdate before the first occurrence
631
+							// $forwardcount is the maximum number of week occurrences we can go ahead after the first occurrence that
632
+							// is still inside the recurrence. We subtract one to make sure that the last week is never forwarded over
633
+							// (eg when numoccur = 2, and daycount = 1)
634
+							$forwardcount = floor((int) ($this->recur["numoccur"] - 1) / $daycount);
635
+
636
+							// $restocc is the number of occurrences left after $forwardcount whole weeks of occurrences, minus one
637
+							// for the occurrence on the first day
638
+							$restocc = ((int) $this->recur["numoccur"]) - ($forwardcount * $daycount) - 1;
639
+
640
+							// $forwardcount is now the number of weeks we can go forward and still be inside the recurrence
641
+							$forwardcount *= (int) $this->recur["everyn"];
642
+						}
643
+
644
+						// The real start is start + dayskip + weekskip-1 (since dayskip will already bring us into the next week)
645
+						$this->recur["start"] = ((int) $this->recur["start"]) + ($dayskip * 24 * 60 * 60) + ($weekskip * (((int) $this->recur["everyn"]) - 1) * 7 * 24 * 60 * 60);
737 646
 					}
738 647
 
739
-					// "start" is now the first occurrence
740
-					if ($term == 0x0C /* monthly */) {
741
-						// Calc first occ
742
-						$monthIndex = ((((12 % $everyn) * ((((int) gmdate("Y", $this->recur["start"])) - 1601) % $everyn)) % $everyn) + (((int) gmdate("n", $this->recur["start"])) - 1)) % $everyn;
648
+					// Calc first occ
649
+					$firstocc = ($this->unixDataToRecurData($this->recur["start"])) % (((int) $this->recur["everyn"]) * 7 * 24 * 60);
650
+					$firstocc -= (((int) gmdate("w", (int) $this->recur["start"])) - 1) * 24 * 60;
743 651
 
744
-						$firstocc = 0;
745
-						for ($i = 0; $i < $monthIndex; ++$i) {
746
-							$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), ($i % 12) + 1) / 60;
747
-						}
748
-						$rdata .= pack("VVVV", $firstocc, $everyn, $this->recur["regen"], (int) $this->recur["monthday"]);
652
+					if ($this->recur["regen"]) {
653
+						$rdata .= pack("VVV", $firstocc, (int) $this->recur["everyn"], 1);
749 654
 					}
750 655
 					else {
751
-						// Calc first occ
752
-						$firstocc = 0;
753
-						$monthIndex = (int) gmdate("n", $this->recur["start"]);
754
-						for ($i = 1; $i < $monthIndex; ++$i) {
755
-							$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), $i) / 60;
756
-						}
757
-						$rdata .= pack("VVVV", $firstocc, $everyn, $this->recur["regen"], (int) $this->recur["monthday"]);
656
+						$rdata .= pack("VVVV", $firstocc, (int) $this->recur["everyn"], 0, (int) $this->recur["weekdays"]);
758 657
 					}
759 658
 					break;
760 659
 
761
-				case 3:
762
-					// monthly: on Nth weekday of every M month
763
-					// yearly: on Nth weekday of M month
764
-					if (!isset($this->recur["weekdays"]) && !isset($this->recur["nday"])) {
660
+				case 0x0C:
661
+					// Monthly
662
+				case 0x0D:
663
+					// Yearly
664
+					if (!isset($this->recur["everyn"])) {
765 665
 						return;
766 666
 					}
767
-
768
-					$weekdays = (int) $this->recur["weekdays"];
769
-					$nday = (int) $this->recur["nday"];
770
-
771
-					// Calc startdate
772
-					$monthbegindow = (int) $this->recur["start"];
773
-
774
-					if ($nday == 5) {
775
-						// Set date on the last day of the last month
776
-						$monthbegindow += (gmdate("t", $monthbegindow) - gmdate("j", $monthbegindow)) * 24 * 60 * 60;
667
+					if ($term == 0x0D /* yearly */ && !isset($this->recur["month"])) {
668
+						return;
669
+					}
670
+					if ($term == 0x0C /* monthly */) {
671
+						$everyn = (int) $this->recur["everyn"];
777 672
 					}
778 673
 					else {
779
-						// Set on the first day of the month
780
-						$monthbegindow -= ((gmdate("j", $monthbegindow) - 1) * 24 * 60 * 60);
674
+						$everyn = $this->recur["regen"] ? ((int) $this->recur["everyn"]) * 12 : 12;
675
+					}
676
+
677
+					// Get montday/month/year of original start
678
+					$curmonthday = gmdate("j", (int) $this->recur["start"]);
679
+					$curyear = gmdate("Y", (int) $this->recur["start"]);
680
+					$curmonth = gmdate("n", (int) $this->recur["start"]);
681
+
682
+					// Check if the recurrence ends after a number of occurrences, in that case we must calculate the
683
+					// remaining occurrences based on the start of the recurrence.
684
+					if (((int) $this->recur["term"]) == 0x22) {
685
+						// $forwardcount is the number of occurrences we can skip and still be inside the recurrence range (minus
686
+						// one to make sure there are always at least one occurrence left)
687
+						$forwardcount = ((((int) $this->recur["numoccur"]) - 1) * $everyn);
781 688
 					}
782 689
 
690
+					// Get month for yearly on D'th day of month M
783 691
 					if ($term == 0x0D /* yearly */) {
784
-						// Set on right month
785
-						if ($selmonth < $curmonth) {
786
-							$tmp = 12 - $curmonth + $selmonth;
787
-						}
788
-						else {
789
-							$tmp = ($selmonth - $curmonth);
790
-						}
692
+						$selmonth = floor(((int) $this->recur["month"]) / (24 * 60 * 29)) + 1;
693
+					} // 1=jan, 2=feb, eg
791 694
 
792
-						for ($i = 0; $i < $tmp; ++$i) {
793
-							$monthbegindow += $this->getMonthInSeconds($curyear, $curmonth);
794
-							if ($curmonth == 12) {
795
-								++$curyear;
796
-								$curmonth = 0;
695
+					switch ((int) $this->recur["subtype"]) {
696
+					// on D day of every M month
697
+						case 2:
698
+							if (!isset($this->recur["monthday"])) {
699
+								return;
700
+							}
701
+							// Recalc startdate
702
+							// Set on the right begin day
703
+							// Go the beginning of the month
704
+							$this->recur["start"] -= ($curmonthday - 1) * 24 * 60 * 60;
705
+							// Go the the correct month day
706
+							$this->recur["start"] += (((int) $this->recur["monthday"]) - 1) * 24 * 60 * 60;
707
+
708
+							// If the previous calculation gave us a start date *before* the original start date, then we need to skip to the next occurrence
709
+							if (($term == 0x0C /* monthly */ && ((int) $this->recur["monthday"]) < $curmonthday) ||
710
+								($term == 0x0D /* yearly */ && ($selmonth < $curmonth || ($selmonth == $curmonth && ((int) $this->recur["monthday"]) < $curmonthday)))) {
711
+								if ($term == 0x0D /* yearly */) {
712
+									$count = ($everyn - ($curmonth - $selmonth));
713
+								} // Yearly, go to next occurrence in 'everyn' months minus difference in first occurrence and original date
714
+								else {
715
+									$count = $everyn;
716
+								} // Monthly, go to next occurrence in 'everyn' months
717
+
718
+								// Forward by $count months. This is done by getting the number of days in that month and forwarding that many days
719
+								for ($i = 0; $i < $count; ++$i) {
720
+									$this->recur["start"] += $this->getMonthInSeconds($curyear, $curmonth);
721
+									if ($curmonth == 12) {
722
+										++$curyear;
723
+										$curmonth = 0;
724
+									}
725
+									++$curmonth;
726
+								}
797 727
 							}
798
-							++$curmonth;
799
-						}
800
-					}
801
-					else {
802
-						// Check or you exist in the right month
803
-						for ($i = 0; $i < 7; ++$i) {
804
-							if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7)) & $weekdays) {
805
-								$day = gmdate("j", $monthbegindow) - $i;
806 728
 
807
-								break;
729
+							// "start" is now pointing to the first occurrence, except that it will overshoot if the
730
+							// month in which it occurs has less days than specified as the day of the month. So 31st
731
+							// of each month will overshoot in february (29 days). We compensate for that by checking
732
+							// if the day of the month we got is wrong, and then back up to the last day of the previous
733
+							// month.
734
+							if (((int) $this->recur["monthday"]) >= 28 && ((int) $this->recur["monthday"]) <= 31 &&
735
+								gmdate("j", ((int) $this->recur["start"])) < ((int) $this->recur["monthday"])) {
736
+								$this->recur["start"] -= gmdate("j", ((int) $this->recur["start"])) * 24 * 60 * 60;
808 737
 							}
809
-							if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7)) & $weekdays) {
810
-								$day = (($nday - 1) * 7) + ($i + 1);
811 738
 
812
-								break;
739
+							// "start" is now the first occurrence
740
+							if ($term == 0x0C /* monthly */) {
741
+								// Calc first occ
742
+								$monthIndex = ((((12 % $everyn) * ((((int) gmdate("Y", $this->recur["start"])) - 1601) % $everyn)) % $everyn) + (((int) gmdate("n", $this->recur["start"])) - 1)) % $everyn;
743
+
744
+								$firstocc = 0;
745
+								for ($i = 0; $i < $monthIndex; ++$i) {
746
+									$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), ($i % 12) + 1) / 60;
747
+								}
748
+								$rdata .= pack("VVVV", $firstocc, $everyn, $this->recur["regen"], (int) $this->recur["monthday"]);
749
+							}
750
+							else {
751
+								// Calc first occ
752
+								$firstocc = 0;
753
+								$monthIndex = (int) gmdate("n", $this->recur["start"]);
754
+								for ($i = 1; $i < $monthIndex; ++$i) {
755
+									$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), $i) / 60;
756
+								}
757
+								$rdata .= pack("VVVV", $firstocc, $everyn, $this->recur["regen"], (int) $this->recur["monthday"]);
758
+							}
759
+							break;
760
+
761
+						case 3:
762
+							// monthly: on Nth weekday of every M month
763
+							// yearly: on Nth weekday of M month
764
+							if (!isset($this->recur["weekdays"]) && !isset($this->recur["nday"])) {
765
+								return;
813 766
 							}
814
-						}
815 767
 
816
-						// Goto the next X month
817
-						if (isset($day) && ($day < gmdate("j", (int) $this->recur["start"]))) {
768
+							$weekdays = (int) $this->recur["weekdays"];
769
+							$nday = (int) $this->recur["nday"];
770
+
771
+							// Calc startdate
772
+							$monthbegindow = (int) $this->recur["start"];
773
+
818 774
 							if ($nday == 5) {
819
-								$monthbegindow += 24 * 60 * 60;
820
-								if ($curmonth == 12) {
821
-									++$curyear;
822
-									$curmonth = 0;
823
-								}
824
-								++$curmonth;
775
+								// Set date on the last day of the last month
776
+								$monthbegindow += (gmdate("t", $monthbegindow) - gmdate("j", $monthbegindow)) * 24 * 60 * 60;
777
+							}
778
+							else {
779
+								// Set on the first day of the month
780
+								$monthbegindow -= ((gmdate("j", $monthbegindow) - 1) * 24 * 60 * 60);
825 781
 							}
826 782
 
827
-							for ($i = 0; $i < $everyn; ++$i) {
828
-								$monthbegindow += $this->getMonthInSeconds($curyear, $curmonth);
829
-								if ($curmonth == 12) {
830
-									++$curyear;
831
-									$curmonth = 0;
783
+							if ($term == 0x0D /* yearly */) {
784
+								// Set on right month
785
+								if ($selmonth < $curmonth) {
786
+									$tmp = 12 - $curmonth + $selmonth;
787
+								}
788
+								else {
789
+									$tmp = ($selmonth - $curmonth);
790
+								}
791
+
792
+								for ($i = 0; $i < $tmp; ++$i) {
793
+									$monthbegindow += $this->getMonthInSeconds($curyear, $curmonth);
794
+									if ($curmonth == 12) {
795
+										++$curyear;
796
+										$curmonth = 0;
797
+									}
798
+									++$curmonth;
832 799
 								}
833
-								++$curmonth;
834 800
 							}
835
-							if ($nday == 5) {
836
-								$monthbegindow -= 24 * 60 * 60;
801
+							else {
802
+								// Check or you exist in the right month
803
+								for ($i = 0; $i < 7; ++$i) {
804
+									if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7)) & $weekdays) {
805
+										$day = gmdate("j", $monthbegindow) - $i;
806
+
807
+										break;
808
+									}
809
+									if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7)) & $weekdays) {
810
+										$day = (($nday - 1) * 7) + ($i + 1);
811
+
812
+										break;
813
+									}
814
+								}
815
+
816
+								// Goto the next X month
817
+								if (isset($day) && ($day < gmdate("j", (int) $this->recur["start"]))) {
818
+									if ($nday == 5) {
819
+										$monthbegindow += 24 * 60 * 60;
820
+										if ($curmonth == 12) {
821
+											++$curyear;
822
+											$curmonth = 0;
823
+										}
824
+										++$curmonth;
825
+									}
826
+
827
+									for ($i = 0; $i < $everyn; ++$i) {
828
+										$monthbegindow += $this->getMonthInSeconds($curyear, $curmonth);
829
+										if ($curmonth == 12) {
830
+											++$curyear;
831
+											$curmonth = 0;
832
+										}
833
+										++$curmonth;
834
+									}
835
+									if ($nday == 5) {
836
+										$monthbegindow -= 24 * 60 * 60;
837
+									}
838
+								}
837 839
 							}
838
-						}
839
-					}
840 840
 
841
-					// FIXME: weekstart?
841
+							// FIXME: weekstart?
842 842
 
843
-					$day = 0;
844
-					// Set start on the right day
845
-					for ($i = 0; $i < 7; ++$i) {
846
-						if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7)) & $weekdays) {
847
-							$day = $i;
843
+							$day = 0;
844
+							// Set start on the right day
845
+							for ($i = 0; $i < 7; ++$i) {
846
+								if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7)) & $weekdays) {
847
+									$day = $i;
848 848
 
849
-							break;
850
-						}
851
-						if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7)) & $weekdays) {
852
-							$day = ($nday - 1) * 7 + ($i + 1);
849
+									break;
850
+								}
851
+								if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7)) & $weekdays) {
852
+									$day = ($nday - 1) * 7 + ($i + 1);
853 853
 
854
-							break;
855
-						}
856
-					}
857
-					if ($nday == 5) {
858
-						$monthbegindow -= $day * 24 * 60 * 60;
859
-					}
860
-					else {
861
-						$monthbegindow += ($day - 1) * 24 * 60 * 60;
862
-					}
854
+									break;
855
+								}
856
+							}
857
+							if ($nday == 5) {
858
+								$monthbegindow -= $day * 24 * 60 * 60;
859
+							}
860
+							else {
861
+								$monthbegindow += ($day - 1) * 24 * 60 * 60;
862
+							}
863 863
 
864
-					$firstocc = 0;
865
-					if ($term == 0x0C /* monthly */) {
866
-						// Calc first occ
867
-						$monthIndex = ((((12 % $everyn) * (((int) gmdate("Y", $this->recur["start"]) - 1601) % $everyn)) % $everyn) + (((int) gmdate("n", $this->recur["start"])) - 1)) % $everyn;
868
-						for ($i = 0; $i < $monthIndex; ++$i) {
869
-							$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), ($i % 12) + 1) / 60;
870
-						}
871
-						$rdata .= pack("VVVVV", $firstocc, $everyn, 0, $weekdays, $nday);
872
-						break;
873
-					}
874
-					// Calc first occ
875
-					$monthIndex = (int) gmdate("n", $this->recur["start"]);
876
-					for ($i = 1; $i < $monthIndex; ++$i) {
877
-						$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), $i) / 60;
864
+							$firstocc = 0;
865
+							if ($term == 0x0C /* monthly */) {
866
+								// Calc first occ
867
+								$monthIndex = ((((12 % $everyn) * (((int) gmdate("Y", $this->recur["start"]) - 1601) % $everyn)) % $everyn) + (((int) gmdate("n", $this->recur["start"])) - 1)) % $everyn;
868
+								for ($i = 0; $i < $monthIndex; ++$i) {
869
+									$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), ($i % 12) + 1) / 60;
870
+								}
871
+								$rdata .= pack("VVVVV", $firstocc, $everyn, 0, $weekdays, $nday);
872
+								break;
873
+							}
874
+							// Calc first occ
875
+							$monthIndex = (int) gmdate("n", $this->recur["start"]);
876
+							for ($i = 1; $i < $monthIndex; ++$i) {
877
+								$firstocc += $this->getMonthInSeconds(1601 + floor($i / 12), $i) / 60;
878
+							}
879
+							$rdata .= pack("VVVVV", $firstocc, $everyn, 0, $weekdays, $nday);
880
+							break;
878 881
 					}
879
-					$rdata .= pack("VVVVV", $firstocc, $everyn, 0, $weekdays, $nday);
880
-					break;
881
-				}
882 882
 				break;
883 883
 			}
884 884
 
@@ -892,20 +892,20 @@  discard block
 block discarded – undo
892 892
 
893 893
 			switch ($term) {
894 894
 			// After the given enddate
895
-			case 0x21:
896
-				$rdata .= pack("V", 10);
897
-				break;
898
-			// After a number of times
899
-			case 0x22:
900
-				if (!isset($this->recur["numoccur"])) {
901
-					return;
902
-				}
903
-				$rdata .= pack("V", (int) $this->recur["numoccur"]);
904
-				break;
905
-			// Never ends
906
-			case 0x23:
907
-				$rdata .= pack("V", 0);
908
-				break;
895
+				case 0x21:
896
+					$rdata .= pack("V", 10);
897
+					break;
898
+				// After a number of times
899
+				case 0x22:
900
+					if (!isset($this->recur["numoccur"])) {
901
+						return;
902
+					}
903
+					$rdata .= pack("V", (int) $this->recur["numoccur"]);
904
+					break;
905
+				// Never ends
906
+				case 0x23:
907
+					$rdata .= pack("V", 0);
908
+					break;
909 909
 			}
910 910
 
911 911
 			// Strange little thing for the recurrence type "every workday"
@@ -958,135 +958,135 @@  discard block
 block discarded – undo
958 958
 			// Set enddate
959 959
 			switch ($term) {
960 960
 			// After the given enddate
961
-			case 0x21:
962
-				$rdata .= pack("V", $this->unixDataToRecurData((int) $this->recur["end"]));
963
-				break;
964
-			// After a number of times
965
-			case 0x22:
966
-				// @todo: calculate enddate with intval($this->recur["startocc"]) + intval($this->recur["duration"]) > 24 hour
967
-				$occenddate = (int) $this->recur["start"];
968
-
969
-				switch ((int) $this->recur["type"]) {
970
-				case 0x0A: // daily
971
-					if ($this->recur["subtype"] != 1) {
972
-						// -1 because the first day already counts (from 1-1-1980 to 1-1-1980 is 1 occurrence)
973
-						$occenddate += (((int) $this->recur["everyn"]) * 60 * (((int) $this->recur["numoccur"] - 1)));
974
-						break;
975
-					}
976
-					// Daily every workday
977
-					$restocc = (int) $this->recur["numoccur"];
978
-					// Get starting weekday
979
-					$nowtime = $this->gmtime($occenddate);
980
-					$j = $nowtime["tm_wday"];
981
-
982
-					while (1) {
983
-						if (($j % 7) > 0 && ($j % 7) < 6) {
984
-							--$restocc;
985
-						}
986
-						++$j;
987
-						if ($restocc <= 0) {
988
-							break;
989
-						}
990
-						$occenddate += 24 * 60 * 60;
991
-					}
961
+				case 0x21:
962
+					$rdata .= pack("V", $this->unixDataToRecurData((int) $this->recur["end"]));
992 963
 					break;
964
+				// After a number of times
965
+				case 0x22:
966
+					// @todo: calculate enddate with intval($this->recur["startocc"]) + intval($this->recur["duration"]) > 24 hour
967
+					$occenddate = (int) $this->recur["start"];
968
+
969
+					switch ((int) $this->recur["type"]) {
970
+						case 0x0A: // daily
971
+							if ($this->recur["subtype"] != 1) {
972
+								// -1 because the first day already counts (from 1-1-1980 to 1-1-1980 is 1 occurrence)
973
+								$occenddate += (((int) $this->recur["everyn"]) * 60 * (((int) $this->recur["numoccur"] - 1)));
974
+								break;
975
+							}
976
+							// Daily every workday
977
+							$restocc = (int) $this->recur["numoccur"];
978
+							// Get starting weekday
979
+							$nowtime = $this->gmtime($occenddate);
980
+							$j = $nowtime["tm_wday"];
981
+
982
+							while (1) {
983
+								if (($j % 7) > 0 && ($j % 7) < 6) {
984
+									--$restocc;
985
+								}
986
+								++$j;
987
+								if ($restocc <= 0) {
988
+									break;
989
+								}
990
+								$occenddate += 24 * 60 * 60;
991
+							}
992
+							break;
993 993
 
994
-				case 0x0B: // weekly
995
-					// Needed values
996
-					// $forwardcount - number of weeks we can skip forward
997
-					// $restocc - number of remaining occurrences after the week skip
998
-
999
-					// Add the weeks till the last item
1000
-					$occenddate += ($forwardcount * 7 * 24 * 60 * 60);
1001
-					$dayofweek = gmdate("w", $occenddate);
1002
-
1003
-					// Loop through the last occurrences until we have had them all
1004
-					for ($j = 1; $restocc > 0; ++$j) {
1005
-						// Jump to the next week (which may be N weeks away) when going over the week boundary
1006
-						if ((($dayofweek + $j) % 7) == $weekstart) {
1007
-							$occenddate += (((int) $this->recur["everyn"]) - 1) * 7 * 24 * 60 * 60;
1008
-						}
994
+						case 0x0B: // weekly
995
+							// Needed values
996
+							// $forwardcount - number of weeks we can skip forward
997
+							// $restocc - number of remaining occurrences after the week skip
1009 998
 
1010
-						// If this is a matching day, once less occurrence to process
1011
-						if (((int) $this->recur["weekdays"]) & (1 << (($dayofweek + $j) % 7))) {
1012
-							--$restocc;
1013
-						}
999
+							// Add the weeks till the last item
1000
+							$occenddate += ($forwardcount * 7 * 24 * 60 * 60);
1001
+							$dayofweek = gmdate("w", $occenddate);
1014 1002
 
1015
-						// Next day
1016
-						$occenddate += 24 * 60 * 60;
1017
-					}
1018
-					break;
1003
+							// Loop through the last occurrences until we have had them all
1004
+							for ($j = 1; $restocc > 0; ++$j) {
1005
+								// Jump to the next week (which may be N weeks away) when going over the week boundary
1006
+								if ((($dayofweek + $j) % 7) == $weekstart) {
1007
+									$occenddate += (((int) $this->recur["everyn"]) - 1) * 7 * 24 * 60 * 60;
1008
+								}
1019 1009
 
1020
-				case 0x0C: // monthly
1021
-				case 0x0D: // yearly
1022
-					$curyear = gmdate("Y", (int) $this->recur["start"]);
1023
-					$curmonth = gmdate("n", (int) $this->recur["start"]);
1024
-					// $forwardcount = months
1010
+								// If this is a matching day, once less occurrence to process
1011
+								if (((int) $this->recur["weekdays"]) & (1 << (($dayofweek + $j) % 7))) {
1012
+									--$restocc;
1013
+								}
1025 1014
 
1026
-					switch ((int) $this->recur["subtype"]) {
1027
-					case 2: // on D day of every M month
1028
-						while ($forwardcount > 0) {
1029
-							$occenddate += $this->getMonthInSeconds($curyear, $curmonth);
1030
-							if ($curmonth >= 12) {
1031
-								$curmonth = 1;
1032
-								++$curyear;
1015
+								// Next day
1016
+								$occenddate += 24 * 60 * 60;
1033 1017
 							}
1034
-							else {
1035
-								++$curmonth;
1036
-							}
1037
-							--$forwardcount;
1038
-						}
1018
+							break;
1039 1019
 
1040
-						// compensation between 28 and 31
1041
-						if (((int) $this->recur["monthday"]) >= 28 && ((int) $this->recur["monthday"]) <= 31 &&
1042
-							gmdate("j", $occenddate) < ((int) $this->recur["monthday"])) {
1043
-							if (gmdate("j", $occenddate) < 28) {
1044
-								$occenddate -= gmdate("j", $occenddate) * 24 * 60 * 60;
1045
-							}
1046
-							else {
1047
-								$occenddate += (gmdate("t", $occenddate) - gmdate("j", $occenddate)) * 24 * 60 * 60;
1048
-							}
1049
-						}
1050
-						break;
1020
+						case 0x0C: // monthly
1021
+						case 0x0D: // yearly
1022
+							$curyear = gmdate("Y", (int) $this->recur["start"]);
1023
+							$curmonth = gmdate("n", (int) $this->recur["start"]);
1024
+							// $forwardcount = months
1025
+
1026
+							switch ((int) $this->recur["subtype"]) {
1027
+								case 2: // on D day of every M month
1028
+									while ($forwardcount > 0) {
1029
+										$occenddate += $this->getMonthInSeconds($curyear, $curmonth);
1030
+										if ($curmonth >= 12) {
1031
+											$curmonth = 1;
1032
+											++$curyear;
1033
+										}
1034
+										else {
1035
+											++$curmonth;
1036
+										}
1037
+										--$forwardcount;
1038
+									}
1051 1039
 
1052
-					case 3: // on Nth weekday of every M month
1053
-						$nday = (int) $this->recur["nday"]; // 1 tot 5
1054
-						$weekdays = (int) $this->recur["weekdays"];
1055
-						while ($forwardcount > 0) {
1056
-							$occenddate += $this->getMonthInSeconds($curyear, $curmonth);
1057
-							if ($curmonth >= 12) {
1058
-								$curmonth = 1;
1059
-								++$curyear;
1060
-							}
1061
-							else {
1062
-								++$curmonth;
1063
-							}
1064
-							--$forwardcount;
1065
-						}
1066
-						if ($nday == 5) {
1067
-							// Set date on the last day of the last month
1068
-							$occenddate += (gmdate("t", $occenddate) - gmdate("j", $occenddate)) * 24 * 60 * 60;
1069
-						}
1070
-						else {
1071
-							// Set date on the first day of the last month
1072
-							$occenddate -= (gmdate("j", $occenddate) - 1) * 24 * 60 * 60;
1073
-						}
1040
+									// compensation between 28 and 31
1041
+									if (((int) $this->recur["monthday"]) >= 28 && ((int) $this->recur["monthday"]) <= 31 &&
1042
+										gmdate("j", $occenddate) < ((int) $this->recur["monthday"])) {
1043
+										if (gmdate("j", $occenddate) < 28) {
1044
+											$occenddate -= gmdate("j", $occenddate) * 24 * 60 * 60;
1045
+										}
1046
+										else {
1047
+											$occenddate += (gmdate("t", $occenddate) - gmdate("j", $occenddate)) * 24 * 60 * 60;
1048
+										}
1049
+									}
1050
+									break;
1074 1051
 
1075
-						for ($i = 0; $i < 7; ++$i) {
1076
-							if ($nday == 5 && (1 << ((gmdate("w", $occenddate) - $i) % 7)) & $weekdays) {
1077
-								$occenddate -= $i * 24 * 60 * 60;
1052
+								case 3: // on Nth weekday of every M month
1053
+									$nday = (int) $this->recur["nday"]; // 1 tot 5
1054
+									$weekdays = (int) $this->recur["weekdays"];
1055
+									while ($forwardcount > 0) {
1056
+										$occenddate += $this->getMonthInSeconds($curyear, $curmonth);
1057
+										if ($curmonth >= 12) {
1058
+											$curmonth = 1;
1059
+											++$curyear;
1060
+										}
1061
+										else {
1062
+											++$curmonth;
1063
+										}
1064
+										--$forwardcount;
1065
+									}
1066
+									if ($nday == 5) {
1067
+										// Set date on the last day of the last month
1068
+										$occenddate += (gmdate("t", $occenddate) - gmdate("j", $occenddate)) * 24 * 60 * 60;
1069
+									}
1070
+									else {
1071
+										// Set date on the first day of the last month
1072
+										$occenddate -= (gmdate("j", $occenddate) - 1) * 24 * 60 * 60;
1073
+									}
1078 1074
 
1079
-								break;
1080
-							}
1081
-							if ($nday != 5 && (1 << ((gmdate("w", $occenddate) + $i) % 7)) & $weekdays) {
1082
-								$occenddate += ($i + (($nday - 1) * 7)) * 24 * 60 * 60;
1075
+									for ($i = 0; $i < 7; ++$i) {
1076
+										if ($nday == 5 && (1 << ((gmdate("w", $occenddate) - $i) % 7)) & $weekdays) {
1077
+											$occenddate -= $i * 24 * 60 * 60;
1083 1078
 
1084
-								break;
1079
+											break;
1080
+										}
1081
+										if ($nday != 5 && (1 << ((gmdate("w", $occenddate) + $i) % 7)) & $weekdays) {
1082
+											$occenddate += ($i + (($nday - 1) * 7)) * 24 * 60 * 60;
1083
+
1084
+											break;
1085
+										}
1086
+									}
1087
+									break; // case 3:
1085 1088
 							}
1086
-						}
1087
-						break; // case 3:
1088
-					}
1089
-					break;
1089
+						break;
1090 1090
 				}
1091 1091
 
1092 1092
 				if (defined("PHP_INT_MAX") && $occenddate > PHP_INT_MAX) {
@@ -1097,11 +1097,11 @@  discard block
 block discarded – undo
1097 1097
 				$rdata .= pack("V", $this->unixDataToRecurData((int) $this->recur["end"]));
1098 1098
 				break;
1099 1099
 			// Never ends
1100
-			case 0x23:
1101
-			default:
1102
-				$this->recur["end"] = 0x7FFFFFFF; // max date -> 2038
1103
-				$rdata .= pack("V", 0x5AE980DF);
1104
-				break;
1100
+				case 0x23:
1101
+				default:
1102
+					$this->recur["end"] = 0x7FFFFFFF; // max date -> 2038
1103
+					$rdata .= pack("V", 0x5AE980DF);
1104
+					break;
1105 1105
 			}
1106 1106
 
1107 1107
 			// UTC date
@@ -1647,188 +1647,188 @@  discard block
 block discarded – undo
1647 1647
 				// Loop through the entire recurrence range of dates, and check for each occurrence whether it is in the view range.
1648 1648
 
1649 1649
 				switch ($this->recur["type"]) {
1650
-				case 10:
1651
-					// Daily
1652
-					if ($this->recur["everyn"] <= 0) {
1653
-						$this->recur["everyn"] = 1440;
1654
-					}
1650
+					case 10:
1651
+						// Daily
1652
+						if ($this->recur["everyn"] <= 0) {
1653
+							$this->recur["everyn"] = 1440;
1654
+						}
1655 1655
 
1656
-					if ($this->recur["subtype"] == 0) {
1657
-						// Every Nth day
1658
-						for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * $this->recur["everyn"]) {
1659
-							$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1656
+						if ($this->recur["subtype"] == 0) {
1657
+							// Every Nth day
1658
+							for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * $this->recur["everyn"]) {
1659
+								$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1660
+							}
1661
+							break;
1660 1662
 						}
1661
-						break;
1662
-					}
1663
-					// Every workday
1664
-					for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * 1440) {
1665
-						$nowtime = $this->gmtime($now);
1666
-						if ($nowtime["tm_wday"] > 0 && $nowtime["tm_wday"] < 6) { // only add items in the given timespace
1667
-							$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1663
+						// Every workday
1664
+						for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * 1440) {
1665
+							$nowtime = $this->gmtime($now);
1666
+							if ($nowtime["tm_wday"] > 0 && $nowtime["tm_wday"] < 6) { // only add items in the given timespace
1667
+								$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1668
+							}
1668 1669
 						}
1669
-					}
1670
-					break;
1671
-
1672
-				case 11:
1673
-					// Weekly
1674
-					if ($this->recur["everyn"] <= 0) {
1675
-						$this->recur["everyn"] = 1;
1676
-					}
1670
+						break;
1677 1671
 
1678
-					// If sliding flag is set then move to 'n' weeks
1679
-					if ($this->recur['regen']) {
1680
-						$daystart += (60 * 60 * 24 * 7 * $this->recur["everyn"]);
1681
-					}
1672
+					case 11:
1673
+						// Weekly
1674
+						if ($this->recur["everyn"] <= 0) {
1675
+							$this->recur["everyn"] = 1;
1676
+						}
1682 1677
 
1683
-					for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += (60 * 60 * 24 * 7 * $this->recur["everyn"])) {
1678
+						// If sliding flag is set then move to 'n' weeks
1684 1679
 						if ($this->recur['regen']) {
1685
-							$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1686
-
1687
-							break;
1680
+							$daystart += (60 * 60 * 24 * 7 * $this->recur["everyn"]);
1688 1681
 						}
1689
-						// Loop through the whole following week to the first occurrence of the week, add each day that is specified
1690
-						for ($wday = 0; $wday < 7; ++$wday) {
1691
-							$daynow = $now + $wday * 60 * 60 * 24;
1692
-							// checks weather the next coming day in recurring pattern is less than or equal to end day of the recurring item
1693
-							if ($daynow > $dayend) {
1694
-								continue;
1695
-							}
1696
-							$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1697
-							if (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"]))) { // Selected ?
1698
-								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1699
-							}
1700
-						}
1701
-					}
1702
-					break;
1703 1682
 
1704
-				case 12:
1705
-					// Monthly
1706
-					if ($this->recur["everyn"] <= 0) {
1707
-						$this->recur["everyn"] = 1;
1708
-					}
1683
+						for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += (60 * 60 * 24 * 7 * $this->recur["everyn"])) {
1684
+							if ($this->recur['regen']) {
1685
+								$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1709 1686
 
1710
-					// Loop through all months from start to end of occurrence, starting at beginning of first month
1711
-					for ($now = $this->monthStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1712
-						if (isset($this->recur["monthday"]) && ($this->recur['monthday'] != "undefined") && !$this->recur['regen']) { // Day M of every N months
1713
-							$difference = 1;
1714
-							if ($this->daysInMonth($now, $this->recur["everyn"]) < $this->recur["monthday"]) {
1715
-								$difference = $this->recur["monthday"] - $this->daysInMonth($now, $this->recur["everyn"]) + 1;
1687
+								break;
1716 1688
 							}
1717
-
1718
-							$daynow = $now + (($this->recur["monthday"] - $difference) * 24 * 60 * 60);
1719
-							// checks weather the next coming day in recurrence pattern is less than or equal to end day of the recurring item
1720
-							if ($daynow <= $dayend) {
1721
-								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1689
+							// Loop through the whole following week to the first occurrence of the week, add each day that is specified
1690
+							for ($wday = 0; $wday < 7; ++$wday) {
1691
+								$daynow = $now + $wday * 60 * 60 * 24;
1692
+								// checks weather the next coming day in recurring pattern is less than or equal to end day of the recurring item
1693
+								if ($daynow > $dayend) {
1694
+									continue;
1695
+								}
1696
+								$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1697
+								if (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"]))) { // Selected ?
1698
+									$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1699
+								}
1722 1700
 							}
1723 1701
 						}
1724
-						elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] of every N months
1725
-							// Sanitize input
1726
-							if ($this->recur["weekdays"] == 0) {
1727
-								$this->recur["weekdays"] = 1;
1728
-							}
1702
+						break;
1729 1703
 
1730
-							// If nday is not set to the last day in the month
1731
-							if ($this->recur["nday"] < 5) {
1732
-								// keep the track of no. of time correct selection pattern(like 2nd weekday, 4th fiday, etc.)is matched
1733
-								$ndaycounter = 0;
1734
-								// Find matching weekday in this month
1735
-								for ($day = 0; $day < $this->daysInMonth($now, 1); ++$day) {
1736
-									$daynow = $now + $day * 60 * 60 * 24;
1737
-									$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1704
+					case 12:
1705
+						// Monthly
1706
+						if ($this->recur["everyn"] <= 0) {
1707
+							$this->recur["everyn"] = 1;
1708
+						}
1738 1709
 
1739
-									if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1740
-										++$ndaycounter;
1741
-									}
1742
-									// check the selected pattern is same as asked Nth weekday,If so set the firstday
1743
-									if ($this->recur["nday"] == $ndaycounter) {
1744
-										$firstday = $day;
1710
+						// Loop through all months from start to end of occurrence, starting at beginning of first month
1711
+						for ($now = $this->monthStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1712
+							if (isset($this->recur["monthday"]) && ($this->recur['monthday'] != "undefined") && !$this->recur['regen']) { // Day M of every N months
1713
+								$difference = 1;
1714
+								if ($this->daysInMonth($now, $this->recur["everyn"]) < $this->recur["monthday"]) {
1715
+									$difference = $this->recur["monthday"] - $this->daysInMonth($now, $this->recur["everyn"]) + 1;
1716
+								}
1745 1717
 
1746
-										break;
1747
-									}
1718
+								$daynow = $now + (($this->recur["monthday"] - $difference) * 24 * 60 * 60);
1719
+								// checks weather the next coming day in recurrence pattern is less than or equal to end day of the recurring item
1720
+								if ($daynow <= $dayend) {
1721
+									$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1748 1722
 								}
1749
-								// $firstday is the day of the month on which the asked pattern of nth weekday matches
1750
-								$daynow = $now + $firstday * 60 * 60 * 24;
1751 1723
 							}
1752
-							else {
1753
-								// Find last day in the month ($now is the firstday of the month)
1754
-								$NumDaysInMonth = $this->daysInMonth($now, 1);
1755
-								$daynow = $now + (($NumDaysInMonth - 1) * 24 * 60 * 60);
1724
+							elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] of every N months
1725
+								// Sanitize input
1726
+								if ($this->recur["weekdays"] == 0) {
1727
+									$this->recur["weekdays"] = 1;
1728
+								}
1729
+
1730
+								// If nday is not set to the last day in the month
1731
+								if ($this->recur["nday"] < 5) {
1732
+									// keep the track of no. of time correct selection pattern(like 2nd weekday, 4th fiday, etc.)is matched
1733
+									$ndaycounter = 0;
1734
+									// Find matching weekday in this month
1735
+									for ($day = 0; $day < $this->daysInMonth($now, 1); ++$day) {
1736
+										$daynow = $now + $day * 60 * 60 * 24;
1737
+										$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1738
+
1739
+										if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1740
+											++$ndaycounter;
1741
+										}
1742
+										// check the selected pattern is same as asked Nth weekday,If so set the firstday
1743
+										if ($this->recur["nday"] == $ndaycounter) {
1744
+											$firstday = $day;
1745
+
1746
+											break;
1747
+										}
1748
+									}
1749
+									// $firstday is the day of the month on which the asked pattern of nth weekday matches
1750
+									$daynow = $now + $firstday * 60 * 60 * 24;
1751
+								}
1752
+								else {
1753
+									// Find last day in the month ($now is the firstday of the month)
1754
+									$NumDaysInMonth = $this->daysInMonth($now, 1);
1755
+									$daynow = $now + (($NumDaysInMonth - 1) * 24 * 60 * 60);
1756 1756
 
1757
-								$nowtime = $this->gmtime($daynow);
1758
-								while (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) == 0) {
1759
-									$daynow -= 86400;
1760 1757
 									$nowtime = $this->gmtime($daynow);
1758
+									while (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) == 0) {
1759
+										$daynow -= 86400;
1760
+										$nowtime = $this->gmtime($daynow);
1761
+									}
1761 1762
 								}
1762
-							}
1763 1763
 
1764
-							/*
1764
+								/*
1765 1765
 							 * checks weather the next coming day in recurrence pattern is less than or equal to end day of the			* recurring item.Also check weather the coming day in recurrence pattern is greater than or equal to start * of recurring pattern, so that appointment that fall under the recurrence range are only displayed.
1766 1766
 							 */
1767
-							if ($daynow <= $dayend && $daynow >= $daystart) {
1768
-								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1767
+								if ($daynow <= $dayend && $daynow >= $daystart) {
1768
+									$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1769
+								}
1769 1770
 							}
1770
-						}
1771
-						elseif ($this->recur['regen']) {
1772
-							$next_month_start = $now + ($this->daysInMonth($now, 1) * 24 * 60 * 60);
1773
-							$now = $daystart + ($this->daysInMonth($next_month_start, $this->recur['everyn']) * 24 * 60 * 60);
1774
-							if ($now <= $dayend) {
1775
-								$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1771
+							elseif ($this->recur['regen']) {
1772
+								$next_month_start = $now + ($this->daysInMonth($now, 1) * 24 * 60 * 60);
1773
+								$now = $daystart + ($this->daysInMonth($next_month_start, $this->recur['everyn']) * 24 * 60 * 60);
1774
+								if ($now <= $dayend) {
1775
+									$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1776
+								}
1776 1777
 							}
1777 1778
 						}
1778
-					}
1779
-					break;
1780
-
1781
-				case 13:
1782
-					// Yearly
1783
-					if ($this->recur["everyn"] <= 0) {
1784
-						$this->recur["everyn"] = 12;
1785
-					}
1779
+						break;
1786 1780
 
1787
-					for ($now = $this->yearStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1788
-						if (isset($this->recur["monthday"]) && !$this->recur['regen']) { // same as monthly, but in a specific month
1789
-							// recur["month"] is in minutes since the beginning of the year
1790
-							$month = $this->monthOfYear($this->recur["month"]); // $month is now month of year [0..11]
1791
-							$monthday = $this->recur["monthday"]; // $monthday is day of the month [1..31]
1792
-							$monthstart = $now + $this->daysInMonth($now, $month) * 24 * 60 * 60; // $monthstart is the timestamp of the beginning of the month
1793
-							if ($monthday > $this->daysInMonth($monthstart, 1)) {
1794
-								$monthday = $this->daysInMonth($monthstart, 1);
1795
-							}	// Cap $monthday on month length (eg 28 feb instead of 29 feb)
1796
-							$daynow = $monthstart + ($monthday - 1) * 24 * 60 * 60;
1797
-							$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1781
+					case 13:
1782
+						// Yearly
1783
+						if ($this->recur["everyn"] <= 0) {
1784
+							$this->recur["everyn"] = 12;
1798 1785
 						}
1799
-						elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] in month X of every N years
1800
-							// Go the correct month
1801
-							$monthnow = $now + $this->daysInMonth($now, $this->monthOfYear($this->recur["month"])) * 24 * 60 * 60;
1802 1786
 
1803
-							// Find first matching weekday in this month
1804
-							for ($wday = 0; $wday < 7; ++$wday) {
1805
-								$daynow = $monthnow + $wday * 60 * 60 * 24;
1806
-								$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1787
+						for ($now = $this->yearStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1788
+							if (isset($this->recur["monthday"]) && !$this->recur['regen']) { // same as monthly, but in a specific month
1789
+								// recur["month"] is in minutes since the beginning of the year
1790
+								$month = $this->monthOfYear($this->recur["month"]); // $month is now month of year [0..11]
1791
+								$monthday = $this->recur["monthday"]; // $monthday is day of the month [1..31]
1792
+								$monthstart = $now + $this->daysInMonth($now, $month) * 24 * 60 * 60; // $monthstart is the timestamp of the beginning of the month
1793
+								if ($monthday > $this->daysInMonth($monthstart, 1)) {
1794
+									$monthday = $this->daysInMonth($monthstart, 1);
1795
+								}	// Cap $monthday on month length (eg 28 feb instead of 29 feb)
1796
+								$daynow = $monthstart + ($monthday - 1) * 24 * 60 * 60;
1797
+								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1798
+							}
1799
+							elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] in month X of every N years
1800
+								// Go the correct month
1801
+								$monthnow = $now + $this->daysInMonth($now, $this->monthOfYear($this->recur["month"])) * 24 * 60 * 60;
1807 1802
 
1808
-								if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1809
-									$firstday = $wday;
1803
+								// Find first matching weekday in this month
1804
+								for ($wday = 0; $wday < 7; ++$wday) {
1805
+									$daynow = $monthnow + $wday * 60 * 60 * 24;
1806
+									$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1810 1807
 
1811
-									break;
1808
+									if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1809
+										$firstday = $wday;
1810
+
1811
+										break;
1812
+									}
1812 1813
 								}
1813
-							}
1814 1814
 
1815
-							// Same as above (monthly)
1816
-							$daynow = $monthnow + ($firstday + ($this->recur["nday"] - 1) * 7) * 60 * 60 * 24;
1817
-							while ($this->monthStartOf($daynow) != $this->monthStartOf($monthnow)) {
1818
-								$daynow -= 7 * 60 * 60 * 24;
1819
-							}
1815
+								// Same as above (monthly)
1816
+								$daynow = $monthnow + ($firstday + ($this->recur["nday"] - 1) * 7) * 60 * 60 * 24;
1817
+								while ($this->monthStartOf($daynow) != $this->monthStartOf($monthnow)) {
1818
+									$daynow -= 7 * 60 * 60 * 24;
1819
+								}
1820 1820
 
1821
-							$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1822
-						}
1823
-						elseif ($this->recur['regen']) {
1824
-							$year_starttime = $this->gmtime($now);
1825
-							$is_next_leapyear = $this->isLeapYear($year_starttime['tm_year'] + 1900 + 1);	// +1 next year
1826
-							$now = $daystart + ($is_next_leapyear ? 31622400 /* Leap year in seconds */ : 31536000 /* year in seconds */);
1827
-							if ($now <= $dayend) {
1828
-								$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1821
+								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1822
+							}
1823
+							elseif ($this->recur['regen']) {
1824
+								$year_starttime = $this->gmtime($now);
1825
+								$is_next_leapyear = $this->isLeapYear($year_starttime['tm_year'] + 1900 + 1);	// +1 next year
1826
+								$now = $daystart + ($is_next_leapyear ? 31622400 /* Leap year in seconds */ : 31536000 /* year in seconds */);
1827
+								if ($now <= $dayend) {
1828
+									$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1829
+								}
1829 1830
 							}
1830 1831
 						}
1831
-					}
1832 1832
 				}
1833 1833
 				// to get all exception items
1834 1834
 				if (!empty($this->recur['changed_occurrences'])) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -801,12 +801,12 @@  discard block
 block discarded – undo
801 801
 					else {
802 802
 						// Check or you exist in the right month
803 803
 						for ($i = 0; $i < 7; ++$i) {
804
-							if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7)) & $weekdays) {
804
+							if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7))&$weekdays) {
805 805
 								$day = gmdate("j", $monthbegindow) - $i;
806 806
 
807 807
 								break;
808 808
 							}
809
-							if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7)) & $weekdays) {
809
+							if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7))&$weekdays) {
810 810
 								$day = (($nday - 1) * 7) + ($i + 1);
811 811
 
812 812
 								break;
@@ -843,12 +843,12 @@  discard block
 block discarded – undo
843 843
 					$day = 0;
844 844
 					// Set start on the right day
845 845
 					for ($i = 0; $i < 7; ++$i) {
846
-						if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7)) & $weekdays) {
846
+						if ($nday == 5 && (1 << ((gmdate("w", $monthbegindow) - $i) % 7))&$weekdays) {
847 847
 							$day = $i;
848 848
 
849 849
 							break;
850 850
 						}
851
-						if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7)) & $weekdays) {
851
+						if ($nday != 5 && (1 << ((gmdate("w", $monthbegindow) + $i) % 7))&$weekdays) {
852 852
 							$day = ($nday - 1) * 7 + ($i + 1);
853 853
 
854 854
 							break;
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
 						}
1074 1074
 
1075 1075
 						for ($i = 0; $i < 7; ++$i) {
1076
-							if ($nday == 5 && (1 << ((gmdate("w", $occenddate) - $i) % 7)) & $weekdays) {
1076
+							if ($nday == 5 && (1 << ((gmdate("w", $occenddate) - $i) % 7))&$weekdays) {
1077 1077
 								$occenddate -= $i * 24 * 60 * 60;
1078 1078
 
1079 1079
 								break;
1080 1080
 							}
1081
-							if ($nday != 5 && (1 << ((gmdate("w", $occenddate) + $i) % 7)) & $weekdays) {
1081
+							if ($nday != 5 && (1 << ((gmdate("w", $occenddate) + $i) % 7))&$weekdays) {
1082 1082
 								$occenddate += ($i + (($nday - 1) * 7)) * 24 * 60 * 60;
1083 1083
 
1084 1084
 								break;
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
 						}
1823 1823
 						elseif ($this->recur['regen']) {
1824 1824
 							$year_starttime = $this->gmtime($now);
1825
-							$is_next_leapyear = $this->isLeapYear($year_starttime['tm_year'] + 1900 + 1);	// +1 next year
1825
+							$is_next_leapyear = $this->isLeapYear($year_starttime['tm_year'] + 1900 + 1); // +1 next year
1826 1826
 							$now = $daystart + ($is_next_leapyear ? 31622400 /* Leap year in seconds */ : 31536000 /* year in seconds */);
1827 1827
 							if ($now <= $dayend) {
1828 1828
 								$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
Please login to merge, or discard this patch.
tests/grommunio-dav/GrommunioDavBackendTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@
 block discarded – undo
62 62
 	 */
63 63
 	public function ObjectUriProvider() {
64 64
 		return [
65
-			['1234.ics', '.ics', '1234'],               // ok, cut .ics
66
-			['5678AF.vcf', '.vcf', '5678AF'],           // ok, cut .vcf
67
-			['123400.vcf', '.ics', '123400.vcf'],       // different extension, return as is
68
-			['1234.ics', '.vcf', '1234.ics'],            // different extension, return as is
65
+			['1234.ics', '.ics', '1234'], // ok, cut .ics
66
+			['5678AF.vcf', '.vcf', '5678AF'], // ok, cut .vcf
67
+			['123400.vcf', '.ics', '123400.vcf'], // different extension, return as is
68
+			['1234.ics', '.vcf', '1234.ics'], // different extension, return as is
69 69
 		];
70 70
 	}
71 71
 }
Please login to merge, or discard this patch.
lib/GrommunioDavBackend.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		// TODO limit the output to subfolders of the principalUri?
118 118
 
119 119
 		$rootfolder = mapi_msgstore_openentry($this->GetStore($principalUri));
120
-		$hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH | MAPI_DEFERRED_ERRORS);
120
+		$hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH|MAPI_DEFERRED_ERRORS);
121 121
 		// TODO also filter hidden folders
122 122
 		$restrictions = [];
123 123
 		foreach ($classes as $class) {
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 					],
654 654
 				], // EXISTS OR
655 655
 			],
656
-		];        // global OR
656
+		]; // global OR
657 657
 	}
658 658
 
659 659
 	/**
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 		// the config. If there are more changes than MAX_SYNC_ITEMS the client will eventually catch up and sync
700 700
 		// the rest on the subsequent sync request(s).
701 701
 		$bufferSize = ($limit !== null && $limit > 0) ? $limit : MAX_SYNC_ITEMS;
702
-		mapi_exportchanges_config($exporter, $stream, SYNC_NORMAL | SYNC_UNICODE, $mapiimporter, null, false, false, $bufferSize);
702
+		mapi_exportchanges_config($exporter, $stream, SYNC_NORMAL|SYNC_UNICODE, $mapiimporter, null, false, false, $bufferSize);
703 703
 		$changesCount = mapi_exportchanges_getchangecount($exporter);
704 704
 		$this->logger->debug("Exporter found %d changes, buffer size for mapi_exportchanges_synchronize %d", $changesCount, $bufferSize);
705 705
 		while ((is_array(mapi_exportchanges_synchronize($exporter)))) {
Please login to merge, or discard this patch.
mapi/class.taskrecurrence.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -300,7 +300,7 @@
 block discarded – undo
300 300
 
301 301
 			if (!empty($msgbody) && strrpos($msgbody, $separator) === false) {
302 302
 				$msgbody = $separator . $msgbody;
303
-				$stream = mapi_openproperty($this->message, PR_BODY, IID_IStream, 0, MAPI_CREATE | MAPI_MODIFY);
303
+				$stream = mapi_openproperty($this->message, PR_BODY, IID_IStream, 0, MAPI_CREATE|MAPI_MODIFY);
304 304
 				mapi_stream_setsize($stream, strlen($msgbody));
305 305
 				mapi_stream_write($stream, $msgbody);
306 306
 				mapi_stream_commit($stream);
Please login to merge, or discard this patch.
mapi/class.recurrence.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 			$props[PR_EXCEPTION_ENDTIME] = $this->fromGMT($this->tz, $exception_props[$this->proptags["duedate"]]);
726 726
 			mapi_setprops($attachment, $props);
727 727
 
728
-			$imessage = mapi_attach_openobj($attachment, MAPI_CREATE | MAPI_MODIFY);
728
+			$imessage = mapi_attach_openobj($attachment, MAPI_CREATE|MAPI_MODIFY);
729 729
 
730 730
 			if ($copy_attach_from) {
731 731
 				$attachmentTable = mapi_message_getattachmenttable($copy_attach_from);
@@ -1089,13 +1089,13 @@  discard block
 block discarded – undo
1089 1089
 			// Remove all deleted recipients
1090 1090
 			if (isset($exception_recips['remove'])) {
1091 1091
 				foreach ($exception_recips['remove'] as &$recip) {
1092
-					if (!isset($recipient[PR_RECIPIENT_FLAGS]) || $recip[PR_RECIPIENT_FLAGS] != (recipReserved | recipExceptionalDeleted | recipSendable)) {
1093
-						$recip[PR_RECIPIENT_FLAGS] = recipSendable | recipExceptionalDeleted;
1092
+					if (!isset($recipient[PR_RECIPIENT_FLAGS]) || $recip[PR_RECIPIENT_FLAGS] != (recipReserved|recipExceptionalDeleted|recipSendable)) {
1093
+						$recip[PR_RECIPIENT_FLAGS] = recipSendable|recipExceptionalDeleted;
1094 1094
 					}
1095 1095
 					else {
1096
-						$recip[PR_RECIPIENT_FLAGS] = recipReserved | recipExceptionalDeleted | recipSendable;
1096
+						$recip[PR_RECIPIENT_FLAGS] = recipReserved|recipExceptionalDeleted|recipSendable;
1097 1097
 					}
1098
-					$recip[PR_RECIPIENT_TRACKSTATUS] = olResponseNone;		// No Response required
1098
+					$recip[PR_RECIPIENT_TRACKSTATUS] = olResponseNone; // No Response required
1099 1099
 				}
1100 1100
 				unset($recip);
1101 1101
 				mapi_message_modifyrecipients($exception, MODRECIP_MODIFY, $exception_recips['remove']);
@@ -1165,13 +1165,13 @@  discard block
 block discarded – undo
1165 1165
 
1166 1166
 						// If recipient is not in list of deleted recipient, add him
1167 1167
 						if (!$foundInDeletedRecipients) {
1168
-							if (!isset($recipient[PR_RECIPIENT_FLAGS]) || $recipient[PR_RECIPIENT_FLAGS] != (recipReserved | recipExceptionalDeleted | recipSendable)) {
1169
-								$recipient[PR_RECIPIENT_FLAGS] = recipSendable | recipExceptionalDeleted;
1168
+							if (!isset($recipient[PR_RECIPIENT_FLAGS]) || $recipient[PR_RECIPIENT_FLAGS] != (recipReserved|recipExceptionalDeleted|recipSendable)) {
1169
+								$recipient[PR_RECIPIENT_FLAGS] = recipSendable|recipExceptionalDeleted;
1170 1170
 							}
1171 1171
 							else {
1172
-								$recipient[PR_RECIPIENT_FLAGS] = recipReserved | recipExceptionalDeleted | recipSendable;
1172
+								$recipient[PR_RECIPIENT_FLAGS] = recipReserved|recipExceptionalDeleted|recipSendable;
1173 1173
 							}
1174
-							$recipient[PR_RECIPIENT_TRACKSTATUS] = olRecipientTrackStatusNone;	// No Response required
1174
+							$recipient[PR_RECIPIENT_TRACKSTATUS] = olRecipientTrackStatusNone; // No Response required
1175 1175
 							$deletedRecipients[] = $recipient;
1176 1176
 						}
1177 1177
 					}
@@ -1230,12 +1230,12 @@  discard block
 block discarded – undo
1230 1230
 			$hasOrganizer = false;
1231 1231
 			// Check if meeting already has an organizer.
1232 1232
 			foreach ($recipients as $key => $recipient) {
1233
-				if (isset($recipient[PR_RECIPIENT_FLAGS]) && $recipient[PR_RECIPIENT_FLAGS] == (recipSendable | recipOrganizer)) {
1233
+				if (isset($recipient[PR_RECIPIENT_FLAGS]) && $recipient[PR_RECIPIENT_FLAGS] == (recipSendable|recipOrganizer)) {
1234 1234
 					$hasOrganizer = true;
1235 1235
 				}
1236 1236
 				elseif ($isException && !isset($recipient[PR_RECIPIENT_FLAGS])) {
1237 1237
 					// Recipients for an occurrence
1238
-					$recipients[$key][PR_RECIPIENT_FLAGS] = recipSendable | recipExceptionalResponse;
1238
+					$recipients[$key][PR_RECIPIENT_FLAGS] = recipSendable|recipExceptionalResponse;
1239 1239
 				}
1240 1240
 			}
1241 1241
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 				$organizer[PR_RECIPIENT_DISPLAY_NAME] = $messageProps[PR_SENT_REPRESENTING_NAME];
1250 1250
 				$organizer[PR_ADDRTYPE] = empty($messageProps[PR_SENT_REPRESENTING_ADDRTYPE]) ? 'SMTP' : $messageProps[PR_SENT_REPRESENTING_ADDRTYPE];
1251 1251
 				$organizer[PR_RECIPIENT_TRACKSTATUS] = olRecipientTrackStatusNone;
1252
-				$organizer[PR_RECIPIENT_FLAGS] = recipSendable | recipOrganizer;
1252
+				$organizer[PR_RECIPIENT_FLAGS] = recipSendable|recipOrganizer;
1253 1253
 				$organizer[PR_SEARCH_KEY] = $messageProps[PR_SENT_REPRESENTING_SEARCH_KEY];
1254 1254
 
1255 1255
 				// Add organizer to recipients list.
Please login to merge, or discard this patch.