Test Failed
Push — master ( 647c72...cd42b5 )
by
unknown
10:25
created

server/includes/exceptions/class.mapiexception.php (1 issue)

1
<?php
2
	/**
3
	 * MAPIException
4
	 * if enabled using mapi_enable_exceptions then php-ext can throw exceptions when
5
	 * any error occurs in mapi calls. this exception will only be thrown when severity bit is set in
6
	 * error code that means it will be thrown only for mapi errors not for mapi warnings.
7
	 */
8
	class MAPIException extends BaseException
9
	{
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
		 * @return string returns error-message that should be sent to client to display.
15
		 */
16
		public function getDisplayMessage()
17
		{
18
			if(!empty($this->displayMessage))
19
				return $this->displayMessage;
20
21
			switch($this->getCode())
22
			{
23
				case MAPI_E_NO_ACCESS:
24
					return dgettext("zarafa","You have insufficient privileges to open this object.");
25
				case MAPI_E_LOGON_FAILED:
26
				case MAPI_E_UNCONFIGURED:
27
					return dgettext("zarafa","Logon Failed. Please check your name/password.");
28
				case MAPI_E_NETWORK_ERROR:
29
					return dgettext("zarafa","Can not connect to Gromox.");
30
				case MAPI_E_UNKNOWN_ENTRYID:
31
					return dgettext("zarafa","Can not open object with provided id.");
32
				case MAPI_E_NO_RECIPIENTS:
33
					return dgettext("zarafa","There are no recipients in the message.");
34
				case MAPI_E_NOT_FOUND:
35
					return dgettext("zarafa","Can not find object.");
36
				case MAPI_E_NOT_ENOUGH_MEMORY:
37
					return dgettext("zarafa","Operation failed: Server does not have enough memory.");
38
				case MAPI_E_INTERFACE_NOT_SUPPORTED:
39
				case MAPI_E_INVALID_PARAMETER:
40
				case MAPI_E_INVALID_ENTRYID:
41
				case MAPI_E_INVALID_OBJECT:
42
				case MAPI_E_TOO_COMPLEX:
43
				case MAPI_E_CORRUPT_DATA:
44
				case MAPI_E_END_OF_SESSION:
45
				case MAPI_E_AMBIGUOUS_RECIP:
46
				case MAPI_E_COLLISION:
47
				case MAPI_E_UNCONFIGURED:
48
				default:
49
					return sprintf(dgettext("zarafa","Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode()));
50
			}
51
		}
52
	}
53
54
	// Tell the PHP extension which exception class to instantiate
55
	if (function_exists('mapi_enable_exceptions')) {
56
		mapi_enable_exceptions("mapiexception");
57
	}
58
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
59