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