class.mapiexception.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * Copyright 2005 - 2016 Zarafa and its licensors
  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.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Affero General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. ?>
  19. <?
  20. /**
  21. * MAPIException
  22. * if enabled using mapi_enable_exceptions then php-ext can throw exceptions when
  23. * any error occurs in mapi calls. this exception will only be thrown when severity bit is set in
  24. * error code that means it will be thrown only for mapi errors not for mapi warnings.
  25. */
  26. class MAPIException extends BaseException {
  27. /**
  28. * Function will return display message of exception if its set by the calle.
  29. * if it is not set then we are generating some default display messages based
  30. * on mapi error code.
  31. * @return string returns error-message that should be sent to client to display.
  32. */
  33. public function getDisplayMessage()
  34. {
  35. if(!empty($this->displayMessage))
  36. return $this->displayMessage;
  37. switch($this->getCode())
  38. {
  39. case MAPI_E_NO_ACCESS:
  40. return dgettext("kopano","You have insufficient privileges to open this object.");
  41. case MAPI_E_LOGON_FAILED:
  42. case MAPI_E_UNCONFIGURED:
  43. return dgettext("kopano","Logon Failed. Please check your name/password.");
  44. case MAPI_E_NETWORK_ERROR:
  45. return dgettext("kopano","Can not connect to storage server.");
  46. case MAPI_E_UNKNOWN_ENTRYID:
  47. return dgettext("kopano","Can not open object with provided id.");
  48. case MAPI_E_NO_RECIPIENTS:
  49. return dgettext("kopano","There are no recipients in the message.");
  50. case MAPI_E_NOT_FOUND:
  51. return dgettext("kopano","Can not find object.");
  52. case MAPI_E_INTERFACE_NOT_SUPPORTED:
  53. case MAPI_E_INVALID_PARAMETER:
  54. case MAPI_E_INVALID_ENTRYID:
  55. case MAPI_E_INVALID_OBJECT:
  56. case MAPI_E_TOO_COMPLEX:
  57. case MAPI_E_CORRUPT_DATA:
  58. case MAPI_E_END_OF_SESSION:
  59. case MAPI_E_AMBIGUOUS_RECIP:
  60. case MAPI_E_COLLISION:
  61. case MAPI_E_UNCONFIGURED:
  62. default:
  63. return sprintf(dgettext("kopano","Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode()));
  64. }
  65. }
  66. }
  67. // Tell the PHP extension which exception class to instantiate
  68. if (function_exists('mapi_enable_exceptions')) {
  69. mapi_enable_exceptions("mapiexception");
  70. }
  71. ?>