zimbraSingle.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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_ClientArea($params)
  39. {
  40. $response = zimbraSingleClientArea($params['customfields']);
  41. logModuleCall(
  42. 'zimbrasingle',
  43. __FUNCTION__,
  44. $params,
  45. "debug: clientarea",
  46. $response
  47. );
  48. return array(
  49. 'templatefile' => 'clientarea',
  50. 'vars' => array($response),
  51. );
  52. }
  53. function zimbraSingle_ChangePassword($params)
  54. {
  55. $response = zimbraSingleChangePassword($params['customfields']);
  56. if($response == 'success') {
  57. return 'success';
  58. }
  59. return $response;
  60. }
  61. function zimbraSingle_CreateAccount($params)
  62. {
  63. $response = zimbraSingleCreateAccount($params['customfields']);
  64. if($response) {
  65. return 'success';
  66. }
  67. return 'Error creating account';
  68. }
  69. function zimbraSingle_SuspendAccount($params)
  70. {
  71. $response = zimbraSingleSuspendAccount($params['customfields']);
  72. if($response) {
  73. return 'success';
  74. }
  75. return 'Error suspending account';
  76. }
  77. function zimbraSingle_UnsuspendAccount($params)
  78. {
  79. $response = zimbraSingleUnsuspendAccount($params['customfields']);
  80. if($response) {
  81. return 'success';
  82. }
  83. return 'Error unsuspending account';
  84. }
  85. function zimbraSingle_TerminateAccount($params)
  86. {
  87. $response = zimbraSingleDeleteAccount($params['customfields']);
  88. if($response == 'success') {
  89. return 'success';
  90. }
  91. return $response;
  92. }
  93. function zimbraSingle_ChangePackage($params)
  94. {
  95. $response = zimbraSingleChangePackage($params['customfields']);
  96. if($response) {
  97. return 'success';
  98. }
  99. return 'Error changing package';
  100. }
  101. function zimbraSingle_ConfigOptions($params)
  102. {
  103. if(isset($_POST['packageconfigoption'])) {
  104. zimbraSingleCreateCustomFields($_POST['packageconfigoption']);
  105. }
  106. $response = zimbraSingleConfigOptions($params);
  107. if($response) {
  108. return $response;
  109. }
  110. return 'Error setting config options';
  111. }
  112. function zimbraSingle_genUsername($name)
  113. {
  114. /* $namelen = strlen($name);
  115. $result = select_query("tblhosting","COUNT(*)",array("username" => $name));
  116. $data = mysql_fetch_array($result);
  117. $username_exists = $data[0];
  118. $suffix=0;
  119. while ($username_exists > 0) {
  120. $suffix++;
  121. $name = substr($name,0,$namelen).$suffix;
  122. $result = select_query( "tblhosting", "COUNT(*)", array( "username" => $name ) );
  123. $data = mysql_fetch_array($result);
  124. $username_exists = $data[0];
  125. }
  126. return $name; */
  127. }