1 | <?php |
||
2 | /* |
||
3 | * SPDX-License-Identifier: AGPL-3.0-only |
||
4 | * SPDX-FileCopyrightText: Copyright 2005-2016 Zarafa Deutschland GmbH |
||
5 | * SPDX-FileCopyrightText: Copyright 2020-2022 grommunio GmbH |
||
6 | */ |
||
7 | |||
8 | /** |
||
9 | * MAPIException |
||
10 | * if enabled using mapi_enable_exceptions then php-ext can throw exceptions when |
||
11 | * any error occurs in mapi calls. this exception will only be thrown when severity bit is set in |
||
12 | * error code that means it will be thrown only for mapi errors not for mapi warnings. |
||
13 | */ |
||
14 | class MAPIException extends BaseException { |
||
15 | /** |
||
16 | * Function will return display message of exception if its set by the callee. |
||
17 | * if it is not set then we are generating some default display messages based |
||
18 | * on mapi error code. |
||
19 | * |
||
20 | * @return string returns error-message that should be sent to client to display |
||
21 | */ |
||
22 | public function getDisplayMessage() { |
||
23 | if (!empty($this->displayMessage)) { |
||
24 | return $this->displayMessage; |
||
25 | } |
||
26 | |||
27 | switch ($this->getCode()) { |
||
28 | /* see also class.webappauthentication.php:getErrorMessage for more instances */ |
||
29 | |||
30 | case MAPI_E_NO_ACCESS: |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
31 | return dgettext("zarafa", "You have insufficient privileges to open this object."); |
||
32 | |||
33 | case ecUnknownUser: |
||
0 ignored issues
–
show
|
|||
34 | case MAPI_E_LOGON_FAILED: |
||
0 ignored issues
–
show
|
|||
35 | case MAPI_E_UNCONFIGURED: |
||
0 ignored issues
–
show
|
|||
36 | return dgettext("zarafa", "Logon Failed. Please check your name/password."); |
||
37 | |||
38 | case MAPI_E_NETWORK_ERROR: |
||
0 ignored issues
–
show
|
|||
39 | return dgettext("zarafa", "Can not connect to Gromox."); |
||
40 | |||
41 | case MAPI_E_UNKNOWN_ENTRYID: |
||
0 ignored issues
–
show
|
|||
42 | return dgettext("zarafa", "Can not open object with provided id."); |
||
43 | |||
44 | case MAPI_E_NO_RECIPIENTS: |
||
0 ignored issues
–
show
|
|||
45 | return dgettext("zarafa", "There are no recipients in the message."); |
||
46 | |||
47 | case MAPI_E_NOT_FOUND: |
||
0 ignored issues
–
show
|
|||
48 | return dgettext("zarafa", "Can not find object."); |
||
49 | |||
50 | case MAPI_E_NOT_ENOUGH_MEMORY: |
||
0 ignored issues
–
show
|
|||
51 | return dgettext("zarafa", "Operation failed: Server does not have enough memory."); |
||
52 | |||
53 | case MAPI_E_INTERFACE_NOT_SUPPORTED: |
||
0 ignored issues
–
show
|
|||
54 | case MAPI_E_INVALID_PARAMETER: |
||
0 ignored issues
–
show
|
|||
55 | case MAPI_E_INVALID_ENTRYID: |
||
0 ignored issues
–
show
|
|||
56 | case MAPI_E_INVALID_OBJECT: |
||
0 ignored issues
–
show
|
|||
57 | case MAPI_E_TOO_COMPLEX: |
||
0 ignored issues
–
show
|
|||
58 | case MAPI_E_CORRUPT_DATA: |
||
0 ignored issues
–
show
|
|||
59 | case MAPI_E_END_OF_SESSION: |
||
0 ignored issues
–
show
|
|||
60 | case MAPI_E_AMBIGUOUS_RECIP: |
||
0 ignored issues
–
show
|
|||
61 | case MAPI_E_COLLISION: |
||
0 ignored issues
–
show
|
|||
62 | case MAPI_E_UNCONFIGURED: |
||
63 | default: |
||
64 | return sprintf(dgettext("zarafa", "Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode())); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | |||
69 | // Tell the PHP extension which exception class to instantiate |
||
70 | if (function_exists('mapi_enable_exceptions')) { |
||
71 | mapi_enable_exceptions("mapiexception"); |
||
72 | } |
||
73 |