Passed
Push — master ( 7a8062...ff661f )
by
unknown
13:06
created

class.mapiexception.php (18 issues)

Labels
Severity
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
The constant MAPI_E_NO_ACCESS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
				return dgettext("zarafa", "You have insufficient privileges to open this object.");
32
33
			case ecUnknownUser:
0 ignored issues
show
The constant ecUnknownUser was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
			case MAPI_E_LOGON_FAILED:
0 ignored issues
show
The constant MAPI_E_LOGON_FAILED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
			case MAPI_E_UNCONFIGURED:
0 ignored issues
show
The constant MAPI_E_UNCONFIGURED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
36
				return dgettext("zarafa", "Logon Failed. Please check your name/password.");
37
38
			case MAPI_E_NETWORK_ERROR:
0 ignored issues
show
The constant MAPI_E_NETWORK_ERROR was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
39
				return dgettext("zarafa", "Can not connect to Gromox.");
40
41
			case MAPI_E_UNKNOWN_ENTRYID:
0 ignored issues
show
The constant MAPI_E_UNKNOWN_ENTRYID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
42
				return dgettext("zarafa", "Can not open object with provided id.");
43
44
			case MAPI_E_NO_RECIPIENTS:
0 ignored issues
show
The constant MAPI_E_NO_RECIPIENTS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
45
				return dgettext("zarafa", "There are no recipients in the message.");
46
47
			case MAPI_E_NOT_FOUND:
0 ignored issues
show
The constant MAPI_E_NOT_FOUND was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
48
				return dgettext("zarafa", "Can not find object.");
49
50
			case MAPI_E_NOT_ENOUGH_MEMORY:
0 ignored issues
show
The constant MAPI_E_NOT_ENOUGH_MEMORY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
51
				return dgettext("zarafa", "Operation failed: Server does not have enough memory.");
52
53
			case MAPI_E_INTERFACE_NOT_SUPPORTED:
0 ignored issues
show
The constant MAPI_E_INTERFACE_NOT_SUPPORTED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
54
			case MAPI_E_INVALID_PARAMETER:
0 ignored issues
show
The constant MAPI_E_INVALID_PARAMETER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
			case MAPI_E_INVALID_ENTRYID:
0 ignored issues
show
The constant MAPI_E_INVALID_ENTRYID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
56
			case MAPI_E_INVALID_OBJECT:
0 ignored issues
show
The constant MAPI_E_INVALID_OBJECT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
57
			case MAPI_E_TOO_COMPLEX:
0 ignored issues
show
The constant MAPI_E_TOO_COMPLEX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
58
			case MAPI_E_CORRUPT_DATA:
0 ignored issues
show
The constant MAPI_E_CORRUPT_DATA was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
59
			case MAPI_E_END_OF_SESSION:
0 ignored issues
show
The constant MAPI_E_END_OF_SESSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
60
			case MAPI_E_AMBIGUOUS_RECIP:
0 ignored issues
show
The constant MAPI_E_AMBIGUOUS_RECIP was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
61
			case MAPI_E_COLLISION:
0 ignored issues
show
The constant MAPI_E_COLLISION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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