diff --git a/WebsitePanel.WHMCSModule/changelog.log b/WebsitePanel.WHMCSModule/changelog.log index 02488cf6..e570fc7b 100644 --- a/WebsitePanel.WHMCSModule/changelog.log +++ b/WebsitePanel.WHMCSModule/changelog.log @@ -1,3 +1,6 @@ +04/16/2013 (1.3) +* Some refactoring done + 01/29/2013 (1.2) * WebsitePanel addons no longer require the storage of the Enterprise Server credentials * Error codes are not properly resolved to their text responses \ No newline at end of file diff --git a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php index 52ddeef0..b8a0fe99 100644 --- a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php +++ b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php @@ -76,14 +76,14 @@ function websitepanel_addons_AddonActivation($params) $wsp = new WebsitePanel($srvSettings['username'], $srvSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE)); // Grab the user's details from WebsitePanel in order to get the user's id - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); if (empty($user)) { return; } // Get the user's current WebsitePanel hosting space Id (Hosting Plan) - $package = $wsp->get_user_packages($user['UserId']); + $package = $wsp->getUserPackages($user['UserId']); $packageId = $package['PackageId']; if (empty($packageId)) { @@ -97,7 +97,7 @@ function websitepanel_addons_AddonActivation($params) $addonIsIpAddress = $addon['is_ipaddress']; // Add the Addon Plan to the customer's WebsitePanel package / hosting space - $results = $wsp->add_package_addon_by_id($packageId, $addonPlanId); + $results = $wsp->addPackageAddonById($packageId, $addonPlanId); // Check the results to verify that the addon has been successfully allocated if ($results['Result'] > 0) @@ -105,7 +105,7 @@ function websitepanel_addons_AddonActivation($params) // If this addon is an IP address addon - attempt to randomly allocate an IP address to the customer's hosting space if ($addonIsIpAddress) { - $wsp->package_allocate_ipaddress($packageId); + $wsp->packageAllocateIpAddress($packageId); } } } diff --git a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php index 0de3f28d..d9129b62 100644 --- a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php +++ b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php @@ -65,7 +65,7 @@ function websitepanel_sync_ClientEdit($params) $wsp = new WebsitePanel($srvSettings['username'], $srvSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE)); // Get all WSP users with the old email - $items = (array)$wsp->get_users_paged_recursive(1, 'Email', $params['olddata']['email'], 0, 0, ''); + $items = (array)$wsp->getUsersPagedRecursive(1, 'Email', $params['olddata']['email'], 0, 0, ''); // Load / parse the XML response $xml = simplexml_load_string($items['any']); @@ -80,10 +80,10 @@ function websitepanel_sync_ClientEdit($params) // Set the current root element and get the users details from WebsitePanel // We cannot use the details provided by the get_users_paged_recursive method as it does not return all the required elements to fully update the user $currentRoot = $rootPath->Table1->$i; - $userDetails = (array)$wsp->get_user_by_username($currentRoot->Username); + $userDetails = (array)$wsp->getUserByUsername($currentRoot->Username); // Update the current user - $wsp->update_user_details($userDetails['RoleId'], (($userDetails['RoleId'] == 2) ? 'Reseller' : 'User'), $userDetails['StatusId'], $userDetails['Status'], $userDetails['LoginStatusId'], $userDetails['LoginStatus'], $userDetails['FailedLogins'], $userDetails['UserId'], $userDetails['OwnerId'], $userDetails['Created'], $userDetails['Changed'], $userDetails['IsDemo'], $userDetails['IsPeer'], $currentRoot->Comments, $userDetails['Username'], $userDetails['Password'], $params['firstname'], $params['lastname'], $params['email'], $params['phonenumber'], $params['postcode'], '', '', '', '', $params['country'], $params['address1'] . (!empty($params['address2']) ? " {$params['address2']}" : ''), $params['city'], $params['state'], TRUE, $params['companyname'], (($userDetails['RoleId'] == 2) ? TRUE : FALSE)); + $wsp->updateUserDetails($userDetails['RoleId'], (($userDetails['RoleId'] == 2) ? 'Reseller' : 'User'), $userDetails['StatusId'], $userDetails['Status'], $userDetails['LoginStatusId'], $userDetails['LoginStatus'], $userDetails['FailedLogins'], $userDetails['UserId'], $userDetails['OwnerId'], $userDetails['Created'], $userDetails['Changed'], $userDetails['IsDemo'], $userDetails['IsPeer'], $currentRoot->Comments, $userDetails['Username'], $userDetails['Password'], $params['firstname'], $params['lastname'], $params['email'], $params['phonenumber'], $params['postcode'], '', '', '', '', $params['country'], $params['address1'] . (!empty($params['address2']) ? " {$params['address2']}" : ''), $params['city'], $params['state'], TRUE, $params['companyname'], (($userDetails['RoleId'] == 2) ? TRUE : FALSE)); // Add log entry to client log logactivity("WebsitePanel Sync - Account {$currentRoot->Username} contact details updated successfully", $params['userid']); diff --git a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php index c9689251..cde28ae6 100644 --- a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php +++ b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php @@ -168,7 +168,7 @@ class WebsitePanel * @param bool $createZoneRecord Create domain DNS zone record (if createMailAccount OR createWebSite are TRUE) * @return int */ - public function create_user_wizard($username, $password, $roleId, $firstName, $lastName, $email, $planId, $parentPackageId, $domainName, $hostName, $htmlMail = TRUE, $sendAccountLetter = TRUE, $sendPackageLetter = TRUE, $createPackage = TRUE, $tempDomain = FALSE, $createWebSite = FALSE, $createFtpAccount = FALSE, $ftpAcountName = '', $createMailAccount = FALSE, $createZoneRecord = FALSE) + public function createUserWizard($username, $password, $roleId, $firstName, $lastName, $email, $planId, $parentPackageId, $domainName, $hostName, $htmlMail = TRUE, $sendAccountLetter = TRUE, $sendPackageLetter = TRUE, $createPackage = TRUE, $tempDomain = FALSE, $createWebSite = FALSE, $createFtpAccount = FALSE, $ftpAcountName = '', $createMailAccount = FALSE, $createZoneRecord = FALSE) { $params = array(); foreach (get_defined_vars() as $key => $value) @@ -178,7 +178,7 @@ class WebsitePanel $params[$key] = $value; } - return $this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'CreateUserWizard', $params)->CreateUserWizardResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'CreateUserWizard', $params)->CreateUserWizardResult; } /** @@ -216,7 +216,7 @@ class WebsitePanel * @param bool $EcommerceEnabled Ecommerce enabled * @return void */ - public function update_user_details($RoleId, $Role, $StatusId, $Status, $LoginStatusId, $LoginStatus, $FailedLogins, $UserId, $OwnerId, $Created, $Changed, $IsDemo, $IsPeer, $Comments, $Username, $Password, $FirstName, $LastName, $Email, $PrimaryPhone, $Zip, $InstantMessenger, $Fax, $SecondaryPhone, $SecondaryEmail, $Country, $Address, $City, $State, $HtmlMail, $CompanyName, $EcommerceEnabled) + public function updateUserDetails($RoleId, $Role, $StatusId, $Status, $LoginStatusId, $LoginStatus, $FailedLogins, $UserId, $OwnerId, $Created, $Changed, $IsDemo, $IsPeer, $Comments, $Username, $Password, $FirstName, $LastName, $Email, $PrimaryPhone, $Zip, $InstantMessenger, $Fax, $SecondaryPhone, $SecondaryEmail, $Country, $Address, $City, $State, $HtmlMail, $CompanyName, $EcommerceEnabled) { $params = array(); foreach (get_defined_vars() as $key => $value) @@ -226,7 +226,7 @@ class WebsitePanel $params[$key] = $value; } - return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'UpdateUser', array('user' => $params))->UpdateUserResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'UpdateUser', array('user' => $params))->UpdateUserResult; } /** @@ -236,9 +236,9 @@ class WebsitePanel * @param int $userid User id * @return int */ - public function delete_user($userId) + public function deleteUser($userId) { - return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'DeleteUser', array('userId' => $userId))->DeleteUserResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'DeleteUser', array('userId' => $userId))->DeleteUserResult; } /** @@ -248,9 +248,9 @@ class WebsitePanel * @param string $username Username * @return array */ - public function get_user_by_username($username) + public function getUserByUsername($username) { - return (array)$this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'GetUserByUsername', array('username' => $username))->GetUserByUsernameResult; + return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'GetUserByUsername', array('username' => $username))->GetUserByUsernameResult; } /** @@ -260,9 +260,9 @@ class WebsitePanel * @param string $status Account status (Active, Suspended, Cancelled, Pending) * @return int */ - public function change_user_status($userId, $status) + public function changeUserStatus($userId, $status) { - return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserStatus', array('userId' => $userId, 'status' => $status))->ChangeUserStatusResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserStatus', array('userId' => $userId, 'status' => $status))->ChangeUserStatusResult; } /** @@ -273,9 +273,9 @@ class WebsitePanel * @param string $password New password * @return int */ - public function change_user_password($userId, $password) + public function changeUserPassword($userId, $password) { - return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserPassword', array('userId' => $userId, 'password' => $password))->ChangeUserPasswordResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserPassword', array('userId' => $userId, 'password' => $password))->ChangeUserPasswordResult; } /** @@ -285,13 +285,14 @@ class WebsitePanel * @param int $userid User id * @return array */ - public function get_user_packages($userid) + public function getUserPackages($userid) { - return (array)$this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'GetMyPackages', array('userId' => $userid))->GetMyPackagesResult->PackageInfo; + return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'GetMyPackages', array('userId' => $userid))->GetMyPackagesResult->PackageInfo; } /** - * + * WebsitePanel::getUsersPagedRecursive() + * * @param int $userId User id * @param string $filterColumn Column name to filter on * @param string $filterValue Filter value @@ -301,14 +302,17 @@ class WebsitePanel * @param int $startRow Row to start at * @param int $maximumRows Maximum rows to return */ - public function get_users_paged_recursive($userId, $filterColumn, $filterValue, $statusId, $roleId, $sortColumn, $startRow = 0, $maximumRows = 999) + public function getUsersPagedRecursive($userId, $filterColumn, $filterValue, $statusId, $roleId, $sortColumn, $startRow = 0, $maximumRows = 999) { $params = array(); - foreach (get_defined_vars() as $name => $value) + foreach (get_defined_vars() as $key => $value) { - $params[$name] = $value; + if ($key == 'params') + continue; + + $params[$key] = $value; } - return $this->execute_server_method(WebSitePanel::SERVICEFILE_USERS, 'GetUsersPagedRecursive', $params)->GetUsersPagedRecursiveResult; + return $this->executeServerMethod(WebSitePanel::SERVICEFILE_USERS, 'GetUsersPagedRecursive', $params)->GetUsersPagedRecursiveResult; } /** @@ -323,7 +327,7 @@ class WebsitePanel * @param string $packageComments Package comments * @return array */ - public function update_package_literal($packageId, $statusId, $planId, $purchaseDate, $packageName, $packageComments) + public function updatePackageLiteral($packageId, $statusId, $planId, $purchaseDate, $packageName, $packageComments) { $params = array(); foreach (get_defined_vars() as $key => $value) @@ -333,11 +337,11 @@ class WebsitePanel $params[$key] = $value; } - return (array)$this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'UpdatePackageLiteral', $params)->UpdatePackageLiteralResult; + return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'UpdatePackageLiteral', $params)->UpdatePackageLiteralResult; } /** - * WebsitePanel::add_package_addon_by_id() + * WebsitePanel::addPackageAddonById() * * @access public * @param mixed $packageId Package id @@ -345,9 +349,9 @@ class WebsitePanel * @param integer $quantity Quantity * @return array */ - public function add_package_addon_by_id($packageId, $addonPlanId, $quantity = 1) + public function addPackageAddonById($packageId, $addonPlanId, $quantity = 1) { - return (array)$this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'AddPackageAddonById', array('packageId' => $packageId, 'addonPlanId' => $addonPlanId, 'quantity' => $quantity))->AddPackageAddonByIdResult; + return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'AddPackageAddonById', array('packageId' => $packageId, 'addonPlanId' => $addonPlanId, 'quantity' => $quantity))->AddPackageAddonByIdResult; } /** @@ -359,9 +363,9 @@ class WebsitePanel * @param string $endDate Ending date * @return object */ - public function get_space_bandwidth_usage($packageId, $startDate, $endDate) + public function getSpaceBandwidthUsage($packageId, $startDate, $endDate) { - return $this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageBandwidth', array('packageId' => $packageId, 'startDate' => $startDate, 'endDate' => $endDate))->GetPackageBandwidthResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageBandwidth', array('packageId' => $packageId, 'startDate' => $startDate, 'endDate' => $endDate))->GetPackageBandwidthResult; } /** @@ -371,13 +375,13 @@ class WebsitePanel * @param int $packageId Package Id * @return object */ - public function get_space_diskspace_usage($packageId) + public function getSpaceDiskspaceUsage($packageId) { - return $this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageDiskspace', array('packageId' => $packageId))->GetPackageDiskspaceResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageDiskspace', array('packageId' => $packageId))->GetPackageDiskspaceResult; } /** - * WebsitePanel::package_allocate_ipaddress() + * WebsitePanel::packageAllocateIpAddress() * * @param mixed $packageId Package id * @param mixed $groupName Group name @@ -386,7 +390,7 @@ class WebsitePanel * @param bool $allocateRandom Allocate IP addresses randomly * @return object */ - public function package_allocate_ipaddress($packageId, $groupName = WebsitePanel::IPADDRESS_POOL_WEB, $pool = WebsitePanel::IPADDRESS_GROUP_WEBSITES, $addressesNumber = 1, $allocateRandom = TRUE) + public function packageAllocateIpAddress($packageId, $groupName = WebsitePanel::IPADDRESS_POOL_WEB, $pool = WebsitePanel::IPADDRESS_GROUP_WEBSITES, $addressesNumber = 1, $allocateRandom = TRUE) { $params = array(); foreach (get_defined_vars() as $key => $value) @@ -396,11 +400,11 @@ class WebsitePanel $params[$key] = $value; } - return $this->execute_server_method(WebsitePanel::SERVICEFILE_SERVERS, 'AllocatePackageIPAddresses', $params)->AllocatePackageIPAddressesResult; + return $this->executeServerMethod(WebsitePanel::SERVICEFILE_SERVERS, 'AllocatePackageIPAddresses', $params)->AllocatePackageIPAddressesResult; } /** - * Executes the request Enterprise Server method / parameters and returns the results + * Executes the requested Enterprise Server method / parameters and returns the results * * @access private * @param string $serviceFile Enterprise Server service filename @@ -409,12 +413,12 @@ class WebsitePanel * @throws Exception * @return object */ - private function execute_server_method($serviceFile, $serviceMethod, $methodParameters = array()) + private function executeServerMethod($serviceFile, $serviceMethod, $methodParameters = array()) { $esUrl = (($this->_esUseSsl ? "https" : "http") . "://{$this->_esServerUrl}:{$this->_esServerPort}/{$serviceFile}?WSDL"); $soapParams = array('login' => $this->_esUsername, 'password' => $this->_esPassword, - 'cache_wsdl' => WSDL_CACHE_NONE // WSDL caching is an annoying nightmare - we will disable it + 'cache_wsdl' => WSDL_CACHE_NONE, // WSDL caching is an annoying nightmare - we will disable it ); try { @@ -428,7 +432,7 @@ class WebsitePanel } catch (Exception $e) { - throw new Exception($e->getMessage()); + throw; } } } \ No newline at end of file diff --git a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.functions.php b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.functions.php index b41b2ddc..32e0eb6b 100644 --- a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.functions.php +++ b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.functions.php @@ -106,7 +106,7 @@ function websitepanel_CalculateBandwidthUsage($params, $packageId, $startDate) try { - $result = $wsp->get_space_bandwidth_usage($packageId, $startDate, date('Y-m-d', time())); + $result = $wsp->getSpaceBandwidthUsage($packageId, $startDate, date('Y-m-d', time())); return websitepanel_CalculateUsage($result, WebsitePanel::USAGE_BANDWIDTH); } catch (Exception $e) @@ -130,7 +130,7 @@ function websitepanel_CalculateDiskspaceUsage($params, $packageId) try { - $result = $wsp->get_space_diskspace_usage($packageId); + $result = $wsp->getSpaceDiskspaceUsage($packageId); return websitepanel_CalculateUsage($result, WebsitePanel::USAGE_DISKSPACE); } catch (Exception $e) diff --git a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.php b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.php index f5735233..ea5c8c05 100644 --- a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.php +++ b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.php @@ -52,7 +52,6 @@ // WebsitePanel WHMCS Server Module Configuration / Commands /****************************************************************************/ require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php'); -require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.errorcodes.php'); require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.functions.php'); /** @@ -100,16 +99,16 @@ function websitepanel_CreateAccount($params) // WHMCS server parameters & package parameters $username = $params['username']; $password = $params['password']; - $accountid = $params['accountid']; - $packageid = $params['packageid']; + $accountId = $params['accountid']; + $packageId = $params['packageid']; $domain = $params['domain']; - $packagetype = $params['type']; - $clientsdetails = $params['clientsdetails']; + $packageType = $params['type']; + $clientsDetails = $params['clientsdetails']; // WebsitePanel API parameters $planId = $params['configoption4']; $parentPackageId = $params['configoption5']; - $roleId = ($packagetype == 'reselleraccount') ? 2 : 3; + $roleId = ($packageType == 'reselleraccount') ? 2 : 3; $htmlMail = ($params['configoption14'] == 'on') ? TRUE : FALSE; $sendAccountLetter = ($params['configoption9'] == 'on') ? TRUE : FALSE; $sendPackageLetter = ($params['configoption10'] == 'on') ? TRUE : FALSE; @@ -123,14 +122,14 @@ function websitepanel_CreateAccount($params) try { // Attempt to create the WSP user account and his / her package / hosting space - $result = $wsp->create_user_wizard($username, $password, $roleId, $clientsdetails['firstname'], $clientsdetails['lastname'], $clientsdetails['email'], $planId, $parentPackageId, $domain, $websitePointerName, $htmlMail, $sendAccountLetter, $sendPackageLetter, TRUE, $createTempDomain, $createWebsite, $createFtpAccount, $username, $createMailAccount, $createZoneRecord); + $result = $wsp->createUserWizard($username, $password, $roleId, $clientsDetails['firstname'], $clientsDetails['lastname'], $clientsDetails['email'], $planId, $parentPackageId, $domain, $websitePointerName, $htmlMail, $sendAccountLetter, $sendPackageLetter, TRUE, $createTempDomain, $createWebsite, $createFtpAccount, $username, $createMailAccount, $createZoneRecord); if ($result >= 0) { // Grab the user's details from WebsitePanel - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); // Update the user's account with his / her WHMCS contact details - $wsp->update_user_details($user['RoleId'], $user['Role'], $user['StatusId'], $user['Status'], $user['LoginStatusId'], $user['LoginStatus'], $user['FailedLogins'], $user['UserId'], $user['OwnerId'], $user['Created'], $user['Changed'], $user['IsDemo'], $user['IsPeer'], $user['Comments'], $username, $password, $clientsdetails['firstname'], $clientsdetails['lastname'], $clientsdetails['email'], $clientsdetails['phonenumber'], $clientsdetails['postcode'], '', '', '', '', $clientsdetails['country'], $clientsdetails['address1'], $clientsdetails['city'], $clientsdetails['state'], $htmlMail, $clientsdetails['companyname'], (($roleId == 2) ? TRUE : FALSE)); + $wsp->updateUserDetails($user['RoleId'], $user['Role'], $user['StatusId'], $user['Status'], $user['LoginStatusId'], $user['LoginStatus'], $user['FailedLogins'], $user['UserId'], $user['OwnerId'], $user['Created'], $user['Changed'], $user['IsDemo'], $user['IsPeer'], $user['Comments'], $username, $password, $clientsDetails['firstname'], $clientsDetails['lastname'], $clientsDetails['email'], $clientsDetails['phonenumber'], $clientsDetails['postcode'], '', '', '', '', $clientsDetails['country'], $clientsDetails['address1'], $clientsDetails['city'], $clientsDetails['state'], $htmlMail, $clientsDetails['companyname'], (($roleId == 2) ? TRUE : FALSE)); // Success - Alert WHMCS return 'success'; @@ -165,7 +164,7 @@ function websitepanel_TerminateAccount($params) try { // Grab the user's details from WebsitePanel in order to get the user's id - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); if (empty($user)) { return "The specified user {$username} does not exist"; @@ -173,7 +172,7 @@ function websitepanel_TerminateAccount($params) else { // Attempt to delete the users account and package / hosting space - $result = $wsp->delete_user($user['UserId']); + $result = $wsp->deleteUser($user['UserId']); if ($result >= 0) { // Success - Alert WHMCS @@ -210,7 +209,7 @@ function websitepanel_SuspendAccount($params) try { // Grab the user's details from WebsitePanel in order to get the user's id - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); if (empty($user)) { return "The specified user {$username} does not exist"; @@ -218,7 +217,7 @@ function websitepanel_SuspendAccount($params) else { // Attempt to suspend the users account and package / hosting space - $result = $wsp->change_user_status($user['UserId'], WebsitePanel::USERSTATUS_SUSPENDED); + $result = $wsp->changeUserStatus($user['UserId'], WebsitePanel::USERSTATUS_SUSPENDED); if ($result >= 0) { // Success - Alert WHMCS @@ -255,7 +254,7 @@ function websitepanel_UnsuspendAccount($params) try { // Grab the user's details from WebsitePanel in order to get the user's id - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); if (empty($user)) { return "The specified user {$username} does not exist"; @@ -263,7 +262,7 @@ function websitepanel_UnsuspendAccount($params) else { // Attempt to activate the users account and package / hosting space - $result = $wsp->change_user_status($user['UserId'], WebsitePanel::USERSTATUS_ACTIVE); + $result = $wsp->changeUserStatus($user['UserId'], WebsitePanel::USERSTATUS_ACTIVE); if ($result >= 0) { // Success - Alert WHMCS @@ -295,13 +294,15 @@ function websitepanel_ChangePassword($params) $wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']); // WHMCS server parameters & package parameters + $serviceId = $params['serviceid']; $username = $params['username']; $password = $params['password']; + $userId = $params['clientsdetails']['userid']; try { // Grab the user's details from WebsitePanel in order to get the user's id - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); if (empty($user)) { return "The specified user {$username} does not exist"; @@ -312,6 +313,9 @@ function websitepanel_ChangePassword($params) $result = $wsp->change_user_password($user['UserId'], $password); if ($result >= 0) { + // Log this action for logging / tracking purposes incase the client complains we have record of what went on and why + logActivity("Control Panel Password Updated - Service ID: {$serviceId}", $userId); + // Success - Alert WHMCS return 'success'; } @@ -350,7 +354,7 @@ function websitepanel_ChangePackage($params) try { // Grab the user's details from WebsitePanel in order to get the user's id - $user = $wsp->get_user_by_username($username); + $user = $wsp->getUserByUsername($username); if (empty($user)) { return "The specified user {$username} does not exist"; @@ -358,11 +362,11 @@ function websitepanel_ChangePackage($params) else { // Get the user's current WebsitePanel hosting space Id (Hosting Plan) - $package = $wsp->get_user_packages($user['UserId']); + $package = $wsp->getUserPackages($user['UserId']); $packageId = $package['PackageId']; // Update the user's package - $result = $wsp->update_package_literal($packageId, $package['StatusId'], $planId, $package['PurchaseDate'], $packageName, ''); + $result = $wsp->updatePackageLiteral($packageId, $package['StatusId'], $planId, $package['PurchaseDate'], $packageName, ''); $result = $result['Result']; if ($result >= 0) { @@ -443,8 +447,8 @@ function websitepanel_UsageUpdate($params) // Get the specified user details // Get the Package id of the user's package - $user = $wsp->get_user_by_username($username); - $package = $wsp->get_user_packages($user['UserId']); + $user = $wsp->getUserByUsername($username); + $package = $wsp->getUserPackages($user['UserId']); // Gather the bandwidth / diskspace usage stats $bandwidthUsage = websitepanel_CalculateBandwidthUsage($params, $package['PackageId'], websitepanel_CreateBandwidthDate($row['regdate'])); diff --git a/WebsitePanel.WHMCSModule/readme.txt b/WebsitePanel.WHMCSModule/readme.txt index f45ca9c4..631f8816 100644 --- a/WebsitePanel.WHMCSModule/readme.txt +++ b/WebsitePanel.WHMCSModule/readme.txt @@ -6,14 +6,14 @@ To enable addon automation... 2. Select "Configure" 3. Enter your WebsitePanel Enterprise Server details 4. WHMCS Admin -> Addons -> "WebsitePanel Addons" -5. Enter your addons here. You can get the WHMCS addon ID by clicking the edit icon on the addon and extracting the &id=x from the URL (x being the WHMCS Addon ID) - You can retrieve your WebsitePanel addon ID by editing the addon and extracting the PlanID=x from the URL (x being the WebsitePanel Addon ID) +5. Enter your addons here. You can get the WHMCS addon ID by clicking the edit icon on the product addon and extracting the &id=x from the URL (x being the WHMCS Addon ID) + You can retrieve your WebsitePanel addon ID by clicking the hosting addon and extracting the PlanID=x from the URL (x being the WebsitePanel Addon ID) 6. If this is a Dedicated IP address addon, check the Dedicated IP Address box to allow the module to auto-allocate an IP address. What does not work? - Quantities, only a single addon => addon can be allocated - Terminating / Suspending Addons, I've ran out of time on what I can do currently -- When an IP address is allocated, WebsitePanel does not return back what IP was allocated, so WHMCS is not updated with which IP was assigned to the users hosting space +- When an IP address is allocated WebsitePanel does not return back what IP was allocated, so WHMCS is not updated which what IP has been allocated to his / her package at this time. - A single user => single package is the only way the WebsitePanel server module works. I have no plans on making this work any other way. DO NOT CONTACT WHMCS FOR SUPPORT WITH THIS MODULE - THIS IS NOT DEVELOPED BY WHMCS AND HAS NO AFFILIATION WITH WHMCS OR WHMCS.COM. \ No newline at end of file