1 | <?php |
---|
2 | /* |
---|
3 | * Copyright 2005 - 2012 Zarafa B.V. |
---|
4 | * |
---|
5 | * This program is free software: you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU Affero General Public License, version 3, |
---|
7 | * as published by the Free Software Foundation with the following additional |
---|
8 | * term according to sec. 7: |
---|
9 | * |
---|
10 | * According to sec. 7 of the GNU Affero General Public License, version |
---|
11 | * 3, the terms of the AGPL are supplemented with the following terms: |
---|
12 | * |
---|
13 | * "Zarafa" is a registered trademark of Zarafa B.V. The licensing of |
---|
14 | * the Program under the AGPL does not imply a trademark license. |
---|
15 | * Therefore any rights, title and interest in our trademarks remain |
---|
16 | * entirely with us. |
---|
17 | * |
---|
18 | * However, if you propagate an unmodified version of the Program you are |
---|
19 | * allowed to use the term "Zarafa" to indicate that you distribute the |
---|
20 | * Program. Furthermore you may use our trademarks where it is necessary |
---|
21 | * to indicate the intended purpose of a product or service provided you |
---|
22 | * use it in accordance with honest practices in industrial or commercial |
---|
23 | * matters. If you want to propagate modified versions of the Program |
---|
24 | * under the name "Zarafa" or "Zarafa Server", you may only do so if you |
---|
25 | * have a written permission by Zarafa B.V. (to acquire a permission |
---|
26 | * please contact Zarafa at trademark@zarafa.com). |
---|
27 | * |
---|
28 | * The interactive user interface of the software displays an attribution |
---|
29 | * notice containing the term "Zarafa" and/or the logo of Zarafa. |
---|
30 | * Interactive user interfaces of unmodified and modified versions must |
---|
31 | * display Appropriate Legal Notices according to sec. 5 of the GNU |
---|
32 | * Affero General Public License, version 3, when you propagate |
---|
33 | * unmodified or modified versions of the Program. In accordance with |
---|
34 | * sec. 7 b) of the GNU Affero General Public License, version 3, these |
---|
35 | * Appropriate Legal Notices must retain the logo of Zarafa or display |
---|
36 | * the words "Initial Development by Zarafa" if the display of the logo |
---|
37 | * is not reasonably feasible for technical reasons. The use of the logo |
---|
38 | * of Zarafa in Legal Notices is allowed for unmodified and modified |
---|
39 | * versions of the software. |
---|
40 | * |
---|
41 | * This program is distributed in the hope that it will be useful, |
---|
42 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
43 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
44 | * GNU Affero General Public License for more details. |
---|
45 | * |
---|
46 | * You should have received a copy of the GNU Affero General Public License |
---|
47 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
48 | * |
---|
49 | */ |
---|
50 | |
---|
51 | |
---|
52 | /** |
---|
53 | * MAPIException |
---|
54 | * if enabled using mapi_enable_exceptions then php-ext can throw exceptions when |
---|
55 | * any error occurs in mapi calls. this exception will only be thrown when severity bit is set in |
---|
56 | * error code that means it will be thrown only for mapi errors not for mapi warnings. |
---|
57 | */ |
---|
58 | // FatalException will trigger a HTTP return code 500 to the mobile |
---|
59 | class MAPIException extends FatalException |
---|
60 | { |
---|
61 | /** |
---|
62 | * Function will return display message of exception if its set by the calle. |
---|
63 | * if it is not set then we are generating some default display messages based |
---|
64 | * on mapi error code. |
---|
65 | * @return string returns error-message that should be sent to client to display. |
---|
66 | */ |
---|
67 | public function getDisplayMessage() |
---|
68 | { |
---|
69 | if(!empty($this->displayMessage)) |
---|
70 | return $this->displayMessage; |
---|
71 | |
---|
72 | switch($this->getCode()) |
---|
73 | { |
---|
74 | case MAPI_E_NO_ACCESS: |
---|
75 | return _("You have insufficient privileges to open this object."); |
---|
76 | case MAPI_E_LOGON_FAILED: |
---|
77 | case MAPI_E_UNCONFIGURED: |
---|
78 | return _("Logon Failed. Please check your username/password."); |
---|
79 | case MAPI_E_NETWORK_ERROR: |
---|
80 | return _("Can not connect to Zarafa server."); |
---|
81 | case MAPI_E_UNKNOWN_ENTRYID: |
---|
82 | return _("Can not open object with provided id."); |
---|
83 | case MAPI_E_NO_RECIPIENTS: |
---|
84 | return _("There are no recipients in the message."); |
---|
85 | case MAPI_E_NOT_FOUND: |
---|
86 | return _("Can not find object."); |
---|
87 | case MAPI_E_INTERFACE_NOT_SUPPORTED: |
---|
88 | case MAPI_E_INVALID_PARAMETER: |
---|
89 | case MAPI_E_INVALID_ENTRYID: |
---|
90 | case MAPI_E_INVALID_OBJECT: |
---|
91 | case MAPI_E_TOO_COMPLEX: |
---|
92 | case MAPI_E_CORRUPT_DATA: |
---|
93 | case MAPI_E_END_OF_SESSION: |
---|
94 | case MAPI_E_AMBIGUOUS_RECIP: |
---|
95 | case MAPI_E_COLLISION: |
---|
96 | case MAPI_E_UNCONFIGURED: |
---|
97 | default : |
---|
98 | return sprintf(_("Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode())); |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | // Tell the PHP extension which exception class to instantiate |
---|
104 | if (function_exists('mapi_enable_exceptions')) { |
---|
105 | //mapi_enable_exceptions("mapiexception"); |
---|
106 | } |
---|
107 | ?> |
---|