zimbraSingle.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * WHMCS Zimbra Provisioning Module
  4. *
  5. * Provisioning for private user accounts on the Zimbra Server
  6. *
  7. * @see https://www.zimbra.com
  8. * @copyright Copyright (c) Thurdata GmbH 2020
  9. * @license GPL
  10. */
  11. if (!defined("WHMCS")) {
  12. die("This file cannot be accessed directly");
  13. }
  14. require_once dirname(__FILE__) . '/zimbraSingle.inc';
  15. function zimbraSingle_TestConnection($params)
  16. {
  17. $auth = new Zm_Auth($params['serverip'], $params['serverusername'], $params['serverpassword'], "admin");
  18. $login = $auth->login();
  19. if(is_a($login, "Exception")) {
  20. logModuleCall(
  21. 'zimbrasingle',
  22. __FUNCTION__,
  23. $params,
  24. "Connection test to " . $params['serverip'] . " failed: Cannot login",
  25. $login->getMessage()
  26. );
  27. return array(
  28. 'success' => false,
  29. 'error' => "Connection test to " . $params['serverip'] . " failed, the error was: " . $login->getMessage(),
  30. );
  31. } else {
  32. return array(
  33. 'success' => true,
  34. 'error' => '',
  35. );
  36. }
  37. }
  38. function zimbraSingle_UsageUpdate($params)
  39. {
  40. }
  41. function zimbraSingle_ClientArea($params)
  42. {
  43. $response = zimbraSingleClientArea($params['customfields']);
  44. return array(
  45. 'templatefile' => 'clientarea',
  46. 'vars' => array(
  47. 'webmailURL' => $response[0]['DATA'],
  48. ),
  49. );
  50. }
  51. function zimbraSingle_ChangePassword($params)
  52. {
  53. $response = zimbraSingleChangePassword($params['customfields']);
  54. if($response) {
  55. return 'success';
  56. }
  57. return $response;
  58. }
  59. function zimbraSingle_CreateAccount($params)
  60. {
  61. $response = zimbraSingleCreateAccount($params['customfields']);
  62. if($response) {
  63. return 'success';
  64. }
  65. return 'Error creating account';
  66. }
  67. function zimbraSingle_SuspendAccount($params)
  68. {
  69. $response = zimbraSingleSuspendAccount($params['customfields']);
  70. if($response) {
  71. return 'success';
  72. }
  73. return 'Error suspending account';
  74. }
  75. function zimbraSingle_UnsuspendAccount($params)
  76. {
  77. $response = zimbraSingleUnsuspendAccount($params['customfields']);
  78. if($response) {
  79. return 'success';
  80. }
  81. return 'Error unsuspending account';
  82. }
  83. function zimbraSingle_TerminateAccount($params)
  84. {
  85. $response = zimbraSingleDeleteAccount($params['customfields']);
  86. if($response) {
  87. return 'success';
  88. }
  89. return 'Error deleting account';
  90. }
  91. function zimbraSingle_ChangePackage($params)
  92. {
  93. $response = zimbraSingleChangePackage($params['customfields']);
  94. if($response) {
  95. return 'success';
  96. }
  97. return 'Error changing package';
  98. }
  99. function zimbraSingle_ConfigOptions()
  100. {
  101. $appInfo = new WHMCS\Application;
  102. $response = zimbraSingleConfigOptions($appInfo);
  103. if($response) {
  104. return $response;
  105. }
  106. return 'Error setting config options';
  107. }
  108. function zimbraSingle_genUsername($name)
  109. {
  110. /* $namelen = strlen($name);
  111. $result = select_query("tblhosting","COUNT(*)",array("username" => $name));
  112. $data = mysql_fetch_array($result);
  113. $username_exists = $data[0];
  114. $suffix=0;
  115. while ($username_exists > 0) {
  116. $suffix++;
  117. $name = substr($name,0,$namelen).$suffix;
  118. $result = select_query( "tblhosting", "COUNT(*)", array( "username" => $name ) );
  119. $data = mysql_fetch_array($result);
  120. $username_exists = $data[0];
  121. }
  122. return $name; */
  123. }