grommunio /
mapi-header-php
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * This class is just static class and will not be instantiate and |
||||||
| 5 | * It contains the functionality to get freebusy message and folder. |
||||||
| 6 | */ |
||||||
| 7 | class FreeBusy { |
||||||
| 8 | /** |
||||||
| 9 | * PR_FREEBUSY_ENTRYIDS contains 4 entryids |
||||||
| 10 | * PR_FREEBUSY_ENTRYIDS[0] gives associated freebusy folder in calendar |
||||||
| 11 | * PR_FREEBUSY_ENTRYIDS[1] Localfreebusy (used for delegate properties) |
||||||
| 12 | * PR_FREEBUSY_ENTRYIDS[2] global Freebusydata in public store |
||||||
| 13 | * PR_FREEBUSY_ENTRYIDS[3] Freebusydata in IPM_SUBTREE. |
||||||
| 14 | */ |
||||||
| 15 | public const ASSOCIATED_FREEBUSY_FOLDER = 0; |
||||||
| 16 | public const DELEGATE_PROPERTIES = 1; |
||||||
| 17 | public const GLOBAL_FREEBUSYDATA = 2; |
||||||
| 18 | public const FREEBUSYDATA_IPM_SUBTREE = 3; |
||||||
| 19 | |||||||
| 20 | /** |
||||||
| 21 | * Function will return resource of the local freebusy message of the user's store. |
||||||
| 22 | * |
||||||
| 23 | * @param mixed $store (optional) user's store |
||||||
| 24 | * |
||||||
| 25 | * @return bool|resource local freebusy message, otherwise false if message not found |
||||||
| 26 | */ |
||||||
| 27 | public static function getLocalFreeBusyMessage($store = false) { |
||||||
| 28 | if (!$store) { |
||||||
| 29 | error_log("getLocalFreeBusyMessage: store not available"); |
||||||
| 30 | |||||||
| 31 | return false; |
||||||
| 32 | } |
||||||
| 33 | |||||||
| 34 | // Check for mapi_freebusy_openmsg function, |
||||||
| 35 | // If yes then use mapi function to get freebusy message. |
||||||
| 36 | if (function_exists('mapi_freebusy_openmsg')) { |
||||||
| 37 | return mapi_freebusy_openmsg($store); |
||||||
| 38 | } |
||||||
| 39 | |||||||
| 40 | // Get 'LocalFreeBusy' message from FreeBusy Store |
||||||
| 41 | $root = mapi_msgstore_openentry($store, null); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 42 | $storeProps = mapi_getprops($root, [PR_FREEBUSY_ENTRYIDS]); |
||||||
|
0 ignored issues
–
show
The function
mapi_getprops was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 43 | $localFreeBusyEntryids = $storeProps[PR_FREEBUSY_ENTRYIDS]; |
||||||
| 44 | |||||||
| 45 | try { |
||||||
| 46 | return mapi_msgstore_openentry($store, $localFreeBusyEntryids[self::DELEGATE_PROPERTIES]); |
||||||
| 47 | } |
||||||
| 48 | catch (MAPIException $e) { |
||||||
| 49 | // Either user store have malformed entryid in PR_FREEBUSY_ENTRYIDS or |
||||||
| 50 | // No message found of given entryid in 'Freebusy Data' folder. |
||||||
| 51 | if ($e->getCode() == MAPI_E_NOT_FOUND || $e->getCode() == MAPI_E_INVALID_ENTRYID) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 52 | $freeBusyFolder = mapi_msgstore_openentry($store, $localFreeBusyEntryids[self::FREEBUSYDATA_IPM_SUBTREE]); |
||||||
| 53 | $table = mapi_folder_getcontentstable($freeBusyFolder); |
||||||
|
0 ignored issues
–
show
The function
mapi_folder_getcontentstable was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 54 | mapi_table_restrict( |
||||||
|
0 ignored issues
–
show
The function
mapi_table_restrict was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 55 | $table, |
||||||
| 56 | [ |
||||||
| 57 | RES_CONTENT, |
||||||
| 58 | [ |
||||||
| 59 | FUZZYLEVEL => FL_PREFIX, |
||||||
| 60 | ULPROPTAG => PR_MESSAGE_CLASS, |
||||||
|
0 ignored issues
–
show
|
|||||||
| 61 | VALUE => [PR_MESSAGE_CLASS => "IPM.Microsoft.ScheduleData.FreeBusy"], |
||||||
| 62 | ], |
||||||
| 63 | ] |
||||||
| 64 | ); |
||||||
| 65 | |||||||
| 66 | $items = mapi_table_queryallrows($table, [PR_ENTRYID]); |
||||||
|
0 ignored issues
–
show
The function
mapi_table_queryallrows was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 67 | if (empty($items)) { |
||||||
| 68 | // FIXME recreate local freebusy message in 'Freebusy Data' folder. |
||||||
| 69 | error_log("Unable to find local free busy message in 'Freebusy Data' folder"); |
||||||
| 70 | |||||||
| 71 | return false; |
||||||
| 72 | } |
||||||
| 73 | |||||||
| 74 | $localFreeBusyEntryids[1] = $items[0][PR_ENTRYID]; |
||||||
| 75 | |||||||
| 76 | // Updating the entryid in the PR_FREEBUSY_ENTRYIDS property of user store. |
||||||
| 77 | mapi_setprops($root, [PR_FREEBUSY_ENTRYIDS => $localFreeBusyEntryids]); |
||||||
|
0 ignored issues
–
show
The function
mapi_setprops was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 78 | mapi_savechanges($root); |
||||||
|
0 ignored issues
–
show
The function
mapi_savechanges was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 79 | |||||||
| 80 | return mapi_msgstore_openentry($store, $localFreeBusyEntryids[self::DELEGATE_PROPERTIES]); |
||||||
| 81 | } |
||||||
| 82 | } |
||||||
| 83 | } |
||||||
| 84 | |||||||
| 85 | /** |
||||||
| 86 | * Function will return resource of the freebusy folder of the user's store. |
||||||
| 87 | * |
||||||
| 88 | * @param mixed $store (optional) user's store |
||||||
| 89 | * |
||||||
| 90 | * @return bool|resource freebusy folder |
||||||
| 91 | */ |
||||||
| 92 | public static function getLocalFreeBusyFolder($store = false) { |
||||||
| 93 | if (!$store) { |
||||||
| 94 | error_log("getLocalFreeBusyFolder: store not available"); |
||||||
| 95 | |||||||
| 96 | return false; |
||||||
| 97 | } |
||||||
| 98 | // Get 'LocalFreeBusy' message from FreeBusy Store |
||||||
| 99 | $root = mapi_msgstore_openentry($store, null); |
||||||
|
0 ignored issues
–
show
The function
mapi_msgstore_openentry was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 100 | $storeProps = mapi_getprops($root, [PR_FREEBUSY_ENTRYIDS]); |
||||||
|
0 ignored issues
–
show
The function
mapi_getprops was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 101 | |||||||
| 102 | return mapi_msgstore_openentry($store, $storeProps[PR_FREEBUSY_ENTRYIDS][self::FREEBUSYDATA_IPM_SUBTREE]); |
||||||
| 103 | } |
||||||
| 104 | } |
||||||
| 105 |