@@ -45,37 +45,37 @@ |
||
| 45 | 45 | |
| 46 | 46 | case 'server.index.load.custom': |
| 47 | 47 | switch ($data['name']) { |
| 48 | - case 'files_get_recipients': |
|
| 49 | - RecipientHandler::doGetRecipients(); |
|
| 50 | - break; |
|
| 48 | + case 'files_get_recipients': |
|
| 49 | + RecipientHandler::doGetRecipients(); |
|
| 50 | + break; |
|
| 51 | 51 | |
| 52 | - case 'download_file': |
|
| 53 | - DownloadHandler::doDownload(); |
|
| 54 | - break; |
|
| 52 | + case 'download_file': |
|
| 53 | + DownloadHandler::doDownload(); |
|
| 54 | + break; |
|
| 55 | 55 | |
| 56 | - case 'upload_file': |
|
| 57 | - UploadHandler::doUpload(); |
|
| 58 | - break; |
|
| 56 | + case 'upload_file': |
|
| 57 | + UploadHandler::doUpload(); |
|
| 58 | + break; |
|
| 59 | 59 | |
| 60 | - case 'form': |
|
| 61 | - if (isset($_GET['backend'])) { |
|
| 62 | - $backend = urldecode($_GET["backend"]); |
|
| 63 | - } |
|
| 64 | - else { |
|
| 65 | - $backend = ''; |
|
| 66 | - } |
|
| 67 | - $backendstore = Files\Backend\BackendStore::getInstance(); |
|
| 60 | + case 'form': |
|
| 61 | + if (isset($_GET['backend'])) { |
|
| 62 | + $backend = urldecode($_GET["backend"]); |
|
| 63 | + } |
|
| 64 | + else { |
|
| 65 | + $backend = ''; |
|
| 66 | + } |
|
| 67 | + $backendstore = Files\Backend\BackendStore::getInstance(); |
|
| 68 | 68 | |
| 69 | - if ($backendstore->backendExists($backend)) { |
|
| 70 | - $backendInstance = $backendstore->getInstanceOfBackend($backend); |
|
| 71 | - $formdata = $backendInstance->getFormConfig(); |
|
| 69 | + if ($backendstore->backendExists($backend)) { |
|
| 70 | + $backendInstance = $backendstore->getInstanceOfBackend($backend); |
|
| 71 | + $formdata = $backendInstance->getFormConfig(); |
|
| 72 | 72 | |
| 73 | - exit($formdata); |
|
| 74 | - } |
|
| 73 | + exit($formdata); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - exit("Specified backend does not exist!"); |
|
| 76 | + exit("Specified backend does not exist!"); |
|
| 77 | 77 | |
| 78 | - break; |
|
| 78 | + break; |
|
| 79 | 79 | } |
| 80 | 80 | break; |
| 81 | 81 | } |
@@ -15,31 +15,31 @@ |
||
| 15 | 15 | $tag = $this->peek(); |
| 16 | 16 | |
| 17 | 17 | switch ($tag) { |
| 18 | - case 0: |
|
| 19 | - $res['otherName'] = $this->oid(-6); |
|
| 20 | - break; |
|
| 21 | - |
|
| 22 | - case 1: |
|
| 23 | - $res['rfc822Name'] = $this->next(-22); |
|
| 24 | - break; |
|
| 25 | - |
|
| 26 | - case 2: |
|
| 27 | - $res['dNSName'] = $this->next(-22); |
|
| 28 | - break; |
|
| 29 | - |
|
| 30 | - case 4: |
|
| 31 | - $this->next(4); |
|
| 32 | - $res['directoryName'] = $this->name(); |
|
| 33 | - $res['directoryName_'] = $this->nameasstring($res['directoryName']); |
|
| 34 | - break; |
|
| 35 | - |
|
| 36 | - case 6: |
|
| 37 | - $res['uniformResourceIdentifier'] = $this->next(-22); |
|
| 38 | - break; |
|
| 39 | - |
|
| 40 | - default: |
|
| 41 | - throw new \Exception("Unsupported GeneralName: {$tag}"); |
|
| 42 | -# trigger_error("Unsupported GeneralName: $tag", E_USER_ERROR); |
|
| 18 | + case 0: |
|
| 19 | + $res['otherName'] = $this->oid(-6); |
|
| 20 | + break; |
|
| 21 | + |
|
| 22 | + case 1: |
|
| 23 | + $res['rfc822Name'] = $this->next(-22); |
|
| 24 | + break; |
|
| 25 | + |
|
| 26 | + case 2: |
|
| 27 | + $res['dNSName'] = $this->next(-22); |
|
| 28 | + break; |
|
| 29 | + |
|
| 30 | + case 4: |
|
| 31 | + $this->next(4); |
|
| 32 | + $res['directoryName'] = $this->name(); |
|
| 33 | + $res['directoryName_'] = $this->nameasstring($res['directoryName']); |
|
| 34 | + break; |
|
| 35 | + |
|
| 36 | + case 6: |
|
| 37 | + $res['uniformResourceIdentifier'] = $this->next(-22); |
|
| 38 | + break; |
|
| 39 | + |
|
| 40 | + default: |
|
| 41 | + throw new \Exception("Unsupported GeneralName: {$tag}"); |
|
| 42 | + # trigger_error("Unsupported GeneralName: $tag", E_USER_ERROR); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | return $res; |
@@ -33,14 +33,14 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | switch ($this->status) { |
| 36 | - case 'good': |
|
| 37 | - return OCSP_CERT_STATUS_GOOD; |
|
| 36 | + case 'good': |
|
| 37 | + return OCSP_CERT_STATUS_GOOD; |
|
| 38 | 38 | |
| 39 | - case 'revoked': |
|
| 40 | - return OCSP_CERT_STATUS_REVOKED; |
|
| 39 | + case 'revoked': |
|
| 40 | + return OCSP_CERT_STATUS_REVOKED; |
|
| 41 | 41 | |
| 42 | - default: |
|
| 43 | - return OCSP_CERT_STATUS_UNKOWN; |
|
| 42 | + default: |
|
| 43 | + return OCSP_CERT_STATUS_UNKOWN; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -29,62 +29,62 @@ |
||
| 29 | 29 | if (!isset($actionType)) |
| 30 | 30 | continue; |
| 31 | 31 | switch ($actionType) { |
| 32 | - case 'certificate': |
|
| 33 | - $data = $this->verifyCertificate($actionData); |
|
| 34 | - $response = [ |
|
| 35 | - 'type' => 3, |
|
| 36 | - 'status' => $data['status'], |
|
| 37 | - 'message' => $data['message'], |
|
| 38 | - 'data' => $data['data'], |
|
| 39 | - ]; |
|
| 40 | - $this->addActionData('certificate', $response); |
|
| 41 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 42 | - break; |
|
| 32 | + case 'certificate': |
|
| 33 | + $data = $this->verifyCertificate($actionData); |
|
| 34 | + $response = [ |
|
| 35 | + 'type' => 3, |
|
| 36 | + 'status' => $data['status'], |
|
| 37 | + 'message' => $data['message'], |
|
| 38 | + 'data' => $data['data'], |
|
| 39 | + ]; |
|
| 40 | + $this->addActionData('certificate', $response); |
|
| 41 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 42 | + break; |
|
| 43 | 43 | |
| 44 | - case 'passphrase': |
|
| 45 | - $data = $this->verifyPassphrase($actionData); |
|
| 46 | - $response = [ |
|
| 47 | - 'type' => 3, |
|
| 48 | - 'status' => $data['status'], |
|
| 49 | - ]; |
|
| 50 | - $this->addActionData('passphrase', $response); |
|
| 51 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 52 | - break; |
|
| 44 | + case 'passphrase': |
|
| 45 | + $data = $this->verifyPassphrase($actionData); |
|
| 46 | + $response = [ |
|
| 47 | + 'type' => 3, |
|
| 48 | + 'status' => $data['status'], |
|
| 49 | + ]; |
|
| 50 | + $this->addActionData('passphrase', $response); |
|
| 51 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 52 | + break; |
|
| 53 | 53 | |
| 54 | - case 'changepassphrase': |
|
| 55 | - $data = $this->changePassphrase($actionData); |
|
| 56 | - if ($data === CHANGE_PASSPHRASE_SUCCESS) { |
|
| 57 | - // Reset cached passphrase. |
|
| 58 | - $encryptionStore = EncryptionStore::getInstance(); |
|
| 59 | - withPHPSession(function () use ($encryptionStore) { |
|
| 60 | - $encryptionStore->add('smime', ''); |
|
| 61 | - }); |
|
| 62 | - } |
|
| 63 | - $response = [ |
|
| 64 | - 'type' => 3, |
|
| 65 | - 'code' => $data, |
|
| 66 | - ]; |
|
| 67 | - $this->addActionData('changepassphrase', $response); |
|
| 68 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 69 | - break; |
|
| 54 | + case 'changepassphrase': |
|
| 55 | + $data = $this->changePassphrase($actionData); |
|
| 56 | + if ($data === CHANGE_PASSPHRASE_SUCCESS) { |
|
| 57 | + // Reset cached passphrase. |
|
| 58 | + $encryptionStore = EncryptionStore::getInstance(); |
|
| 59 | + withPHPSession(function () use ($encryptionStore) { |
|
| 60 | + $encryptionStore->add('smime', ''); |
|
| 61 | + }); |
|
| 62 | + } |
|
| 63 | + $response = [ |
|
| 64 | + 'type' => 3, |
|
| 65 | + 'code' => $data, |
|
| 66 | + ]; |
|
| 67 | + $this->addActionData('changepassphrase', $response); |
|
| 68 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 69 | + break; |
|
| 70 | 70 | |
| 71 | - case 'list': |
|
| 72 | - $data = $this->getPublicCertificates(); |
|
| 73 | - $this->addActionData('list', $data); |
|
| 74 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 75 | - break; |
|
| 71 | + case 'list': |
|
| 72 | + $data = $this->getPublicCertificates(); |
|
| 73 | + $this->addActionData('list', $data); |
|
| 74 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 75 | + break; |
|
| 76 | 76 | |
| 77 | - case 'delete': |
|
| 78 | - // FIXME: handle multiple deletes? Separate function? |
|
| 79 | - $entryid = $actionData['entryid']; |
|
| 80 | - $root = mapi_msgstore_openentry($this->store); |
|
| 81 | - mapi_folder_deletemessages($root, [hex2bin($entryid)]); |
|
| 77 | + case 'delete': |
|
| 78 | + // FIXME: handle multiple deletes? Separate function? |
|
| 79 | + $entryid = $actionData['entryid']; |
|
| 80 | + $root = mapi_msgstore_openentry($this->store); |
|
| 81 | + mapi_folder_deletemessages($root, [hex2bin($entryid)]); |
|
| 82 | 82 | |
| 83 | - $this->sendFeedback(true); |
|
| 84 | - break; |
|
| 83 | + $this->sendFeedback(true); |
|
| 84 | + break; |
|
| 85 | 85 | |
| 86 | - default: |
|
| 87 | - $this->handleUnknownActionType($actionType); |
|
| 86 | + default: |
|
| 87 | + $this->handleUnknownActionType($actionType); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | catch (Exception $e) { |
@@ -64,150 +64,150 @@ discard block |
||
| 64 | 64 | $this->store_entryid = $action["store_entryid"] ?? ''; |
| 65 | 65 | |
| 66 | 66 | switch ($actionType) { |
| 67 | - case "keepalive": |
|
| 68 | - /* |
|
| 67 | + case "keepalive": |
|
| 68 | + /* |
|
| 69 | 69 | * as we haven't done any processing here but still we need to send |
| 70 | 70 | * success message to client so client can know that there isn't any problem |
| 71 | 71 | * on server side (this will also make bus class happy as it will cry when |
| 72 | 72 | * there isn't any data to send to client). |
| 73 | 73 | */ |
| 74 | - $this->sendFeedback(true); |
|
| 75 | - break; |
|
| 74 | + $this->sendFeedback(true); |
|
| 75 | + break; |
|
| 76 | 76 | |
| 77 | - case "destroysession": |
|
| 78 | - // This actiontype should never get this far, but should already have been |
|
| 79 | - // intercepted by the Session class. |
|
| 80 | - // Nevertheless implement processing here for unforeseen cases. |
|
| 81 | - $this->sendFeedback(true); |
|
| 82 | - break; |
|
| 77 | + case "destroysession": |
|
| 78 | + // This actiontype should never get this far, but should already have been |
|
| 79 | + // intercepted by the Session class. |
|
| 80 | + // Nevertheless implement processing here for unforeseen cases. |
|
| 81 | + $this->sendFeedback(true); |
|
| 82 | + break; |
|
| 83 | 83 | |
| 84 | - case "list": |
|
| 85 | - $this->hierarchyList(); |
|
| 86 | - break; |
|
| 84 | + case "list": |
|
| 85 | + $this->hierarchyList(); |
|
| 86 | + break; |
|
| 87 | 87 | |
| 88 | - case "open": |
|
| 89 | - $folder = mapi_msgstore_openentry($store, $entryid); |
|
| 90 | - $data = $this->getFolderProps($store, $folder); |
|
| 88 | + case "open": |
|
| 89 | + $folder = mapi_msgstore_openentry($store, $entryid); |
|
| 90 | + $data = $this->getFolderProps($store, $folder); |
|
| 91 | 91 | |
| 92 | - // return response |
|
| 93 | - $this->addActionData("item", $data); |
|
| 94 | - $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 95 | - break; |
|
| 92 | + // return response |
|
| 93 | + $this->addActionData("item", $data); |
|
| 94 | + $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 95 | + break; |
|
| 96 | 96 | |
| 97 | - case "foldersize": |
|
| 98 | - $folders = []; |
|
| 97 | + case "foldersize": |
|
| 98 | + $folders = []; |
|
| 99 | 99 | |
| 100 | - $folder = mapi_msgstore_openentry($store, $entryid); |
|
| 101 | - $data = $this->getFolderProps($store, $folder); |
|
| 100 | + $folder = mapi_msgstore_openentry($store, $entryid); |
|
| 101 | + $data = $this->getFolderProps($store, $folder); |
|
| 102 | 102 | |
| 103 | - $info = $this->getFolderSize($store, $folder, '', $folders); |
|
| 103 | + $info = $this->getFolderSize($store, $folder, '', $folders); |
|
| 104 | 104 | |
| 105 | - // It could be that the $props already contains the data, |
|
| 106 | - // this happens when the folder is the IPM_SUBTREE and the |
|
| 107 | - // folder size is read directly from the store. Adjust |
|
| 108 | - // total_size accordingly. |
|
| 109 | - if (isset($data["props"]["store_size"])) { |
|
| 110 | - if (!isset($data["props"]["message_size"])) { |
|
| 111 | - $data["props"]["message_size"] = $data["props"]["store_size"]; |
|
| 105 | + // It could be that the $props already contains the data, |
|
| 106 | + // this happens when the folder is the IPM_SUBTREE and the |
|
| 107 | + // folder size is read directly from the store. Adjust |
|
| 108 | + // total_size accordingly. |
|
| 109 | + if (isset($data["props"]["store_size"])) { |
|
| 110 | + if (!isset($data["props"]["message_size"])) { |
|
| 111 | + $data["props"]["message_size"] = $data["props"]["store_size"]; |
|
| 112 | + } |
|
| 113 | + $data["props"]["total_message_size"] = $data["props"]["store_size"] + $info["total_size"]; |
|
| 112 | 114 | } |
| 113 | - $data["props"]["total_message_size"] = $data["props"]["store_size"] + $info["total_size"]; |
|
| 114 | - } |
|
| 115 | - else { |
|
| 116 | - $data["props"]["message_size"] = $info["size"]; |
|
| 117 | - $data["props"]["total_message_size"] = $info["total_size"]; |
|
| 118 | - } |
|
| 119 | - $data["folders"] = [ |
|
| 120 | - "item" => $folders, |
|
| 121 | - ]; |
|
| 122 | - |
|
| 123 | - // return response |
|
| 124 | - $this->addActionData("item", $data); |
|
| 125 | - $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 126 | - break; |
|
| 115 | + else { |
|
| 116 | + $data["props"]["message_size"] = $info["size"]; |
|
| 117 | + $data["props"]["total_message_size"] = $info["total_size"]; |
|
| 118 | + } |
|
| 119 | + $data["folders"] = [ |
|
| 120 | + "item" => $folders, |
|
| 121 | + ]; |
|
| 127 | 122 | |
| 128 | - case "delete": |
|
| 129 | - if (!$store || !$parententryid || !$entryid) |
|
| 130 | - break; |
|
| 131 | - if (!isset($action["message_action"], $action["message_action"]["action_type"]) || |
|
| 132 | - $action["message_action"]["action_type"] !== "removefavorites") { |
|
| 133 | - $this->deleteFolder($store, $parententryid, $entryid, $action); |
|
| 134 | - break; |
|
| 135 | - } |
|
| 136 | - if (!isset($action["message_action"]["isSearchFolder"]) || |
|
| 137 | - !$action["message_action"]["isSearchFolder"]) { |
|
| 138 | - $this->removeFromFavorite($entryid); |
|
| 123 | + // return response |
|
| 124 | + $this->addActionData("item", $data); |
|
| 125 | + $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 139 | 126 | break; |
| 140 | - } |
|
| 141 | - $result = $this->deleteSearchFolder($store, $parententryid, $entryid, $action); |
|
| 142 | - dump($result, '$result'); |
|
| 143 | - if ($result) { |
|
| 144 | - $this->sendFeedback(true); |
|
| 145 | - } |
|
| 146 | - break; |
|
| 147 | 127 | |
| 148 | - case "save": |
|
| 149 | - if (!$store || !$parententryid) |
|
| 150 | - break; |
|
| 151 | - if ($entryid) { |
|
| 152 | - // The "message_action" object has been set, check the action_type field for |
|
| 153 | - // the exact action which must be taken. |
|
| 154 | - // Supported actions: |
|
| 155 | - // - copy: Copy the folder to the new destination folder |
|
| 156 | - // - move: Move the folder to the new destination folder |
|
| 157 | - // - emptyfolder: Delete all items within the folder |
|
| 158 | - // - readflags: Mark all items within the folder as read |
|
| 159 | - // - addtofavorites: Add the folder to "favorites" |
|
| 160 | - if (!isset($action["message_action"]["isSearchFolder"])) { |
|
| 161 | - $folder = mapi_msgstore_openentry($store, $entryid); |
|
| 162 | - $data = $this->getFolderProps($store, $folder); |
|
| 128 | + case "delete": |
|
| 129 | + if (!$store || !$parententryid || !$entryid) |
|
| 130 | + break; |
|
| 131 | + if (!isset($action["message_action"], $action["message_action"]["action_type"]) || |
|
| 132 | + $action["message_action"]["action_type"] !== "removefavorites") { |
|
| 133 | + $this->deleteFolder($store, $parententryid, $entryid, $action); |
|
| 134 | + break; |
|
| 163 | 135 | } |
| 164 | - if (isset($action["message_action"], $action["message_action"]["action_type"])) { |
|
| 165 | - switch ($action["message_action"]["action_type"]) { |
|
| 166 | - case "copy": |
|
| 167 | - case "move": |
|
| 168 | - $destentryid = false; |
|
| 169 | - if (isset($action["message_action"]["destination_parent_entryid"])) { |
|
| 170 | - $destentryid = hex2bin($action["message_action"]["destination_parent_entryid"]); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - $deststore = $store; |
|
| 174 | - if (isset($action["message_action"]["destination_store_entryid"])) { |
|
| 175 | - $deststore = $GLOBALS['mapisession']->openMessageStore(hex2bin($action["message_action"]["destination_store_entryid"])); |
|
| 176 | - } |
|
| 136 | + if (!isset($action["message_action"]["isSearchFolder"]) || |
|
| 137 | + !$action["message_action"]["isSearchFolder"]) { |
|
| 138 | + $this->removeFromFavorite($entryid); |
|
| 139 | + break; |
|
| 140 | + } |
|
| 141 | + $result = $this->deleteSearchFolder($store, $parententryid, $entryid, $action); |
|
| 142 | + dump($result, '$result'); |
|
| 143 | + if ($result) { |
|
| 144 | + $this->sendFeedback(true); |
|
| 145 | + } |
|
| 146 | + break; |
|
| 177 | 147 | |
| 178 | - if ($destentryid && $deststore) { |
|
| 179 | - $this->copyFolder($store, $parententryid, $entryid, $destentryid, $deststore, $action["message_action"]["action_type"] == "move"); |
|
| 180 | - } |
|
| 181 | - if ($data["props"]["container_class"] === "IPF.Contact") { |
|
| 182 | - $GLOBALS["bus"]->notify(ADDRESSBOOK_ENTRYID, OBJECT_SAVE); |
|
| 183 | - } |
|
| 184 | - break; |
|
| 148 | + case "save": |
|
| 149 | + if (!$store || !$parententryid) |
|
| 150 | + break; |
|
| 151 | + if ($entryid) { |
|
| 152 | + // The "message_action" object has been set, check the action_type field for |
|
| 153 | + // the exact action which must be taken. |
|
| 154 | + // Supported actions: |
|
| 155 | + // - copy: Copy the folder to the new destination folder |
|
| 156 | + // - move: Move the folder to the new destination folder |
|
| 157 | + // - emptyfolder: Delete all items within the folder |
|
| 158 | + // - readflags: Mark all items within the folder as read |
|
| 159 | + // - addtofavorites: Add the folder to "favorites" |
|
| 160 | + if (!isset($action["message_action"]["isSearchFolder"])) { |
|
| 161 | + $folder = mapi_msgstore_openentry($store, $entryid); |
|
| 162 | + $data = $this->getFolderProps($store, $folder); |
|
| 163 | + } |
|
| 164 | + if (isset($action["message_action"], $action["message_action"]["action_type"])) { |
|
| 165 | + switch ($action["message_action"]["action_type"]) { |
|
| 166 | + case "copy": |
|
| 167 | + case "move": |
|
| 168 | + $destentryid = false; |
|
| 169 | + if (isset($action["message_action"]["destination_parent_entryid"])) { |
|
| 170 | + $destentryid = hex2bin($action["message_action"]["destination_parent_entryid"]); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + $deststore = $store; |
|
| 174 | + if (isset($action["message_action"]["destination_store_entryid"])) { |
|
| 175 | + $deststore = $GLOBALS['mapisession']->openMessageStore(hex2bin($action["message_action"]["destination_store_entryid"])); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + if ($destentryid && $deststore) { |
|
| 179 | + $this->copyFolder($store, $parententryid, $entryid, $destentryid, $deststore, $action["message_action"]["action_type"] == "move"); |
|
| 180 | + } |
|
| 181 | + if ($data["props"]["container_class"] === "IPF.Contact") { |
|
| 182 | + $GLOBALS["bus"]->notify(ADDRESSBOOK_ENTRYID, OBJECT_SAVE); |
|
| 183 | + } |
|
| 184 | + break; |
|
| 185 | 185 | |
| 186 | - case "emptyfolder": |
|
| 187 | - $this->emptyFolder($store, $entryid); |
|
| 188 | - break; |
|
| 186 | + case "emptyfolder": |
|
| 187 | + $this->emptyFolder($store, $entryid); |
|
| 188 | + break; |
|
| 189 | 189 | |
| 190 | - case "readflags": |
|
| 191 | - $this->setReadFlags($store, $entryid); |
|
| 192 | - break; |
|
| 190 | + case "readflags": |
|
| 191 | + $this->setReadFlags($store, $entryid); |
|
| 192 | + break; |
|
| 193 | 193 | |
| 194 | - case "addtofavorites": |
|
| 195 | - if (isset($action["message_action"]["isSearchFolder"]) && $action["message_action"]["isSearchFolder"]) { |
|
| 196 | - $searchStoreEntryId = $action["message_action"]["search_store_entryid"]; |
|
| 197 | - // Set display name to search folder. |
|
| 198 | - $searchStore = $GLOBALS["mapisession"]->openMessageStore(hex2bin($searchStoreEntryId)); |
|
| 199 | - $searchFolder = mapi_msgstore_openentry($searchStore, $entryid); |
|
| 200 | - mapi_setprops($searchFolder, [ |
|
| 201 | - PR_DISPLAY_NAME => $action["props"]["display_name"], |
|
| 202 | - ]); |
|
| 203 | - mapi_savechanges($searchFolder); |
|
| 204 | - $this->createLinkedSearchFolder($searchFolder); |
|
| 205 | - } |
|
| 206 | - else { |
|
| 207 | - $this->addToFavorite($store, $entryid); |
|
| 194 | + case "addtofavorites": |
|
| 195 | + if (isset($action["message_action"]["isSearchFolder"]) && $action["message_action"]["isSearchFolder"]) { |
|
| 196 | + $searchStoreEntryId = $action["message_action"]["search_store_entryid"]; |
|
| 197 | + // Set display name to search folder. |
|
| 198 | + $searchStore = $GLOBALS["mapisession"]->openMessageStore(hex2bin($searchStoreEntryId)); |
|
| 199 | + $searchFolder = mapi_msgstore_openentry($searchStore, $entryid); |
|
| 200 | + mapi_setprops($searchFolder, [ |
|
| 201 | + PR_DISPLAY_NAME => $action["props"]["display_name"], |
|
| 202 | + ]); |
|
| 203 | + mapi_savechanges($searchFolder); |
|
| 204 | + $this->createLinkedSearchFolder($searchFolder); |
|
| 205 | + } |
|
| 206 | + else { |
|
| 207 | + $this->addToFavorite($store, $entryid); |
|
| 208 | + } |
|
| 209 | + break; |
|
| 208 | 210 | } |
| 209 | - break; |
|
| 210 | - } |
|
| 211 | 211 | } |
| 212 | 212 | else { |
| 213 | 213 | // save folder |
@@ -262,93 +262,93 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | break; |
| 264 | 264 | |
| 265 | - case "closesharedfolder": |
|
| 266 | - if (isset($action["folder_type"]) && $action["folder_type"] != "all") { |
|
| 267 | - // We're closing a Shared folder, check if we still have other |
|
| 268 | - // folders for the same user opened, if not we can safely close |
|
| 269 | - // the usrstore. |
|
| 270 | - $stores = $GLOBALS["settings"]->get("zarafa/v1/contexts/hierarchy/shared_stores/" . strtolower(bin2hex($action["user_name"]))); |
|
| 271 | - if (!isset($stores) || empty($stores) || (count($stores) == 1 && isset($stores[$action["folder_type"]]))) { |
|
| 272 | - $entryid = $GLOBALS["mapisession"]->removeUserStore($action["user_name"]); |
|
| 265 | + case "closesharedfolder": |
|
| 266 | + if (isset($action["folder_type"]) && $action["folder_type"] != "all") { |
|
| 267 | + // We're closing a Shared folder, check if we still have other |
|
| 268 | + // folders for the same user opened, if not we can safely close |
|
| 269 | + // the usrstore. |
|
| 270 | + $stores = $GLOBALS["settings"]->get("zarafa/v1/contexts/hierarchy/shared_stores/" . strtolower(bin2hex($action["user_name"]))); |
|
| 271 | + if (!isset($stores) || empty($stores) || (count($stores) == 1 && isset($stores[$action["folder_type"]]))) { |
|
| 272 | + $entryid = $GLOBALS["mapisession"]->removeUserStore($action["user_name"]); |
|
| 273 | + } |
|
| 274 | + else { |
|
| 275 | + $entryid = $GLOBALS["mapisession"]->getStoreEntryIdOfUser($action["user_name"]); |
|
| 276 | + $this->removeFromFavorite(hex2bin($action["entryid"]), $store, PR_WLINK_ENTRYID, false); |
|
| 277 | + } |
|
| 273 | 278 | } |
| 274 | 279 | else { |
| 275 | - $entryid = $GLOBALS["mapisession"]->getStoreEntryIdOfUser($action["user_name"]); |
|
| 276 | - $this->removeFromFavorite(hex2bin($action["entryid"]), $store, PR_WLINK_ENTRYID, false); |
|
| 280 | + // We're closing a Shared Store, simply remove it from the session. |
|
| 281 | + $entryid = $GLOBALS["mapisession"]->removeUserStore($action["user_name"]); |
|
| 282 | + |
|
| 283 | + if (isset($action["remove_favorites"]) && $action["remove_favorites"]) { |
|
| 284 | + $this->removeFromFavorite(hex2bin($action["store_entryid"]), $store, PR_WLINK_STORE_ENTRYID, false); |
|
| 285 | + } |
|
| 277 | 286 | } |
| 278 | - } |
|
| 279 | - else { |
|
| 280 | - // We're closing a Shared Store, simply remove it from the session. |
|
| 281 | - $entryid = $GLOBALS["mapisession"]->removeUserStore($action["user_name"]); |
|
| 282 | 287 | |
| 283 | - if (isset($action["remove_favorites"]) && $action["remove_favorites"]) { |
|
| 284 | - $this->removeFromFavorite(hex2bin($action["store_entryid"]), $store, PR_WLINK_STORE_ENTRYID, false); |
|
| 288 | + $data = []; |
|
| 289 | + $data["store_entryid"] = bin2hex($entryid); |
|
| 290 | + if (isset($action["folder_type"])) { |
|
| 291 | + $data["folder_type"] = $action["folder_type"]; |
|
| 285 | 292 | } |
| 286 | - } |
|
| 287 | 293 | |
| 288 | - $data = []; |
|
| 289 | - $data["store_entryid"] = bin2hex($entryid); |
|
| 290 | - if (isset($action["folder_type"])) { |
|
| 291 | - $data["folder_type"] = $action["folder_type"]; |
|
| 292 | - } |
|
| 294 | + $this->addActionData("delete", $data); |
|
| 295 | + $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 296 | + $GLOBALS["bus"]->notify(ADDRESSBOOK_ENTRYID, OBJECT_SAVE); |
|
| 297 | + break; |
|
| 293 | 298 | |
| 294 | - $this->addActionData("delete", $data); |
|
| 295 | - $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 296 | - $GLOBALS["bus"]->notify(ADDRESSBOOK_ENTRYID, OBJECT_SAVE); |
|
| 297 | - break; |
|
| 299 | + case "opensharedfolder": |
|
| 300 | + $username = strtolower($action["user_name"]); |
|
| 301 | + $store = $GLOBALS["mapisession"]->addUserStore($username); |
|
| 302 | + if (!$store) { |
|
| 303 | + break; |
|
| 304 | + } |
|
| 298 | 305 | |
| 299 | - case "opensharedfolder": |
|
| 300 | - $username = strtolower($action["user_name"]); |
|
| 301 | - $store = $GLOBALS["mapisession"]->addUserStore($username); |
|
| 302 | - if (!$store) { |
|
| 303 | - break; |
|
| 304 | - } |
|
| 306 | + $options = [$username => [$action["folder_type"] => $action]]; |
|
| 307 | + $data = $GLOBALS["operations"]->getHierarchyList($this->list_properties, HIERARCHY_GET_ONE, $store, $options, $username); |
|
| 305 | 308 | |
| 306 | - $options = [$username => [$action["folder_type"] => $action]]; |
|
| 307 | - $data = $GLOBALS["operations"]->getHierarchyList($this->list_properties, HIERARCHY_GET_ONE, $store, $options, $username); |
|
| 309 | + if (empty($data["item"][0]["folders"]["item"])) { |
|
| 310 | + throw new MAPIException(null, MAPI_E_NO_ACCESS); |
|
| 311 | + } |
|
| 308 | 312 | |
| 309 | - if (empty($data["item"][0]["folders"]["item"])) { |
|
| 310 | - throw new MAPIException(null, MAPI_E_NO_ACCESS); |
|
| 311 | - } |
|
| 313 | + $folders = count($data["item"][0]["folders"]["item"]); |
|
| 314 | + if ($folders === 0) { |
|
| 315 | + throw new MAPIException(null, MAPI_E_NO_ACCESS); |
|
| 316 | + } |
|
| 312 | 317 | |
| 313 | - $folders = count($data["item"][0]["folders"]["item"]); |
|
| 314 | - if ($folders === 0) { |
|
| 315 | - throw new MAPIException(null, MAPI_E_NO_ACCESS); |
|
| 316 | - } |
|
| 318 | + $noPermissionFolders = array_filter($data['item'][0]['folders']['item'], function ($item) { |
|
| 319 | + return $item['props']['access'] === 0; |
|
| 320 | + }); |
|
| 321 | + if (count($noPermissionFolders) >= $folders) { |
|
| 322 | + // Throw an exception that we couldn't open the shared store, |
|
| 323 | + // lets have processException() fill in our error message. |
|
| 324 | + throw new MAPIException(null, MAPI_E_NO_ACCESS); |
|
| 325 | + } |
|
| 317 | 326 | |
| 318 | - $noPermissionFolders = array_filter($data['item'][0]['folders']['item'], function ($item) { |
|
| 319 | - return $item['props']['access'] === 0; |
|
| 320 | - }); |
|
| 321 | - if (count($noPermissionFolders) >= $folders) { |
|
| 322 | - // Throw an exception that we couldn't open the shared store, |
|
| 323 | - // lets have processException() fill in our error message. |
|
| 324 | - throw new MAPIException(null, MAPI_E_NO_ACCESS); |
|
| 325 | - } |
|
| 327 | + $this->addActionData("list", $data); |
|
| 328 | + $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 329 | + $GLOBALS["bus"]->notify(ADDRESSBOOK_ENTRYID, OBJECT_SAVE); |
|
| 330 | + break; |
|
| 326 | 331 | |
| 327 | - $this->addActionData("list", $data); |
|
| 328 | - $GLOBALS["bus"]->addData($this->getResponseData()); |
|
| 329 | - $GLOBALS["bus"]->notify(ADDRESSBOOK_ENTRYID, OBJECT_SAVE); |
|
| 330 | - break; |
|
| 332 | + case "sharedstoreupdate": |
|
| 333 | + $supported_types = ['inbox' => 1, 'all' => 1]; |
|
| 334 | + $users = $GLOBALS["settings"]->get("zarafa/v1/contexts/hierarchy/shared_stores", []); |
|
| 331 | 335 | |
| 332 | - case "sharedstoreupdate": |
|
| 333 | - $supported_types = ['inbox' => 1, 'all' => 1]; |
|
| 334 | - $users = $GLOBALS["settings"]->get("zarafa/v1/contexts/hierarchy/shared_stores", []); |
|
| 336 | + foreach ($users as $username => $data) { |
|
| 337 | + $key = array_keys($data)[0]; |
|
| 338 | + $folder_type = $data[$key]['folder_type']; |
|
| 335 | 339 | |
| 336 | - foreach ($users as $username => $data) { |
|
| 337 | - $key = array_keys($data)[0]; |
|
| 338 | - $folder_type = $data[$key]['folder_type']; |
|
| 340 | + if (!isset($supported_types[$folder_type])) { |
|
| 341 | + continue; |
|
| 342 | + } |
|
| 339 | 343 | |
| 340 | - if (!isset($supported_types[$folder_type])) { |
|
| 341 | - continue; |
|
| 344 | + $GLOBALS["bus"]->notify(REQUEST_ENTRYID, HIERARCHY_UPDATE, [strtolower(hex2bin($username)), $folder_type]); |
|
| 342 | 345 | } |
| 343 | 346 | |
| 344 | - $GLOBALS["bus"]->notify(REQUEST_ENTRYID, HIERARCHY_UPDATE, [strtolower(hex2bin($username)), $folder_type]); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - $this->sendFeedback(true); |
|
| 348 | - break; |
|
| 347 | + $this->sendFeedback(true); |
|
| 348 | + break; |
|
| 349 | 349 | |
| 350 | - default: |
|
| 351 | - $this->handleUnknownActionType($actionType); |
|
| 350 | + default: |
|
| 351 | + $this->handleUnknownActionType($actionType); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | catch (MAPIException $e) { |