|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only |
|
5
|
|
|
* SPDX-FileCopyrightText: Copyright 2005-2016 Zarafa Deutschland GmbH |
|
6
|
|
|
* SPDX-FileCopyrightText: Copyright 2020-2024 grommunio GmbH |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* MAPIException |
|
11
|
|
|
* if enabled using mapi_enable_exceptions then php-ext can throw exceptions when |
|
12
|
|
|
* any error occurs in mapi calls. this exception will only be thrown when severity bit is set in |
|
13
|
|
|
* error code that means it will be thrown only for mapi errors not for mapi warnings. |
|
14
|
|
|
*/ |
|
15
|
|
|
class MAPIException extends BaseException { |
|
16
|
|
|
/** |
|
17
|
|
|
* Returns display message of exception if its set by the callee. |
|
18
|
|
|
* If it is not set then we are generating some default display messages based |
|
19
|
|
|
* on mapi error code. |
|
20
|
|
|
*/ |
|
21
|
|
|
#[Override] |
|
22
|
|
|
public function getDisplayMessage(): string { |
|
23
|
|
|
if (!empty($this->displayMessage)) { |
|
24
|
|
|
return $this->displayMessage; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
return match ($this->getCode()) { |
|
28
|
|
|
MAPI_E_NO_ACCESS => _("You have insufficient privileges to open this object."), |
|
29
|
|
|
ecUnknownUser, MAPI_E_LOGON_FAILED, MAPI_E_UNCONFIGURED => _("Logon Failed. Please check your name/password."), |
|
30
|
|
|
MAPI_E_NETWORK_ERROR => _("Can not connect to Gromox."), |
|
31
|
|
|
MAPI_E_UNKNOWN_ENTRYID => _("Can not open object with provided id."), |
|
32
|
|
|
MAPI_E_NO_RECIPIENTS => _("There are no recipients in the message."), |
|
33
|
|
|
MAPI_E_NOT_FOUND => _("Can not find object."), |
|
34
|
|
|
MAPI_E_NOT_ENOUGH_MEMORY => _("Operation failed: Server does not have enough memory."), |
|
35
|
|
|
default => sprintf(_("Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode())), |
|
36
|
|
|
}; |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
// Tell the PHP extension which exception class to instantiate |
|
41
|
|
|
if (function_exists('mapi_enable_exceptions')) { |
|
42
|
|
|
mapi_enable_exceptions("mapiexception"); |
|
43
|
|
|
} |
|
44
|
|
|
|