zimbraSingle.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. use WHMCS\Database\Capsule;
  15. require_once dirname(__FILE__) . '/zimbraSingle.inc';
  16. function zimbraSingle_TestConnection($params)
  17. {
  18. $auth = new Zm_Auth($params['serverip'], $params['serverusername'], $params['serverpassword'], "admin");
  19. $login = $auth->login();
  20. if(is_a($login, "Exception")) {
  21. logModuleCall(
  22. 'zimbrasingle',
  23. __FUNCTION__,
  24. $params,
  25. "Connection test to " . $params['serverip'] . " failed: Cannot login",
  26. $login->getMessage()
  27. );
  28. return array(
  29. 'success' => false,
  30. 'error' => "Connection test to " . $params['serverip'] . " failed, the error was: " . $login->getMessage(),
  31. );
  32. } else {
  33. return array(
  34. 'success' => true,
  35. 'error' => '',
  36. );
  37. }
  38. }
  39. function zimbraSingle_ClientArea($params)
  40. {
  41. $response = zimbraSingleClientArea($params['customfields']);
  42. return array(
  43. 'templatefile' => 'clientarea',
  44. 'vars' => $response,
  45. );
  46. }
  47. function zimbraSingle_ChangePassword($params)
  48. {
  49. $response = zimbraSingleChangePassword($params);
  50. if($response == 'success') {
  51. return 'success';
  52. }
  53. return $response;
  54. }
  55. function zimbraSingle_CreateAccount($params)
  56. {
  57. $response = zimbraSingleCreateAccount($params['customfields']);
  58. if($response) {
  59. return 'success';
  60. }
  61. return 'Error creating account';
  62. }
  63. function zimbraSingle_SuspendAccount($params)
  64. {
  65. $response = zimbraSingleSuspendAccount($params['customfields']);
  66. if($response) {
  67. return 'success';
  68. }
  69. return 'Error suspending account';
  70. }
  71. function zimbraSingle_UnsuspendAccount($params)
  72. {
  73. $response = zimbraSingleUnsuspendAccount($params['customfields']);
  74. if($response) {
  75. return 'success';
  76. }
  77. return 'Error unsuspending account';
  78. }
  79. function zimbraSingle_TerminateAccount($params)
  80. {
  81. $response = zimbraSingleDeleteAccount($params['customfields']);
  82. if($response == 'success') {
  83. return 'success';
  84. }
  85. return $response;
  86. }
  87. function zimbraSingle_ChangePackage($params)
  88. {
  89. $response = zimbraSingleChangePackage($params['customfields']);
  90. if($response) {
  91. return 'success';
  92. }
  93. return 'Error changing package';
  94. }
  95. function zimbraSingle_ConfigOptions($params)
  96. {
  97. if(isset($_POST['packageconfigoption'])) {
  98. zimbraSingleCreateCustomFields($_POST['packageconfigoption']);
  99. }
  100. $response = zimbraSingleConfigOptions($params);
  101. if($response) {
  102. return $response;
  103. }
  104. return 'Error setting config options';
  105. }
  106. function zimbraSingle_genUsername($name)
  107. {
  108. /* $namelen = strlen($name);
  109. $result = select_query("tblhosting","COUNT(*)",array("username" => $name));
  110. $data = mysql_fetch_array($result);
  111. $username_exists = $data[0];
  112. $suffix=0;
  113. while ($username_exists > 0) {
  114. $suffix++;
  115. $name = substr($name,0,$namelen).$suffix;
  116. $result = select_query( "tblhosting", "COUNT(*)", array( "username" => $name ) );
  117. $data = mysql_fetch_array($result);
  118. $username_exists = $data[0];
  119. }
  120. return $name; */
  121. }