zimbraSingle.php 3.6 KB

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