diff --git a/.gitignore b/.gitignore index fa38ac0..a4465a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ _notes *.bak +/nbproject/ +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d74b8..6b8d927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] ### Changed +- Formatted all source code to PSR-2 standards for Blesta +- Fixed a couple "undefined variable" errors encountered on initial installation +- Updated the look of the submit buttons +- Fixed a "Undefined property" error, when there are no domains available in Audit Domains ## [1.8.5] = 2018-11-19 ### Added diff --git a/README.md b/README.md index ec90278..89bcd4b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Blesta-Namesilo +# Blesta/Namesilo Blesta Namesilo module This module interfaces with Namesilo's domain API to allow domain registrations, transfers and renewals through Blesta. @@ -43,4 +43,11 @@ The module provides the following template tags for use in welcome email templat | service.years | Years of registration or extension if it's a transfer | | package.meta.ns | Array of default nameservers configured on the package. This may not match what the customer submitted if they changed it. | -**[Get your Namesilo account here](https://www.namesilo.com/)** \ No newline at end of file +**[Get your Namesilo account here](https://www.namesilo.com/)** + +### Blesta Compatibility + +|Blesta Version|Module Version| +|--------------|--------------| +|< v4.9.0|v1.9.0| +|>= v4.9.0|v1.10.0+| diff --git a/apis/codes.php b/apis/codes.php index 3e6b9a9..deed285 100644 --- a/apis/codes.php +++ b/apis/codes.php @@ -1,51 +1,51 @@ array( 'HTTPS not used', 'fail' ), - '102' => array( 'No version specified', 'fail' ), - '103' => array( 'Invalid API version', 'fail' ), - '104' => array( 'No type specified', 'fail' ), - '105' => array( 'Invalid API type', 'fail' ), - '106' => array( 'No operation specified', 'fail' ), - '107' => array( 'Invalid API operation', 'fail' ), - '108' => array( 'Missing parameters for the specified operation', 'fail' ), - '109' => array( 'No API key specified', 'fail' ), - '110' => array( 'Invalid API key', 'fail' ), - '111' => array( 'Invalid User', 'fail' ), - '112' => array( 'API not available to Sub-Accounts', 'fail' ), - '113' => array( 'This API account cannot be accessed from your IP', 'fail' ), - '114' => array( 'Invalid Domain Syntax', 'fail' ), - '115' => array( 'Central Registry Not Responding - try again later', 'fail' ), - '116' => array( 'Invalid sandbox account', 'fail' ), - '117' => array( 'The provided credit card profile either does not exist, or is not associated with your account', 'fail' ), - '118' => array( 'The provided credit card profile has not been verified', 'fail' ), - '119' => array( 'Insufficient account funds for requested transaction', 'fail' ), - '120' => array( 'API key must be passed as a GET', 'fail' ), + '101' => [ 'HTTPS not used', 'fail' ], + '102' => [ 'No version specified', 'fail' ], + '103' => [ 'Invalid API version', 'fail' ], + '104' => [ 'No type specified', 'fail' ], + '105' => [ 'Invalid API type', 'fail' ], + '106' => [ 'No operation specified', 'fail' ], + '107' => [ 'Invalid API operation', 'fail' ], + '108' => [ 'Missing parameters for the specified operation', 'fail' ], + '109' => [ 'No API key specified', 'fail' ], + '110' => [ 'Invalid API key', 'fail' ], + '111' => [ 'Invalid User', 'fail' ], + '112' => [ 'API not available to Sub-Accounts', 'fail' ], + '113' => [ 'This API account cannot be accessed from your IP', 'fail' ], + '114' => [ 'Invalid Domain Syntax', 'fail' ], + '115' => [ 'Central Registry Not Responding - try again later', 'fail' ], + '116' => [ 'Invalid sandbox account', 'fail' ], + '117' => [ 'The provided credit card profile either does not exist, or is not associated with your account', 'fail' ], + '118' => [ 'The provided credit card profile has not been verified', 'fail' ], + '119' => [ 'Insufficient account funds for requested transaction', 'fail' ], + '120' => [ 'API key must be passed as a GET', 'fail' ], - '200' => array( 'Domain is not active, or does not belong to this user', 'fail' ), - '201' => array( 'Internal system error', 'fail' ), - '210' => array( 'General error (details provided in response)', 'fail' ), - '250' => array( 'Domain is already set to AutoRenew - No update made.', 'fail' ), - '251' => array( 'Domain is already set not to AutoRenew - No update made.', 'fail' ), - '252' => array( 'Domain is already Locked - No update made.', 'fail' ), - '253' => array( 'Domain is already Unlocked - No update made.', 'fail' ), - '254' => array( 'NameServer update cannot be made. (details provided in response)', 'fail' ), - '255' => array( 'Domain is already Private - No update made.', 'fail' ), - '256' => array( 'Domain is already Not Private - No update made.', 'fail' ), - '261' => array( 'Domain processing error (details provided in response)', 'fail' ), - '262' => array( 'This domain is already active within our system and therefore cannot be processed.', 'fail' ), - '263' => array( 'Invalid number of years, or no years provided.', 'fail' ), - '264' => array( 'Domain cannot be renewed for specified number of years (details provided in response)', 'fail' ), - '265' => array( 'Domain cannot be transferred at this time (details provided in response)', 'fail' ), - '266' => array( 'No domain transfer exists for this user for this domain', 'fail' ), - '267' => array( 'Invalid domain name, or we do not support the provided extension/TLD.', 'fail' ), - '280' => array( 'DNS modification error', 'fail' ), + '200' => [ 'Domain is not active, or does not belong to this user', 'fail' ], + '201' => [ 'Internal system error', 'fail' ], + '210' => [ 'General error (details provided in response)', 'fail' ], + '250' => [ 'Domain is already set to AutoRenew - No update made.', 'fail' ], + '251' => [ 'Domain is already set not to AutoRenew - No update made.', 'fail' ], + '252' => [ 'Domain is already Locked - No update made.', 'fail' ], + '253' => [ 'Domain is already Unlocked - No update made.', 'fail' ], + '254' => [ 'NameServer update cannot be made. (details provided in response)', 'fail' ], + '255' => [ 'Domain is already Private - No update made.', 'fail' ], + '256' => [ 'Domain is already Not Private - No update made.', 'fail' ], + '261' => [ 'Domain processing error (details provided in response)', 'fail' ], + '262' => [ 'This domain is already active within our system and therefore cannot be processed.', 'fail' ], + '263' => [ 'Invalid number of years, or no years provided.', 'fail' ], + '264' => [ 'Domain cannot be renewed for specified number of years (details provided in response)', 'fail' ], + '265' => [ 'Domain cannot be transferred at this time (details provided in response)', 'fail' ], + '266' => [ 'No domain transfer exists for this user for this domain', 'fail' ], + '267' => [ 'Invalid domain name, or we do not support the provided extension/TLD.', 'fail' ], + '280' => [ 'DNS modification error', 'fail' ], - '300' => array( 'Successful API operation', 'success' ), - '301' => array( 'Successful registration, but not all provided hosts were valid, resulting in our nameservers being used', 'success' ), - '302' => array( 'Successful order, but there was an error with the contact information provided so your account default contact profile was used', 'success' ), + '300' => [ 'Successful API operation', 'success' ], + '301' => [ 'Successful registration, but not all provided hosts were valid, resulting in our nameservers being used', 'success' ], + '302' => [ 'Successful order, but there was an error with the contact information provided so your account default contact profile was used', 'success' ], - '400' => array( 'Existing API request is still processing - request will need to be re-submitted', 'fail' ), + '400' => [ 'Existing API request is still processing - request will need to be re-submitted', 'fail' ], -)); \ No newline at end of file +]); diff --git a/apis/commands/domains.php b/apis/commands/domains.php index 727d275..e8f7914 100644 --- a/apis/commands/domains.php +++ b/apis/commands/domains.php @@ -6,237 +6,282 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloDomains { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Returns a list of domains for the particular user. - * - * @param array $vars An array of input params including: - * - portfolio (optional) portfolio to fetch domains for - * @return NamesiloResponse - */ - public function getList(array $vars) { - return $this->api->submit("listDomains", $vars); - } - - /** - * Returns a list of tlds - * - * @return NamesiloResponse - */ - public function getTldList() { - return $this->api->submit("namesilo.domains.getTldList"); - } - - /** - * Registers a new domain name. - * - * https://www.namesilo.com/api_reference.php#registerDomain - */ - public function create(array $vars) { - return $this->api->submit("registerDomain", array_merge($vars,array('auto_renew'=>0))); - } - - /** - * Get essential information on a particular domain, including the expiration date, creation date, status, locked status and nameservers. - * - * https://www.namesilo.com/api_reference.php#getDomainInfo - */ - public function getDomainInfo( array $vars ) { - return $this->api->submit( "getDomainInfo", $vars ); - } - - /** - * Gets contact information for the requested domain. - * - * @param array $vars An array of input params including: - * - DomainName Domain to get contacts - * @return NamesiloResponse - */ - public function getContacts( array $vars ) { - - return $this->api->submit( "contactList", $vars ); - - $response = self::getDomainInfo( $vars ); - - if ( parent::$codes[$response->status()][1] != "fail" ) { - - $contact_ids = $response->response()->contact_ids; - - $contacts = $temp = array(); - foreach ( $contact_ids as $type => $id ) { - if ( !isset( $temp[$id] ) ) { - $response = $this->api->submit( "contactList", array( "contact_id" => $id ) ); - if ( parent::$codes[$response->status()][1] != "fail" ) { - $temp[$id] = $response->response()->contact; - $contacts[$type] = $temp[$id]; - } - } - else { - $contacts[$type] = $temp[$id]; - } - } - return $contacts; - } - return false; - } - - public function addContacts( array $vars ) { - return $this->api->submit( "contactAdd", $vars ); - } - - /** - * Sets contact information for the requested domain. - * - * @return NamesiloResponse - */ - public function setContacts( array $vars ) { - return $this->api->submit( "contactDomainAssociate", $vars ); - } - - /** - * Delete a contact profile in your account. Please remember - * that the only contact profiles that can be deleted are those - * that are not the account default and are not associated with - * any active domains or order profiles. - * - * https://www.namesilo.com/api_reference.php#contactDelete - */ - public function deleteContacts( array $vars ) { - return $this->api->submit( "contactDelete", $vars ); - } - - /** - * Checks the availability of a domain name. - * - * https://www.namesilo.com/api_reference.php#checkRegisterAvailability - */ - public function check(array $vars) { - return $this->api->submit("checkRegisterAvailability", $vars); - } - - /** - * Reactivates an expired domain. - * - * @param array $vars An array of input params including: - * - DomainName DomainName to reactivate - * @return NamesiloResponse - */ - public function reactivate(array $vars) { - return $this->api->submit("namesilo.domains.reactivate", $vars); - } - - /** - * Renews a domain. - * - * @param array $vars An array of input params including: - * - domain DomainName to renew - * - years Number of years to renew - * - coupon Promotional (coupon) code for renewing the domain - * @return NamesiloResponse - * - * https://www.namesilo.com/api_reference.php#renewDomain - */ - public function renew(array $vars) { - return $this->api->submit("renewDomain", $vars); - } - - /** - * Gets the RegistrarLock status for the requested domain. - * - * @param array $vars An array of input params including: - * - domain Domain name to get status - * @return NamesiloResponse - */ - public function getRegistrarLock(array $vars) { - return $this->api->submit("getDomainInfo", $vars); - } - - /** - * Sets the RegistrarLock status for a domain. - * - * @param array $vars An array of input params including: - * - domain Domain name to set status - * - LockAction Possible values are LOCK and UNLOCK - * @return NamesiloResponse - */ - public function setRegistrarLock( $lock_action, array $vars ) { - return $this->api->submit( "domain{$lock_action}", $vars ); - } - - /** - * Sets the Auto Renew for a domain. - * - * @param array $vars An array of input params including: - * - domain Domain name to set status - * - autorenew (boolean) true to enable auto renewal, (boolean) false to disable - * @return NamesiloResponse - */ - public function setAutoRenewal( $domain, $autorenew = false ) { - if ( !$autorenew ) $action = "remove"; else $action = "add"; - return $this->api->submit( "{$action}AutoRenewal", array( "domain" => $domain ) ); - } - - /** - * @param array $vars +class NamesiloDomains +{ + /** + * @var NamesiloApi + */ + private $api; + + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Returns a list of domains for the particular user. + * + * @param array $vars An array of input params including: + * + * - portfolio (optional) portfolio to fetch domains for + * @return NamesiloResponse + */ + public function getList(array $vars) + { + return $this->api->submit('listDomains', $vars); + } + + /** + * Returns a list of tlds + * + * @return NamesiloResponse + */ + public function getTldList() + { + return $this->api->submit('namesilo.domains.getTldList'); + } + + /** + * Registers a new domain name. + * + * https://www.namesilo.com/api_reference.php#registerDomain + */ + public function create(array $vars) + { + return $this->api->submit('registerDomain', array_merge($vars, ['auto_renew' => 0])); + } + + /** + * Get essential information on a particular domain, including the expiration date, creation date, status, + * locked status and nameservers. + * + * https://www.namesilo.com/api_reference.php#getDomainInfo + */ + public function getDomainInfo(array $vars) + { + return $this->api->submit('getDomainInfo', $vars); + } + + /** + * Gets contact information for the requested domain. + * + * @param array $vars An array of input params including: + * + * - DomainName Domain to get contacts + * @return NamesiloResponse + */ + public function getContacts(array $vars) + { + return $this->api->submit('contactList', $vars); + + $response = self::getDomainInfo($vars); + + if (parent::$codes[$response->status()][1] != 'fail') { + $contact_ids = $response->response()->contact_ids; + + $contacts = $temp = []; + foreach ($contact_ids as $type => $id) { + if (!isset($temp[$id])) { + $response = $this->api->submit('contactList', ['contact_id' => $id]); + if (parent::$codes[$response->status()][1] != 'fail') { + $temp[$id] = $response->response()->contact; + $contacts[$type] = $temp[$id]; + } + } else { + $contacts[$type] = $temp[$id]; + } + } + return $contacts; + } + return false; + } + + /** + * Adds a contact + * + * @param array $vars An array of contact information + * @return NamesiloResponse + */ + public function addContacts(array $vars) + { + return $this->api->submit('contactAdd', $vars); + } + + /** + * Sets contact information for the requested domain. + * + * @return NamesiloResponse + */ + public function setContacts(array $vars) + { + return $this->api->submit('contactDomainAssociate', $vars); + } + + /** + * Delete a contact profile in your account. Please remember + * that the only contact profiles that can be deleted are those + * that are not the account default and are not associated with + * any active domains or order profiles. + * + * https://www.namesilo.com/api_reference.php#contactDelete + */ + public function deleteContacts(array $vars) + { + return $this->api->submit('contactDelete', $vars); + } + + /** + * Checks the availability of a domain name. + * + * https://www.namesilo.com/api_reference.php#checkRegisterAvailability + */ + public function check(array $vars) + { + return $this->api->submit('checkRegisterAvailability', $vars); + } + + /** + * Reactivates an expired domain. + * + * @param array $vars An array of input params including: + * + * - DomainName DomainName to reactivate + * @return NamesiloResponse + */ + public function reactivate(array $vars) + { + return $this->api->submit('namesilo.domains.reactivate', $vars); + } + + /** + * Renews a domain. + * + * @param array $vars An array of input params including: + * + * - domain DomainName to renew + * - years Number of years to renew + * - coupon Promotional (coupon) code for renewing the domain + * @return NamesiloResponse + * + * https://www.namesilo.com/api_reference.php#renewDomain + */ + public function renew(array $vars) + { + return $this->api->submit('renewDomain', $vars); + } + + /** + * Gets the RegistrarLock status for the requested domain. + * + * @param array $vars An array of input params including: + * + * - domain Domain name to get status + * @return NamesiloResponse + */ + public function getRegistrarLock(array $vars) + { + return $this->api->submit('getDomainInfo', $vars); + } + + /** + * Sets the RegistrarLock status for a domain. + * + * @param array $vars An array of input params including: + * + * - domain Domain name to set status + * - LockAction Possible values are LOCK and UNLOCK + * @return NamesiloResponse + */ + public function setRegistrarLock($lock_action, array $vars) + { + return $this->api->submit('domain' . $lock_action, $vars); + } + + /** + * Sets the Auto Renew for a domain. + * + * @param array $vars An array of input params including: + * + * - domain Domain name to set status + * - autorenew (boolean) true to enable auto renewal, (boolean) false to disable + * @return NamesiloResponse + */ + public function setAutoRenewal($domain, $autorenew = false) + { + if (!$autorenew) { + $action = 'remove'; + } else { + $action = 'add'; + } + return $this->api->submit($action . 'AutoRenewal', ['domain' => $domain]); + } + + /** + * Adds privacy + * + * @param array $vars An array of data + * * - domain * @return NamesiloResponse */ - public function addPrivacy(array $vars){ - return $this->api->submit("addPrivacy",$vars); + public function addPrivacy(array $vars) + { + return $this->api->submit('addPrivacy', $vars); } /** - * @param array $vars + * Removes privacy + * + * @param array $vars An array of data + * * - domain * @return NamesiloResponse */ - public function removePrivacy(array $vars){ - return $this->api->submit("removePrivacy",$vars); + public function removePrivacy(array $vars) + { + return $this->api->submit('removePrivacy', $vars); } /** - * @param array $vars + * @param array $vars An array of data * @return NamesiloResponse */ - public function portfolioList(){ - return $this->api->submit("portfolioList"); + public function portfolioList() + { + return $this->api->submit('portfolioList'); } /** * @return NamesiloResponse */ - public function getPrices(){ - return $this->api->submit("getPrices"); + public function getPrices() + { + return $this->api->submit('getPrices'); } /** * @return NamesiloResponse */ - public function registrantVerificationStatus(){ - return $this->api->submit("registrantVerificationStatus"); + public function registrantVerificationStatus() + { + return $this->api->submit('registrantVerificationStatus'); } /** - * @param array $vars + * Performs email verification + * + * @param array $vars An array of data + * * - email string email address to verify * @return NamesiloResponse */ - public function emailVerification(array $vars){ - return $this->api->submit("emailVerification", $vars); + public function emailVerification(array $vars) + { + return $this->api->submit('emailVerification', $vars); } -} \ No newline at end of file +} diff --git a/apis/commands/domains_dns.php b/apis/commands/domains_dns.php index e32bbba..fc87494 100644 --- a/apis/commands/domains_dns.php +++ b/apis/commands/domains_dns.php @@ -6,99 +6,109 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloDomainsDns { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Sets domain to use our default DNS servers. Required for free services - * like Host record management, URL forwarding, email forwarding, dynamic - * dns and other value added services. - * - * @param array $vars An array of input params including: - * - SLD SLD of the DomainName - * - TLD TLD of the DomainName - * @return NamesiloResponse - */ - public function setDefault(array $vars) { - return $this->api->submit("namesilo.domains.dns.setDefault", $vars); - } +class NamesiloDomainsDns +{ + /** + * @var NamesiloApi + */ + private $api; + + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Sets domain to use our default DNS servers. Required for free services + * like Host record management, URL forwarding, email forwarding, dynamic + * dns and other value added services. + * + * @param array $vars An array of input params including: + * + * - SLD SLD of the DomainName + * - TLD TLD of the DomainName + * @return NamesiloResponse + */ + public function setDefault(array $vars) + { + return $this->api->submit('namesilo.domains.dns.setDefault', $vars); + } + + /** + * Sets domain to use custom DNS servers. NOTE: Services like URL forwarding, + * Email forwarding, Dynamic DNS will not work for domains using custom + * nameservers. + * + * https://www.namesilo.com/api_reference.php#changeNameServers + */ + public function setCustom(array $vars) + { + return $this->api->submit('changeNameServers', $vars); + } + + /** + * Gets a list of DNS servers associated with the requested domain. + * + * https://www.namesilo.com/api_reference.php#getDomainInfo + */ + public function getList(array $vars) + { + return $this->api->submit('getDomainInfo', $vars); + } - /** - * Sets domain to use custom DNS servers. NOTE: Services like URL forwarding, - * Email forwarding, Dynamic DNS will not work for domains using custom - * nameservers. - * - * https://www.namesilo.com/api_reference.php#changeNameServers - */ - public function setCustom(array $vars) { - return $this->api->submit("changeNameServers", $vars); - } - - /** - * Gets a list of DNS servers associated with the requested domain. - * - * https://www.namesilo.com/api_reference.php#getDomainInfo - */ - public function getList(array $vars) { - return $this->api->submit("getDomainInfo", $vars); - } - - /** - * Retrieves DNS host record settings for the requested domain. - * - * https://www.namesilo.com/api_reference.php#dnsListRecords - */ - public function getHosts(array $vars) { - return $this->api->submit("dnsListRecords", $vars); - } - - /** - * Sets DNS host records settings for the requested domain. - * - * https://www.namesilo.com/api_reference.php#dnsAddRecord - */ - public function setHosts(array $vars) { - return $this->api->submit("dnsAddRecord", $vars); - } - - /** - * Gets email forwarding settings for the requested domain. - * - * https://www.namesilo.com/api_reference.php#listEmailForwards - */ - public function getEmailForwarding(array $vars) { - return $this->api->submit("listEmailForwards", $vars); - } - - /** - * Sets email forwarding for a domain name. - * - * https://www.namesilo.com/api_reference.php#configureEmailForward - */ - public function setEmailForwarding(array $vars) { - return $this->api->submit("configureEmailForward", $vars); - } + /** + * Retrieves DNS host record settings for the requested domain. + * + * https://www.namesilo.com/api_reference.php#dnsListRecords + */ + public function getHosts(array $vars) + { + return $this->api->submit('dnsListRecords', $vars); + } + + /** + * Sets DNS host records settings for the requested domain. + * + * https://www.namesilo.com/api_reference.php#dnsAddRecord + */ + public function setHosts(array $vars) + { + return $this->api->submit('dnsAddRecord', $vars); + } + + /** + * Gets email forwarding settings for the requested domain. + * + * https://www.namesilo.com/api_reference.php#listEmailForwards + */ + public function getEmailForwarding(array $vars) + { + return $this->api->submit('listEmailForwards', $vars); + } + + /** + * Sets email forwarding for a domain name. + * + * https://www.namesilo.com/api_reference.php#configureEmailForward + */ + public function setEmailForwarding(array $vars) + { + return $this->api->submit('configureEmailForward', $vars); + } /** * Retrieves DS records * * https://www.namesilo.com/api_reference.php#dnsSecListRecords */ - public function dnsSecListRecords(array $vars) { - return $this->api->submit("dnsSecListRecords", $vars); + public function dnsSecListRecords(array $vars) + { + return $this->api->submit('dnsSecListRecords', $vars); } /** @@ -106,8 +116,9 @@ public function dnsSecListRecords(array $vars) { * * https://www.namesilo.com/api_reference.php#dnsSecListRecords */ - public function dnsSecAddRecord(array $vars) { - return $this->api->submit("dnsSecAddRecord", $vars); + public function dnsSecAddRecord(array $vars) + { + return $this->api->submit('dnsSecAddRecord', $vars); } /** @@ -115,7 +126,8 @@ public function dnsSecAddRecord(array $vars) { * * https://www.namesilo.com/api_reference.php#dnsSecListRecords */ - public function dnsSecDeleteRecord(array $vars) { - return $this->api->submit("dnsSecDeleteRecord", $vars); + public function dnsSecDeleteRecord(array $vars) + { + return $this->api->submit('dnsSecDeleteRecord', $vars); } } diff --git a/apis/commands/domains_ns.php b/apis/commands/domains_ns.php index b4e40b1..882d236 100644 --- a/apis/commands/domains_ns.php +++ b/apis/commands/domains_ns.php @@ -6,75 +6,83 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloDomainsNs { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Creates a new nameserver. - * - * @param array $vars An array of input params including: - * - SLD SLD of domain - * - TLD TLD of domain - * - Nameserver Nameserver to create - * - IP Nameserver IP address - * @return NamesiloResponse - */ - public function create(array $vars) { - return $this->api->submit("addRegisteredNameServer", $vars); - } +class NamesiloDomainsNs +{ + /** + * @var NamesiloApi + */ + private $api; - /** - * Deletes a nameserver associated with the requested domain. - * - * @param array $vars An array of input params including: - * - SLD SLD of domain - * - TLD TLD of domain - * - Nameserver Nameserver for deletion - * @return NamesiloResponse - */ - public function delete(array $vars) { - return $this->api->submit("deleteRegisteredNameServer", $vars); - } - - /** - * Retrieves information about a registered nameserver. - * - * @param array $vars An array of input params including: - * - SLD SLD of domain - * - TLD TLD of domain - * - Nameserver Nameserver - * @return NamesiloResponse - */ - public function getInfo(array $vars) { - return $this->api->submit("listRegisteredNameServers", $vars); - } - - /** - * Updates the IP address of a registered nameserver. - * - * @param array $vars An array of input params including: - * - SLD SLD of domain - * - TLD TLD of domain - * - Nameserver Nameserver Name - * - OldIP Existing IP address - * - IP New IP address - * @return NamesiloResponse - */ - public function update(array $vars) { - return $this->api->submit("modifyRegisteredNameServer", $vars); - } + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Creates a new nameserver. + * + * @param array $vars An array of input params including: + * + * - SLD SLD of domain + * - TLD TLD of domain + * - Nameserver Nameserver to create + * - IP Nameserver IP address + * @return NamesiloResponse + */ + public function create(array $vars) + { + return $this->api->submit('addRegisteredNameServer', $vars); + } + + /** + * Deletes a nameserver associated with the requested domain. + * + * @param array $vars An array of input params including: + * + * - SLD SLD of domain + * - TLD TLD of domain + * - Nameserver Nameserver for deletion + * @return NamesiloResponse + */ + public function delete(array $vars) + { + return $this->api->submit('deleteRegisteredNameServer', $vars); + } + + /** + * Retrieves information about a registered nameserver. + * + * @param array $vars An array of input params including: + * + * - SLD SLD of domain + * - TLD TLD of domain + * - Nameserver Nameserver + * @return NamesiloResponse + */ + public function getInfo(array $vars) + { + return $this->api->submit('listRegisteredNameServers', $vars); + } + + /** + * Updates the IP address of a registered nameserver. + * + * @param array $vars An array of input params including: + * + * - SLD SLD of domain + * - TLD TLD of domain + * - Nameserver Nameserver Name + * - OldIP Existing IP address + * - IP New IP address + * @return NamesiloResponse + */ + public function update(array $vars) + { + return $this->api->submit('modifyRegisteredNameServer', $vars); + } } -?> \ No newline at end of file diff --git a/apis/commands/domains_transfer.php b/apis/commands/domains_transfer.php index faad55c..136a4c3 100644 --- a/apis/commands/domains_transfer.php +++ b/apis/commands/domains_transfer.php @@ -6,94 +6,107 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloDomainsTransfer { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Transfers a domain to Namesilo. - * - * @param array $vars An array of input params including: - * - domain Domain name to transfer - * - years Number of years to renew after a successful transfer - * - EPPCode The EPPCode is required for transferring .com, .net, .de, .org, .biz, .info, .mobi, .cn , .co, .ca and .us domains only. - * - PromotionCode Promotional (coupon) code for transfer - * - AddFreeWhoisguard Adds free Whoisguard for the domain - * - WGEnable Promotional (coupon) code for transfer - * @return NamesiloResponse - * - * https://www.namesilo.com/api_reference.php#transferDomain - */ - public function create( array $vars ) { - if ( isset( $vars['auth'] ) /*&& substr( $vars['auth'], 0, 7 ) != "base64:"*/ ) - $vars['auth'] = /*"base64:" .*/ urlencode( $vars['auth'] ); - return $this->api->submit( "transferDomain", array_merge($vars,array('auto_renew'=>0)) ); - } - - /** - * Requests the EPP Code for the given domain. The code is not returned, - * but is instead emailed to the registered domain contact (under whois). - * - * @param array $vars An array of input params including: - * - DomainName Domain name to get EPP code for - * - Reason (optional) Should be one of: price, support, technical, others - * - Description (optional) More information regarding the reason if available. Max length: 200 - * - Contact (optional) If customer can be contacted regarding this. Value should be: true/ false - * @return NamesiloResponses - */ - public function getEpp(array $vars) { - return $this->api->submit("retrieveAuthCode", $vars); - } - - /** - * Gets the status of a particular transfer. - * - * @param array $vars An array of input params including: - * - TransferID The unique Transfer ID which you get after placing a transfer request - * @return NamesiloResponse - */ - public function getStatus( array $vars ) { - return $this->api->submit( "checkTransferStatus", $vars ); - } - - /** - * Updates the status of a particular transfer. Allows you to re-submit the - * transfer after releasing the registry lock. - * - * @param array $vars An array of input params including: - * - TransferID The unique TransferID - * - Resubmit The value 'true' resubmits the transfer - * @return NamesiloResponse - */ - public function updateStatus(array $vars) { - return $this->api->submit("namesilo.domains.transfer.updateStatus", $vars); - } - - /** - * Gets the list of domain transfers. - * - * @param array $vars An array of input params including: - * - ListType Possible values are ALL,INPROGRESS,CANCELLED,COMPLETED - * - SearchTerm The keyword should be a domainname - * - Page Page to return - * - PageSize Number of transfers to be listed in a page. Minimum value is 10 and maximum value is 100. - * - SortBy Possible values are DOMAINNAME,DOMAINNAME_DESC,TRANSFERDATE,TRANSFERDATE_DESC,STATUSDATE,STATUSDATE_DESC. - * @return NamesiloResponse - */ - public function getList(array $vars) { - return $this->api->submit("namesilo.domains.transfer.getList", $vars); - } +class NamesiloDomainsTransfer +{ + /** + * @var NamesiloApi + */ + private $api; + + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Transfers a domain to Namesilo. + * + * @param array $vars An array of input params including: + * + * - domain Domain name to transfer + * - years Number of years to renew after a successful transfer + * - EPPCode The EPPCode is required for transferring .com, .net, .de, .org, .biz, .info, .mobi, .cn , + * .co, .ca and .us domains only. + * - PromotionCode Promotional (coupon) code for transfer + * - AddFreeWhoisguard Adds free Whoisguard for the domain + * - WGEnable Promotional (coupon) code for transfer + * @return NamesiloResponse + * + * https://www.namesilo.com/api_reference.php#transferDomain + */ + public function create(array $vars) + { + if (isset($vars['auth'])) { + $vars['auth'] = urlencode($vars['auth']); + } + return $this->api->submit('transferDomain', array_merge($vars, ['auto_renew' => 0])); + } + + /** + * Requests the EPP Code for the given domain. The code is not returned, + * but is instead emailed to the registered domain contact (under whois). + * + * @param array $vars An array of input params including: + * + * - DomainName Domain name to get EPP code for + * - Reason (optional) Should be one of: price, support, technical, others + * - Description (optional) More information regarding the reason if available. Max length: 200 + * - Contact (optional) If customer can be contacted regarding this. Value should be: true/ false + * @return NamesiloResponses + */ + public function getEpp(array $vars) + { + return $this->api->submit('retrieveAuthCode', $vars); + } + + /** + * Gets the status of a particular transfer. + * + * @param array $vars An array of input params including: + * + * - TransferID The unique Transfer ID which you get after placing a transfer request + * @return NamesiloResponse + */ + public function getStatus(array $vars) + { + return $this->api->submit('checkTransferStatus', $vars); + } + + /** + * Updates the status of a particular transfer. Allows you to re-submit the + * transfer after releasing the registry lock. + * + * @param array $vars An array of input params including: + * + * - TransferID The unique TransferID + * - Resubmit The value 'true' resubmits the transfer + * @return NamesiloResponse + */ + public function updateStatus(array $vars) + { + return $this->api->submit('namesilo.domains.transfer.updateStatus', $vars); + } + + /** + * Gets the list of domain transfers. + * + * @param array $vars An array of input params including: + * + * - ListType Possible values are ALL, INPROGRESS, CANCELLED, COMPLETED + * - SearchTerm The keyword should be a domainname + * - Page Page to return + * - PageSize Number of transfers to be listed in a page. Minimum value is 10 and maximum value is 100. + * - SortBy Possible values are DOMAINNAME, DOMAINNAME_DESC, TRANSFERDATE, + * TRANSFERDATE_DESC, STATUSDATE, STATUSDATE_DESC + * @return NamesiloResponse + */ + public function getList(array $vars) + { + return $this->api->submit('namesilo.domains.transfer.getList', $vars); + } } -?> \ No newline at end of file diff --git a/apis/commands/ssl.php b/apis/commands/ssl.php index 93bf151..9599671 100644 --- a/apis/commands/ssl.php +++ b/apis/commands/ssl.php @@ -6,198 +6,226 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloSsl { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Activates a newly purchased SSL certificate. - * - * @param array $vars An array of input params including: - * - CertificateID Unique ID of the SSL certificate you wish to activate - * - ApproverEmail The EmailID which is on the Approver Email list - * - csr Certificate Signing Request - * - WebServerType Possible values: apacheopenssl, apachessl, apacheraven, apachessleay, c2net, ibmhttp, iplanet, domino, dominogo4625, dominogo4626, netscape, zeusv3, apache2, apacheapachessl, cobaltseries, cpanel, ensim, hsphere,ipswitch, plesk, tomcat, weblogic, website, webstar, iis, other, iis4, iis5 - * - AdminOrganizationName Organization of the Admin contact - * - AdminJobTitle Job title of the Admin contact - * - AdminFirstName First name of the Admin contact - * - AdminLastName Last name of the Admin contact - * - AdminAddress1 Address1 of the Admin contact - * - AdminAddress2 Address2 of the Admin contact - * - AdminCity City of the Admin contact - * - AdminStateProvince State/Province of the Admin contact - * - AdminStateProvinceChoice StateProvinceChoice of the Admin contact - * - AdminPostalCode Postal/ZIP Code of the Admin contact - * - AdminCountry Country of the Admin contact - * - AdminPhone Phone number in the format +NNN.NNNNNNNNNN - * - AdminPhoneExt PhoneExt of the Admin contact - * - AdminFax Fax number in the format +NNN.NNNNNNNNNN - * - AdminEmailAddress Email address of the Admin contact - * - TechOrganizationName Oraganization of the Tech contact - * - TechJobTitle Job title of the Tech contact - * - TechFirstName First name of the Tech contact - * - TechLastName Last name of the Tech contact - * - TechAddress1 Address1 of the Tech contact - * - TechAddress2 Address2 of the Tech contact - * - TechCity City of the Tech contact - * - TechStateProvince State/Province of the Tech contact - * - TechStateProvinceChoice StateProvinceChoice of the Tech contact - * - TechPostalCode Postal/ZIP Code of the Tech contact - * - TechCountry Country of the Tech contact - * - TechPhone Phone number in format the +NNN.NNNNNNNNNN - * - TechPhoneExt PhoneExt of the Tech contact - * - TechFax Fax number in format the +NNN.NNNNNNNNNN - * - TechEmailAddress Email address of the Tech contact - * - BillingOrganizationName Organization of the Billing contact - * - BillingJobTitle Job title of the Billing contact - * - BillingFirstName First name of the Billing contact - * - BillingLastName Last name of the Billing contact - * - BillingAddress1 Address1 of the Billing contact - * - BillingAddress2 Address2 of the Billing contact - * - BillingCity City of the Billing contact - * - BillingStateProvince State/Province of the Billing contact - * - BillingStateProvinceChoice StateProvinceChoice of the Billing contact - * - BillingPostalCode Postal/ZIP Code of the Billing contact - * - BillingCountry Country of the Billing contact - * - BillingPhone Phone number in the format +NNN.NNNNNNNNNN - * - BillingPhoneExt PhoneExt of the Billing contact - * - BillingFax Fax number in the format +NNN.NNNNNNNNNN - * - BillingEmailAddress Email address of the Billing contact - * - *** Additional Parameters *** - * Geotrust, Verisign and Thawte OV and EV Certificates and Thawte SSL 123 - * - OrganizationLegalName Legal Name of the Organization - * - OrganizationDUNS DUNS of the Organization - * - OrganizationAddress1 Address1 of the Organization - * - OrganizationAddress2 Address2 of the Organization - * - OrganizationCity City of the Organization - * - OrganizationStateProvince State/Province of the Organization - * - OrganizationPostalCode PostalCode/ZIP of the Organization - * - OrganizationCountry Country of the Organization - * - OrganizationPhone Phone number in the format +NNN.NNNNNNNNNN - * - OrganizationFax Fax number in the format +NNN.NNNNNNNNNN - * Comodo EV Certificates (Comodo EV SSL, Comodo EV SGC SSL) - * - CompanyIncorporationCountry Country of Company incorpration - * - CompanyIncorporationStateProvince State/province of company incorporation - * - CompanyIncorporationLocality locality of company incorporation - * - CompanyIncorporationDate Company Incorporation date - * - CompanyDBA Company DBA - * - CompanyRegistrationNumber Registration number of the company - * Comodo OV Certificates (InstantSSL, InstantSSL Pro, PremiumSSL, PremiumSSL Wildcard) - * - OrganizationRepEmailAddress Represantative's email address used for verification by comodo - * - OrganizationRepCallbackMethod Possible values: phone, letter - * - OrganizationRepFirstName Represantative's first name - * - OrganizationRepLastName Represantative's last name - * - OrganizationRepTitle Represantative's title - * - OrganizationRepCallbackDestinationSame Possible values: yes, no - * - OrganizationRepLegalName Representative's Legal Name. This parameter is required only if OrganizationRepCallbackDestinationSame parameter is set as No - * - OrganizationRepDUNS - * - OrganizationRepAddress1 Representative's Address. This parameter is required only if OrganizationRepCallbackDestinationSame parameter is set as No - * - OrganizationRepAddress2 Representative's Address - * - OrganizationRepCity Representative's City. This parameter is required only if OrganizationRepCallbackDestinationSame parameter is set as No - * - OrganizationRepStateProvince Representative's State/Province. This parameter is required if OrganizationRepCallbackDestinationSame parameter is set as No - * - OrganizationRepPostalCode Representative's postal code. This parameter is required only if OrganizationRepCallbackDestinationSame parameter is set as No - * - OrganizationRepCountry Representative's country. This parameter is required only if OrganizationRepCallbackDestinationSame parameter is set as No - * - OrganizationRepPhone Representative's phone number - * - OrganizationRepFax Representative's fax number - * - OrganizationRepPostOfficeBox Representative's PO Box - * @return NamesiloResponse - */ - public function activate(array $vars) { - return $this->api->submit("namesilo.ssl.activate", $vars); - } - - /** - * Retrieves information about the requested SSL certificate - * - * @param array $vars An array of input params including: - * - CertificateID Unique ID of the SSL Certificate - * @return NamesiloResponse - */ - public function getInfo(array $vars) { - return $this->api->submit("namesilo.ssl.getInfo", $vars); - } - - /** - * Parsers the CSR - * - * @param array $vars An array of input params including: - * - csr Certificate Signing Request - * - CertificateType Type of SSL Certificate - * @return NamesiloResponse - */ - public function parseCsr(array $vars) { - return $this->api->submit("namesilo.ssl.parseCSR", $vars); - } - - /** - * Gets approver email list for the requested domain. - * - * @param array $vars An array of input params including: - * - DomainName Domain name to get the list - * - CertificateType Type of SSL Certificate - * @return NamesiloResponse - */ - public function getApproverEmailList(array $vars) { - return $this->api->submit("namesilo.ssl.getApproverEmailList", $vars); - } - - /** - * Returns a list of SSL certificates for a particular user. - * - * @param array $vars An array of input params including: - * - DomainName Domain name to get the list - * - CertificateType Type of SSL Certificate - * @return NamesiloResponse - */ - public function getList(array $vars) { - return $this->api->submit("namesilo.ssl.getList", $vars); - } - - /** - * Creates a new SSL certificate. - * - * @param array $vars An array of input params including: - * - Years Number of years to register - * - PromotionCode Promotional (coupon) code for the certificate - * - Type Type of SSL (QuickSSL, QuickSSL Premium, RapidSSL, RapidSSL Wildcard, PremiumSSL, InstantSSL, PositiveSSL, PositiveSSL Wildcard, True BusinessID with EV, True BusinessID , True BusinessID Wildcard , Secure Site , Secure Site Pro , Secure Site with EV , Secure Site Pro with EV, EssentialSSL, EssentialSSL Wildcard, InstantSSL Pro, Premiumssl wildcard, EV SSL, EV SSL SGC, SSL123, SSL Web Server, SGC Super Certs, SSL Webserver EV) - * @return NamesiloResponse - */ - public function create(array $vars) { - return $this->api->submit("namesilo.ssl.create", $vars); - } - - /** - * Resends the approver email. - * - * @param array $vars An array of input params including: - * - CertificateID The unique certID that you get after calling ssl.create command - * @return NamesiloResponse - */ - public function resendApproverEmail(array $vars) { - return $this->api->submit("namesilo.ssl.resendApproverEmail", $vars); - } +class NamesiloSsl +{ + /** + * @var NamesiloApi + */ + private $api; - /** - * Resends the fulfilment email containing the certificate. - * - * @param array $vars An array of input params including: - * - CertificateID The unique certID that you get after calling ssl.create command - * @return NamesiloResponse - */ - public function resendFulfillmentEmail(array $vars) { - return $this->api->submit("namesilo.ssl.resendFulfillmentEmail", $vars); - } + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Activates a newly purchased SSL certificate. + * + * @param array $vars An array of input params including: + * + * - CertificateID Unique ID of the SSL certificate you wish to activate + * - ApproverEmail The EmailID which is on the Approver Email list + * - csr Certificate Signing Request + * - WebServerType Possible values: apacheopenssl, apachessl, apacheraven, apachessleay, c2net, ibmhttp, iplanet, + * domino, dominogo4625, dominogo4626, netscape, zeusv3, apache2, apacheapachessl, cobaltseries, cpanel, + * ensim, hsphere,ipswitch, plesk, tomcat, weblogic, website, webstar, iis, other, iis4, iis5 + * - AdminOrganizationName Organization of the Admin contact + * - AdminJobTitle Job title of the Admin contact + * - AdminFirstName First name of the Admin contact + * - AdminLastName Last name of the Admin contact + * - AdminAddress1 Address1 of the Admin contact + * - AdminAddress2 Address2 of the Admin contact + * - AdminCity City of the Admin contact + * - AdminStateProvince State/Province of the Admin contact + * - AdminStateProvinceChoice StateProvinceChoice of the Admin contact + * - AdminPostalCode Postal/ZIP Code of the Admin contact + * - AdminCountry Country of the Admin contact + * - AdminPhone Phone number in the format +NNN.NNNNNNNNNN + * - AdminPhoneExt PhoneExt of the Admin contact + * - AdminFax Fax number in the format +NNN.NNNNNNNNNN + * - AdminEmailAddress Email address of the Admin contact + * - TechOrganizationName Oraganization of the Tech contact + * - TechJobTitle Job title of the Tech contact + * - TechFirstName First name of the Tech contact + * - TechLastName Last name of the Tech contact + * - TechAddress1 Address1 of the Tech contact + * - TechAddress2 Address2 of the Tech contact + * - TechCity City of the Tech contact + * - TechStateProvince State/Province of the Tech contact + * - TechStateProvinceChoice StateProvinceChoice of the Tech contact + * - TechPostalCode Postal/ZIP Code of the Tech contact + * - TechCountry Country of the Tech contact + * - TechPhone Phone number in format the +NNN.NNNNNNNNNN + * - TechPhoneExt PhoneExt of the Tech contact + * - TechFax Fax number in format the +NNN.NNNNNNNNNN + * - TechEmailAddress Email address of the Tech contact + * - BillingOrganizationName Organization of the Billing contact + * - BillingJobTitle Job title of the Billing contact + * - BillingFirstName First name of the Billing contact + * - BillingLastName Last name of the Billing contact + * - BillingAddress1 Address1 of the Billing contact + * - BillingAddress2 Address2 of the Billing contact + * - BillingCity City of the Billing contact + * - BillingStateProvince State/Province of the Billing contact + * - BillingStateProvinceChoice StateProvinceChoice of the Billing contact + * - BillingPostalCode Postal/ZIP Code of the Billing contact + * - BillingCountry Country of the Billing contact + * - BillingPhone Phone number in the format +NNN.NNNNNNNNNN + * - BillingPhoneExt PhoneExt of the Billing contact + * - BillingFax Fax number in the format +NNN.NNNNNNNNNN + * - BillingEmailAddress Email address of the Billing contact + * - *** Additional Parameters *** + * Geotrust, Verisign and Thawte OV and EV Certificates and Thawte SSL 123 + * - OrganizationLegalName Legal Name of the Organization + * - OrganizationDUNS DUNS of the Organization + * - OrganizationAddress1 Address1 of the Organization + * - OrganizationAddress2 Address2 of the Organization + * - OrganizationCity City of the Organization + * - OrganizationStateProvince State/Province of the Organization + * - OrganizationPostalCode PostalCode/ZIP of the Organization + * - OrganizationCountry Country of the Organization + * - OrganizationPhone Phone number in the format +NNN.NNNNNNNNNN + * - OrganizationFax Fax number in the format +NNN.NNNNNNNNNN + * Comodo EV Certificates (Comodo EV SSL, Comodo EV SGC SSL) + * - CompanyIncorporationCountry Country of Company incorpration + * - CompanyIncorporationStateProvince State/province of company incorporation + * - CompanyIncorporationLocality locality of company incorporation + * - CompanyIncorporationDate Company Incorporation date + * - CompanyDBA Company DBA + * - CompanyRegistrationNumber Registration number of the company + * Comodo OV Certificates (InstantSSL, InstantSSL Pro, PremiumSSL, PremiumSSL Wildcard) + * - OrganizationRepEmailAddress Represantative's email address used for verification by comodo + * - OrganizationRepCallbackMethod Possible values: phone, letter + * - OrganizationRepFirstName Represantative's first name + * - OrganizationRepLastName Represantative's last name + * - OrganizationRepTitle Represantative's title + * - OrganizationRepCallbackDestinationSame Possible values: yes, no + * - OrganizationRepLegalName Representative's Legal Name. This parameter is required only if + * OrganizationRepCallbackDestinationSame parameter is set as No + * - OrganizationRepDUNS + * - OrganizationRepAddress1 Representative's Address. This parameter is required only if + * OrganizationRepCallbackDestinationSame parameter is set as No + * - OrganizationRepAddress2 Representative's Address + * - OrganizationRepCity Representative's City. This parameter is required only if + * OrganizationRepCallbackDestinationSame parameter is set as No + * - OrganizationRepStateProvince Representative's State/Province. This parameter is required if + * OrganizationRepCallbackDestinationSame parameter is set as No + * - OrganizationRepPostalCode Representative's postal code. This parameter is required only if + * OrganizationRepCallbackDestinationSame parameter is set as No + * - OrganizationRepCountry Representative's country. This parameter is required only if + * OrganizationRepCallbackDestinationSame parameter is set as No + * - OrganizationRepPhone Representative's phone number + * - OrganizationRepFax Representative's fax number + * - OrganizationRepPostOfficeBox Representative's PO Box + * @return NamesiloResponse + */ + public function activate(array $vars) + { + return $this->api->submit('namesilo.ssl.activate', $vars); + } + + /** + * Retrieves information about the requested SSL certificate + * + * @param array $vars An array of input params including: + * + * - CertificateID Unique ID of the SSL Certificate + * @return NamesiloResponse + */ + public function getInfo(array $vars) + { + return $this->api->submit('namesilo.ssl.getInfo', $vars); + } + + /** + * Parsers the CSR + * + * @param array $vars An array of input params including: + * + * - csr Certificate Signing Request + * - CertificateType Type of SSL Certificate + * @return NamesiloResponse + */ + public function parseCsr(array $vars) + { + return $this->api->submit('namesilo.ssl.parseCSR', $vars); + } + + /** + * Gets approver email list for the requested domain. + * + * @param array $vars An array of input params including: + * + * - DomainName Domain name to get the list + * - CertificateType Type of SSL Certificate + * @return NamesiloResponse + */ + public function getApproverEmailList(array $vars) + { + return $this->api->submit('namesilo.ssl.getApproverEmailList', $vars); + } + + /** + * Returns a list of SSL certificates for a particular user. + * + * @param array $vars An array of input params including: + * + * - DomainName Domain name to get the list + * - CertificateType Type of SSL Certificate + * @return NamesiloResponse + */ + public function getList(array $vars) + { + return $this->api->submit('namesilo.ssl.getList', $vars); + } + + /** + * Creates a new SSL certificate. + * + * @param array $vars An array of input params including: + * + * - Years Number of years to register + * - PromotionCode Promotional (coupon) code for the certificate + * - Type Type of SSL (QuickSSL, QuickSSL Premium, RapidSSL, RapidSSL Wildcard, PremiumSSL, InstantSSL, + * PositiveSSL, PositiveSSL Wildcard, True BusinessID with EV, True BusinessID , True BusinessID Wildcard, + * Secure Site, Secure Site Pro, Secure Site with EV, Secure Site Pro with EV, EssentialSSL, + * EssentialSSL Wildcard, InstantSSL Pro, Premiumssl wildcard, EV SSL, EV SSL SGC, SSL123, SSL Web Server, + * SGC Super Certs, SSL Webserver EV) + * @return NamesiloResponse + */ + public function create(array $vars) + { + return $this->api->submit('namesilo.ssl.create', $vars); + } + + /** + * Resends the approver email. + * + * @param array $vars An array of input params including: + * + * - CertificateID The unique certID that you get after calling ssl.create command + * @return NamesiloResponse + */ + public function resendApproverEmail(array $vars) + { + return $this->api->submit('namesilo.ssl.resendApproverEmail', $vars); + } + + /** + * Resends the fulfilment email containing the certificate. + * + * @param array $vars An array of input params including: + * + * - CertificateID The unique certID that you get after calling ssl.create command + * @return NamesiloResponse + */ + public function resendFulfillmentEmail(array $vars) + { + return $this->api->submit('namesilo.ssl.resendFulfillmentEmail', $vars); + } } -?> \ No newline at end of file diff --git a/apis/commands/users.php b/apis/commands/users.php index 6321390..8a1e5ce 100644 --- a/apis/commands/users.php +++ b/apis/commands/users.php @@ -6,172 +6,190 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloUsers { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Creates a new user account at Namesilo under this ApiUser. NOTE: Use - * the global parameter "UserName" to specify new user value. - * - * @param array $vars An array of input params including: - * - NewUserName Username for the new user account - * - NewUserPassword Password for the new user account - * - EmailAddress Email address of the user - * - IgnoreDuplicateEmailAddress By default, it ignores to check if the email address is already in use. - * - FirstName First name of the user - * - LastName Last name of the user - * - AcceptTerms Terms of agreement. The Value should be 1 for user account creation. - * - AcceptNews Possible values are 0 and 1. Value should be 1 if the user wants to recieve newsletters else it should be 0. - * - JobTitle Job designation of the user - * - Organization Organization of the user - * - Address1 StreetAddress1 of the user - * - Address2 StreetAddress2 of the user - * - City City of the user - * - StateProvince State/Province name of the user - * - Zip Zip/Postal code of the user - * - Country Two letter country code of the user - * - Phone Phone number in the format +NNN.NNNNNNNNNN - * - PhoneExt PhoneExt of the user - * - Fax Fax number in the format +NNN.NNNNNNNNNN - * @return NamesiloResponse - */ - public function create(array $vars) { - return $this->api->submit("namesilo.users.create", $vars); - } +class NamesiloUsers +{ + /** + * @var NamesiloApi + */ + private $api; - /** - * Returns pricing information for a requested product type. - * - * @param array $vars An array of input params including: - * - ProductType Product Type to get pricing information, possible values: - * - DOMAIN - * - SSLCERTIFICATE - * - WHOISGUARD - * - ProductCategory Specific category within a product type, possible values: - * - If ProductType is DOMAIN: REGISTER,RENEW,REACTIVATE,TRANSFER,WBL - * - If ProductType is SSLCERTIFICATE: COMODO,GEOTRUST - * - If ProductType is WHOISGUARD: WHOISGUARD - * - PromotionCode Promotional (coupon) code for the user - * @return NamesiloResponse - */ - public function getPricing(array $vars) { - return $this->api->submit("namesilo.users.getPricing", $vars); - } - - /** - * Gets information about fund in the user's account.This method returns - * the following information: Available Balance, Account Balance, - * Earned Amount, Withdrawable Amount and Funds Required for AutoRenew. - * NOTE: If a domain setup with automatic renewal is expiring within the - * next 90 days, the "FundsRequiredForAutoRenew" attribute shows the amount - * needed in your Namesilo account to complete auto renewal. - * - * @return NamesiloResponse - */ - public function getBalances() { - return $this->api->submit("namesilo.users.getBalances"); - } - - /** - * Changes password of the particular user's account. - * - * @param array $vars An array of input params including: - * - OldPassword Old password of the user - * - NewPassword New password of the user - * @return NamesiloResponse - */ - public function changePassword(array $vars) { - return $this->api->submit("namesilo.users.changePassword", $vars); - } - - /** - * Updates user account information for the particular user. - * - * @param array $vars An array of input params including: - * - JobTitle Job designation of the user - * - Organization Organization of the user - * - Address1 StreetAddress1 of the user - * - Address2 StreetAddress2 of the user - * - City City of the user - * - StateProvince State/Province name of the user - * - Zip Zip/Postal code of the user - * - Country Two letter country code of the user - * - EmailAddress Email address of the user - * - Phone Phone number in the format +NNN.NNNNNNNNNN - * - PhoneExt PhoneExt of the user - * - Fax Fax number in the format +NNN.NNNNNNNNNN - * @return NamesiloResponse - */ - public function update(array $vars) { - return $this->api->submit("namesilo.users.update", $vars); - } - - /** - * Creates a request to add funds through a credit card. - * - * @param array $vars An array of input params including: - * - Username Username to add funds to - * - PaymentType Possible value: Creditcard - * - Amount Amount to add in USD - * - ReturnUrl A valid URL where the user should be redirected once payment is complete - * @return NamesiloResponse - */ - public function createAddFundsRequest(array $vars) { - return $this->api->submit("namesilo.users.createAddFundsRequest", $vars); - } - - /** - * Gets the status of add funds request. - * - * @param array $vars An array of input params including: - * - TokenId The Unique ID that you received after calling namesilo.users.createaddfundsrequest method - * @return NamesiloResponse - */ - public function getAddFundsStatus(array $vars) { - return $this->api->submit("namesilo.users.getAddFundsStatus", $vars); - } - - /** - * Validates the username and password of user accounts you have created - * using the API command namesilo.users.create. You cannot use this - * command to validate user accounts created directly at namesilo.com - * - * @param array $vars An array of input params including: - * - Password Password of the user account - * @return NamesiloResponse - */ - public function login(array $vars) { - return $this->api->submit("namesilo.users.login", $vars); - } - - /** - * When you call this API, a link to reset password will be emailed to the - * end user's profile email id.The end user needs to click on the link to - * reset password. - * - * @param array $vars An array of input params including: - * - FindBy Possible values:EMAILADDRESS, DOMAINNAME,USERNAME - * - FindByValue The username/email address/domain of the user. - * - EmailFromName Enter a different value to overwrite the default value - * - EmailFrom Enter a different value to overwrite the default value - * - URLPattern Enter a different URL to overwrite namesilo.com. - * @return NamesiloResponse - */ - public function resetPassword(array $vars) { - return $this->api->submit("namesilo.users.resetPassword", $vars); - } + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Creates a new user account at Namesilo under this ApiUser. NOTE: Use + * the global parameter "UserName" to specify new user value. + * + * @param array $vars An array of input params including: + * + * - NewUserName Username for the new user account + * - NewUserPassword Password for the new user account + * - EmailAddress Email address of the user + * - IgnoreDuplicateEmailAddress By default, it ignores to check if the email address is already in use. + * - FirstName First name of the user + * - LastName Last name of the user + * - AcceptTerms Terms of agreement. The Value should be 1 for user account creation. + * - AcceptNews Possible values are 0 and 1. Value should be 1 if the user wants to recieve newsletters else + * it should be 0. + * - JobTitle Job designation of the user + * - Organization Organization of the user + * - Address1 StreetAddress1 of the user + * - Address2 StreetAddress2 of the user + * - City City of the user + * - StateProvince State/Province name of the user + * - Zip Zip/Postal code of the user + * - Country Two letter country code of the user + * - Phone Phone number in the format +NNN.NNNNNNNNNN + * - PhoneExt PhoneExt of the user + * - Fax Fax number in the format +NNN.NNNNNNNNNN + * @return NamesiloResponse + */ + public function create(array $vars) + { + return $this->api->submit('namesilo.users.create', $vars); + } + + /** + * Returns pricing information for a requested product type. + * + * @param array $vars An array of input params including: + * + * - ProductType Product Type to get pricing information, possible values: + * - DOMAIN + * - SSLCERTIFICATE + * - WHOISGUARD + * - ProductCategory Specific category within a product type, possible values: + * - If ProductType is DOMAIN: REGISTER,RENEW,REACTIVATE,TRANSFER,WBL + * - If ProductType is SSLCERTIFICATE: COMODO,GEOTRUST + * - If ProductType is WHOISGUARD: WHOISGUARD + * - PromotionCode Promotional (coupon) code for the user + * @return NamesiloResponse + */ + public function getPricing(array $vars) + { + return $this->api->submit('namesilo.users.getPricing', $vars); + } + + /** + * Gets information about fund in the user's account.This method returns + * the following information: Available Balance, Account Balance, + * Earned Amount, Withdrawable Amount and Funds Required for AutoRenew. + * NOTE: If a domain setup with automatic renewal is expiring within the + * next 90 days, the "FundsRequiredForAutoRenew" attribute shows the amount + * needed in your Namesilo account to complete auto renewal. + * + * @return NamesiloResponse + */ + public function getBalances() + { + return $this->api->submit('namesilo.users.getBalances'); + } + + /** + * Changes password of the particular user's account. + * + * @param array $vars An array of input params including: + * + * - OldPassword Old password of the user + * - NewPassword New password of the user + * @return NamesiloResponse + */ + public function changePassword(array $vars) + { + return $this->api->submit('namesilo.users.changePassword', $vars); + } + + /** + * Updates user account information for the particular user. + * + * @param array $vars An array of input params including: + * + * - JobTitle Job designation of the user + * - Organization Organization of the user + * - Address1 StreetAddress1 of the user + * - Address2 StreetAddress2 of the user + * - City City of the user + * - StateProvince State/Province name of the user + * - Zip Zip/Postal code of the user + * - Country Two letter country code of the user + * - EmailAddress Email address of the user + * - Phone Phone number in the format +NNN.NNNNNNNNNN + * - PhoneExt PhoneExt of the user + * - Fax Fax number in the format +NNN.NNNNNNNNNN + * @return NamesiloResponse + */ + public function update(array $vars) + { + return $this->api->submit('namesilo.users.update', $vars); + } + + /** + * Creates a request to add funds through a credit card. + * + * @param array $vars An array of input params including: + * + * - Username Username to add funds to + * - PaymentType Possible value: Creditcard + * - Amount Amount to add in USD + * - ReturnUrl A valid URL where the user should be redirected once payment is complete + * @return NamesiloResponse + */ + public function createAddFundsRequest(array $vars) + { + return $this->api->submit('namesilo.users.createAddFundsRequest', $vars); + } + + /** + * Gets the status of add funds request. + * + * @param array $vars An array of input params including: + * + * - TokenId The Unique ID that you received after calling namesilo.users.createaddfundsrequest method + * @return NamesiloResponse + */ + public function getAddFundsStatus(array $vars) + { + return $this->api->submit('namesilo.users.getAddFundsStatus', $vars); + } + + /** + * Validates the username and password of user accounts you have created + * using the API command namesilo.users.create. You cannot use this + * command to validate user accounts created directly at namesilo.com + * + * @param array $vars An array of input params including: + * + * - Password Password of the user account + * @return NamesiloResponse + */ + public function login(array $vars) + { + return $this->api->submit('namesilo.users.login', $vars); + } + + /** + * When you call this API, a link to reset password will be emailed to the + * end user's profile email id.The end user needs to click on the link to + * reset password. + * + * @param array $vars An array of input params including: + * + * - FindBy Possible values:EMAILADDRESS, DOMAINNAME,USERNAME + * - FindByValue The username/email address/domain of the user. + * - EmailFromName Enter a different value to overwrite the default value + * - EmailFrom Enter a different value to overwrite the default value + * - URLPattern Enter a different URL to overwrite namesilo.com. + * @return NamesiloResponse + */ + public function resetPassword(array $vars) + { + return $this->api->submit('namesilo.users.resetPassword', $vars); + } } -?> \ No newline at end of file diff --git a/apis/commands/users_address.php b/apis/commands/users_address.php index 3968528..9bff74b 100644 --- a/apis/commands/users_address.php +++ b/apis/commands/users_address.php @@ -6,117 +6,129 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo.commands */ -class NamesiloUsersAddress { - - /** - * @var NamesiloApi - */ - private $api; - - /** - * Sets the API to use for communication - * - * @param NamesiloApi $api The API to use for communication - */ - public function __construct(NamesiloApi $api) { - $this->api = $api; - } - - /** - * Creates a new address for the user - * - * @param array $vars An array of input params including: - * - AddressName Address name to create - * - DefaultYN Possible values are 0 and 1.If the value of this parameter is set to 1, the address is set as default address for the user. - * - FirstName First name of the user - * - LastName Last name of the user - * - JobTitle Job designation of the user - * - Organization Organization of the user - * - Address1 StreetAddress1 of the user - * - Address2 StreetAddress2 of the user - * - City City of the user - * - StateProvince State/Province name of the user - * - StateProvinceChoice State/Province choice of the user - * - Zip Zip/Postal code of the user - * - Country Two letter country code of the user - * - Phone Phone number in the format +NNN.NNNNNNNNNN - * - Fax Fax number in the format +NNN.NNNNNNNNNN - * - PhoneExt PhoneExt of the user - * - EmailAddress Email address of the user - * @return NamesiloResponse - */ - public function create(array $vars) { - return $this->api->submit("namesilo.users.address.create", $vars); - } - - /** - * Creates a new address for the user - * - * @param array $vars An array of input params including: - * - AddressId The unique address ID to update - * - AddressName Address name to create - * - DefaultYN Possible values are 0 and 1.If the value of this parameter is set to 1, the address is set as default address for the user. - * - FirstName First name of the user - * - LastName Last name of the user - * - JobTitle Job designation of the user - * - Organization Organization of the user - * - Address1 StreetAddress1 of the user - * - Address2 StreetAddress2 of the user - * - City City of the user - * - StateProvince State/Province name of the user - * - StateProvinceChoice State/Province choice of the user - * - Zip Zip/Postal code of the user - * - Country Two letter country code of the user - * - Phone Phone number in the format +NNN.NNNNNNNNNN - * - Fax Fax number in the format +NNN.NNNNNNNNNN - * - PhoneExt PhoneExt of the user - * - EmailAddress Email address of the user - * @return NamesiloResponse - */ - public function update(array $vars) { - return $this->api->submit("namesilo.users.address.update", $vars); - } - - /** - * Creates a new address for the user - * - * @param array $vars An array of input params including: - * - AddressId The unique AddressID to delete - * @return NamesiloResponse - */ - public function delete(array $vars) { - return $this->api->submit("namesilo.users.address.delete", $vars); - } - - /** - * Creates a new address for the user - * - * @return NamesiloResponse - */ - public function getList() { - return $this->api->submit("namesilo.users.address.getList"); - } - - /** - * Creates a new address for the user - * - * @param array $vars An array of input params including: - * - AddressId The unique addressID - * @return NamesiloResponse - */ - public function getInfo(array $vars) { - return $this->api->submit("namesilo.users.address.getInfo", $vars); - } - - /** - * Creates a new address for the user - * - * @param array $vars An array of input params including: - * - AddressId The unique addressID to set default - * @return NamesiloResponse - */ - public function setDefault(array $vars) { - return $this->api->submit("namesilo.users.address.setDefault", $vars); - } +class NamesiloUsersAddress +{ + /** + * @var NamesiloApi + */ + private $api; + + /** + * Sets the API to use for communication + * + * @param NamesiloApi $api The API to use for communication + */ + public function __construct(NamesiloApi $api) + { + $this->api = $api; + } + + /** + * Creates a new address for the user + * + * @param array $vars An array of input params including: + * + * - AddressName Address name to create + * - DefaultYN Possible values are 0 and 1.If the value of this parameter is set to 1, the address is + * set as default address for the user. + * - FirstName First name of the user + * - LastName Last name of the user + * - JobTitle Job designation of the user + * - Organization Organization of the user + * - Address1 StreetAddress1 of the user + * - Address2 StreetAddress2 of the user + * - City City of the user + * - StateProvince State/Province name of the user + * - StateProvinceChoice State/Province choice of the user + * - Zip Zip/Postal code of the user + * - Country Two letter country code of the user + * - Phone Phone number in the format +NNN.NNNNNNNNNN + * - Fax Fax number in the format +NNN.NNNNNNNNNN + * - PhoneExt PhoneExt of the user + * - EmailAddress Email address of the user + * @return NamesiloResponse + */ + public function create(array $vars) + { + return $this->api->submit('namesilo.users.address.create', $vars); + } + + /** + * Creates a new address for the user + * + * @param array $vars An array of input params including: + * - AddressId The unique address ID to update + * - AddressName Address name to create + * - DefaultYN Possible values are 0 and 1.If the value of this parameter is set to 1, the address is + * set as default address for the user. + * - FirstName First name of the user + * - LastName Last name of the user + * - JobTitle Job designation of the user + * - Organization Organization of the user + * - Address1 StreetAddress1 of the user + * - Address2 StreetAddress2 of the user + * - City City of the user + * - StateProvince State/Province name of the user + * - StateProvinceChoice State/Province choice of the user + * - Zip Zip/Postal code of the user + * - Country Two letter country code of the user + * - Phone Phone number in the format +NNN.NNNNNNNNNN + * - Fax Fax number in the format +NNN.NNNNNNNNNN + * - PhoneExt PhoneExt of the user + * - EmailAddress Email address of the user + * @return NamesiloResponse + */ + public function update(array $vars) + { + return $this->api->submit('namesilo.users.address.update', $vars); + } + + /** + * Creates a new address for the user + * + * @param array $vars An array of input params including: + * + * - AddressId The unique AddressID to delete + * @return NamesiloResponse + */ + public function delete(array $vars) + { + return $this->api->submit('namesilo.users.address.delete', $vars); + } + + /** + * Creates a new address for the user + * + * @return NamesiloResponse + */ + public function getList() + { + return $this->api->submit('namesilo.users.address.getList'); + } + + /** + * Creates a new address for the user + * + * @param array $vars An array of input params including: + * + * - AddressId The unique addressID + * @return NamesiloResponse + */ + public function getInfo(array $vars) + { + return $this->api->submit('namesilo.users.address.getInfo', $vars); + } + + /** + * Creates a new address for the user + * + * @param array $vars An array of input params including: + * + * - AddressId The unique addressID to set default + * @return NamesiloResponse + */ + public function setDefault(array $vars) + { + return $this->api->submit('namesilo.users.address.setDefault', $vars); + } } -?> \ No newline at end of file diff --git a/apis/namesilo_api.php b/apis/namesilo_api.php index 522afa7..69d1d72 100644 --- a/apis/namesilo_api.php +++ b/apis/namesilo_api.php @@ -1,12 +1,11 @@ null, 'args' => null); +class NamesiloApi +{ + const SANDBOX_URL = 'http://sandbox.namesilo.com/api'; + const LIVE_URL = 'https://www.namesilo.com/api'; + + /** + * @var string API version + */ + private $api_version = 1; + /** + * @var string The format of the API response + */ + private $format = 'xml'; + /** + * @var string The user to connect as + */ + private $user; + /** + * @var string The username to execute an API command using + */ + private $username; + /** + * @var string The key to use when connecting + */ + private $key; + /** + * @var bool Whether or not to process in sandbox mode (for testing) + */ + private $sandbox; + /** + * @var array An array representing the last request made + */ + private $last_request = ['url' => null, 'args' => null]; /** * @var bool use batch api url if true */ - private $batch; + private $batch; /** * @var int http return code */ - public $httpcode; - - /** - * Sets the connection details - * - * @param string $user The user to connect as - * @param string $key The key to use when connecting - * @param boolean $sandbox Whether or not to process in sandbox mode (for testing) - * @param string $username The username to execute an API command using + public $httpcode; + + /** + * Sets the connection details + * + * @param string $user The user to connect as + * @param string $key The key to use when connecting + * @param bool $sandbox Whether or not to process in sandbox mode (for testing) + * @param string $username The username to execute an API command using * @param bool $batch Set true to pass commands to batch API URL. * See https://www.namesilo.com/Support/API-Automated-Batch-Processing - */ - public function __construct($user, $key, $sandbox = true, $username = null, $batch=false) { - - $this->user = $user; - $this->key = $key; - - $this->sandbox = filter_var( $sandbox, FILTER_VALIDATE_BOOLEAN ); - - if (!$username) - $username = $user; - - $this->username = $username; - - $this->batch = $batch; - } - - /** - * Submits a request to the API - * - * @param string $command The command to submit - * @param array $args An array of key/value pair arguments to submit to the given API command - * @return NamesiloResponse The response object - */ - public function submit($command, array $args = array()) { - - $url = self::LIVE_URL; - if ($this->sandbox) - $url = self::SANDBOX_URL; - - if($this->batch) + */ + public function __construct($user, $key, $sandbox = true, $username = null, $batch = false) + { + $this->user = $user; + $this->key = $key; + + $this->sandbox = filter_var($sandbox, FILTER_VALIDATE_BOOLEAN); + + if (!$username) { + $username = $user; + } + + $this->username = $username; + + $this->batch = $batch; + } + + /** + * Submits a request to the API + * + * @param string $command The command to submit + * @param array $args An array of key/value pair arguments to submit to the given API command + * @return NamesiloResponse The response object + */ + public function submit($command, array $args = []) + { + $url = self::LIVE_URL; + if ($this->sandbox) { + $url = self::SANDBOX_URL; + } + + if ($this->batch) { $url = $url . 'batch'; - - $url .= '/' . $command . "?key={$this->key}"; - - //$args['ApiUser'] = $this->user; - //if (!array_key_exists("UserName", $args)) - //$args['UserName'] = $this->username; - $args['version'] = $this->api_version; - $args['type'] = $this->format; - //$args['key'] = $this->key; - //$args['Command'] = $command; - - //if (!isset($args['ClientIP'])) - //$args['ClientIP'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "127.0.0.1"; - - $this->last_request = array( - 'url' => $url, - 'args' => $args - ); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $args); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - $response = curl_exec($ch); + } + + $url .= '/' . $command . '?key=' . $this->key; + + $args['version'] = $this->api_version; + $args['type'] = $this->format; + + $this->last_request = [ + 'url' => $url, + 'args' => $args + ]; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $args); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + $response = curl_exec($ch); $this->httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); - - //trigger_error( var_export( $args, true ) ); - //trigger_error( var_export( $response, true ) ); - - return new NamesiloResponse($response); - } - - /** - * Returns the details of the last request made - * - * @return array An array containg: - * - url The URL of the last request - * - args The paramters passed to the URL - */ - public function lastRequest() { - return $this->last_request; - } + curl_close($ch); + + return new NamesiloResponse($response); + } + + /** + * Returns the details of the last request made + * + * @return array An array containg: + * + * - url The URL of the last request + * - args The paramters passed to the URL + */ + public function lastRequest() + { + return $this->last_request; + } } -?> diff --git a/apis/namesilo_response.php b/apis/namesilo_response.php index 9de594f..d964739 100644 --- a/apis/namesilo_response.php +++ b/apis/namesilo_response.php @@ -6,99 +6,104 @@ * @license http://opensource.org/licenses/mit-license.php MIT License * @package namesilo */ -class NamesiloResponse { - - /** - * @var SimpleXMLElement The XML parsed response from the API - */ - private $xml; - /** - * @var string The raw response from the API - */ - private $raw; +class NamesiloResponse +{ + /** + * @var SimpleXMLElement The XML parsed response from the API + */ + private $xml; + /** + * @var string The raw response from the API + */ + private $raw; - /** - * Initializes the Namesilo Response - * - * @param string $response The raw XML response data from an API request - */ - public function __construct($response) { - $this->raw = $response; - - try { - $this->xml = new SimpleXMLElement($this->raw); - } - catch (Exception $e) { - // Invalid response - } - } - - /** - * Returns the CommandResponse - * - * @return stdClass A stdClass object representing the CommandResponses, null if invalid response - */ - public function response( $assoc = false ) { - if ($this->xml && $this->xml instanceof SimpleXMLElement) { - return $this->formatResponse( $this->xml->reply, $assoc ); - } - return null; - } - - /** - * Returns the status of the API Responses - * - * @return string The status (300 = success) - */ - public function status() { - # To do: add status codes - if ($this->xml && $this->xml instanceof SimpleXMLElement) { - return (string)$this->xml->reply->code; - } - return null; - } - - /** - * Returns all errors contained in the response - * - * @return stdClass A stdClass object representing the errors in the response, false if invalid response - */ - public function errors() { - if ($this->xml && $this->xml instanceof SimpleXMLElement) { - return $this->formatResponse($this->xml->reply->detail); - } - return false; - } - - /** - * Returns all warnings contained in the response - * - * @return stdClass A stdClass object representing the warnings in the response, false if invalid response - */ - public function warnings() { - if ($this->xml && $this->xml instanceof SimpleXMLElement) { - return $this->formatResponse($this->xml->Warnings); - } - return false; - } - - /** - * Returns the raw response - * - * @return string The raw response - */ - public function raw() { - return $this->raw; - } - - /** - * Formats the given $data into a stdClass object by first JSON encoding, then JSON decoding it - * - * @param mixed $data The data to convert to a stdClass object - * @return stdClass $data in a stdClass object form - */ - private function formatResponse( $data, $assoc = false ) { - return json_decode( json_encode( $data ), $assoc ); - } + /** + * Initializes the Namesilo Response + * + * @param string $response The raw XML response data from an API request + */ + public function __construct($response) + { + $this->raw = $response; + + try { + $this->xml = new SimpleXMLElement($this->raw); + } catch (Exception $e) { + // Invalid response + } + } + + /** + * Returns the CommandResponse + * + * @return stdClass A stdClass object representing the CommandResponses, null if invalid response + */ + public function response($assoc = false) + { + if ($this->xml && $this->xml instanceof SimpleXMLElement) { + return $this->formatResponse($this->xml->reply, $assoc); + } + return null; + } + + /** + * Returns the status of the API Responses + * + * @return string The status (300 = success) + */ + public function status() + { + # To do: add status codes + if ($this->xml && $this->xml instanceof SimpleXMLElement) { + return (string)$this->xml->reply->code; + } + return null; + } + + /** + * Returns all errors contained in the response + * + * @return stdClass A stdClass object representing the errors in the response, false if invalid response + */ + public function errors() + { + if ($this->xml && $this->xml instanceof SimpleXMLElement) { + return $this->formatResponse($this->xml->reply->detail); + } + return false; + } + + /** + * Returns all warnings contained in the response + * + * @return stdClass A stdClass object representing the warnings in the response, false if invalid response + */ + public function warnings() + { + if ($this->xml && $this->xml instanceof SimpleXMLElement) { + return $this->formatResponse($this->xml->Warnings); + } + return false; + } + + /** + * Returns the raw response + * + * @return string The raw response + */ + public function raw() + { + return $this->raw; + } + + /** + * Formats the given $data into a stdClass object by first JSON encoding, then JSON decoding it + * + * @param mixed $data The data to convert to a stdClass object + * @return stdClass $data in a stdClass object form + */ + private function formatResponse($data, $assoc = false) + { + return json_decode(json_encode($data), $assoc); + } } -?> \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f2ef508 --- /dev/null +++ b/composer.json @@ -0,0 +1,24 @@ +{ + "name": "blesta/namesilo", + "description": "NameSilo Module", + "license": "proprietary", + "type": "blesta-module", + "require": { + "php": ">=5.4.0", + "blesta/composer-installer": "~1.0" + }, + "authors": [ + { + "name": "Phillips Data, Inc.", + "email": "jonathan@phillipsdata.com" + }, + { + "name": "KnownHost LLC", + "email": "support@knownhost.com" + }, + { + "name": "NETLINK IT SERVICES", + "email": "info@netlink.ie" + } + ] +} diff --git a/config.json b/config.json index 5ba94db..146c991 100644 --- a/config.json +++ b/config.json @@ -1,15 +1,35 @@ { - "version": "1.8.5", - "name": "NameSilo Domains Module", - "description": "Resell domains through NameSilo.", + "version": "1.10.0", + "name": "Namesilo.name", + "description": "Namesilo.description", "authors": [ + { + "name": "Phillips Data Inc.", + "url": "https://www.blesta.com" + }, { - "name": "KnownHost LLC &", + "name": "KnownHost LLC", "url": "https://www.knownhost.com" }, { "name": "NETLINK IT SERVICES", "url": "http://www.netlink.ie/" } - ] + ], + "package": { + "name_key": "domain" + }, + "service": { + "name_key": "domain" + }, + "module": { + "row": "Namesilo.module_row", + "rows": "Namesilo.module_row_plural", + "row_key": "user" + }, + "email_tags": { + "module": [], + "package": [], + "service": ["domain"] + } } diff --git a/config/codes.php b/config/codes.php index ae1c912..1f85977 100644 --- a/config/codes.php +++ b/config/codes.php @@ -1,51 +1,51 @@ array( 'HTTPS not used', 'fail' ), - '102' => array( 'No version specified', 'fail' ), - '103' => array( 'Invalid API version', 'fail' ), - '104' => array( 'No type specified', 'fail' ), - '105' => array( 'Invalid API type', 'fail' ), - '106' => array( 'No operation specified', 'fail' ), - '107' => array( 'Invalid API operation', 'fail' ), - '108' => array( 'Missing parameters for the specified operation', 'fail' ), - '109' => array( 'No API key specified', 'fail' ), - '110' => array( 'Invalid API key', 'fail' ), - '111' => array( 'Invalid User', 'fail' ), - '112' => array( 'API not available to Sub-Accounts', 'fail' ), - '113' => array( 'This API account cannot be accessed from your IP', 'fail' ), - '114' => array( 'Invalid Domain Syntax', 'fail' ), - '115' => array( 'Central Registry Not Responding - try again later', 'fail' ), - '116' => array( 'Invalid sandbox account', 'fail' ), - '117' => array( 'The provided credit card profile either does not exist, or is not associated with your account', 'fail' ), - '118' => array( 'The provided credit card profile has not been verified', 'fail' ), - '119' => array( 'Insufficient account funds for requested transaction', 'fail' ), - '120' => array( 'API key must be passed as a GET', 'fail' ), + '101' => [ 'HTTPS not used', 'fail' ], + '102' => [ 'No version specified', 'fail' ], + '103' => [ 'Invalid API version', 'fail' ], + '104' => [ 'No type specified', 'fail' ], + '105' => [ 'Invalid API type', 'fail' ], + '106' => [ 'No operation specified', 'fail' ], + '107' => [ 'Invalid API operation', 'fail' ], + '108' => [ 'Missing parameters for the specified operation', 'fail' ], + '109' => [ 'No API key specified', 'fail' ], + '110' => [ 'Invalid API key', 'fail' ], + '111' => [ 'Invalid User', 'fail' ], + '112' => [ 'API not available to Sub-Accounts', 'fail' ], + '113' => [ 'This API account cannot be accessed from your IP', 'fail' ], + '114' => [ 'Invalid Domain Syntax', 'fail' ], + '115' => [ 'Central Registry Not Responding - try again later', 'fail' ], + '116' => [ 'Invalid sandbox account', 'fail' ], + '117' => [ 'The provided credit card profile either does not exist, or is not associated with your account', 'fail' ], + '118' => [ 'The provided credit card profile has not been verified', 'fail' ], + '119' => [ 'Insufficient account funds for requested transaction', 'fail' ], + '120' => [ 'API key must be passed as a GET', 'fail' ], - '200' => array( 'Domain is not active, or does not belong to this user', 'fail' ), - '201' => array( 'Internal system error', 'fail' ), - '210' => array( 'General error (details provided in response)', 'fail' ), - '250' => array( 'Domain is already set to AutoRenew - No update made.', 'info' ), - '251' => array( 'Domain is already set not to AutoRenew - No update made.', 'info' ), - '252' => array( 'Domain is already Locked - No update made.', 'info' ), - '253' => array( 'Domain is already Unlocked - No update made.', 'info' ), - '254' => array( 'Nameserver update cannot be made. (details provided in response)', 'fail' ), - '255' => array( 'Domain is already Private - No update made.', 'info' ), - '256' => array( 'Domain is already Not Private - No update made.', 'info' ), - '261' => array( 'Domain processing error (details provided in response)', 'fail' ), - '262' => array( 'This domain is already active within our system and therefore cannot be processed.', 'fail' ), - '263' => array( 'Invalid number of years, or no years provided.', 'fail' ), - '264' => array( 'Domain cannot be renewed for specified number of years (details provided in response)', 'fail' ), - '265' => array( 'Domain cannot be transferred at this time (details provided in response)', 'fail' ), - '266' => array( 'No domain transfer exists for this user for this domain', 'fail' ), - '267' => array( 'Invalid domain name, or we do not support the provided extension/TLD.', 'fail' ), - '280' => array( 'DNS modification error', 'fail' ), + '200' => [ 'Domain is not active, or does not belong to this user', 'fail' ], + '201' => [ 'Internal system error', 'fail' ], + '210' => [ 'General error (details provided in response)', 'fail' ], + '250' => [ 'Domain is already set to AutoRenew - No update made.', 'info' ], + '251' => [ 'Domain is already set not to AutoRenew - No update made.', 'info' ], + '252' => [ 'Domain is already Locked - No update made.', 'info' ], + '253' => [ 'Domain is already Unlocked - No update made.', 'info' ], + '254' => [ 'Nameserver update cannot be made. (details provided in response)', 'fail' ], + '255' => [ 'Domain is already Private - No update made.', 'info' ], + '256' => [ 'Domain is already Not Private - No update made.', 'info' ], + '261' => [ 'Domain processing error (details provided in response)', 'fail' ], + '262' => [ 'This domain is already active within our system and therefore cannot be processed.', 'fail' ], + '263' => [ 'Invalid number of years, or no years provided.', 'fail' ], + '264' => [ 'Domain cannot be renewed for specified number of years (details provided in response)', 'fail' ], + '265' => [ 'Domain cannot be transferred at this time (details provided in response)', 'fail' ], + '266' => [ 'No domain transfer exists for this user for this domain', 'fail' ], + '267' => [ 'Invalid domain name, or we do not support the provided extension/TLD.', 'fail' ], + '280' => [ 'DNS modification error', 'fail' ], - '300' => array( 'Successful API operation', 'success' ), - '301' => array( 'Successful registration, but not all provided hosts were valid, resulting in our nameservers being used', 'success' ), - '302' => array( 'Successful order, but there was an error with the contact information provided so your account default contact profile was used', 'success' ), + '300' => [ 'Successful API operation', 'success' ], + '301' => [ 'Successful registration, but not all provided hosts were valid, resulting in our nameservers being used', 'success' ], + '302' => [ 'Successful order, but there was an error with the contact information provided so your account default contact profile was used', 'success' ], - '400' => array( 'Existing API request is still processing - request will need to be re-submitted', 'fail' ), + '400' => [ 'Existing API request is still processing - request will need to be re-submitted', 'fail' ], -)); \ No newline at end of file +]); diff --git a/config/namesilo.php b/config/namesilo.php index c3a124f..b6bf048 100644 --- a/config/namesilo.php +++ b/config/namesilo.php @@ -1,77 +1,77 @@ array( - 'label' => Language::_("Namesilo.transfer.domain", true), - 'type' => "text" - ), - 'auth' => array( - 'label' => Language::_("Namesilo.transfer.EPPCode", true), - 'type' => "text" - ), - 'private' => array( - 'label' => Language::_("Namesilo.domain.WhoisPrivacy", true), - 'type' => "checkbox", - 'options' => array( '1' => "Yes" ), - ), -)); +Configure::set('Namesilo.transfer_fields', [ + 'domain' => [ + 'label' => Language::_('Namesilo.transfer.domain', true), + 'type' => 'text' + ], + 'auth' => [ + 'label' => Language::_('Namesilo.transfer.EPPCode', true), + 'type' => 'text' + ], + 'private' => [ + 'label' => Language::_('Namesilo.domain.WhoisPrivacy', true), + 'type' => 'checkbox', + 'options' => [ '1' => 'Yes' ], + ], +]); // Domain fields -Configure::set("Namesilo.domain_fields", array( - 'domain' => array( - 'label' => Language::_("Namesilo.domain.domain", true), - 'type' => "text" - ), - 'private' => array( - "label" => Language::_("Namesilo.domain.WhoisPrivacy", true), - "type" => "checkbox", - "options" => array ( '1' => "Yes" ), - ), -)); +Configure::set('Namesilo.domain_fields', [ + 'domain' => [ + 'label' => Language::_('Namesilo.domain.domain', true), + 'type' => 'text' + ], + 'private' => [ + 'label' => Language::_('Namesilo.domain.WhoisPrivacy', true), + 'type' => 'checkbox', + 'options' => [ '1' => 'Yes' ], + ], +]); // Nameserver fields -Configure::set("Namesilo.nameserver_fields", array( - 'ns1' => array( - 'label' => Language::_("Namesilo.nameserver.ns1", true), - 'type' => "text" - ), - 'ns2' => array( - 'label' => Language::_("Namesilo.nameserver.ns2", true), - 'type' => "text" - ), - 'ns3' => array( - 'label' => Language::_("Namesilo.nameserver.ns3", true), - 'type' => "text" - ), - 'ns4' => array( - 'label' => Language::_("Namesilo.nameserver.ns4", true), - 'type' => "text" - ), - 'ns5' => array( - 'label' => Language::_("Namesilo.nameserver.ns5", true), - 'type' => "text" - ) -)); +Configure::set('Namesilo.nameserver_fields', [ + 'ns1' => [ + 'label' => Language::_('Namesilo.nameserver.ns1', true), + 'type' => 'text' + ], + 'ns2' => [ + 'label' => Language::_('Namesilo.nameserver.ns2', true), + 'type' => 'text' + ], + 'ns3' => [ + 'label' => Language::_('Namesilo.nameserver.ns3', true), + 'type' => 'text' + ], + 'ns4' => [ + 'label' => Language::_('Namesilo.nameserver.ns4', true), + 'type' => 'text' + ], + 'ns5' => [ + 'label' => Language::_('Namesilo.nameserver.ns5', true), + 'type' => 'text' + ] +]); // DNSSEC -Configure::set("Namesilo.dnssec", array( - 'digest_type' => array( - 'label' => Language::_("Namesilo.dnssec.digest_type", true), - 'type' => "select", - 'options' => array( - '' => Language::_("AppController.select.please", true), +Configure::set('Namesilo.dnssec', [ + 'digest_type' => [ + 'label' => Language::_('Namesilo.dnssec.digest_type', true), + 'type' => 'select', + 'options' => [ + '' => Language::_('AppController.select.please', true), '1' => 'SHA-1 (1)', '2' => 'SHA-256 (2)', '3' => 'GOST R 34.11-94 (3)', '4' => 'SHA-384 (4)' - ) - ), - 'algorithm' => array( - 'label' => Language::_("Namesilo.dnssec.algorithm", true), - 'type' => "select", - 'options' => array( - '' => Language::_("AppController.select.please", true), + ] + ], + 'algorithm' => [ + 'label' => Language::_('Namesilo.dnssec.algorithm', true), + 'type' => 'select', + 'options' => [ + '' => Language::_('AppController.select.please', true), '1' => 'RSA/MD5 (1)', '2' => 'Diffie-Hellman (2)', '3' => 'DSA/SHA-1 (3)', @@ -87,114 +87,114 @@ '252' => 'Indirect (252)', '253' => 'Private DNS (253)', '254' => 'Private OID (254)' - ) - ), -)); + ] + ], +]); // Whois fields -Configure::set("Namesilo.whois_fields", array( - /* - 'nickname' => array( - 'label' => Language::_("Namesilo.whois.Nickname", true), - 'type' => "text", - 'key' => 'nn', - ), - */ - 'first_name' => array( - 'label' => Language::_("Namesilo.whois.FirstName", true), - 'type' => "text", - 'rp' => 'fn', - 'lp' => 'first_name', - ), - 'last_name' => array( - 'label' => Language::_("Namesilo.whois.LastName", true), - 'type' => "text", - 'rp' => 'ln', - 'lp' => 'last_name', - ), - 'company' => array( - 'label' => Language::_("Namesilo.whois.Organization", true), - 'type' => "text", - 'rp' => 'cp', - 'lp' => 'company', - ), - 'address' => array( - 'label' => Language::_("Namesilo.whois.Address1", true), - 'type' => "text", - 'rp' => 'ad', - 'lp' => 'address1', - ), - 'address2' => array( - 'label' => Language::_("Namesilo.whois.Address2", true), - 'type' => "text", - 'rp' => 'ad2', - 'lp' => 'address2', - ), - 'city' => array( - 'label' => Language::_("Namesilo.whois.City", true), - 'type' => "text", - 'rp' => 'cy', - 'lp' => 'city', - ), - 'state' => array( - 'label' => Language::_("Namesilo.whois.StateProvince", true), - 'type' => "text", - 'rp' => 'st', - 'lp' => 'state', - ), - 'zip' => array( - 'label' => Language::_("Namesilo.whois.PostalCode", true), - 'type' => "text", - 'rp' => 'zp', - 'lp' => 'zip', - ), - 'country' => array( - 'label' => Language::_("Namesilo.whois.Country", true), - 'type' => "text", - 'rp' => 'ct', - 'lp' => 'country', - ), - 'phone' => array( - 'label' => Language::_("Namesilo.whois.Phone", true), - 'type' => "text", - 'rp' => 'ph', - 'lp' => 'phone', - ), - 'email' => array( - 'label' => Language::_("Namesilo.whois.EmailAddress", true), - 'type' => "text", - 'rp' => 'em', - 'lp' => 'email', - ), -)); +Configure::set('Namesilo.whois_fields', [ + /* + 'nickname' => array( + 'label' => Language::_("Namesilo.whois.Nickname", true), + 'type' => "text", + 'key' => 'nn', + ), + */ + 'first_name' => [ + 'label' => Language::_('Namesilo.whois.FirstName', true), + 'type' => 'text', + 'rp' => 'fn', + 'lp' => 'first_name', + ], + 'last_name' => [ + 'label' => Language::_('Namesilo.whois.LastName', true), + 'type' => 'text', + 'rp' => 'ln', + 'lp' => 'last_name', + ], + 'company' => [ + 'label' => Language::_('Namesilo.whois.Organization', true), + 'type' => 'text', + 'rp' => 'cp', + 'lp' => 'company', + ], + 'address' => [ + 'label' => Language::_('Namesilo.whois.Address1', true), + 'type' => 'text', + 'rp' => 'ad', + 'lp' => 'address1', + ], + 'address2' => [ + 'label' => Language::_('Namesilo.whois.Address2', true), + 'type' => 'text', + 'rp' => 'ad2', + 'lp' => 'address2', + ], + 'city' => [ + 'label' => Language::_('Namesilo.whois.City', true), + 'type' => 'text', + 'rp' => 'cy', + 'lp' => 'city', + ], + 'state' => [ + 'label' => Language::_('Namesilo.whois.StateProvince', true), + 'type' => 'text', + 'rp' => 'st', + 'lp' => 'state', + ], + 'zip' => [ + 'label' => Language::_('Namesilo.whois.PostalCode', true), + 'type' => 'text', + 'rp' => 'zp', + 'lp' => 'zip', + ], + 'country' => [ + 'label' => Language::_('Namesilo.whois.Country', true), + 'type' => 'text', + 'rp' => 'ct', + 'lp' => 'country', + ], + 'phone' => [ + 'label' => Language::_('Namesilo.whois.Phone', true), + 'type' => 'text', + 'rp' => 'ph', + 'lp' => 'phone', + ], + 'email' => [ + 'label' => Language::_('Namesilo.whois.EmailAddress', true), + 'type' => 'text', + 'rp' => 'em', + 'lp' => 'email', + ], +]); // .US -Configure::set("Namesilo.domain_fields.us", array( - 'usnc' => array( - 'label' => Language::_("Namesilo.domain.RegistrantNexus", true), - 'type' => "select", - 'options' => array( - '' => Language::_("AppController.select.please", true), - 'C11' => Language::_("Namesilo.domain.RegistrantNexus.c11", true), - 'C12' => Language::_("Namesilo.domain.RegistrantNexus.c12", true), - 'C21' => Language::_("Namesilo.domain.RegistrantNexus.c21", true), - 'C31' => Language::_("Namesilo.domain.RegistrantNexus.c31", true), - 'C32' => Language::_("Namesilo.domain.RegistrantNexus.c32", true) - ) - ), - 'usap' => array( - 'label' => Language::_("Namesilo.domain.RegistrantPurpose", true), - 'type' => "select", - 'options' => array( - '' => Language::_("AppController.select.please", true), - 'P1' => Language::_("Namesilo.domain.RegistrantPurpose.p1", true), - 'P2' => Language::_("Namesilo.domain.RegistrantPurpose.p2", true), - 'P3' => Language::_("Namesilo.domain.RegistrantPurpose.p3", true), - 'P4' => Language::_("Namesilo.domain.RegistrantPurpose.p4", true), - 'P5' => Language::_("Namesilo.domain.RegistrantPurpose.p5", true) - ) - ) -)); +Configure::set('Namesilo.domain_fields.us', [ + 'usnc' => [ + 'label' => Language::_('Namesilo.domain.RegistrantNexus', true), + 'type' => 'select', + 'options' => [ + '' => Language::_('AppController.select.please', true), + 'C11' => Language::_('Namesilo.domain.RegistrantNexus.c11', true), + 'C12' => Language::_('Namesilo.domain.RegistrantNexus.c12', true), + 'C21' => Language::_('Namesilo.domain.RegistrantNexus.c21', true), + 'C31' => Language::_('Namesilo.domain.RegistrantNexus.c31', true), + 'C32' => Language::_('Namesilo.domain.RegistrantNexus.c32', true) + ] + ], + 'usap' => [ + 'label' => Language::_('Namesilo.domain.RegistrantPurpose', true), + 'type' => 'select', + 'options' => [ + '' => Language::_('AppController.select.please', true), + 'P1' => Language::_('Namesilo.domain.RegistrantPurpose.p1', true), + 'P2' => Language::_('Namesilo.domain.RegistrantPurpose.p2', true), + 'P3' => Language::_('Namesilo.domain.RegistrantPurpose.p3', true), + 'P4' => Language::_('Namesilo.domain.RegistrantPurpose.p4', true), + 'P5' => Language::_('Namesilo.domain.RegistrantPurpose.p5', true) + ] + ] +]); // .CA // the commented types represent options that namesilo doesn't allow via the API. @@ -205,7 +205,7 @@ 'label' => Language::_('Namesilo.domain.CIRALegalType', true), 'type' => 'select', 'options' => [ - '' => Language::_("AppController.select.please", true), + '' => Language::_('AppController.select.please', true), 'CCT' => Language::_('Namesilo.domain.RegistrantPurpose.cct', true), 'RES' => Language::_('Namesilo.domain.RegistrantPurpose.res', true), 'ABO' => Language::_('Namesilo.domain.RegistrantPurpose.abo', true), @@ -232,7 +232,7 @@ 'label' => Language::_('Namesilo.domain.CIRAWhoisDisplay', true), 'type' => 'select', 'options' => [ - '' => Language::_("AppController.select.please", true), + '' => Language::_('AppController.select.please', true), '1' => Language::_('Namesilo.domain.CIRAWhoisDisplay.full', true), '0' => Language::_('Namesilo.domain.CIRAWhoisDisplay.private', true), ] @@ -241,7 +241,7 @@ 'label' => Language::_('Namesilo.domain.CIRALanguage', true), 'type' => 'select', 'options' => [ - '' => Language::_("AppController.select.please", true), + '' => Language::_('AppController.select.please', true), 'en' => Language::_('Namesilo.domain.CIRALanguage.en', true), 'fr' => Language::_('Namesilo.domain.CIRALanguage.fr', true), ] diff --git a/config/notices.php b/config/notices.php index bbd520f..d4e8612 100644 --- a/config/notices.php +++ b/config/notices.php @@ -1,10 +1,10 @@ Language::_( "Namesilo.notices.renewal_reminder", true ), - 'overdue_payment' => Language::_( "Namesilo.notices.overdue_payment", true ), - 'expiry_notice' => Language::_( "Namesilo.notices.expiry_notice", true ), - 'suspension_notice' => Language::_( "Namesilo.notices.suspension_notice", true ), + 'renewal_reminder' => Language::_('Namesilo.notices.renewal_reminder', true), + 'overdue_payment' => Language::_('Namesilo.notices.overdue_payment', true), + 'expiry_notice' => Language::_('Namesilo.notices.expiry_notice', true), + 'suspension_notice' => Language::_('Namesilo.notices.suspension_notice', true), -) ); +]); diff --git a/includes/communication.php b/includes/communication.php index 81f7c77..7bf0c70 100644 --- a/includes/communication.php +++ b/includes/communication.php @@ -1,53 +1,58 @@ service = $service; - $this->client = $this->Clients->get( $service->client_id, false ); - $this->company = $this->Companies->get( $this->client->company_id ); - } - - public function getNotices() { - $notices = Configure::get( 'Namesilo.notices' ); - /* - $notices = array( - 'renewal_reminder' => Language::_( "Namesilo.notices.renewal_reminder", true ), - 'expiry_notice' => Language::_( "Namesilo.notices.expiry_notice", true ), - 'suspension_notice' => Language::_( "Namesilo.notices.suspension_notice", true ), - ); - */ - return $notices; - } - - public function send( array $post ) { - - if ( empty ( $notice = $post['notice'] ) || !array_key_exists( $notice, $this->getNotices() ) ) { - return false; - } - - if ( !isset ( $this->Emails ) ) { - Loader::loadModels( $this, array( "Emails" ) ); - } - - $template = $this->Emails->getByType( $this->company->id, "service_suspension" ); - $from = $template->from; - $from_name = $template->from_name; - - $tags = array ( - 'first_name' => $this->client->first_name, - 'domain' => $this->getServiceName( $this->service ), - 'expiry_date' => strftime( '%F', strtotime( $this->service->date_renews ) ), - 'from_name' => $from_name, - 'client_url' => $this->company->hostname, - ); - - $result = $this->Emails->sendCustom( $from, $from_name, $this->client->email, Language::_( "Namesilo.notices.{$notice}.subject", true ), array( 'text' => Language::_( "Namesilo.notices.{$notice}.text", true ) ), $tags, null, $from ); - - return $result; - } - +class Communication extends Namesilo +{ + private $service; + private $client; + private $company; + + public function __construct($service) + { + Loader::loadModels($this, ['Clients', 'Companies']); + $this->service = $service; + $this->client = $this->Clients->get($service->client_id, false); + $this->company = $this->Companies->get($this->client->company_id); + } + + public function getNotices() + { + return Configure::get('Namesilo.notices'); + } + + public function send(array $post) + { + $notice = isset($post['notice']) ? $post['notice'] : ''; + if (empty($notice) || !array_key_exists($notice, $this->getNotices())) { + return false; + } + + if (!isset($this->Emails)) { + Loader::loadModels($this, ['Emails']); + } + + $template = $this->Emails->getByType($this->company->id, 'service_suspension'); + $from = $template->from; + $from_name = $template->from_name; + + $tags = [ + 'first_name' => $this->client->first_name, + 'domain' => $this->getServiceName($this->service), + 'expiry_date' => strftime('%F', strtotime($this->service->date_renews)), + 'from_name' => $from_name, + 'client_url' => $this->company->hostname + ]; + + $result = $this->Emails->sendCustom( + $from, + $from_name, + $this->client->email, + Language::_('Namesilo.notices.' . $notice . '.subject', true), + ['text' => Language::_('Namesilo.notices.' . $notice . '.text', true)], + $tags, + null, + $from + ); + + return $result; + } } diff --git a/includes/namesilo_packages.php b/includes/namesilo_packages.php new file mode 100644 index 0000000..6330911 --- /dev/null +++ b/includes/namesilo_packages.php @@ -0,0 +1,409 @@ +getPackagesMap($module_row_id); + + // Process packages + if (!empty($vars['pricing'])) { + foreach ($vars['pricing'] as $tld => $pricing) { + if (isset($pricing['tld']) && (bool)$pricing['tld']) { + // Get price rows for the current package + $price_rows = $this->generatePricingRows($pricing); + + // Get module row + $module_row = $this->ModuleManager->getRow($module_row_id); + + // Set unset checkboxes + $fields = ['upgrades_use_renewal', 'taxable', 'price_enable_renews_all']; + + foreach ($fields as $field) { + if (!isset($vars[$field])) { + $vars[$field] = 0; + } + } + + // Build parameters + $tld = '.' . trim($tld, '.'); + $params = [ + 'names' => $this->parseNameTags($vars['names'], $tld), + 'descriptions' => $this->parseDescriptionTags($vars['descriptions'], $tld), + 'status' => 'active', + 'qty_unlimited' => 'true', + 'upgrades_use_renewal' => $vars['upgrades_use_renewal'], + 'module_id' => $module_row->module_id, + 'module_row' => $module_row_id, + 'pricing' => $price_rows, + 'taxable' => $vars['taxable'], + 'meta' => [ + 'type' => 'domain', + 'tlds' => [$tld] + ], + 'select_group_type' => 'existing', + 'groups' => [$vars['package_group']], + 'company_id' => Configure::get('Blesta.company_id') + ]; + $params['meta'] = array_merge($params['meta'], $vars['meta']); + + $languages = $this->Languages->getAll(Configure::get('Blesta.company_id')); + + foreach ($languages as $language) { + $params['email_content'][] = [ + 'lang' => $language->code, + 'html' => null, + 'text' => null + ]; + } + + // Add or update the package + $tld_packages_map[$tld] = $this->savePackage( + $params, + isset($tld_packages_map[$tld]) ? $tld_packages_map[$tld] : null + ); + + if (($errors = $this->Packages->Input->errors())) { + return false; + } + } else { + unset($vars['pricing'][$tld]); + } + } + + $this->savePackagesMap($tld_packages_map, $module_row_id); + $this->saveSettings($vars, $module_row_id); + + return true; + } + + return false; + } + + /** + * Fetches the packages map for the enabled TLDs + * + * @param int $module_row_id The ID of the module row to fetch the packages map + * @return array An array of key/value pairs where each key is the TLD and each value is the package id + */ + public function getPackagesMap($module_row_id) + { + $tld_packages_map = $this->Record->select('value') + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'tld_packages_map') + ->fetch(); + + return !empty($tld_packages_map->value) ? json_decode($tld_packages_map->value, true) : []; + } + + /** + * Saves the packages map for the enabled TLDs + * + * @param array $vars An array containing the posted data + * @param int $module_row_id The ID of the module row to save the packages map + * @return PDOStatement An instance of the PDOStatement + */ + public function savePackagesMap(array $vars, $module_row_id) + { + $packages_map = $this->getPackagesMap($module_row_id); + $vars = array_merge($packages_map, $vars); + + $fields = [ + 'module_row_id' => $module_row_id, + 'key' => 'tld_packages_map', + 'value' => json_encode($vars) + ]; + + return $this->Record->duplicate('module_row_meta.value', '=', $fields['value']) + ->insert('module_row_meta', $fields); + } + + /** + * Fetches the packages settings + * + * @param $module_row_id The ID of the module row to fetch the packages settings + * @return array An array containing all the packages settings + */ + public function getSettings($module_row_id) + { + $settings = $this->Record->select('value') + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'tld_packages_settings') + ->fetch(); + $settings = !empty($settings->value) ? json_decode($settings->value, true) : []; + + // Fetch tld pricing + $tld_pricing = $this->Record->select('value') + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', 'LIKE', 'tld_%_pricing') + ->fetchAll(); + + if (!empty($settings)) { + $settings['pricing'] = []; + foreach ($tld_pricing as $pricing) { + $settings['pricing'] = array_merge($settings['pricing'], json_decode($pricing->value, true)); + } + } + + return $settings; + } + + /** + * Saves the packages settings + * + * @param array $vars An array containing the posted data + * @param int $module_row_id The ID of the module row to save the packages map + * @return PDOStatement An instance of the PDOStatement + */ + public function saveSettings(array $vars, $module_row_id) + { + // Save TLD pricing rows + $prices = $this->getPrices(); + + foreach ($vars['pricing'] as $tld => $pricing) { + $tld_pricing = []; + + foreach ($pricing as $currency => $price_row) { + if ($currency !== 'tld') { + // Set unset checkboxes + if (!isset($vars['pricing'][$tld][$currency]['price_enable_renews'])) { + $vars['pricing'][$tld][$currency]['price_enable_renews'] = 0; + } + + $tld_pricing[$tld] = $vars['pricing'][$tld]; + $tld_pricing[$tld][$currency]['previous_registration_price'] = $prices[$tld][$currency]->registration; + $tld_pricing[$tld][$currency]['previous_renewal_price'] = $prices[$tld][$currency]->renew; + } + } + + $fields = [ + 'module_row_id' => $module_row_id, + 'key' => 'tld_' . trim($tld, '.') . '_pricing', + 'value' => json_encode($tld_pricing) + ]; + + $this->Record->duplicate('module_row_meta.value', '=', $fields['value']) + ->insert('module_row_meta', $fields); + } + unset($vars['pricing']); + + // Save packages settings + $fields = [ + 'module_row_id' => $module_row_id, + 'key' => 'tld_packages_settings', + 'value' => json_encode($vars) + ]; + + return $this->Record->duplicate('module_row_meta.value', '=', $fields['value']) + ->insert('module_row_meta', $fields); + } + + /** + * Creates a new package, if a package already exists it will be updated + * + * @param array $params An array of package information including: + * - names A list of names for the package in different languages + * - descriptions A list of descriptions in text and html for the + * package in different languages (optional, default NULL) + * - lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) + * - text The text description in the specified language + * - html The HTML description in the specified language + * - status The status of this package, 'active', 'inactive', 'restricted' (optional, default 'active') + * - module_id The ID of the module this package belongs to (optional, default NULL) + * - module_row The module row this package belongs to (optional, default 0) + * - pricing A numerically indexed array of pricing info including: + * - term The term as an integer 1-65535 (period should be given if this is set; optional, default 1) + * - period The period, 'day', 'week', 'month', 'year', 'onetime' (optional, default 'month') + * - price The price of this term (optional, default 0.00) + * - setup_fee The setup fee for this package (optional, default 0.00) + * - cancel_fee The cancellation fee for this package (optional, default 0.00) + * - currency The ISO 4217 currency code for this pricing + * - taxable Whether or not this package is taxable (optional, default 0) + * - groups A numerically indexed array of package group assignments (optional) + * - company_id The ID of the company this package belongs to + * - * A set of miscellaneous fields to pass, in addition to the above + * fields, to the module when adding the package (optional) + * @param int $package_id The package id to update, by default null to create a new one instead + * @return mixed The package id if the package has been successfully saved, null otherwise + */ + private function savePackage(array $params, $package_id = null) + { + if (is_null($package_id)) { + // Add new package + $package_id = $this->Packages->add($params); + } else { + // Update existing package + $pricing_ids = []; + $package = $this->Packages->get($package_id); + + foreach ($package->pricing as $pricing) { + $pricing_ids[$pricing->currency] = $pricing->id; + } + unset($pricing); + + foreach ($params['pricing'] as $key => $pricing) { + $params['pricing'][$key]['id'] = isset($pricing_ids[$pricing['currency']]) ? $pricing_ids[$pricing['currency']] : null; + } + unset($pricing); + + $params['email_content'] = json_decode(json_encode($package->email_content), true); + + $this->Packages->edit($package_id, $params); + } + + return $package_id; + } + + /** + * Generates the pricing rows for a specific TLD package + * + * @param array $pricing An array of key/value pairs where each key is the currency + * and each value is an array, containing: + * - price The registration price for the domain + * - price_enable_renews Whether or not the renewal price is enabled + * - price_renews The renewal price for the domain + * @return array An numerically-indexed array containing the package pricing rows + */ + private function generatePricingRows(array $pricing) + { + $package_pricing = []; + + foreach ($pricing as $currency => $price) { + if ($currency !== 'tld') { + $price_row = [ + 'term' => 1, + 'period' => 'year', + 'price' => $price['price'], + 'currency' => $currency, + 'price_enable_renews' => isset($price['price_enable_renews']) ? $price['price_enable_renews'] : 0, + 'price_renews' => isset($price['price_enable_renews']) ? $price['price_renews'] : $price['price'], + 'setup_fee' => 0, + 'cancel_fee' => 0 + ]; + + $package_pricing[] = $price_row; + } + } + + return $package_pricing; + } + + /** + * Parse the name tags, replacing them with the given TLD + * + * @param array $names A numerically-indexed array of the descriptions to parse, containing: + * - html The HTML version of the email content + * - text The text version of the email content + * @param string $tld The TLD to be used on the tags + * @return array A numerically-indexed array containing the parsed names + */ + private function parseNameTags(array $names, $tld) + { + // Load the template parser + $parser = new H2o(); + + // Don't escape text + $parser_options_text = Configure::get('Blesta.parser_options'); + $parser_options_text['autoescape'] = false; + + // Parse package name using template parser + $tags = [ + 'domain' => [ + 'tld' => strtolower($tld), + 'tld_uppercase' => strtoupper($tld) + ] + ]; + + foreach ($names as $key => $name) { + $names[$key]['name'] = $parser->parseString($name['name'], $parser_options_text)->render($tags); + } + + return $names; + } + + /** + * Parse the description tags, replacing them with the given TLD + * + * @param array $descriptions A numerically-indexed array of the descriptions to parse, containing: + * - html The HTML version of the email content + * - text The text version of the email content + * @param string $tld The TLD to be used on the tags + * @return array A numerically-indexed array containing the parsed descriptions + */ + private function parseDescriptionTags(array $descriptions, $tld) + { + // Load the template parser + $parser = new H2o(); + + // Don't escape html + $parser_options_html = Configure::get('Blesta.parser_options'); + $parser_options_html['autoescape'] = false; + + // Don't escape text + $parser_options_text = Configure::get('Blesta.parser_options'); + $parser_options_text['autoescape'] = false; + + // Parse package name using template parser + $tags = [ + 'domain' => [ + 'tld' => strtolower($tld), + 'tld_uppercase' => strtoupper($tld) + ] + ]; + + foreach ($descriptions as $key => $description) { + $descriptions[$key]['html'] = $parser->parseString( + $description['html'], + $parser_options_html + )->render($tags); + $descriptions[$key]['text'] = $parser->parseString( + $description['text'], + $parser_options_text + )->render($tags); + } + + return $descriptions; + } + + /** + * Return all errors + * + * @return mixed An array of error messages indexed as their field name, boolean false if no errors set + */ + public function errors() + { + return $this->Packages->Input->errors(); + } +} diff --git a/language/en_us/namesilo.php b/language/en_us/namesilo.php index f1e003d..83f41fb 100644 --- a/language/en_us/namesilo.php +++ b/language/en_us/namesilo.php @@ -1,153 +1,185 @@ verified in your Namesilo account to use it for purchases. You can get this ID from"; -$lang['Namesilo.row_meta.sandbox'] = "Sandbox"; -$lang['Namesilo.row_meta.sandbox_true'] = "Yes"; -$lang['Namesilo.row_meta.sandbox_false'] = "No"; +$lang['Namesilo.row_meta.user'] = 'User'; +$lang['Namesilo.row_meta.key'] = 'API Key'; +$lang['Namesilo.row_meta.portfolio'] = 'Portfolio'; +$lang['Namesilo.row_meta.payment_id'] = 'Payment ID'; +$lang['Namesilo.row_meta.payment_id.description'] = 'Leave blank to use account funds or enter the ID of a billing profile that is verified in your Namesilo account to use it for purchases. You can get this ID from'; +$lang['Namesilo.row_meta.sandbox'] = 'Sandbox'; +$lang['Namesilo.row_meta.sandbox_true'] = 'Yes'; +$lang['Namesilo.row_meta.sandbox_false'] = 'No'; // Add row -$lang['Namesilo.add_row.box_title'] = "Add Namesilo Account"; -$lang['Namesilo.add_row.basic_title'] = "Basic Settings"; -$lang['Namesilo.add_row.add_btn'] = "Add Account"; +$lang['Namesilo.add_row.box_title'] = 'Add Namesilo Account'; +$lang['Namesilo.add_row.basic_title'] = 'Basic Settings'; +$lang['Namesilo.add_row.add_btn'] = 'Add Account'; // Edit row -$lang['Namesilo.edit_row.box_title'] = "Edit Namesilo Account"; -$lang['Namesilo.edit_row.basic_title'] = "Basic Settings"; -$lang['Namesilo.edit_row.add_btn'] = "Update Account"; +$lang['Namesilo.edit_row.box_title'] = 'Edit Namesilo Account'; +$lang['Namesilo.edit_row.basic_title'] = 'Basic Settings'; +$lang['Namesilo.edit_row.add_btn'] = 'Update Account'; // Package fields -$lang['Namesilo.package_fields.type'] = "Type"; -$lang['Namesilo.package_fields.type_domain'] = "Domain Registration"; -$lang['Namesilo.package_fields.type_ssl'] = "SSL Certificate"; -$lang['Namesilo.package_fields.tld_options'] = "TLDs"; -$lang['Namesilo.package_fields.ns1'] = "Name Server 1"; -$lang['Namesilo.package_fields.ns2'] = "Name Server 2"; -$lang['Namesilo.package_fields.ns3'] = "Name Server 3"; -$lang['Namesilo.package_fields.ns4'] = "Name Server 4"; -$lang['Namesilo.package_fields.ns5'] = "Name Server 5"; +$lang['Namesilo.package_fields.type'] = 'Type'; +$lang['Namesilo.package_fields.type_domain'] = 'Domain Registration'; +$lang['Namesilo.package_fields.type_ssl'] = 'SSL Certificate'; +$lang['Namesilo.package_fields.tld_options'] = 'TLDs'; +$lang['Namesilo.package_fields.ns1'] = 'Name Server 1'; +$lang['Namesilo.package_fields.ns2'] = 'Name Server 2'; +$lang['Namesilo.package_fields.ns3'] = 'Name Server 3'; +$lang['Namesilo.package_fields.ns4'] = 'Name Server 4'; +$lang['Namesilo.package_fields.ns5'] = 'Name Server 5'; // Service management -$lang['Namesilo.tab_whois.title'] = "Whois"; -$lang['Namesilo.tab_whois.section_registrant'] = "Registrant"; -$lang['Namesilo.tab_whois.section_admin'] = "Administrative"; -$lang['Namesilo.tab_whois.section_tech'] = "Technical"; -$lang['Namesilo.tab_whois.section_billing'] = "Billing"; -$lang['Namesilo.tab_whois.field_submit'] = "Update Whois"; - -$lang['Namesilo.tab_nameservers.title'] = "Name Servers"; -$lang['Namesilo.tab_nameserver.field_ns'] = "Name Server %1\$s"; // %1$s is the name server number -$lang['Namesilo.tab_nameservers.field_submit'] = "Update Name Servers"; - -$lang['Namesilo.tab_hosts.title'] = "Register Nameservers"; -$lang['Namesilo.tab_hosts.field_host'] = "Host %1\$s"; // %1$s is the host number -$lang['Namesilo.tab_hosts.field_ip'] = "IP Address(es)"; -$lang['Namesilo.tab_hosts.field_hostname'] = "Host"; -$lang['Namesilo.tab_hosts.field_submit'] = "Update All Hosts"; -$lang['Namesilo.tab_client_hosts.help_text'] = "On this page you can add your own custom name servers (sometimes referred to as \"glue records\") to associate with your domains. To remove a host record blank all IP fields associated with it before clicking update. You can not delete any host records which have domains actively using it as a nameserver."; - -$lang['Namesilo.tab_dnssec.title'] = "DNSSEC"; -$lang['Namesilo.tab_dnssec.title_list'] = "Current DS (DNSSEC) Records"; -$lang['Namesilo.tab_dnssec.title_add'] = "Add DS (DNSSEC) Record"; -$lang['Namesilo.tab_dnssec.field_delete'] = "Delete Record(s)"; -$lang['Namesilo.tab_dnssec.field_add'] = "Add Record"; -$lang['Namesilo.tab_dnssec.field_delete'] = "Delete"; -$lang['Namesilo.tab_dnssec.title_disclaimer'] = "Disclaimer"; -$lang['Namesilo.tab_dnssec.warning_message1'] = "You can use this page to manage the DS records for your domain. You should only use this page if you are comfortable with DS records and DNSSEC."; -$lang['Namesilo.tab_dnssec.warning_message2'] = "When you manage DS records, the domain will stop resolving correctly if your nameservers are not configured correctly with the associated DNSSEC resource records."; -$lang['Namesilo.dnssec.algorithm'] = "Algorithm"; -$lang['Namesilo.dnssec.digest_type'] = "Digest Type"; -$lang['Namesilo.dnssec.digest'] = "Digest"; -$lang['Namesilo.dnssec.key_tag'] = "Key Tag"; - -$lang['Namesilo.tab_settings.title'] = "Settings"; -$lang['Namesilo.tab_settings.field_registrar_lock'] = "Registrar Lock"; -$lang['Namesilo.tab_settings.field_registrar_lock_yes'] = "Set the registrar lock. Recommended to prevent unauthorized transfer."; -$lang['Namesilo.tab_settings.field_registrar_lock_no'] = "Release the registrar lock so the domain can be transferred."; -$lang['Namesilo.tab_settings.field_request_epp'] = "Request EPP Code/Transfer Key"; -$lang['Namesilo.tab_settings.field_submit'] = "Update Settings"; -$lang['Namesilo.tab_settings.section_verification'] = "Registrant Email Verification"; -$lang['Namesilo.tab_settings.verification_text'] = "Registrant email verification status for "; -$lang['Namesilo.tab_settings.verified'] = "Verified"; -$lang['Namesilo.tab_settings.not_verified'] = "NOT VERIFIED"; -$lang['Namesilo.tab_settings.not_verified_warning'] = "WARNING: Your domain is at risk of being deactivated if you do not verify the registrant email address."; -$lang['Namesilo.tab_settings.field_resend_verification_email'] = "Resend Verification Email"; - -$lang['Namesilo.tab_adminactions.title'] = "Admin Actions"; -$lang['Namesilo.tab_adminactions.field_submit'] = "Send Selected Notice"; -$lang['Namesilo.tab_adminactions.sync_date'] = "Synchronize Renew Date"; - -$lang['Namesilo.manage.manual_renewal'] = "Manually Renew (select years)"; +$lang['Namesilo.tab_whois.title'] = 'Whois'; +$lang['Namesilo.tab_whois.section_registrant'] = 'Registrant'; +$lang['Namesilo.tab_whois.section_admin'] = 'Administrative'; +$lang['Namesilo.tab_whois.section_tech'] = 'Technical'; +$lang['Namesilo.tab_whois.section_billing'] = 'Billing'; +$lang['Namesilo.tab_whois.field_submit'] = 'Update Whois'; + +$lang['Namesilo.tab_nameservers.title'] = 'Name Servers'; +$lang['Namesilo.tab_nameserver.field_ns'] = 'Name Server %1$s'; // %1$s is the name server number +$lang['Namesilo.tab_nameservers.field_submit'] = 'Update Name Servers'; + +$lang['Namesilo.tab_hosts.title'] = 'Register Nameservers'; +$lang['Namesilo.tab_hosts.field_host'] = 'Host %1$s'; // %1$s is the host number +$lang['Namesilo.tab_hosts.field_ip'] = 'IP Address(es)'; +$lang['Namesilo.tab_hosts.field_hostname'] = 'Host'; +$lang['Namesilo.tab_hosts.field_submit'] = 'Update All Hosts'; +$lang['Namesilo.tab_client_hosts.help_text'] = 'On this page you can add your own custom name servers (sometimes referred to as "glue records") to associate with your domains. To remove a host record blank all IP fields associated with it before clicking update. You can not delete any host records which have domains actively using it as a nameserver.'; + +$lang['Namesilo.tab_dnssec.title'] = 'DNSSEC'; +$lang['Namesilo.tab_dnssec.title_list'] = 'Current DS (DNSSEC) Records'; +$lang['Namesilo.tab_dnssec.title_add'] = 'Add DS (DNSSEC) Record'; +$lang['Namesilo.tab_dnssec.field_delete'] = 'Delete Record(s)'; +$lang['Namesilo.tab_dnssec.field_add'] = 'Add Record'; +$lang['Namesilo.tab_dnssec.field_delete'] = 'Delete'; +$lang['Namesilo.tab_dnssec.title_disclaimer'] = 'Disclaimer'; +$lang['Namesilo.tab_dnssec.warning_message1'] = 'You can use this page to manage the DS records for your domain. You should only use this page if you are comfortable with DS records and DNSSEC.'; +$lang['Namesilo.tab_dnssec.warning_message2'] = 'When you manage DS records, the domain will stop resolving correctly if your nameservers are not configured correctly with the associated DNSSEC resource records.'; +$lang['Namesilo.dnssec.algorithm'] = 'Algorithm'; +$lang['Namesilo.dnssec.digest_type'] = 'Digest Type'; +$lang['Namesilo.dnssec.digest'] = 'Digest'; +$lang['Namesilo.dnssec.key_tag'] = 'Key Tag'; + +$lang['Namesilo.tab_settings.title'] = 'Settings'; +$lang['Namesilo.tab_settings.field_registrar_lock'] = 'Registrar Lock'; +$lang['Namesilo.tab_settings.field_registrar_lock_yes'] = 'Set the registrar lock. Recommended to prevent unauthorized transfer.'; +$lang['Namesilo.tab_settings.field_registrar_lock_no'] = 'Release the registrar lock so the domain can be transferred.'; +$lang['Namesilo.tab_settings.field_request_epp'] = 'Request EPP Code/Transfer Key'; +$lang['Namesilo.tab_settings.field_submit'] = 'Update Settings'; +$lang['Namesilo.tab_settings.section_verification'] = 'Registrant Email Verification'; +$lang['Namesilo.tab_settings.verification_text'] = 'Registrant email verification status for '; +$lang['Namesilo.tab_settings.verified'] = 'Verified'; +$lang['Namesilo.tab_settings.not_verified'] = 'NOT VERIFIED'; +$lang['Namesilo.tab_settings.not_verified_warning'] = 'WARNING: Your domain is at risk of being deactivated if you do not verify the registrant email address.'; +$lang['Namesilo.tab_settings.field_resend_verification_email'] = 'Resend Verification Email'; + +$lang['Namesilo.tab_adminactions.title'] = 'Admin Actions'; +$lang['Namesilo.tab_adminactions.field_submit'] = 'Send Selected Notice'; +$lang['Namesilo.tab_adminactions.sync_date'] = 'Synchronize Renew Date'; + +$lang['Namesilo.manage.manual_renewal'] = 'Manually Renew (select years)'; // Errors -$lang['Namesilo.!error.user.valid'] = "Please enter a user"; -$lang['Namesilo.!error.key.valid'] = "Please enter a key"; -$lang['Namesilo.!error.key.valid_connection'] = "The user and key combination appear to be invalid, or your Namesilo account may not be configured to allow API access."; -$lang['Namesilo.!error.portfolio.valid_portfolio'] = "The portfolio entered does not appear valid. Are you sure it has been created in your Namesilo account?"; -$lang['Namesilo.!error.payment_id.valid_format'] = "Payment ID must be either blank or numeric only."; -$lang['Namesilo.!error.epp.empty'] = "Domain transfers require an EPP code to be entered."; +$lang['Namesilo.!error.user.valid'] = 'Please enter a user'; +$lang['Namesilo.!error.key.valid'] = 'Please enter a key'; +$lang['Namesilo.!error.key.valid_connection'] = 'The user and key combination appear to be invalid, or your Namesilo account may not be configured to allow API access.'; +$lang['Namesilo.!error.portfolio.valid_portfolio'] = 'The portfolio entered does not appear valid. Are you sure it has been created in your Namesilo account?'; +$lang['Namesilo.!error.payment_id.valid_format'] = 'Payment ID must be either blank or numeric only.'; +$lang['Namesilo.!error.epp.empty'] = 'Domain transfers require an EPP code to be entered.'; // Notices -$lang['Namesilo.notice.StatusPending'] = "This order is pending. The feature you are trying to access will become available once the order has been activated successfully."; -$lang['Namesilo.notice.StatusSuspended'] = "This domain name has been suspended; domain management features are therefore currently unavailable. Please contact your service provider for more details or to reinstate service."; -$lang['Namesilo.notice.TransferPending'] = "This domain is currently awaiting transfer completion. Until the transfer is complete domain management features are unavailable."; +$lang['Namesilo.notice.StatusPending'] = 'This order is pending. The feature you are trying to access will become available once the order has been activated successfully.'; +$lang['Namesilo.notice.StatusSuspended'] = 'This domain name has been suspended; domain management features are therefore currently unavailable. Please contact your service provider for more details or to reinstate service.'; +$lang['Namesilo.notice.TransferPending'] = 'This domain is currently awaiting transfer completion. Until the transfer is complete domain management features are unavailable.'; // Domain Transfer Fields -$lang['Namesilo.transfer.domain'] = "Domain Name"; -$lang['Namesilo.transfer.EPPCode'] = "EPP Code"; +$lang['Namesilo.transfer.domain'] = 'Domain Name'; +$lang['Namesilo.transfer.EPPCode'] = 'EPP Code'; // Domain Fields -$lang['Namesilo.domain.domain'] = "Domain Name"; -$lang['Namesilo.domain.Years'] = "Years"; -$lang['Namesilo.domain.WhoisPrivacy'] = "Whois Privacy"; -$lang["Namesilo.domain.DomainAction"] = "Domain Action"; +$lang['Namesilo.domain.domain'] = 'Domain Name'; +$lang['Namesilo.domain.Years'] = 'Years'; +$lang['Namesilo.domain.WhoisPrivacy'] = 'Whois Privacy'; +$lang['Namesilo.domain.DomainAction'] = 'Domain Action'; // Nameserver Fields -$lang['Namesilo.nameserver.ns1'] = "Name Server 1"; -$lang['Namesilo.nameserver.ns2'] = "Name Server 2"; -$lang['Namesilo.nameserver.ns3'] = "Name Server 3"; -$lang['Namesilo.nameserver.ns4'] = "Name Server 4"; -$lang['Namesilo.nameserver.ns5'] = "Name Server 5"; +$lang['Namesilo.nameserver.ns1'] = 'Name Server 1'; +$lang['Namesilo.nameserver.ns2'] = 'Name Server 2'; +$lang['Namesilo.nameserver.ns3'] = 'Name Server 3'; +$lang['Namesilo.nameserver.ns4'] = 'Name Server 4'; +$lang['Namesilo.nameserver.ns5'] = 'Name Server 5'; //$lang['Namesilo.domain.IdnCode'] = ""; //$lang['Namesilo.domain.Nameservers'] = ""; @@ -156,91 +188,95 @@ //$lang['Namesilo.domain.AddFreePositiveSSL'] = ""; // Whois Fields -$lang['Namesilo.whois.Organization'] = "Organization"; +$lang['Namesilo.whois.Organization'] = 'Organization'; //$lang['Namesilo.whois.RegistrantJobTitle'] = "Job Title"; -$lang['Namesilo.whois.Nickname'] = "Nickname"; -$lang['Namesilo.whois.FirstName'] = "First Name"; -$lang['Namesilo.whois.LastName'] = "Last Name"; -$lang['Namesilo.whois.Address1'] = "Address 1"; -$lang['Namesilo.whois.Address2'] = "Address 2"; -$lang['Namesilo.whois.City'] = "City"; -$lang['Namesilo.whois.StateProvince'] = "State/Province"; +$lang['Namesilo.whois.Nickname'] = 'Nickname'; +$lang['Namesilo.whois.FirstName'] = 'First Name'; +$lang['Namesilo.whois.LastName'] = 'Last Name'; +$lang['Namesilo.whois.Address1'] = 'Address 1'; +$lang['Namesilo.whois.Address2'] = 'Address 2'; +$lang['Namesilo.whois.City'] = 'City'; +$lang['Namesilo.whois.StateProvince'] = 'State/Province'; //$lang['Namesilo.whois.RegistrantStateProvinceChoice'] = "State/Province Choice"; -$lang['Namesilo.whois.PostalCode'] = "Postal Code"; -$lang['Namesilo.whois.Country'] = "Country"; -$lang['Namesilo.whois.Phone'] = "Phone"; +$lang['Namesilo.whois.PostalCode'] = 'Postal Code'; +$lang['Namesilo.whois.Country'] = 'Country'; +$lang['Namesilo.whois.Phone'] = 'Phone'; //$lang['Namesilo.whois.RegistrantPhoneExt'] = "Phone Extension"; //$lang['Namesilo.whois.RegistrantFax'] = "Fax"; -$lang['Namesilo.whois.EmailAddress'] = "Email"; +$lang['Namesilo.whois.EmailAddress'] = 'Email'; // .US domain fields -$lang['Namesilo.domain.RegistrantNexus'] = "Registrant Type"; -$lang['Namesilo.domain.RegistrantNexus.error'] = "Please select a registrant type"; -$lang['Namesilo.domain.RegistrantNexus.c11'] = "US citizen"; -$lang['Namesilo.domain.RegistrantNexus.c12'] = "Permanent resident of the US"; -$lang['Namesilo.domain.RegistrantNexus.c21'] = "US entity or organization"; -$lang['Namesilo.domain.RegistrantNexus.c31'] = "Foreign organization"; -$lang['Namesilo.domain.RegistrantNexus.c32'] = "Foreign organization with an office in the US"; -$lang['Namesilo.domain.RegistrantPurpose'] = "Purpose"; -$lang['Namesilo.domain.RegistrantPurpose.error'] = "Please select a registrant purpose"; -$lang['Namesilo.domain.RegistrantPurpose.p1'] = "Business"; -$lang['Namesilo.domain.RegistrantPurpose.p2'] = "Non-profit"; -$lang['Namesilo.domain.RegistrantPurpose.p3'] = "Personal"; -$lang['Namesilo.domain.RegistrantPurpose.p4'] = "Educational"; -$lang['Namesilo.domain.RegistrantPurpose.p5'] = "Governmental"; +$lang['Namesilo.domain.RegistrantNexus'] = 'Registrant Type'; +$lang['Namesilo.domain.RegistrantNexus.error'] = 'Please select a registrant type'; +$lang['Namesilo.domain.RegistrantNexus.c11'] = 'US citizen'; +$lang['Namesilo.domain.RegistrantNexus.c12'] = 'Permanent resident of the US'; +$lang['Namesilo.domain.RegistrantNexus.c21'] = 'US entity or organization'; +$lang['Namesilo.domain.RegistrantNexus.c31'] = 'Foreign organization'; +$lang['Namesilo.domain.RegistrantNexus.c32'] = 'Foreign organization with an office in the US'; +$lang['Namesilo.domain.RegistrantPurpose'] = 'Purpose'; +$lang['Namesilo.domain.RegistrantPurpose.error'] = 'Please select a registrant purpose'; +$lang['Namesilo.domain.RegistrantPurpose.p1'] = 'Business'; +$lang['Namesilo.domain.RegistrantPurpose.p2'] = 'Non-profit'; +$lang['Namesilo.domain.RegistrantPurpose.p3'] = 'Personal'; +$lang['Namesilo.domain.RegistrantPurpose.p4'] = 'Educational'; +$lang['Namesilo.domain.RegistrantPurpose.p5'] = 'Governmental'; // .CA domain fields -$lang['Namesilo.domain.CIRALegalType'] = "Legal Type"; -$lang['Namesilo.domain.RegistrantPurpose.cco'] = "Corporation"; -$lang['Namesilo.domain.RegistrantPurpose.cct'] = "Canadian citizen"; -$lang['Namesilo.domain.RegistrantPurpose.res'] = "Canadian resident"; -$lang['Namesilo.domain.RegistrantPurpose.gov'] = "Government entity"; -$lang['Namesilo.domain.RegistrantPurpose.edu'] = "Educational"; -$lang['Namesilo.domain.RegistrantPurpose.ass'] = "Unincorporated Association"; -$lang['Namesilo.domain.RegistrantPurpose.hop'] = "Hospital"; -$lang['Namesilo.domain.RegistrantPurpose.prt'] = "Partnership"; -$lang['Namesilo.domain.RegistrantPurpose.tdm'] = "Trade-mark"; -$lang['Namesilo.domain.RegistrantPurpose.trd'] = "Trade Union"; -$lang['Namesilo.domain.RegistrantPurpose.plt'] = "Political Party"; -$lang['Namesilo.domain.RegistrantPurpose.lam'] = "Libraries, Archives and Museums"; -$lang['Namesilo.domain.RegistrantPurpose.trs'] = "Trust"; -$lang['Namesilo.domain.RegistrantPurpose.abo'] = "Aboriginal Peoples"; -$lang['Namesilo.domain.RegistrantPurpose.inb'] = "Indian Band"; -$lang['Namesilo.domain.RegistrantPurpose.lgr'] = "Legal Representative"; -$lang['Namesilo.domain.RegistrantPurpose.omk'] = "Official Mark"; -$lang['Namesilo.domain.RegistrantPurpose.maj'] = "Her Majesty the Queen"; -$lang['Namesilo.domain.RegistrantPurpose.other'] = "Other"; -$lang['Namesilo.domain.CIRAWhoisDisplay'] = "Whois Publishing"; -$lang['Namesilo.domain.CIRAWhoisDisplay.full'] = "Make Public"; -$lang['Namesilo.domain.CIRAWhoisDisplay.private'] = "Keep Private"; -$lang['Namesilo.domain.CIRALanguage'] = "Language"; -$lang['Namesilo.domain.CIRALanguage.en'] = "English"; -$lang['Namesilo.domain.CIRALanguage.fr'] = "French"; +$lang['Namesilo.domain.CIRALegalType'] = 'Legal Type'; +$lang['Namesilo.domain.RegistrantPurpose.cco'] = 'Corporation'; +$lang['Namesilo.domain.RegistrantPurpose.cct'] = 'Canadian citizen'; +$lang['Namesilo.domain.RegistrantPurpose.res'] = 'Canadian resident'; +$lang['Namesilo.domain.RegistrantPurpose.gov'] = 'Government entity'; +$lang['Namesilo.domain.RegistrantPurpose.edu'] = 'Educational'; +$lang['Namesilo.domain.RegistrantPurpose.ass'] = 'Unincorporated Association'; +$lang['Namesilo.domain.RegistrantPurpose.hop'] = 'Hospital'; +$lang['Namesilo.domain.RegistrantPurpose.prt'] = 'Partnership'; +$lang['Namesilo.domain.RegistrantPurpose.tdm'] = 'Trade-mark'; +$lang['Namesilo.domain.RegistrantPurpose.trd'] = 'Trade Union'; +$lang['Namesilo.domain.RegistrantPurpose.plt'] = 'Political Party'; +$lang['Namesilo.domain.RegistrantPurpose.lam'] = 'Libraries, Archives and Museums'; +$lang['Namesilo.domain.RegistrantPurpose.trs'] = 'Trust'; +$lang['Namesilo.domain.RegistrantPurpose.abo'] = 'Aboriginal Peoples'; +$lang['Namesilo.domain.RegistrantPurpose.inb'] = 'Indian Band'; +$lang['Namesilo.domain.RegistrantPurpose.lgr'] = 'Legal Representative'; +$lang['Namesilo.domain.RegistrantPurpose.omk'] = 'Official Mark'; +$lang['Namesilo.domain.RegistrantPurpose.maj'] = 'Her Majesty the Queen'; +$lang['Namesilo.domain.RegistrantPurpose.other'] = 'Other'; +$lang['Namesilo.domain.CIRAWhoisDisplay'] = 'Whois Publishing'; +$lang['Namesilo.domain.CIRAWhoisDisplay.full'] = 'Make Public'; +$lang['Namesilo.domain.CIRAWhoisDisplay.private'] = 'Keep Private'; +$lang['Namesilo.domain.CIRALanguage'] = 'Language'; +$lang['Namesilo.domain.CIRALanguage.en'] = 'English'; +$lang['Namesilo.domain.CIRALanguage.fr'] = 'French'; +// Success messages +$lang['Namesilo.!success.packages_saved'] = 'The packages have been successfully saved.'; // Errors -$lang['Namesilo.!error.FRLegalType.format'] = "Please select a valid Legal Type"; -$lang['Namesilo.!error.FRRegistrantBirthDate.format'] = "Please set your birth date in the format: YYYY-MM-DD"; -$lang['Namesilo.!error.FRRegistrantBirthplace.format'] = "Please set your birth place."; -$lang['Namesilo.!error.FRRegistrantLegalId.format'] = "Please set your SIREN/SIRET Number"; -$lang['Namesilo.!error.FRRegistrantTradeNumber.format'] = "Please set your Trademark Number."; -$lang['Namesilo.!error.FRRegistrantDunsNumber.format'] = "Please set your DUNS Number."; -$lang['Namesilo.!error.FRRegistrantLocalId.format'] = "Please set your EEA Local ID."; -$lang['Namesilo.!error.FRRegistrantJoDateDec.format'] = "Please set the Journal Declaration Date in the format: YYYY-MM-DD"; -$lang['Namesilo.!error.FRRegistrantJoDatePub.format'] = "Please set the Journal Publication Date in the format: YYYY-MM-DD"; -$lang['Namesilo.!error.FRRegistrantJoNumber.format'] = "Please set the Journal Number."; -$lang['Namesilo.!error.FRRegistrantJoPage.format'] = "Please set the Journal Announcement Page Number."; -$lang['Namesilo.!error.US.RegistrantNexus.empty'] = "Please select a registrant type."; -$lang['Namesilo.!error.US.RegistrantPurpose.empty'] = "Please select a registrant purpose."; -$lang['Namesilo.!error.US.RegistrantNexus.invalid'] = "Invalid registrant type submitted."; -$lang['Namesilo.!error.US.RegistrantPurpose.invalid'] = "Invalid registrat purpose submitted."; -$lang['Namesilo.!error.CA.CIRALegalType.empty'] = "Please select a legal type."; -$lang['Namesilo.!error.CA.CIRAWhoisDisplay.empty'] = "Please select a whois display option."; -$lang['Namesilo.!error.CA.CIRALanaguage.empty'] = "Please select a language."; -$lang['Namesilo.!error.CA.CIRALegalType.invalid'] = "Invalid legal type submitted."; -$lang['Namesilo.!error.CA.CIRAWhoisDisplay.invalid'] = "Invalid whois display option submitted."; -$lang['Namesilo.!error.CA.CIRALanaguage.invalid'] = "Invalid language submitted."; -$lang['Namesilo.!error.CA.CIRALegalType.other'] = "Only individual legal types may be processed automatically. Please contact us for more information."; +$lang['Namesilo.!error.FRLegalType.format'] = 'Please select a valid Legal Type'; +$lang['Namesilo.!error.FRRegistrantBirthDate.format'] = 'Please set your birth date in the format: YYYY-MM-DD'; +$lang['Namesilo.!error.FRRegistrantBirthplace.format'] = 'Please set your birth place.'; +$lang['Namesilo.!error.FRRegistrantLegalId.format'] = 'Please set your SIREN/SIRET Number'; +$lang['Namesilo.!error.FRRegistrantTradeNumber.format'] = 'Please set your Trademark Number.'; +$lang['Namesilo.!error.FRRegistrantDunsNumber.format'] = 'Please set your DUNS Number.'; +$lang['Namesilo.!error.FRRegistrantLocalId.format'] = 'Please set your EEA Local ID.'; +$lang['Namesilo.!error.FRRegistrantJoDateDec.format'] = 'Please set the Journal Declaration Date in the format: YYYY-MM-DD'; +$lang['Namesilo.!error.FRRegistrantJoDatePub.format'] = 'Please set the Journal Publication Date in the format: YYYY-MM-DD'; +$lang['Namesilo.!error.FRRegistrantJoNumber.format'] = 'Please set the Journal Number.'; +$lang['Namesilo.!error.FRRegistrantJoPage.format'] = 'Please set the Journal Announcement Page Number.'; +$lang['Namesilo.!error.US.RegistrantNexus.empty'] = 'Please select a registrant type.'; +$lang['Namesilo.!error.US.RegistrantPurpose.empty'] = 'Please select a registrant purpose.'; +$lang['Namesilo.!error.US.RegistrantNexus.invalid'] = 'Invalid registrant type submitted.'; +$lang['Namesilo.!error.US.RegistrantPurpose.invalid'] = 'Invalid registrat purpose submitted.'; +$lang['Namesilo.!error.CA.CIRALegalType.empty'] = 'Please select a legal type.'; +$lang['Namesilo.!error.CA.CIRAWhoisDisplay.empty'] = 'Please select a whois display option.'; +$lang['Namesilo.!error.CA.CIRALanaguage.empty'] = 'Please select a language.'; +$lang['Namesilo.!error.CA.CIRALegalType.invalid'] = 'Invalid legal type submitted.'; +$lang['Namesilo.!error.CA.CIRAWhoisDisplay.invalid'] = 'Invalid whois display option submitted.'; +$lang['Namesilo.!error.CA.CIRALanaguage.invalid'] = 'Invalid language submitted.'; +$lang['Namesilo.!error.CA.CIRALegalType.other'] = 'Only individual legal types may be processed automatically. Please contact us for more information.'; +// Tooltips +$lang['Namesilo.!tooltip.upgrades_use_renewal'] = 'When enabled, upgrading to this package will use renewal prices if they are set. The regular price will be used if this setting is disabled.'; require_once __DIR__ . '/notices.php'; diff --git a/language/en_us/notices.php b/language/en_us/notices.php index 49fbab5..50e9f47 100644 --- a/language/en_us/notices.php +++ b/language/en_us/notices.php @@ -1,18 +1,17 @@ loadConfig( __DIR__ . DS . "config.json" ); - # Load components required by this module - Loader::loadComponents( $this, array ( "Input" ) ); - # Load the language required by this module - Language::loadLang( "namesilo", null, __DIR__ . DS . "language" . DS ); - # Load configuration - Configure::load( "namesilo", __DIR__ . DS . "config" . DS ); - # Get Namesilo response codes - self::$codes = Configure::get( 'Namesilo.status.codes' ); - # Set default module view - self::$defaultModuleView = "components" . DS . "modules" . DS . "namesilo" . DS; - } - - /** - * Returns the name of this module - * - * @return string The common name of this module - */ - public function getName() { - return Language::_( "Namesilo.name", true ); - } - - /** - * Returns the value used to identify a particular service - * - * @param stdClass $service A stdClass object representing the service - * @return string A value used to identify this service amongst other similar services - */ - public function getServiceName( $service ) { - foreach ( $service->fields as $field ) { - if ( $field->key == "domain" ) { - return $field->value; - } - } - return null; - } - - /** - * Returns a noun used to refer to a module row (e.g. "Server", "VPS", "Reseller Account", etc.) - * - * @return string The noun used to refer to a module row - */ - public function moduleRowName() { - return Language::_( "Namesilo.module_row", true ); - } - - /** - * Returns a noun used to refer to a module row in plural form (e.g. "Servers", "VPSs", "Reseller Accounts", etc.) - * - * @return string The noun used to refer to a module row in plural form - */ - public function moduleRowNamePlural() { - return Language::_("Namesilo.module_row_plural", true); - } - - /** - * Returns a noun used to refer to a module group (e.g. "Server Group", "Cloud", etc.) - * - * @return string The noun used to refer to a module group - */ - public function moduleGroupName() { - return null; - } - - /** - * Returns the key used to identify the primary field from the set of module row meta fields. - * This value can be any of the module row meta fields. - * - * @return string The key used to identify the primary field from the set of module row meta fields - */ - public function moduleRowMetaKey() { - return "user"; - } - - /** - * Returns the value used to identify a particular package service which has - * not yet been made into a service. This may be used to uniquely identify - * an uncreated services of the same package (i.e. in an order form checkout) - * - * @param stdClass $package A stdClass object representing the selected package - * @param array $vars An array of user supplied info to satisfy the request - * @return string The value used to identify this package service - * @see Module::getServiceName() - */ - public function getPackageServiceName($packages, array $vars=null) { - if (isset($vars['domain'])) - return $vars['domain']; - return null; - } - - /** - * Attempts to validate service info. This is the top-level error checking method. Sets Input errors on failure. - * - * @param stdClass $package A stdClass object representing the selected package - * @param array $vars An array of user supplied info to satisfy the request - * @return boolean True if the service validates, false otherwise. Sets Input errors when false. - */ - public function validateService($package, array $vars=null) { - $rules = array(); +class Namesilo extends Module +{ + /** + * @var string Debug email address + */ + private static $debug_to = 'root@localhost'; + + /** + * @var array Namesilo response codes + */ + private static $codes; + + /** + * @var array Pending statutes + */ + private static $pending = ['in_review', 'pending']; + + /** + * @var string Default module view path + */ + private static $defaultModuleView; + + /** + * Initializes the module + */ + public function __construct() + { + // Load config.json + $this->loadConfig(__DIR__ . DS . 'config.json'); + + // Load components required by this module + Loader::loadComponents($this, ['Input', 'Record']); + + // Load the language required by this module + Language::loadLang('namesilo', null, __DIR__ . DS . 'language' . DS); + + // Load configuration + Configure::load('namesilo', __DIR__ . DS . 'config' . DS); + + // Get Namesilo response codes + self::$codes = Configure::get('Namesilo.status.codes'); + + // Set default module view + self::$defaultModuleView = 'components' . DS . 'modules' . DS . 'namesilo' . DS; + } + + /** + * Attempts to validate service info. This is the top-level error checking method. Sets Input errors on failure. + * + * @param stdClass $package A stdClass object representing the selected package + * @param array $vars An array of user supplied info to satisfy the request + * @return bool True if the service validates, false otherwise. Sets Input errors when false. + */ + public function validateService($package, array $vars = null) + { + $rules = []; // Transfers (EPP Code) - if (isset($vars['transfer']) && ($vars['transfer'] == '1' || $vars['transfer'] == true)) { + if (isset($vars['transfer']) && ($vars['transfer'] == '1' || $vars['transfer'] == true)) { $rule = [ 'auth' => [ - 'empty' => array( - 'rule' => array("isEmpty"), + 'empty' => [ + 'rule' => ['isEmpty'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.epp.empty", true), - 'post_format' => "trim" - ) + 'message' => Language::_('Namesilo.!error.epp.empty', true), + 'post_format' => 'trim' + ] ], ]; - $rules = array_merge($rules,$rule); + $rules = array_merge($rules, $rule); } // .us fields - if(isset($vars['usnc']) || isset($vars['usap'])){ + if (isset($vars['usnc']) || isset($vars['usap'])) { $rule = [ 'usnc' => [ - 'empty' => array( - 'rule' => array("isEmpty"), + 'empty' => [ + 'rule' => ['isEmpty'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.US.RegistrantNexus.empty", true), - 'post_format' => "trim", + 'message' => Language::_('Namesilo.!error.US.RegistrantNexus.empty', true), + 'post_format' => 'trim', 'final' => true - ), + ], 'valid' => [ - 'rule' => ['array_key_exists', Configure::get("Namesilo.domain_fields.us")['usnc']['options']], - 'message' => Language::_("Namesilo.!error.US.RegistrantNexus.invalid", true) + 'rule' => ['array_key_exists', Configure::get('Namesilo.domain_fields.us')['usnc']['options']], + 'message' => Language::_('Namesilo.!error.US.RegistrantNexus.invalid', true) ] ], 'usap' => [ - 'empty' => array( - 'rule' => array("isEmpty"), + 'empty' => [ + 'rule' => ['isEmpty'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.US.RegistrantPurpose.empty", true), - 'post_format' => "trim", + 'message' => Language::_('Namesilo.!error.US.RegistrantPurpose.empty', true), + 'post_format' => 'trim', 'final' => true - ), + ], 'valid' => [ - 'rule' => ['array_key_exists', Configure::get("Namesilo.domain_fields.us")['usap']['options']], - 'message' => Language::_("Namesilo.!error.US.RegistrantPurpose.invalid", true) + 'rule' => ['array_key_exists', Configure::get('Namesilo.domain_fields.us')['usap']['options']], + 'message' => Language::_('Namesilo.!error.US.RegistrantPurpose.invalid', true) ] ], ]; - $rules = array_merge($rules,$rule); + $rules = array_merge($rules, $rule); } // .ca fields - if(isset($vars['calf']) || isset($vars['cawd']) || isset($vars['caln'])){ + if (isset($vars['calf']) || isset($vars['cawd']) || isset($vars['caln'])) { $rule = [ 'calf' => [ - 'empty' => array( - 'rule' => array("isEmpty"), + 'empty' => [ + 'rule' => ['isEmpty'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.CA.CIRALegalType.empty", true), - 'post_format' => "trim", + 'message' => Language::_('Namesilo.!error.CA.CIRALegalType.empty', true), + 'post_format' => 'trim', 'final' => true - ), + ], 'valid' => [ - 'rule' => ['array_key_exists', Configure::get("Namesilo.domain_fields.ca")['calf']['options']], - 'message' => Language::_("Namesilo.!error.CA.CIRALegalType.invalid", true) + 'rule' => ['array_key_exists', Configure::get('Namesilo.domain_fields.ca')['calf']['options']], + 'message' => Language::_('Namesilo.!error.CA.CIRALegalType.invalid', true) ], 'other' => [ 'rule' => ['matches', '/^OTHER$/'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.CA.CIRALegalType.other", true) + 'message' => Language::_('Namesilo.!error.CA.CIRALegalType.other', true) ] ], 'cawd' => [ - 'empty' => array( - 'rule' => array("isEmpty"), + 'empty' => [ + 'rule' => ['isEmpty'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.CA.CIRAWhoisDisplay.empty", true), - 'post_format' => "trim", + 'message' => Language::_('Namesilo.!error.CA.CIRAWhoisDisplay.empty', true), + 'post_format' => 'trim', 'final' => true - ), + ], 'valid' => [ - 'rule' => ['array_key_exists', Configure::get("Namesilo.domain_fields.ca")['cawd']['options']], - 'message' => Language::_("Namesilo.!error.CA.CIRAWhoisDisplay.invalid", true) - ] + 'rule' => ['array_key_exists', Configure::get('Namesilo.domain_fields.ca')['cawd']['options']], + 'message' => Language::_('Namesilo.!error.CA.CIRAWhoisDisplay.invalid', true) + ] ], 'caln' => [ - 'empty' => array( - 'rule' => array("isEmpty"), + 'empty' => [ + 'rule' => ['isEmpty'], 'negate' => true, - 'message' => Language::_("Namesilo.!error.CA.CIRALanguage.empty", true), - 'post_format' => "trim", + 'message' => Language::_('Namesilo.!error.CA.CIRALanguage.empty', true), + 'post_format' => 'trim', 'final' => true - ), + ], 'valid' => [ - 'rule' => ['array_key_exists', Configure::get("Namesilo.domain_fields.ca")['caln']['options']], - 'message' => Language::_("Namesilo.!error.CA.CIRALanguage.invalid", true) - ] + 'rule' => ['array_key_exists', Configure::get('Namesilo.domain_fields.ca')['caln']['options']], + 'message' => Language::_('Namesilo.!error.CA.CIRALanguage.invalid', true) + ] ], ]; - $rules = array_merge($rules,$rule); + $rules = array_merge($rules, $rule); } - if(isset($rules) && count($rules) > 0){ + if (isset($rules) && count($rules) > 0) { $this->Input->setRules($rules); return $this->Input->validates($vars); } + return true; - } - - /** - * Adds the service to the remote server. Sets Input errors on failure, - * preventing the service from being added. - * - * @param stdClass $package A stdClass object representing the selected package - * @param array $vars An array of user supplied info to satisfy the request - * @param stdClass $parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service) - * @param stdClass $parent_service A stdClass object representing the parent service of the service being added (if the current service is an addon service and parent service has already been provisioned) - * @param string $status The status of the service being added. These include: - * - active - * - canceled - * - pending - * - suspended - * @return array A numerically indexed array of meta fields to be stored for this service containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - * @see Module::getModule() - * @see Module::getModuleRow() - */ - public function addService( $package, array $vars = null, $parent_package = null, $parent_service = null, $status = "pending" ) { - - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - - # - # TODO: Handle validation checks - # TODO: Fix nameservers - # - - if ( isset( $vars['domain'] ) ) { - $tld = $this->getTld($vars['domain'],$row); + } + + /** + * Adds the service to the remote server. Sets Input errors on failure, + * preventing the service from being added. + * + * @param stdClass $package A stdClass object representing the selected package + * @param array $vars An array of user supplied info to satisfy the request + * @param stdClass $parent_package A stdClass object representing the parent service's selected package + * (if the current service is an addon service) + * @param stdClass $parent_service A stdClass object representing the parent service of the service being added + * (if the current service is an addon service and parent service has already been provisioned) + * @param string $status The status of the service being added. These include: + * + * - active + * - canceled + * - pending + * - suspended + * @return array A numerically indexed array of meta fields to be stored for this service containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + * @see Module::getModule() + * @see Module::getModuleRow() + */ + public function addService( + $package, + array $vars = null, + $parent_package = null, + $parent_service = null, + $status = 'pending' + ) { + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + + # + # TODO: Handle validation checks + # TODO: Fix nameservers + # + + if (isset($vars['domain'])) { + $tld = $this->getTld($vars['domain'], $row); $vars['domain'] = trim($vars['domain']); } $input_fields = array_merge( - Configure::get( "Namesilo.domain_fields" ), - (array) Configure::get("Namesilo.domain_fields" . $tld ), - (array) Configure::get("Namesilo.nameserver_fields"), - (array) Configure::get("Namesilo.transfer_fields"), - array( 'years' => true, 'transfer' => isset( $vars['transfer'] ) ? $vars['transfer'] : 1 ) + Configure::get('Namesilo.domain_fields'), + (array) Configure::get('Namesilo.domain_fields' . $tld), + (array) Configure::get('Namesilo.nameserver_fields'), + (array) Configure::get('Namesilo.transfer_fields'), + ['years' => true, 'transfer' => isset($vars['transfer']) ? $vars['transfer'] : 1 ] ); // .ca and .us domains can't have traditional whois privacy - if($tld == '.ca' || $tld == '.us') + if ($tld == '.ca' || $tld == '.us') { unset($input_fields['private']); + } - - if ( isset( $vars['use_module'] ) && $vars['use_module'] == "true" ) { - - if ( $package->meta->type == "domain" ) { - - $vars['years'] = 1; - - foreach ( $package->pricing as $pricing ) { - if ( $pricing->id == $vars['pricing_id'] ) { - $vars['years'] = $pricing->term; - break; - } - } + if (isset($vars['use_module']) && $vars['use_module'] == 'true') { + if ($package->meta->type == 'domain') { + $vars['years'] = 1; + + foreach ($package->pricing as $pricing) { + if ($pricing->id == $vars['pricing_id']) { + $vars['years'] = $pricing->term; + break; + } + } - $whois_fields = Configure::get("Namesilo.whois_fields"); + $whois_fields = Configure::get('Namesilo.whois_fields'); // Set all whois info from client ($vars['client_id']) - if ( !isset( $this->Clients ) ) { - Loader::loadModels( $this, array( "Clients" ) ); + if (!isset($this->Clients)) { + Loader::loadModels($this, ['Clients']); } - if ( !isset( $this->Contacts ) ) { - Loader::loadModels( $this, array( "Contacts" ) ); + if (!isset($this->Contacts)) { + Loader::loadModels($this, ['Contacts']); } - $client = $this->Clients->get( $vars['client_id'] ); + $client = $this->Clients->get($vars['client_id']); - if ( $client ) - $contact_numbers = $this->Contacts->getNumbers( $client->contact_id ); + if ($client) { + $contact_numbers = $this->Contacts->getNumbers($client->contact_id); + } - foreach ( $whois_fields as $key => $value ) { + foreach ($whois_fields as $key => $value) { $input_fields[$value['rp']] = true; - if ( strpos( $key, "phone" ) !== false ) { - $vars[$value['rp']] = $this->formatPhone( isset( $contact_numbers[0] ) ? $contact_numbers[0]->number : null, $client->country ); - } - else { - $vars[$value['rp']] = ( isset( $value['lp'] ) && !empty( $value['lp'] ) ) ? $client->{$value['lp']} : 'NA'; + if (strpos($key, 'phone') !== false) { + $vars[$value['rp']] = $this->formatPhone( + isset($contact_numbers[0]) ? $contact_numbers[0]->number : null, + $client->country + ); + } else { + $vars[$value['rp']] = (isset($value['lp']) && !empty($value['lp'])) + ? $client->{$value['lp']} + : 'NA'; } } - $fields = array_intersect_key( $vars, $input_fields ); + $fields = array_intersect_key($vars, $input_fields); - if(!empty($row->meta->portfolio)) + if (!empty($row->meta->portfolio)) { $fields['portfolio'] = $row->meta->portfolio; - if(!empty($row->meta->payment_id)) + } + if (!empty($row->meta->payment_id)) { $fields['payment_id'] = $row->meta->payment_id; + } // for .ca domains we need to create a special contact to use - if($tld == '.ca'){ - $domains = new NamesiloDomains( $api ); + if ($tld == '.ca') { + $domains = new NamesiloDomains($api); $response = $domains->addContacts($vars); - $this->processResponse($api,$response); - if ($this->Input->errors()) + $this->processResponse($api, $response); + if ($this->Input->errors()) { return; + } $fields['contact_id'] = $response->response()->contact_id; } - // Handle transfer - if ( isset($vars['auth']) && $vars['auth'] ) { + // Handle transfer + if (isset($vars['auth']) && $vars['auth']) { + $transfer = new NamesiloDomainsTransfer($api); - $transfer = new NamesiloDomainsTransfer( $api ); + $response = $transfer->create($fields); + $this->processResponse($api, $response); - $response = $transfer->create( $fields ); - $this->processResponse( $api, $response ); - - if ($this->Input->errors()) { - if(isset($vars['contact_id'])) - $domains->deleteContacts(array('contact_id'=>$vars['contact_id'])); + if ($this->Input->errors()) { + if (isset($vars['contact_id'])) { + $domains->deleteContacts(['contact_id' => $vars['contact_id']]); + } return; } - }else{ - // Handle registration - $domains = new NamesiloDomains( $api ); - - //$this->debug( $fields ); - //$this->Input->setErrors( array( 'errors' => array( 'Test' ) ) ); - //return; + } else { + // Handle registration + $domains = new NamesiloDomains($api); - $response = $domains->create( $fields ); - $this->processResponse( $api, $response ); + $response = $domains->create($fields); + $this->processResponse($api, $response); - if ($this->Input->errors()) { - // if namesilo is running a promotion on registrations we have to work around their system if + if ($this->Input->errors()) { + // if namesilo is running a promotion on registrations we have to work around their system if // we are doing a multi-year registration - if(reset($this->Input->errors()['errors']) === 'Invalid number of years, or no years provided.'){ - // unset the errors since we are working around it + $error = 'Invalid number of years, or no years provided.'; + if (reset($this->Input->errors()['errors']) === $error) { + // unset the errors since we are working around it $this->Input->setErrors([]); - // set the registration length to 1 year and save the remainder for an extension + // set the registration length to 1 year and save the remainder for an extension $total_years = $fields['years']; $fields['years'] = 1; - $response = $domains->create($fields); - $this->processResponse($api,$response); - // now extend the remainder of the years + $response = $domains->create($fields); + $this->processResponse($api, $response); + // now extend the remainder of the years $fields['years'] = $total_years - 1; $response = $domains->renew($fields); - $this->processResponse($api,$response); + $this->processResponse($api, $response); } - if(isset($vars['contact_id'])) - $domains->deleteContacts(array('contact_id'=>$vars['contact_id'])); + if (isset($vars['contact_id'])) { + $domains->deleteContacts(['contact_id' => $vars['contact_id']]); + } return; } - } - } - } + } + } + } $meta = []; $fields = array_intersect_key($vars, $input_fields); @@ -398,471 +350,627 @@ public function addService( $package, array $vars = null, $parent_package = null } return $meta; - } - - /** - * Edits the service on the remote server. Sets Input errors on failure, - * preventing the service from being edited. - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $vars An array of user supplied info to satisfy the request - * @param stdClass $parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service) - * @param stdClass $parent_service A stdClass object representing the parent service of the service being edited (if the current service is an addon service) - * @return array A numerically indexed array of meta fields to be stored for this service containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - * @see Module::getModule() - * @see Module::getModuleRow() - */ - public function editService( $package, $service, array $vars = array(), $parent_package = null, $parent_service = null ) { - $renew = isset( $vars["renew"] ) ? (int) $vars["renew"] : 0; - if ( $renew > 0 && $vars["use_module"] == 'true' ) { - $this->renewService( $package, $service, $parent_package, $parent_service, $renew ); - unset( $vars['renew'] ); - } - return null; // All this handled by admin/client tabs instead - } - - /** - * Cancels the service on the remote server. Sets Input errors on failure, - * preventing the service from being canceled. - */ - public function cancelService( $package, $service, $parent_package = null, $parent_service = null ) { - - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - - if ( $package->meta->type == "domain" ) { - - $fields = $this->serviceFieldsToObject( $service->fields ); - - $domains = new NamesiloDomains( $api ); - $response = $domains->setAutoRenewal( $fields->{"domain"}, false ); - $this->processResponse( $api, $response ); - - if ($this->Input->errors()) - return; - - } - return; - } - - /** - * Suspends the service on the remote server. Sets Input errors on failure, - * preventing the service from being suspended. - */ - public function suspendService( $package, $service, $parent_package = null, $parent_service = null ) { - - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - - if ( $package->meta->type == "domain" ) { - - $fields = $this->serviceFieldsToObject( $service->fields ); - - # Make sure auto renew is off - $domains = new NamesiloDomains( $api ); - $response = $domains->setAutoRenewal( $fields->{"domain"}, false ); - $this->processResponse( $api, $response ); - - if ( $this->Input->errors() ) { - return; - } - - } - return; - } - - /** - * Unsuspends the service on the remote server. Sets Input errors on failure, - * preventing the service from being unsuspended. - */ - public function unsuspendService($package, $service, $parent_package=null, $parent_service=null) { - return null; // Nothing to do - } - - /** - * Allows the module to perform an action when the service is ready to renew. - * Sets Input errors on failure, preventing the service from renewing. - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param stdClass $parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service) - * @param stdClass $parent_service A stdClass object representing the parent service of the service being renewed (if the current service is an addon service) - * @return mixed null to maintain the existing meta fields or a numerically indexed array of meta fields to be stored for this service containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - * @see Module::getModule() - * @see Module::getModuleRow() - */ - public function renewService( $package, $service, $parent_package = NULL, $parent_service = NULL, $years = NULL ) { - - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - - // Renew domain renewDomain?version=1&type=xml&key=12345&domain=namesilo.com&years=2 - if ( $package->meta->type == "domain" ) { - - $fields = $this->serviceFieldsToObject( $service->fields ); - - $vars = array( - "domain" => $fields->{"domain"}, - "years" => 1 - ); - - if ( !$years ) - { - foreach ( $package->pricing as $pricing ) { - if ( $pricing->id == $service->pricing_id ) { - $vars['years'] = $pricing->term; - break; - } - } - } - else { - $vars["years"] = $years; - } - - $domains = new NamesiloDomains( $api ); - $response = $domains->renew( $vars ); - $this->processResponse( $api, $response ); - - if ($this->Input->errors()) - return; - } - - return null; - } - - /** - * Updates the package for the service on the remote server. Sets Input - * errors on failure, preventing the service's package from being changed. - */ - public function changeServicePackage($package_from, $package_to, $service, $parent_package=null, $parent_service=null) { - return null; // Nothing to do - } - - /** - * Validates input data when attempting to add a package, returns the meta - * data to save when adding a package. Performs any action required to add - * the package on the remote server. Sets Input errors on failure, - * preventing the package from being added. - * - * @param array An array of key/value pairs used to add the package - * @return array A numerically indexed array of meta fields to be stored for this package containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - * @see Module::getModule() - * @see Module::getModuleRow() - */ - public function addPackage(array $vars=null) { - - $meta = array(); - if (isset($vars['meta']) && is_array($vars['meta'])) { - // Return all package meta fields - foreach ($vars['meta'] as $key => $value) { - $meta[] = array( - 'key' => $key, - 'value' => $value, - 'encrypted' => 0 - ); - } - } - - return $meta; - } - - /** - * Validates input data when attempting to edit a package, returns the meta - * data to save when editing a package. Performs any action required to edit - * the package on the remote server. Sets Input errors on failure, - * preventing the package from being edited. - * - * @param stdClass $package A stdClass object representing the selected package - * @param array An array of key/value pairs used to edit the package - * @return array A numerically indexed array of meta fields to be stored for this package containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - * @see Module::getModule() - * @see Module::getModuleRow() - */ - public function editPackage($package, array $vars=null) { - - $meta = array(); - if (isset($vars['meta']) && is_array($vars['meta'])) { - // Return all package meta fields - foreach ($vars['meta'] as $key => $value) { - $meta[] = array( - 'key' => $key, - 'value' => $value, - 'encrypted' => 0 - ); - } - } - - return $meta; - } - - /** - * Returns the rendered view of the manage module page - * - * @param mixed $module A stdClass object representing the module and its rows - * @param array $vars An array of post data submitted to or on the manage module page (used to repopulate fields after an error) - * @return string HTML content containing information to display when viewing the manager module page - */ - public function manageModule( $module, array &$vars ) { - // Load the view into this object, so helpers can be automatically added to the view - $this->view = new View( "manage", "default" ); - $this->view->base_uri = $this->base_uri; - $this->view->setDefaultView( self::$defaultModuleView ); - - # - # - # TODO: add tab to check status of all transfers: check if possible with Namesilo... ref: NamesiloDomainsTransfer->getList() - # - # - - foreach($module->rows as $row){ - if(isset($row->meta->key)){ - $link_buttons[] = array('name'=>Language::_("Namesilo.manage.sync_renew_dates",true),'attributes'=>array('href'=>array('href'=>$this->base_uri . "settings/company/modules/addrow/" . $module->id."?action=sync_renew_dates"))); - $link_buttons[] = array('name'=>Language::_("Namesilo.manage.audit_domains", true), 'attributes'=>array('href'=>$this->base_uri . "settings/company/modules/addrow/" . $module->id."?action=audit_domains")); - break; + } + + /** + * Edits the service on the remote server. Sets Input errors on failure, + * preventing the service from being edited. + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $vars An array of user supplied info to satisfy the request + * @param stdClass $parent_package A stdClass object representing the parent service's selected package + * (if the current service is an addon service) + * @param stdClass $parent_service A stdClass object representing the parent service of the service being edited + * (if the current service is an addon service) + * @return array A numerically indexed array of meta fields to be stored for this service containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + * @see Module::getModule() + * @see Module::getModuleRow() + */ + public function editService($package, $service, array $vars = [], $parent_package = null, $parent_service = null) + { + $renew = isset($vars['renew']) ? (int) $vars['renew'] : 0; + if ($renew > 0 && $vars['use_module'] == 'true') { + $this->renewService($package, $service, $parent_package, $parent_service, $renew); + unset($vars['renew']); + } + + return null; // All this handled by admin/client tabs instead + } + + /** + * Cancels the service on the remote server. Sets Input errors on failure, + * preventing the service from being canceled. + */ + public function cancelService($package, $service, $parent_package = null, $parent_service = null) + { + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + + if ($package->meta->type == 'domain') { + $fields = $this->serviceFieldsToObject($service->fields); + + $domains = new NamesiloDomains($api); + $response = $domains->setAutoRenewal($fields->{'domain'}, false); + $this->processResponse($api, $response); + + if ($this->Input->errors()) { + return; + } + } + + return; + } + + /** + * Suspends the service on the remote server. Sets Input errors on failure, + * preventing the service from being suspended. + */ + public function suspendService($package, $service, $parent_package = null, $parent_service = null) + { + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + + if ($package->meta->type == 'domain') { + $fields = $this->serviceFieldsToObject($service->fields); + + // Make sure auto renew is off + $domains = new NamesiloDomains($api); + $response = $domains->setAutoRenewal($fields->{'domain'}, false); + $this->processResponse($api, $response); + + if ($this->Input->errors()) { + return; + } + } + + return; + } + + /** + * Allows the module to perform an action when the service is ready to renew. + * Sets Input errors on failure, preventing the service from renewing. + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param stdClass $parent_package A stdClass object representing the parent service's selected package + * (if the current service is an addon service) + * @param stdClass $parent_service A stdClass object representing the parent service of the service being renewed + * (if the current service is an addon service) + * @return mixed null to maintain the existing meta fields or a numerically indexed array of meta fields to be + * stored for this service containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + * @see Module::getModule() + * @see Module::getModuleRow() + */ + public function renewService($package, $service, $parent_package = null, $parent_service = null, $years = null) + { + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + + // Renew domain renewDomain?version=1&type=xml&key=12345&domain=namesilo.com&years=2 + if ($package->meta->type == 'domain') { + $fields = $this->serviceFieldsToObject($service->fields); + + $vars = [ + 'domain' => $fields->{'domain'}, + 'years' => 1 + ]; + + if (!$years) { + foreach ($package->pricing as $pricing) { + if ($pricing->id == $service->pricing_id) { + $vars['years'] = $pricing->term; + break; + } + } + } else { + $vars['years'] = $years; + } + + $domains = new NamesiloDomains($api); + $response = $domains->renew($vars); + $this->processResponse($api, $response); + + if ($this->Input->errors()) { + return; + } + } + + return null; + } + + /** + * Validates input data when attempting to add a package, returns the meta + * data to save when adding a package. Performs any action required to add + * the package on the remote server. Sets Input errors on failure, + * preventing the package from being added. + * + * @param array An array of key/value pairs used to add the package + * @return array A numerically indexed array of meta fields to be stored for this package containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + * @see Module::getModule() + * @see Module::getModuleRow() + */ + public function addPackage(array $vars = null) + { + $meta = []; + if (isset($vars['meta']) && is_array($vars['meta'])) { + // Return all package meta fields + foreach ($vars['meta'] as $key => $value) { + $meta[] = [ + 'key' => $key, + 'value' => $value, + 'encrypted' => 0 + ]; + } + } + + return $meta; + } + + /** + * Validates input data when attempting to edit a package, returns the meta + * data to save when editing a package. Performs any action required to edit + * the package on the remote server. Sets Input errors on failure, + * preventing the package from being edited. + * + * @param stdClass $package A stdClass object representing the selected package + * @param array An array of key/value pairs used to edit the package + * @return array A numerically indexed array of meta fields to be stored for this package containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + * @see Module::getModule() + * @see Module::getModuleRow() + */ + public function editPackage($package, array $vars = null) + { + $meta = []; + if (isset($vars['meta']) && is_array($vars['meta'])) { + // Return all package meta fields + foreach ($vars['meta'] as $key => $value) { + $meta[] = [ + 'key' => $key, + 'value' => $value, + 'encrypted' => 0 + ]; } } - $this->view->set("module", $module); - $this->view->set("link_buttons",$link_buttons); - - // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html", "Widget" ) ); - - $this->view->set( "module", $module ); - - return $this->view->fetch(); - } - - /** - * Returns the rendered view of the add module row page - * - * @param array $vars An array of post data submitted to or on the add module row page (used to repopulate fields after an error) - * @return string HTML content containing information to display when viewing the add module row page - */ - public function manageAddRow(array &$vars) { - $action = isset($_GET['action']) ? $_GET['action'] : null; - - if($action == 'audit_domains') { - $vars = []; - $this->view = new View("audit_domains", "default"); + return $meta; + } + + /** + * Returns the rendered view of the manage module page + * + * @param mixed $module A stdClass object representing the module and its rows + * @param array $vars An array of post data submitted to or on the manage module page + * (used to repopulate fields after an error) + * @return string HTML content containing information to display when viewing the manager module page + */ + public function manageModule($module, array &$vars) + { + $action = isset($_GET['action']) ? $_GET['action'] : null; + + // Load the required models + Loader::loadModels($this, ['Languages', 'Settings', 'Currencies', 'Packages']); + + if ($action == 'manage_packages') { + // Load Namesilo packages + Loader::load(__DIR__ . DS . 'includes' . DS . 'namesilo_packages.php'); + $this->NamesiloPackages = new NamesiloPackages(); + + // Fetch stored packages vars, if available + $module_row = $this->getRow(); + $settings = $this->NamesiloPackages->getSettings($module_row->id); + + $post = $vars; + $vars = []; + + $this->view = new View('manage_packages', 'default'); $this->view->base_uri = $this->base_uri; - $this->view->setDefaultView( self::$defaultModuleView ); + $this->view->setDefaultView(self::$defaultModuleView); // Load the helpers required for this view - Loader::loadHelpers($this, array ("Form", "Html", "Widget")); - Loader::loadModels($this,array("Services","Record","ModuleManager")); + Loader::loadHelpers($this, ['Form', 'Html', 'Javascript', 'Widget', 'CurrencyFormat']); + // Fetch TLD prices + $tlds = $this->getPrices(); - $module_row = $this->getNamesiloRow(); + // Get all currencies + $currencies = $this->Form->collapseObjectArray( + $this->Currencies->getAll(Configure::get('Blesta.company_id')), + 'code', + 'code' + ); - $api = $this->getApi($module_row->meta->user, $module_row->meta->key, $module_row->meta->sandbox == "true", null, true); - $domains = new NamesiloDomains($api); + // Fetch module rows + $module_rows = $this->getRowsOptions(); - if($module_row->meta->portfolio) - $vars['portfolio'] = $module_row->meta->portfolio; + // Fetch all available package groups + $package_groups = $this->Form->collapseObjectArray( + $this->Packages->getAllGroups(Configure::get('Blesta.company_id')), + 'name', + 'id' + ); - $domain_list = $domains->getList($vars)->response()->domains->domain; + // Calculate maximum packages that can be saved at a time + $max_packages = round( + (ini_get('max_input_vars') - 30) / ((count($currencies) * 3) + 1), + 0, + PHP_ROUND_HALF_DOWN + ); - $vars['domains'] = []; - foreach($domain_list as $domain){ - $record = $this->Record->select("*")->from("services") - ->leftJoin("service_fields","services.id","=","service_fields.service_id", false) - ->where("services.status","IN",array("active","suspended")) - ->where("service_fields.value","=",$domain) - ->where("services.module_row_id","=",$module_row->id) - ->where("service_fields.key","=",'domain') - ->numResults(); - if(!$record){ - $vars['domains'][] = $domain; + // Save packages + if (!empty($post)) { + $this->NamesiloPackages->process($post); + + if (($errors = $this->NamesiloPackages->errors())) { + $this->setMessage('error', reset($errors)); + } else { + $this->setMessage( + 'success', + Language::_( + 'Namesilo.!success.packages_saved', + true + ) + ); } } - $this->view->set( "vars", (object)$vars ); + // Set view + $this->view->set('tlds', $tlds); + $this->view->set('module_rows', $module_rows); + $this->view->set('languages', $this->Languages->getAll(Configure::get('Blesta.company_id'))); + $this->view->set('currencies', $currencies); + $this->view->set('package_groups', $package_groups); + $this->view->set('max_packages', $max_packages); + $this->view->set('vars', !empty($post) ? (object)$post : (object)$settings); + + $this->view->set('messages', $this->getMessages()); + $this->view->set('package_name_tags', $this->getPackageNameTags()); return $this->view->fetch(); - }elseif($action == 'sync_renew_dates'){ - if(isset($_POST['sync_services'])) - $post['sync_services'] = $_POST['sync_services']; + } elseif ($action == 'tld_rows') { + // Load Namesilo packages + Loader::load(__DIR__ . DS . 'includes' . DS . 'namesilo_packages.php'); + $this->NamesiloPackages = new NamesiloPackages(); - $this->view = new View("sync_renew_dates", "default"); + // Fetch stored packages vars, if available + $module_row = $this->getRow(); + $settings = $this->NamesiloPackages->getSettings($module_row->id); + + $this->view = new View('tld_rows', 'default'); $this->view->base_uri = $this->base_uri; - $this->view->setDefaultView( self::$defaultModuleView ); + $this->view->setDefaultView(self::$defaultModuleView); // Load the helpers required for this view - Loader::loadHelpers($this, array ("Form", "Html", "Widget")); - Loader::loadModels($this,array("Services","Clients","Record","ModuleManager","ClientGroups")); + Loader::loadHelpers($this, ['Form', 'Html', 'CurrencyFormat']); + + // Fetch TLD prices + $tlds = $this->getPrices(); + $tld = array_key_exists('.' . $_GET['tld'], $tlds) ? '.' . $_GET['tld'] : null; + + // Get all currencies + $currencies = $this->Form->collapseObjectArray( + $this->Currencies->getAll(Configure::get('Blesta.company_id')), + 'code', + 'code' + ); + + // Set view + $this->view->set('tld', $tld); + $this->view->set('pricing', $tlds[$tld]); + $this->view->set('currencies', $currencies); + $this->view->set('vars', !empty($vars) ? (object)$vars : (object)$settings); + + $this->view->set('messages', $this->getMessages()); + $this->view->set('package_name_tags', $this->getPackageNameTags()); + + echo $this->view->fetch(); + exit; + } else { + // Load the view into this object, so helpers can be automatically added to the view + $this->view = new View('manage', 'default'); + $this->view->base_uri = $this->base_uri; + $this->view->setDefaultView(self::$defaultModuleView); + + // Load the helpers required for this view + Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); + + # + # + # TODO: add tab to check status of all transfers: check if possible with Namesilo... + # ref: NamesiloDomainsTransfer->getList() + # + # + $link_buttons = []; + foreach ($module->rows as $row) { + if (isset($row->meta->key)) { + $link_buttons = [ + [ + 'name' => Language::_('Namesilo.manage.manage_packages', true), + 'attributes' => [ + 'href' => [ + 'href' => $this->base_uri . 'settings/company/modules/manage/' + . $module->id . '?action=manage_packages' + ] + ] + ], + [ + 'name' => Language::_('Namesilo.manage.sync_renew_dates', true), + 'attributes' => [ + 'href' => [ + 'href' => $this->base_uri . 'settings/company/modules/addrow/' + . $module->id . '?action=sync_renew_dates' + ] + ] + ], + [ + 'name' => Language::_('Namesilo.manage.audit_domains', true), + 'attributes' => [ + 'href' => $this->base_uri . 'settings/company/modules/addrow/' + . $module->id . '?action=audit_domains' + ] + ] + ]; + break; + } + } - $module_row = $this->getNamesiloRow(); + $this->view->set('module', $module); + $this->view->set('link_buttons', $link_buttons); + $this->view->set('module', $module); - $api = $this->getApi($module_row->meta->user, $module_row->meta->key, $module_row->meta->sandbox == "true", null, true); + return $this->view->fetch(); + } + } + + /** + * Returns the rendered view of the add module row page + * + * @param array $vars An array of post data submitted to or on the add module row page + * (used to repopulate fields after an error) + * @return string HTML content containing information to display when viewing the add module row page + */ + public function manageAddRow(array &$vars) + { + $action = isset($_GET['action']) ? $_GET['action'] : null; + + // Load the view into this object, so helpers can be automatically added to the view + $this->view = new View((!empty($action) ? $action : 'add_row'), 'default'); + $this->view->base_uri = $this->base_uri; + $this->view->setDefaultView(self::$defaultModuleView); + + // Load the helpers and models required for this view + Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); + Loader::loadModels($this, ['Services', 'ModuleManager', 'Clients', 'ClientGroups']); + + if ($action == 'audit_domains') { + $vars = []; + $module_row = $this->getRow(); + + $api = $this->getApi( + $module_row->meta->user, + $module_row->meta->key, + $module_row->meta->sandbox == 'true', + null, + true + ); $domains = new NamesiloDomains($api); - $services = $this->Record->select(array("services.id","services.client_id")) - ->from("services") - ->where('module_row_id','=',$module_row->id) - ->where('status','=','active') - ->fetchAll(); + if ($module_row->meta->portfolio) { + $vars['portfolio'] = $module_row->meta->portfolio; + } + + $response = $domains->getList($vars)->response(); + $domain_list = $this->Html->ifSet($response->domains->domain); - $vars['changes'] = array(); + $vars['domains'] = []; - foreach($services as $service_id){ - $vars['changes'][] = $this->getRenewInfo($service_id->id,$domains); + if (!empty($domain_list)) { + foreach ($domain_list as $domain) { + $record = $this->Record->select() + ->from('services') + ->leftJoin('service_fields', 'services.id', '=', 'service_fields.service_id', false) + ->where('services.status', 'IN', ['active', 'suspended']) + ->where('service_fields.value', '=', $domain) + ->where('services.module_row_id', '=', $module_row->id) + ->where('service_fields.key', '=', 'domain') + ->numResults(); + + if (!$record) { + $vars['domains'][] = $domain; + } + } } - $this->view->set( "vars", $vars ); + // Set view + $this->view->set('vars', (object)$vars); + return $this->view->fetch(); - }else{ - // Load the view into this object, so helpers can be automatically added to the view - $this->view = new View("add_row", "default"); - $this->view->base_uri = $this->base_uri; - $this->view->setDefaultView( self::$defaultModuleView ); + } elseif ($action == 'sync_renew_dates') { + if (isset($vars['sync_services'])) { + $post['sync_services'] = $vars['sync_services']; + } - // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html", "Widget" ) ); + $module_row = $this->getRow(); + + $api = $this->getApi( + $module_row->meta->user, + $module_row->meta->key, + $module_row->meta->sandbox == 'true', + null, + true + ); + $domains = new NamesiloDomains($api); + + $services = $this->Record->select(['services.id', 'services.client_id']) + ->from('services') + ->where('module_row_id', '=', $module_row->id) + ->where('status', '=', 'active') + ->fetchAll(); + $vars['changes'] = []; + + foreach ($services as $service_id) { + $vars['changes'][] = $this->getRenewInfo($service_id->id, $domains); + } + + // Set view + $this->view->set('vars', $vars); + + return $this->view->fetch(); + } else { // Set unspecified checkboxes if (!empty($vars)) { - if (empty($vars['sandbox'])) - $vars['sandbox'] = "false"; + if (empty($vars['sandbox'])) { + $vars['sandbox'] = 'false'; + } } - $this->view->set("vars", (object)$vars); + // Set view + $this->view->set('vars', (object)$vars); + return $this->view->fetch(); } - } - - /** - * Returns the rendered view of the edit module row page - * - * @param stdClass $module_row The stdClass representation of the existing module row - * @param array $vars An array of post data submitted to or on the edit module row page (used to repopulate fields after an error) - * @return string HTML content containing information to display when viewing the edit module row page - */ - public function manageEditRow($module_row, array &$vars) { - // Load the view into this object, so helpers can be automatically added to the view - $this->view = new View("edit_row", "default"); - $this->view->base_uri = $this->base_uri; - $this->view->setDefaultView( self::$defaultModuleView ); - - // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html", "Widget" ) ); - - if (empty($vars)) - $vars = $module_row->meta; - else { - // Set unspecified checkboxes - if (empty($vars['sandbox'])) - $vars['sandbox'] = "false"; - } - - $this->view->set( "vars", (object)$vars ); - return $this->view->fetch(); - } - - /** - * Adds the module row on the remote server. Sets Input errors on failure, - * preventing the row from being added. - * - * @param array $vars An array of module info to add - * @return array A numerically indexed array of meta fields for the module row containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - */ - public function addModuleRow(array &$vars) { - if(isset($_POST['sync_services'])){ - Loader::loadModels($this,array("ModuleManager","Services","Clients","ClientGroups")); - - $module_row = $this->getNamesiloRow(); - - foreach($_POST['sync_services'] as $service_id) { - $api = $this->getApi($module_row->meta->user, $module_row->meta->key, $module_row->meta->sandbox == "true", null, true); + } + + /** + * Returns the rendered view of the edit module row page + * + * @param stdClass $module_row The stdClass representation of the existing module row + * @param array $vars An array of post data submitted to or on the edit module row page + * (used to repopulate fields after an error) + * @return string HTML content containing information to display when viewing the edit module row page + */ + public function manageEditRow($module_row, array &$vars) + { + // Load the view into this object, so helpers can be automatically added to the view + $this->view = new View('edit_row', 'default'); + $this->view->base_uri = $this->base_uri; + $this->view->setDefaultView(self::$defaultModuleView); + + // Load the helpers required for this view + Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); + + if (empty($vars)) { + $vars = $module_row->meta; + } else { + // Set unspecified checkboxes + if (empty($vars['sandbox'])) { + $vars['sandbox'] = 'false'; + } + } + + $this->view->set('vars', (object)$vars); + return $this->view->fetch(); + } + + /** + * Adds the module row on the remote server. Sets Input errors on failure, + * preventing the row from being added. + * + * @param array $vars An array of module info to add + * @return array A numerically indexed array of meta fields for the module row containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + */ + public function addModuleRow(array &$vars) + { + if (isset($vars['sync_services'])) { + Loader::loadModels($this, ['ModuleManager', 'Services', 'Clients', 'ClientGroups']); + + $module_row = $this->getRow(); + + foreach ($vars['sync_services'] as $service_id) { + $api = $this->getApi( + $module_row->meta->user, + $module_row->meta->key, + $module_row->meta->sandbox == 'true', + null, + true + ); $domains = new NamesiloDomains($api); $info = $this->getRenewInfo($service_id, $domains); - $this->Services->edit($service_id, array('date_renews' => $info['date_after']), true); + $this->Services->edit($service_id, ['date_renews' => $info['date_after']], true); } - $url = explode("?",$_SERVER['REQUEST_URI']); + $url = explode('?', $_SERVER['REQUEST_URI']); header('Location:' . $url[0].'?action=sync_renew_dates&msg=success'); exit(); } - $meta_fields = array("user", "key", "sandbox", "portfolio", "payment_id", "namesilo_module"); - $encrypted_fields = array("key"); - - // Set unspecified checkboxes - if (empty($vars['sandbox'])) - $vars['sandbox'] = "false"; - - $this->Input->setRules($this->getRowRules($vars)); - - // Validate module row - if ($this->Input->validates($vars)) { - - // Build the meta data for this row - $meta = array(); - foreach ($vars as $key => $value) { - - if (in_array($key, $meta_fields)) { - $meta[] = array( - 'key' => $key, - 'value' => $value, - 'encrypted' => in_array($key, $encrypted_fields) ? 1 : 0 - ); - } - } - - return $meta; - } - } - - /** - * Edits the module row on the remote server. Sets Input errors on failure, - * preventing the row from being updated. - * - * @param stdClass $module_row The stdClass representation of the existing module row - * @param array $vars An array of module info to update - * @return array A numerically indexed array of meta fields for the module row containing: - * - key The key for this meta field - * - value The value for this key - * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) - */ - public function editModuleRow($module_row, array &$vars) { - // Same as adding - return $this->addModuleRow($vars); - } - - /** - * Deletes the module row on the remote server. Sets Input errors on failure, - * preventing the row from being deleted. - * - * @param stdClass $module_row The stdClass representation of the existing module row - */ - public function deleteModuleRow($module_row) { - - } - - /** - * Returns all fields used when adding/editing a package, including any - * javascript to execute when the page is rendered with these fields. - * - * @param $vars stdClass A stdClass object representing a set of post fields - * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional HTML markup to include - */ - public function getPackageFields($vars=null) { - Loader::loadHelpers($this, array("Html")); + + $meta_fields = ['user', 'key', 'sandbox', 'portfolio', 'payment_id', 'namesilo_module']; + $encrypted_fields = ['key']; + + // Set unspecified checkboxes + if (empty($vars['sandbox'])) { + $vars['sandbox'] = 'false'; + } + + $this->Input->setRules($this->getRowRules($vars)); + + // Validate module row + if ($this->Input->validates($vars)) { + // Build the meta data for this row + $meta = []; + foreach ($vars as $key => $value) { + if (in_array($key, $meta_fields)) { + $meta[] = [ + 'key' => $key, + 'value' => $value, + 'encrypted' => in_array($key, $encrypted_fields) ? 1 : 0 + ]; + } + } + + return $meta; + } + } + + /** + * Edits the module row on the remote server. Sets Input errors on failure, + * preventing the row from being updated. + * + * @param stdClass $module_row The stdClass representation of the existing module row + * @param array $vars An array of module info to update + * @return array A numerically indexed array of meta fields for the module row containing: + * + * - key The key for this meta field + * - value The value for this key + * - encrypted Whether or not this field should be encrypted (default 0, not encrypted) + */ + public function editModuleRow($module_row, array &$vars) + { + return $this->addModuleRow($vars); + } + + /** + * Returns all fields used when adding/editing a package, including any + * javascript to execute when the page is rendered with these fields. + * + * @param $vars stdClass A stdClass object representing a set of post fields + * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional + * HTML markup to include + */ + public function getPackageFields($vars = null) + { + Loader::loadHelpers($this, ['Html']); // Fetch all packages available for the given server or server group $module_row = null; @@ -885,47 +993,70 @@ public function getPackageFields($vars=null) { unset($rows); } - $fields = new ModuleFields(); - - $types = array( - 'domain' => Language::_("Namesilo.package_fields.type_domain", true), - ); - - // Set type of package - $type = $fields->label(Language::_("Namesilo.package_fields.type", true), "namesilo_type"); - $type->attach($fields->fieldSelect("meta[type]", $types, - $this->Html->ifSet($vars->meta['type']), array('id'=>"namesilo_type"))); - $fields->setField($type); - - // Set all TLD checkboxes - $tld_options = $fields->label(Language::_("Namesilo.package_fields.tld_options", true)); - - $tlds = $this->getTlds($module_row); - sort( $tlds ); - foreach ( $tlds as $tld ) { - $tld_label = $fields->label( $tld, "tld_" . $tld ); - $tld_options->attach( $fields->fieldCheckbox( "meta[tlds][]", $tld, ( isset( $vars->meta['tlds'] ) && in_array( $tld, $vars->meta['tlds'] ) ), array( 'id' => "tld_" . $tld ), $tld_label ) ); - } - $fields->setField( $tld_options ); - - // Set nameservers - for ( $i=1; $i<=5; $i++ ) { - $type = $fields->label( Language::_( "Namesilo.package_fields.ns" . $i, true ), "namesilo_ns" . $i ); - $type->attach( $fields->fieldText( "meta[ns][]", - $this->Html->ifSet( $vars->meta['ns'][$i-1] ), array ( 'id' => "namesilo_ns" . $i ) ) ); - $fields->setField( $type ); - } - - $fields->setHtml(" + $fields = new ModuleFields(); + + $types = [ + 'domain' => Language::_('Namesilo.package_fields.type_domain', true), + ]; + + // Set type of package + $type = $fields->label( + Language::_('Namesilo.package_fields.type', true), + 'namesilo_type' + ); + $type->attach( + $fields->fieldSelect( + 'meta[type]', + $types, + $this->Html->ifSet($vars->meta['type']), + ['id' => 'namesilo_type'] + ) + ); + $fields->setField($type); + + // Set all TLD checkboxes + $tld_options = $fields->label(Language::_('Namesilo.package_fields.tld_options', true)); + + $tlds = $this->getTlds($module_row); + sort($tlds); + + foreach ($tlds as $tld) { + $tld_label = $fields->label($tld, 'tld_' . $tld); + $tld_options->attach( + $fields->fieldCheckbox( + 'meta[tlds][]', + $tld, + (isset($vars->meta['tlds']) && in_array($tld, $vars->meta['tlds'])), + ['id' => 'tld_' . $tld], + $tld_label + ) + ); + } + $fields->setField($tld_options); + + // Set nameservers + for ($i = 1; $i <= 5; $i++) { + $type = $fields->label(Language::_('Namesilo.package_fields.ns' . $i, true), 'namesilo_ns' . $i); + $type->attach( + $fields->fieldText( + 'meta[ns][]', + $this->Html->ifSet($vars->meta['ns'][$i - 1]), + ['id' => 'namesilo_ns' . $i] + ) + ); + $fields->setField($type); + } + + $fields->setHtml(" "); - return $fields; - } - - /** - * Returns an array of key values for fields stored for a module, package, - * and service under this module, used to substitute those keys with their - * actual module, package, or service meta values in related emails. - * - * @return array A multi-dimensional array of key/value pairs where each key is one of 'module', 'package', or 'service' and each value is a numerically indexed array of key values that match meta fields under that category. - * @see Modules::addModuleRow() - * @see Modules::editModuleRow() - * @see Modules::addPackage() - * @see Modules::editPackage() - * @see Modules::addService() - * @see Modules::editService() - */ - public function getEmailTags() { - return array( 'service' => array ( 'domain' ) ); - } - - /** - * Returns all fields to display to an admin attempting to add a service with the module - * - * @param stdClass $package A stdClass object representing the selected package - * @param $vars stdClass A stdClass object representing a set of post fields - * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional HTML markup to include - */ - public function getAdminAddFields( $package, $vars = null ) { - - Loader::loadHelpers( $this, array( "Form", "Html" ) ); - - if ( $package->meta->type == "domain" ) { - - // Set default name servers - if ( !isset( $vars->ns1 ) && isset( $package->meta->ns ) ) { - $i = 1; - foreach ( $package->meta->ns as $ns ) { - $vars->{"ns" . $i++} = $ns; - } - } - - // Handle transfer request - if ( ( isset( $vars->transfer ) && $vars->transfer ) || isset( $vars->auth ) ) { - return $this->arrayToModuleFields( Configure::get( "Namesilo.transfer_fields" ), null, $vars ); - } - // Handle domain registration - else { - - # - # TODO: Select TLD, then display additional fields - # - - $fields = Configure::get( "Namesilo.transfer_fields" ); - - $fields["transfer"] = array( - 'label' => Language::_( "Namesilo.domain.DomainAction", true ), - 'type' => "radio", - 'value' => "1", - 'options' => array( - '0' => "Register", - '1' => "Transfer", - ), - ); - - $fields["auth"] = array( - "label" => Language::_( "Namesilo.transfer.EPPCode", true ), - "type" => "text", - ); - - $module_fields = $this->arrayToModuleFields( array_merge( $fields, Configure::get( "Namesilo.nameserver_fields" ) ), null, $vars ); - - // $module_fields = $this->arrayToModuleFields(array_merge(Configure::get("Namesilo.domain_fields"), Configure::get("Namesilo.nameserver_fields")), null, $vars); - - $module_fields->setHtml(" + return $fields; + } + + /** + * Returns an array of key values for fields stored for a module, package, + * and service under this module, used to substitute those keys with their + * actual module, package, or service meta values in related emails. + * + * @return array A multi-dimensional array of key/value pairs where each key is one of 'module', 'package', + * or 'service' and each value is a numerically indexed array of key values that match meta fields under + * that category. + * @see Modules::addModuleRow() + * @see Modules::editModuleRow() + * @see Modules::addPackage() + * @see Modules::editPackage() + * @see Modules::addService() + * @see Modules::editService() + */ + public function getEmailTags() + { + return ['service' => ['domain']]; + } + + /** + * Returns all fields to display to an admin attempting to add a service with the module + * + * @param stdClass $package A stdClass object representing the selected package + * @param $vars stdClass A stdClass object representing a set of post fields + * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional + * HTML markup to include + */ + public function getAdminAddFields($package, $vars = null) + { + Loader::loadHelpers($this, ['Form', 'Html']); + + if ($package->meta->type == 'domain') { + // Set default name servers + if (!isset($vars->ns1) && isset($package->meta->ns)) { + $i = 1; + foreach ($package->meta->ns as $ns) { + $vars->{'ns' . $i++} = $ns; + } + } + + // Handle transfer request + if ((isset($vars->transfer) && $vars->transfer) || isset($vars->auth)) { + return $this->arrayToModuleFields(Configure::get('Namesilo.transfer_fields'), null, $vars); + } else { + // Handle domain registration + # + # TODO: Select TLD, then display additional fields + # + + $fields = Configure::get('Namesilo.transfer_fields'); + + $fields['transfer'] = [ + 'label' => Language::_('Namesilo.domain.DomainAction', true), + 'type' => 'radio', + 'value' => '1', + 'options' => [ + '0' => 'Register', + '1' => 'Transfer', + ], + ]; + + $fields['auth'] = [ + 'label' => Language::_('Namesilo.transfer.EPPCode', true), + 'type' => 'text', + ]; + + $module_fields = $this->arrayToModuleFields( + array_merge($fields, Configure::get('Namesilo.nameserver_fields')), + null, + $vars + ); + + $module_fields->setHtml(" "); // Build the domain fields - $fields = $this->buildDomainModuleFields( $vars ); - if ( $fields ) + $fields = $this->buildDomainModuleFields($vars); + if ($fields) { $module_fields = $fields; - } - } - - return ( isset( $module_fields ) ? $module_fields : new ModuleFields() ); - } - - /** - * Returns all fields to display to a client attempting to add a service with the module - * - * @param stdClass $package A stdClass object representing the selected package - * @param $vars stdClass A stdClass object representing a set of post fields - * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional HTML markup to include - */ - public function getClientAddFields($package, $vars=null) { - - // Handle universal domain name - if (isset($vars->domain)) - $vars->domain = $vars->domain; - - if ($package->meta->type == "domain") { - - // Set default name servers - if (!isset($vars->ns) && isset($package->meta->ns)) { - $i=1; - foreach ($package->meta->ns as $ns) { - $vars->{"ns" . $i++} = $ns; - } - } - - if ( isset( $vars->domain ) ) { + } + } + } + + return (isset($module_fields) ? $module_fields : new ModuleFields()); + } + + /** + * Returns all fields to display to a client attempting to add a service with the module + * + * @param stdClass $package A stdClass object representing the selected package + * @param $vars stdClass A stdClass object representing a set of post fields + * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional + * HTML markup to include + */ + public function getClientAddFields($package, $vars = null) + { + + // Handle universal domain name + if (isset($vars->domain)) { + $vars->domain = $vars->domain; + } + + if ($package->meta->type == 'domain') { + // Set default name servers + if (!isset($vars->ns) && isset($package->meta->ns)) { + $i = 1; + foreach ($package->meta->ns as $ns) { + $vars->{'ns' . $i++} = $ns; + } + } + + if (isset($vars->domain)) { $tld = $this->getTld($vars->domain); } - // Handle transfer request - if ( ( isset( $vars->transfer ) && $vars->transfer ) || isset( $vars->auth ) ) { - $fields = array_merge( - Configure::get( 'Namesilo.transfer_fields' ), - (array) Configure::get( "Namesilo.domain_fields{$tld}" ) - ); + // Handle transfer request + if ((isset($vars->transfer) && $vars->transfer) || isset($vars->auth)) { + $fields = array_merge( + Configure::get('Namesilo.transfer_fields'), + (array) Configure::get('Namesilo.domain_fields' . $tld) + ); // .ca domains can't have traditional whois privacy - if($tld == '.ca') + if ($tld == '.ca') { unset($fields['private']); + } - // We should already have the domain name don't make editable - $fields['domain']['type'] = "hidden"; - $fields['domain']['label'] = null; - // we already know we're doing a transfer, don't make it editable - $fields['transfer']['type'] = "hidden"; - $fields['transfer']['label'] = null; + // We should already have the domain name don't make editable + $fields['domain']['type'] = 'hidden'; + $fields['domain']['label'] = null; + // we already know we're doing a transfer, don't make it editable + $fields['transfer']['type'] = 'hidden'; + $fields['transfer']['label'] = null; - $module_fields = $this->arrayToModuleFields($fields, null, $vars); + $module_fields = $this->arrayToModuleFields($fields, null, $vars); return $module_fields; - } - // Handle domain registration - else { - $fields = array_merge( - Configure::get("Namesilo.nameserver_fields"), - Configure::get("Namesilo.domain_fields"), - (array) Configure::get("Namesilo.domain_fields" . $tld) + } else { + // Handle domain registration + $fields = array_merge( + Configure::get('Namesilo.nameserver_fields'), + Configure::get('Namesilo.domain_fields'), + (array) Configure::get('Namesilo.domain_fields' . $tld) ); // .ca domains can't have traditional whois privacy - if($tld == '.ca') + if ($tld == '.ca') { unset($fields['private']); + } - // We should already have the domain name don't make editable - $fields['domain']['type'] = "hidden"; - $fields['domain']['label'] = null; + // We should already have the domain name don't make editable + $fields['domain']['type'] = 'hidden'; + $fields['domain']['label'] = null; - $module_fields = $this->arrayToModuleFields( $fields, null, $vars ); - } - } + $module_fields = $this->arrayToModuleFields($fields, null, $vars); + } + } // Determine whether this is an AJAX request - return ( isset ( $module_fields ) ? $module_fields : new ModuleFields() ); - } + return (isset($module_fields) ? $module_fields : new ModuleFields()); + } /** * Builds and returns the module fields for domain registration @@ -1129,24 +1267,25 @@ public function getClientAddFields($package, $vars=null) { * @param $client True if rendering the client view, or false for the admin (optional, default false) * return mixed The module fields for this service, or false if none could be created */ - private function buildDomainModuleFields($vars, $client = false) { + private function buildDomainModuleFields($vars, $client = false) + { if (isset($vars->domain)) { $tld = $this->getTld($vars->domain); - $extension_fields = Configure::get("Namesilo.domain_fields" . $tld); + $extension_fields = Configure::get('Namesilo.domain_fields' . $tld); if ($extension_fields) { // Set the fields - $fields = array_merge(Configure::get("Namesilo.domain_fields"), $extension_fields); + $fields = array_merge(Configure::get('Namesilo.domain_fields'), $extension_fields); - if (!isset( $vars->transfer ) || $vars->transfer == '0') { - $fields = array_merge( $fields, Configure::get( 'Namesilo.nameserver_fields' ) ); - }else{ - $fields = array_merge( $fields, Configure::get( 'Namesilo.transfer_fields' ) ); - } + if (!isset($vars->transfer) || $vars->transfer == '0') { + $fields = array_merge($fields, Configure::get('Namesilo.nameserver_fields')); + } else { + $fields = array_merge($fields, Configure::get('Namesilo.transfer_fields')); + } if ($client) { // We should already have the domain name don't make editable - $fields['domain']['type'] = "hidden"; + $fields['domain']['type'] = 'hidden'; $fields['domain']['label'] = null; } @@ -1154,33 +1293,43 @@ private function buildDomainModuleFields($vars, $client = false) { $module_fields = new ModuleFields(); // Allow AJAX requests - $ajax = $module_fields->fieldHidden("allow_ajax", "true", array('id'=>"namesilo_allow_ajax")); + $ajax = $module_fields->fieldHidden('allow_ajax', 'true', ['id' => 'namesilo_allow_ajax']); $module_fields->setField($ajax); - $please_select = array('' => Language::_("AppController.select.please", true)); + $please_select = ['' => Language::_('AppController.select.please', true)]; foreach ($fields as $key => $field) { // Build the field - $label = $module_fields->label((isset($field['label']) ? $field['label'] : ""), $key); + $label = $module_fields->label((isset($field['label']) ? $field['label'] : ''), $key); $type = null; - if ($field['type'] == "text") { - $type = $module_fields->fieldText($key, (isset($vars->{$key}) ? $vars->{$key} : ""), array('id'=>$key)); - } - elseif ($field['type'] == "select") { - $type = $module_fields->fieldSelect($key, (isset($field['options']) ? $please_select + $field['options'] : $please_select), - (isset($vars->{$key}) ? $vars->{$key} : ""), array('id'=>$key)); - } - elseif($field['type'] == "checkbox"){ - $type = $module_fields->fieldCheckbox($key, (isset($field['options']) ? $field['options']: 1)); - $label = $module_fields->label((isset($field['label']) ? $field['label'] : ""), $key); - } - elseif ($field['type'] == "hidden") { - $type = $module_fields->fieldHidden($key, (isset($vars->{$key}) ? $vars->{$key} : ""), array('id'=>$key)); + if ($field['type'] == 'text') { + $type = $module_fields->fieldText( + $key, + (isset($vars->{$key}) ? $vars->{$key} : ''), + ['id' => $key] + ); + } elseif ($field['type'] == 'select') { + $type = $module_fields->fieldSelect( + $key, + (isset($field['options']) ? $please_select + $field['options'] : $please_select), + (isset($vars->{$key}) ? $vars->{$key} : ''), + ['id' => $key] + ); + } elseif ($field['type'] == 'checkbox') { + $type = $module_fields->fieldCheckbox($key, (isset($field['options']) ? $field['options'] : 1)); + $label = $module_fields->label((isset($field['label']) ? $field['label'] : ''), $key); + } elseif ($field['type'] == 'hidden') { + $type = $module_fields->fieldHidden( + $key, + (isset($vars->{$key}) ? $vars->{$key} : ''), + ['id' => $key] + ); } // Include a tooltip if set - if (!empty($field['tooltip'])) + if (!empty($field['tooltip'])) { $label->attach($module_fields->tooltip($field['tooltip'])); + } if ($type) { $label->attach($type); @@ -1193,134 +1342,150 @@ private function buildDomainModuleFields($vars, $client = false) { return (isset($module_fields) ? $module_fields : false); } - /** - * Returns all fields to display to an admin attempting to edit a service with the module - * - * @param stdClass $package A stdClass object representing the selected package - * @param $vars stdClass A stdClass object representing a set of post fields - * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional HTML markup to include - */ - public function getAdminEditFields( $package, $vars = NULL ) { - - Loader::loadHelpers( $this, array( "Html" ) ); - - $fields = new ModuleFields(); - - // Create domain label - //$domain = $fields->label( Language::_( "Cpanel.service_field.domain", true ), "cpanel_domain" ); - $domain = $fields->label( Language::_( "Namesilo.manage.manual_renewal", true ), "renew" ); - // Create domain field and attach to domain label - $domain->attach( $fields->fieldSelect( "renew", array( 0, "1 year", "2 years", "3 years", "4 years", "5 years" ), $this->Html->ifSet( $vars->renew ), array( 'id'=>"renew" ) ) ); - // Set the label as a field - $fields->setField( $domain ); - - return $fields; - } - - /** - * Fetches the HTML content to display when viewing the service info in the - * admin interface. - * - * @param stdClass $service A stdClass object representing the service - * @param stdClass $package A stdClass object representing the service's package - * @return string HTML content containing information to display when viewing the service info - */ - public function getAdminServiceInfo($service, $package) { - return ""; - } - - /** - * Fetches the HTML content to display when viewing the service info in the - * client interface. - * - * @param stdClass $service A stdClass object representing the service - * @param stdClass $package A stdClass object representing the service's package - * @return string HTML content containing information to display when viewing the service info - */ - public function getClientServiceInfo($service, $package) { - return ""; - } - - /** - * Returns all tabs to display to an admin when managing a service whose - * package uses this module - * - * @param stdClass $package A stdClass object representing the selected package - * @return array An array of tabs in the format of method => title. Example: array('methodName' => "Title", 'methodName2' => "Title2") - */ - public function getAdminTabs( $package ) { - if ( $package->meta->type == "domain" ) { - return array( - 'tabWhois' => Language::_( "Namesilo.tab_whois.title", true ), - 'tabNameservers' => Language::_( "Namesilo.tab_nameservers.title", true ), - 'tabHosts' => Language::_( "Namesilo.tab_hosts.title", true ), - 'tabDnssec' => Language::_( "Namesilo.tab_dnssec.title", true ), - 'tabSettings' => Language::_( "Namesilo.tab_settings.title", true ), - 'tabAdminActions' => Language::_( "Namesilo.tab_adminactions.title", true ), - ); - } - } - - /** - * Returns all tabs to display to a client when managing a service whose - * package uses this module - * - * @param stdClass $package A stdClass object representing the selected package - * @return array An array of tabs in the format of method => title. Example: array('methodName' => "Title", 'methodName2' => "Title2") - */ - public function getClientTabs( $package ) { - if ( $package->meta->type == "domain" ) { - return array( - 'tabClientWhois' => Language::_( "Namesilo.tab_whois.title", true ), - 'tabClientNameservers' => Language::_( "Namesilo.tab_nameservers.title", true ), - 'tabClientHosts' => Language::_( "Namesilo.tab_hosts.title", true ), - 'tabClientDnssec' => Language::_( "Namesilo.tab_dnssec.title", true ), - 'tabClientSettings' => Language::_( "Namesilo.tab_settings.title", true ), - ); - } - } - - /** - * Admin Whois tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabWhois($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageWhois("tab_whois", $package, $service, $get, $post, $files); - } - - /** - * Client Whois tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabClientWhois($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageWhois("tab_client_whois", $package, $service, $get, $post, $files); - } - - /** - * Admin Nameservers tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabNameservers($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageNameservers("tab_nameservers", $package, $service, $get, $post, $files); - } + /** + * Returns all fields to display to an admin attempting to edit a service with the module + * + * @param stdClass $package A stdClass object representing the selected package + * @param $vars stdClass A stdClass object representing a set of post fields + * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional + * HTML markup to include + */ + public function getAdminEditFields($package, $vars = null) + { + Loader::loadHelpers($this, ['Html']); + + $fields = new ModuleFields(); + + // Create domain label + $domain = $fields->label(Language::_('Namesilo.manage.manual_renewal', true), 'renew'); + // Create domain field and attach to domain label + $domain->attach( + $fields->fieldSelect( + 'renew', + [0, '1 year', '2 years', '3 years', '4 years', '5 years'], + $this->Html->ifSet($vars->renew), + ['id' => 'renew'] + ) + ); + // Set the label as a field + $fields->setField($domain); + + return $fields; + } + + /** + * Fetches the HTML content to display when viewing the service info in the + * admin interface. + * + * @param stdClass $service A stdClass object representing the service + * @param stdClass $package A stdClass object representing the service's package + * @return string HTML content containing information to display when viewing the service info + */ + public function getAdminServiceInfo($service, $package) + { + return ''; + } + + /** + * Fetches the HTML content to display when viewing the service info in the + * client interface. + * + * @param stdClass $service A stdClass object representing the service + * @param stdClass $package A stdClass object representing the service's package + * @return string HTML content containing information to display when viewing the service info + */ + public function getClientServiceInfo($service, $package) + { + return ''; + } + + /** + * Returns all tabs to display to an admin when managing a service whose + * package uses this module + * + * @param stdClass $package A stdClass object representing the selected package + * @return array An array of tabs in the format of method => title. + * Example: array('methodName' => "Title", 'methodName2' => "Title2") + */ + public function getAdminTabs($package) + { + if ($package->meta->type == 'domain') { + return [ + 'tabWhois' => Language::_('Namesilo.tab_whois.title', true), + 'tabNameservers' => Language::_('Namesilo.tab_nameservers.title', true), + 'tabHosts' => Language::_('Namesilo.tab_hosts.title', true), + 'tabDnssec' => Language::_('Namesilo.tab_dnssec.title', true), + 'tabSettings' => Language::_('Namesilo.tab_settings.title', true), + 'tabAdminActions' => Language::_('Namesilo.tab_adminactions.title', true), + ]; + } + } + + /** + * Returns all tabs to display to a client when managing a service whose + * package uses this module + * + * @param stdClass $package A stdClass object representing the selected package + * @return array An array of tabs in the format of method => title. + * Example: array('methodName' => "Title", 'methodName2' => "Title2") + */ + public function getClientTabs($package) + { + if ($package->meta->type == 'domain') { + return [ + 'tabClientWhois' => Language::_('Namesilo.tab_whois.title', true), + 'tabClientNameservers' => Language::_('Namesilo.tab_nameservers.title', true), + 'tabClientHosts' => Language::_('Namesilo.tab_hosts.title', true), + 'tabClientDnssec' => Language::_('Namesilo.tab_dnssec.title', true), + 'tabClientSettings' => Language::_('Namesilo.tab_settings.title', true), + ]; + } + } + + /** + * Admin Whois tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabWhois($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageWhois('tab_whois', $package, $service, $get, $post, $files); + } + + /** + * Client Whois tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabClientWhois($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageWhois('tab_client_whois', $package, $service, $get, $post, $files); + } + + /** + * Admin Nameservers tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabNameservers($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageNameservers('tab_nameservers', $package, $service, $get, $post, $files); + } /** * Admin Hosts tab @@ -1332,8 +1497,9 @@ public function tabNameservers($package, $service, array $get=null, array $post= * @param array $files Any FILES parameters * @return string The string representing the contents of this tab */ - public function tabHosts($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageHosts("tab_hosts", $package, $service, $get, $post, $files); + public function tabHosts($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageHosts('tab_hosts', $package, $service, $get, $post, $files); } /** @@ -1346,23 +1512,25 @@ public function tabHosts($package, $service, array $get=null, array $post=null, * @param array $files Any FILES parameters * @return string The string representing the contents of this tab */ - public function tabDnssec($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageDnssec("tab_dnssec", $package, $service, $get, $post, $files); + public function tabDnssec($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageDnssec('tab_dnssec', $package, $service, $get, $post, $files); } - /** - * Admin Nameservers tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabClientNameservers($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageNameservers("tab_client_nameservers", $package, $service, $get, $post, $files); - } + /** + * Admin Nameservers tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabClientNameservers($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageNameservers('tab_client_nameservers', $package, $service, $get, $post, $files); + } /** * Admin Hosts tab @@ -1374,8 +1542,9 @@ public function tabClientNameservers($package, $service, array $get=null, array * @param array $files Any FILES parameters * @return string The string representing the contents of this tab */ - public function tabClientHosts($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageHosts("tab_client_hosts", $package, $service, $get, $post, $files); + public function tabClientHosts($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageHosts('tab_client_hosts', $package, $service, $get, $post, $files); } /** @@ -1388,340 +1557,326 @@ public function tabClientHosts($package, $service, array $get=null, array $post= * @param array $files Any FILES parameters * @return string The string representing the contents of this tab */ - public function tabClientDnssec($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageDnssec("tab_client_dnssec", $package, $service, $get, $post, $files); + public function tabClientDnssec($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageDnssec('tab_client_dnssec', $package, $service, $get, $post, $files); + } + + /** + * Admin Settings tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabSettings($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageSettings('tab_settings', $package, $service, $get, $post, $files); + } + + /** + * Client Settings tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabClientSettings($package, $service, array $get = null, array $post = null, array $files = null) + { + if (!isset($this->Clients)) { + Loader::loadModels($this, ['Clients']); + } + foreach ($this->Clients->getCustomFieldValues($service->{'client_id'}) as $key => $value) { + if ($value->{'name'} == 'Disable Domain Transfers' + && $value->{'value'} == 'Yes' + ) { + $this->view = new View('whois_disabled', 'default'); + $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); + } + } + return $this->manageSettings('tab_client_settings', $package, $service, $get, $post, $files); } - /** - * Admin Settings tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabSettings($package, $service, array $get=null, array $post=null, array $files=null) { - return $this->manageSettings("tab_settings", $package, $service, $get, $post, $files); - } - - /** - * Client Settings tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabClientSettings( $package, $service, array $get = null, array $post = null, array $files = null ) { - if ( !isset( $this->Clients ) ) { - Loader::loadModels( $this, array( "Clients" ) ); - } - foreach ( $this->Clients->getCustomFieldValues( $service->{'client_id'} ) as $key => $value ) { - if ( $value->{'name'} == "Disable Domain Transfers" - && $value->{'value'} == "Yes" ) - { - //$this->view = new View( "whois_disabled", "client/NETLINK" ); - //$this->view->setDefaultView( "app" . DS ); - $this->view = new View( "whois_disabled", "default" ); - $this->view->setDefaultView( self::$defaultModuleView ); - return $this->view->fetch(); - } - } - return $this->manageSettings("tab_client_settings", $package, $service, $get, $post, $files); - } - - /** - * Admin Actions tab - * - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - public function tabAdminActions( $package, $service, array $get = null, array $post = null, array $files = null ) { - - $vars = new stdClass(); - - Loader::load( __DIR__ . DS . "includes" . DS . "communication.php" ); - - $communication = new Communication( $service ); - - $vars->options = $communication->getNotices(); - - if (!empty($post)){ - $fields = $this->serviceFieldsToObject( $service->fields ); + /** + * Admin Actions tab + * + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + public function tabAdminActions($package, $service, array $get = null, array $post = null, array $files = null) + { + $vars = new stdClass(); + + Loader::load(__DIR__ . DS . 'includes' . DS . 'communication.php'); + + $communication = new Communication($service); + + $vars->options = $communication->getNotices(); + + if (!empty($post)) { + $fields = $this->serviceFieldsToObject($service->fields); $row = $this->getModuleRow($package->module_row); - $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == "true"); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); $domains = new NamesiloDomains($api); - if(!empty($post['notice'])) { + if (!empty($post['notice'])) { $communication->send($post); } - if(isset($post['action']) && $post['action'] == 'sync_date'){ + if (isset($post['action']) && $post['action'] == 'sync_date') { Loader::loadModels($this, ['Services']); - $domain_info = $domains->getDomainInfo(array('domain'=>$fields->domain)); - $this->processResponse($api,$domain_info); + $domain_info = $domains->getDomainInfo(['domain' => $fields->domain]); + $this->processResponse($api, $domain_info); - if(!$this->Input->errors()) { + if (!$this->Input->errors()) { $domain_info = $domain_info->response(); $expires = $domain_info->expires; $edit_vars['date_renews'] = date('Y-m-d h:i:s', strtotime($expires)); $this->Services->edit($service->id, $edit_vars, $bypass_module = true); } } - } - - $this->view = new View( 'tab_admin_actions', "default" ); - - Loader::loadHelpers( $this, array ( "Form", "Html" ) ); - - $this->view->set( "vars", $vars ); - $this->view->setDefaultView( self::$defaultModuleView ); - - return $this->view->fetch(); - } - - /** - * Handle updating whois information - * - * @param string $view The view to use - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - private function manageWhois( $view, $package, $service, array $get = null, array $post = null, array $files = null ) { - - $vars = new stdClass(); - - if ( in_array( $service->status, self::$pending ) ) { - $this->view = new View( 'pending', "default" ); - $this->view->setDefaultView( self::$defaultModuleView ); - return $this->view->fetch(); - } - else if ( $view == "tab_client_whois" && $service->status == "suspended" ) { - $this->view = new View( 'suspended', "default" ); - $this->view->setDefaultView( self::$defaultModuleView ); - return $this->view->fetch(); - } - - // if the domain is pending transfer display a notice of such - $checkDomainStatus = $this->checkDomainStatus($service,$package); - if(isset($checkDomainStatus)) { - return $checkDomainStatus; } + $this->view = new View('tab_admin_actions', 'default'); - $this->view = new View( $view, "default" ); - // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html" ) ); + Loader::loadHelpers($this, ['Form', 'Html']); - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - $domains = new NamesiloDomains( $api ); + $this->view->set('vars', $vars); + $this->view->setDefaultView(self::$defaultModuleView); - $sections = array( 'registrant', 'admin', 'tech', 'billing' ); + return $this->view->fetch(); + } - $vars = new stdClass(); + /** + * Handle updating whois information + * + * @param string $view The view to use + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + private function manageWhois($view, $package, $service, array $get = null, array $post = null, array $files = null) + { + $vars = new stdClass(); - $whois_fields = Configure::get( "Namesilo.whois_fields" ); - $fields = $this->serviceFieldsToObject( $service->fields ); + if (in_array($service->status, self::$pending)) { + $this->view = new View('pending', 'default'); + $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); + } elseif ($view == 'tab_client_whois' && $service->status == 'suspended') { + $this->view = new View('suspended', 'default'); + $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); + } - $domainInfo = $domains->getDomainInfo( array( 'domain' => $fields->domain ) ); - if ( self::$codes[$domainInfo->status()][1] == "fail" ) { - $this->processResponse( $api, $domainInfo ); - return false; - } + // if the domain is pending transfer display a notice of such + $checkDomainStatus = $this->checkDomainStatus($service, $package); + if (isset($checkDomainStatus)) { + return $checkDomainStatus; + } - $contact_ids = $domainInfo->response( true )['contact_ids']; + $this->view = new View($view, 'default'); + // Load the helpers required for this view + Loader::loadHelpers($this, ['Form', 'Html']); + + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $domains = new NamesiloDomains($api); - if ( !empty( $post ) ) { - $new_ids = $delete_ids = array(); + $sections = ['registrant', 'admin', 'tech', 'billing']; - $params = array("domain" => $fields->domain); + $vars = new stdClass(); + + $whois_fields = Configure::get('Namesilo.whois_fields'); + $fields = $this->serviceFieldsToObject($service->fields); + + $domainInfo = $domains->getDomainInfo(['domain' => $fields->domain ]); + if (self::$codes[$domainInfo->status()][1] == 'fail') { + $this->processResponse($api, $domainInfo); + return false; + } + + $contact_ids = $domainInfo->response(true)['contact_ids']; + + if (!empty($post)) { + $new_ids = $delete_ids = []; + + $params = ['domain' => $fields->domain]; foreach ($post as $key => $value) { $response = $domains->addContacts($value); $this->processResponse($api, $response); - if (self::$codes[$response->status()][1] == "success") { + if (self::$codes[$response->status()][1] == 'success') { $new_ids[$key] = $params[$key] = $response->response()->contact_id; $delete_ids[] = $contact_ids[$key]; } } - $response = $domains->setContacts($params); - if (self::$codes[$response->status()][1] == "success") { - // Delete old contact IDs and set new ones - foreach ($delete_ids as $id) $domains->deleteContacts(array('contact_id' => $id)); - $contact_ids = array_replace($contact_ids, $new_ids); + $response = $domains->setContacts($params); + if (self::$codes[$response->status()][1] == 'success') { + // Delete old contact IDs and set new ones + foreach ($delete_ids as $id) { + $domains->deleteContacts(['contact_id' => $id]); + } + $contact_ids = array_replace($contact_ids, $new_ids); + } + } + + $contacts = $temp = []; + foreach ($contact_ids as $type => $id) { + if (!isset($temp[$id])) { + $response = $domains->getContacts(['contact_id' => $id ]); + if (self::$codes[$response->status()][1] != 'fail') { + $temp[$id] = $response->response()->contact; + $contacts[$type] = $temp[$id]; + } + } else { + $contacts[$type] = $temp[$id]; + } + + // Format fields + foreach ($contacts as $section => $element) { + foreach ($element as $name => $value) { + // Value must be a string + if (!is_scalar($value)) { + $value = ''; + } + if (isset($whois_fields[$name]['rp'])) { + $vars->{$section . '[' . $whois_fields[$name]['rp'] . ']'} = $value; + } + } } + } - //$vars = (object)$post; - } - - $contacts = $temp = array(); - foreach ( $contact_ids as $type => $id ) { - if ( !isset( $temp[$id] ) ) { - $response = $domains->getContacts( array( "contact_id" => $id ) ); - if ( self::$codes[$response->status()][1] != "fail" ) { - $temp[$id] = $response->response()->contact; - $contacts[$type] = $temp[$id]; - } - } - else { - $contacts[$type] = $temp[$id]; - } - //*/ - - // Format fields - foreach ( $contacts as $section => $element ) { - foreach ( $element as $name => $value ) { - // Value must be a string - if ( !is_scalar( $value ) ) - $value = ""; - if ( isset( $whois_fields[$name]['rp'] ) ) - $vars->{$section . '[' . $whois_fields[$name]['rp'] . ']'} = $value; - } - } - } - - $all_fields = array(); - foreach ( $whois_fields as $field => $value ) { - $key = $value['rp']; - $all_fields["administrative[{$key}]"] = $value; - $all_fields["technical[{$key}]"] = $value; - $all_fields["registrant[{$key}]"] = $value; - $all_fields["billing[{$key}]"] = $value; - } - - $this->view->set( "vars", $vars ); - $this->view->set( "fields", $this->arrayToModuleFields( $all_fields, null, $vars )->getFields()); - $this->view->set( "sections", $sections ); - $this->view->setDefaultView( self::$defaultModuleView ); - return $this->view->fetch(); - } - - /* - private function whoisContacts( array $vars ) { - - $response = $domains->getDomainInfo( array( 'domain' => $fields->domain ) ); - - if ( self::$codes[$response->status()][1] != "fail" ) { - - $contact_ids = $response->response()->contact_ids; - - $contacts = $temp = array(); - foreach ( $contact_ids as $type => $id ) { - if ( !isset( $temp[$id] ) ) { - $response = $domains->getContacts( array( "contact_id" => $id ) ); - if ( self::$codes[$response->status()][1] != "fail" ) { - $temp[$id] = $response->response()->contact; - $contacts[$type] = $temp[$id]; - } - } - else { - $contacts[$type] = $temp[$id]; - } - } - } - } - */ - - /** - * Handle updating nameserver information - * - */ - private function manageNameservers( $view, $package, $service, array $get = null, array $post = null, array $files = null ) { + $all_fields = []; + foreach ($whois_fields as $field => $value) { + $key = $value['rp']; + $all_fields['administrative[' . $key . ']'] = $value; + $all_fields['technical[' . $key . ']'] = $value; + $all_fields['registrant[' . $key . ']'] = $value; + $all_fields['billing[' . $key . ']'] = $value; + } - $vars = new stdClass(); + $this->view->set('vars', $vars); + $this->view->set('fields', $this->arrayToModuleFields($all_fields, null, $vars)->getFields()); + $this->view->set('sections', $sections); + $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); + } - if ( in_array( $service->status, self::$pending ) ) { - $this->view = new View( 'pending', "default" ); - } - else if ( $view == "tab_client_nameservers" && $service->status == "suspended" ) { - $this->view = new View( 'suspended', "default" ); - } - else { + /** + * Handle updating nameserver information + * + * @param string $view The name of the view to fetch + * @param stdClass $package An stdClass object representing the package + * @param stdClass $service An stdClass object representing the service + * @param array $get Any GET arguments (optional) + * @param array $post Any POST arguments (optional) + * @param array $files Any FILES data (optional) + * @return string The rendered view + */ + private function manageNameservers( + $view, + $package, + $service, + array $get = null, + array $post = null, + array $files = null + ) { + $vars = new stdClass(); + if (in_array($service->status, self::$pending)) { + $this->view = new View('pending', 'default'); + } elseif ($view == 'tab_client_nameservers' && $service->status == 'suspended') { + $this->view = new View('suspended', 'default'); + } else { // if the domain is pending transfer display a notice of such - $checkDomainStatus = $this->checkDomainStatus($service,$package); - if(isset($checkDomainStatus)) { + $checkDomainStatus = $this->checkDomainStatus($service, $package); + if (isset($checkDomainStatus)) { return $checkDomainStatus; } - $this->view = new View( $view, "default" ); + $this->view = new View($view, 'default'); // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html" ) ); + Loader::loadHelpers($this, ['Form', 'Html']); - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - $dns = new NamesiloDomainsDns( $api ); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $dns = new NamesiloDomainsDns($api); - $fields = $this->serviceFieldsToObject( $service->fields ); + $fields = $this->serviceFieldsToObject($service->fields); - $tld = $this->getTld( $fields->domain,$row ); - $sld = substr( $fields->domain, 0, -strlen( $tld ) ); + $tld = $this->getTld($fields->domain, $row); + $sld = substr($fields->domain, 0, -strlen($tld)); - if ( ! empty ( $post ) ) { - $args = array(); $i = 1; - foreach( $post['ns'] as $ns ) { - $args["ns{$i}"] = $ns; + if (! empty($post)) { + $args = []; + $i = 1; + foreach ($post['ns'] as $ns) { + $args['ns' . $i] = $ns; $i++; } $args['domain'] = $fields->domain; - $response = $dns->setCustom( $args ); - $this->processResponse( $api, $response ); + $response = $dns->setCustom($args); + $this->processResponse($api, $response); $vars = (object)$post; - } - else { - $response = $dns->getList( array( 'domain' => $fields->domain ) )->response(); + } else { + $response = $dns->getList(['domain' => $fields->domain ])->response(); - if ( isset ( $response->nameservers ) ) { - $vars->ns = array(); - foreach ( $response->nameservers->nameserver as $ns ) { + if (isset($response->nameservers)) { + $vars->ns = []; + foreach ($response->nameservers->nameserver as $ns) { $vars->ns[] = $ns; } } } - } - $this->view->set( "vars", $vars ); - $this->view->setDefaultView( self::$defaultModuleView ); + $this->view->set('vars', $vars); + $this->view->setDefaultView(self::$defaultModuleView); return $this->view->fetch(); } - /** - * since the api only returns XML sometimes the return array/object changes based on the xml. lets get it consistent for hosts - */ - private function getRegisteredHosts($package,$service){ + /** + * Since the api only returns XML sometimes the return array/object changes based on the XML + * + * @param stdClass $package An stdClass object representing the package + * @param stdClass $service An stdClass object representing the service + */ + private function getRegisteredHosts($package, $service) + { $fields = $this->serviceFieldsToObject($service->fields); - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - $ns = new NamesiloDomainsNs( $api ); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $ns = new NamesiloDomainsNs($api); - $response = $ns->getInfo( array( 'domain' => $fields->domain ) )->response(); + $response = $ns->getInfo(['domain' => $fields->domain ])->response(); $host_obj = new stdClass(); $hosts = []; // lets get our data in a consistent format - if(isset($response->hosts->host) && isset($response->hosts->ip)){ - if(!is_array($response->hosts->ip)) { + if (isset($response->hosts->host) && isset($response->hosts->ip)) { + if (!is_array($response->hosts->ip)) { $ips[] = $response->hosts->ip; - }else{ + } else { $ips = $response->hosts->ip; } $host_obj->host = $response->hosts->host; @@ -1730,7 +1885,7 @@ private function getRegisteredHosts($package,$service){ return $hosts; } - if(isset($response->hosts)) { + if (isset($response->hosts)) { foreach ($response->hosts as $host) { if (!is_array($host->ip)) { $ips[] = $host->ip; @@ -1748,65 +1903,78 @@ private function getRegisteredHosts($package,$service){ return $hosts; } - /** * Handle updating host information * + * @param string $view The name of the view to fetch + * @param stdClass $package An stdClass object representing the package + * @param stdClass $service An stdClass object representing the service + * @param array $get Any GET arguments (optional) + * @param array $post Any POST arguments (optional) + * @param array $files Any FILES data (optional) + * @return string The rendered view */ - private function manageHosts( $view, $package, $service, array $get = null, array $post = null, array $files = null ) { + private function manageHosts($view, $package, $service, array $get = null, array $post = null, array $files = null) + { $vars = new stdClass(); - if ( in_array( $service->status, self::$pending ) ) { - $this->view = new View( 'pending', "default" ); - }elseif( $view == "tab_client_hosts" && $service->status == "suspended" ) { - $this->view = new View('suspended', "default"); - }else{ + if (in_array($service->status, self::$pending)) { + $this->view = new View('pending', 'default'); + } elseif ($view == 'tab_client_hosts' && $service->status == 'suspended') { + $this->view = new View('suspended', 'default'); + } else { // if the domain is pending transfer display a notice of such - $checkDomainStatus = $this->checkDomainStatus($service,$package); - if(isset($checkDomainStatus)) { + $checkDomainStatus = $this->checkDomainStatus($service, $package); + if (isset($checkDomainStatus)) { return $checkDomainStatus; } - $this->view = new View( $view, "default" ); + $this->view = new View($view, 'default'); $this->view->base_uri = $this->base_uri; // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html" ) ); + Loader::loadHelpers($this, ['Form', 'Html']); - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - $ns = new NamesiloDomainsNs( $api ); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $ns = new NamesiloDomainsNs($api); - $fields = $this->serviceFieldsToObject( $service->fields ); + $fields = $this->serviceFieldsToObject($service->fields); $this->view->set('domain', $fields->domain); if (!empty($post)) { - foreach($post['hosts'] as $host=>$ips){ + foreach ($post['hosts'] as $host => $ips) { $ips_arr = []; foreach ($ips as $key => $ip) { - if ($ip) - $ips_arr["ip" . ($key + 1)] = $ip; + if ($ip) { + $ips_arr['ip' . ($key + 1)] = $ip; + } } // if all of the ips are blanked, lets remove the host - if(!$ips_arr) { - $response = $ns->delete(array('domain' => $fields->domain, 'current_host' => $host)); + if (!$ips_arr) { + $response = $ns->delete(['domain' => $fields->domain, 'current_host' => $host]); $this->processResponse($api, $response); - }else{ - $args = array_merge(array('domain' => $fields->domain, 'current_host' => $host, 'new_host' => $host), $ips_arr); + } else { + $args = array_merge( + ['domain' => $fields->domain, 'current_host' => $host, 'new_host' => $host], + $ips_arr + ); $response = $ns->update($args); $this->processResponse($api, $response); } } - if(!empty($post['new_host']) && !empty($post['new_host_ip'])){ - $response = $ns->create(array('domain' => $fields->domain, 'new_host' => $post['new_host'], 'ip1' => $post['new_host_ip'])); + if (!empty($post['new_host']) && !empty($post['new_host_ip'])) { + $response = $ns->create( + ['domain' => $fields->domain, 'new_host' => $post['new_host'], 'ip1' => $post['new_host_ip']] + ); $this->processResponse($api, $response); } $vars = (object)$post; } - $vars->hosts = $this->getRegisteredHosts($package,$service); - $this->view->set("vars", $vars); + $vars->hosts = $this->getRegisteredHosts($package, $service); + $this->view->set('vars', $vars); $this->view->set('client_id', $service->client_id); $this->view->set('service_id', $service->id); } @@ -1818,463 +1986,552 @@ private function manageHosts( $view, $package, $service, array $get = null, arra /** * Handle updating host information * + * @param string $view The name of the view to fetch + * @param stdClass $package An stdClass object representing the package + * @param stdClass $service An stdClass object representing the service + * @param array $get Any GET arguments (optional) + * @param array $post Any POST arguments (optional) + * @param array $files Any FILES data (optional) + * @return string The rendered view */ - private function manageDnssec( $view, $package, $service, array $get = null, array $post = null, array $files = null ) { + private function manageDnssec($view, $package, $service, array $get = null, array $post = null, array $files = null) + { $vars = new stdClass(); - if ( in_array( $service->status, self::$pending ) ) { - $this->view = new View( 'pending', "default" ); - }elseif( $view == "tab_client_dnssec" && $service->status == "suspended" ) { - $this->view = new View('suspended', "default"); - }else{ + if (in_array($service->status, self::$pending)) { + $this->view = new View('pending', 'default'); + } elseif ($view == 'tab_client_dnssec' && $service->status == 'suspended') { + $this->view = new View('suspended', 'default'); + } else { // if the domain is pending transfer display a notice of such - $checkDomainStatus = $this->checkDomainStatus($service,$package); - if(isset($checkDomainStatus)) { + $checkDomainStatus = $this->checkDomainStatus($service, $package); + if (isset($checkDomainStatus)) { return $checkDomainStatus; } - $this->view = new View( $view, "default" ); + $this->view = new View($view, 'default'); $this->view->base_uri = $this->base_uri; // Load the helpers required for this view - Loader::loadHelpers( $this, array ( "Form", "Html" ) ); + Loader::loadHelpers($this, ['Form', 'Html']); - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - $dns = new NamesiloDomainsDns( $api ); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $dns = new NamesiloDomainsDns($api); - $fields = $this->serviceFieldsToObject( $service->fields ); + $fields = $this->serviceFieldsToObject($service->fields); $this->view->set('domain', $fields->domain); if (!empty($post)) { - if(isset($post['action'])){ - if($post['action'] == 'addDnssec') { + if (isset($post['action'])) { + if ($post['action'] == 'addDnssec') { $response = $dns->dnsSecAddRecord( - array( + [ 'domain' => $fields->domain, 'digest' => $post['digest'], 'keyTag' => $post['key_tag'], 'digestType' => $post['digest_type'], 'alg' => $post['algorithm'], - ) + ] ); $this->processResponse($api, $response); - }elseif($post['action'] == 'deleteDnssec'){ + } elseif ($post['action'] == 'deleteDnssec') { $response = $dns->dnsSecDeleteRecord( - array( + [ 'domain' => $fields->domain, 'digest' => $post['digest'], 'keyTag' => $post['key_tag'], 'digestType' => $post['digest_type'], 'alg' => $post['algorithm'], - ) + ] ); $this->processResponse($api, $response); } } } - $ds = $dns->dnsSecListRecords(array('domain'=>$fields->domain))->response(); + $ds = $dns->dnsSecListRecords(['domain' => $fields->domain])->response(); // get a consistent format because xml parsing in php is inconsistent - if(isset($ds->ds_record) && !is_array($ds->ds_record)) { - $ds->ds_record = array($ds->ds_record); - }else{ + if (isset($ds->ds_record) && !is_array($ds->ds_record)) { + $ds->ds_record = [$ds->ds_record]; + } else { $ds->ds_record = []; } - $vars->selects = Configure::get("Namesilo.dnssec"); + $vars->selects = Configure::get('Namesilo.dnssec'); $vars->records = $ds->ds_record; - $this->view->set("vars", $vars); + $this->view->set('vars', $vars); $this->view->set('client_id', $service->client_id); $this->view->set('service_id', $service->id); } $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); } - /** - * Handle updating settings - * - * @param string $view The view to use - * @param stdClass $package A stdClass object representing the current package - * @param stdClass $service A stdClass object representing the current service - * @param array $get Any GET parameters - * @param array $post Any POST parameters - * @param array $files Any FILES parameters - * @return string The string representing the contents of this tab - */ - private function manageSettings($view, $package, $service, array $get=null, array $post=null, array $files=null) { - - $vars = new stdClass(); - - if ( in_array( $service->status, self::$pending ) ) { - $this->view = new View( 'pending', "default" ); - } - else if ( $view == "tab_client_settings" && $service->status == "suspended" ) { - $this->view = new View( 'suspended', "default" ); - } - else { + /** + * Handle updating settings + * + * @param string $view The view to use + * @param stdClass $package A stdClass object representing the current package + * @param stdClass $service A stdClass object representing the current service + * @param array $get Any GET parameters + * @param array $post Any POST parameters + * @param array $files Any FILES parameters + * @return string The string representing the contents of this tab + */ + private function manageSettings( + $view, + $package, + $service, + array $get = null, + array $post = null, + array $files = null + ) { + $vars = new stdClass(); + if (in_array($service->status, self::$pending)) { + $this->view = new View('pending', 'default'); + } elseif ($view == 'tab_client_settings' && $service->status == 'suspended') { + $this->view = new View('suspended', 'default'); + } else { // if the domain is pending transfer display a notice of such - $checkDomainStatus = $this->checkDomainStatus($service,$package); - if(isset($checkDomainStatus)) { + $checkDomainStatus = $this->checkDomainStatus($service, $package); + if (isset($checkDomainStatus)) { return $checkDomainStatus; } - $this->view = new View($view, "default"); - // Load the helpers required for this view - Loader::loadHelpers($this, array("Form", "Html")); + $this->view = new View($view, 'default'); + // Load the helpers required for this view + Loader::loadHelpers($this, ['Form', 'Html']); - $row = $this->getModuleRow($package->module_row); - $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == "true"); - $domains = new NamesiloDomains($api); - $transfer = new NamesiloDomainsTransfer($api); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $domains = new NamesiloDomains($api); + $transfer = new NamesiloDomainsTransfer($api); - $fields = $this->serviceFieldsToObject($service->fields); + $fields = $this->serviceFieldsToObject($service->fields); - if ( !empty( $post ) ) { - if(isset($post['resend_verification_email'])) { - $response = $domains->emailVerification(array('email' => $post['resend_verification_email'])); + if (!empty($post)) { + if (isset($post['resend_verification_email'])) { + $response = $domains->emailVerification(['email' => $post['resend_verification_email']]); $this->processResponse($api, $response); - }else { + } else { if (isset($post['registrar_lock'])) { - $LockAction = $post['registrar_lock'] == "Yes" ? "Lock" : "Unlock"; - $response = $domains->setRegistrarLock($LockAction, array('domain' => $fields->domain)); + $LockAction = $post['registrar_lock'] == 'Yes' ? 'Lock' : 'Unlock'; + $response = $domains->setRegistrarLock($LockAction, ['domain' => $fields->domain]); $this->processResponse($api, $response); } if (isset($post['request_epp'])) { - $response = $transfer->getEpp(array('domain' => $fields->domain)); + $response = $transfer->getEpp(['domain' => $fields->domain]); $this->processResponse($api, $response); } if (isset($post['whois_privacy_before']) || isset($post['whois_privacy'])) { if ($post['whois_privacy_before'] == 'No' && $post['whois_privacy'] == 'Yes') { - $response = $domains->addPrivacy(array('domain' => $fields->domain)); + $response = $domains->addPrivacy(['domain' => $fields->domain]); $this->processResponse($api, $response); } elseif ($post['whois_privacy_before'] == 'Yes' && !isset($post['whois_privacy'])) { - $response = $domains->removePrivacy(array('domain' => $fields->domain)); + $response = $domains->removePrivacy(['domain' => $fields->domain]); $this->processResponse($api, $response); } } $vars = (object)$post; } - }else{ - $response = $domains->getRegistrarLock( array ( 'domain' => $fields->domain ) )->response(); - if ( isset ( $response->locked ) ) { - $vars->registrar_lock = $response->locked; - } - - $info = $domains->getDomainInfo(array('domain'=>$fields->domain)); - $info_response = $info->response(); - if(isset($info_response->private)) { + } else { + $response = $domains->getRegistrarLock(['domain' => $fields->domain ])->response(); + if (isset($response->locked)) { + $vars->registrar_lock = $response->locked; + } + + $info = $domains->getDomainInfo(['domain' => $fields->domain]); + $info_response = $info->response(); + if (isset($info_response->private)) { $vars->whois_privacy = $info_response->private; } - } + } - if(!isset($info)) - $info = $domains->getDomainInfo(array('domain'=>$fields->domain)); + if (!isset($info)) { + $info = $domains->getDomainInfo(['domain' => $fields->domain]); + } $registrant_id = $info->response(true)['contact_ids']['registrant']; - $registrant_info = $domains->getContacts(array('contact_id'=>$registrant_id)); + $registrant_info = $domains->getContacts(['contact_id' => $registrant_id]); $registrant_email = $registrant_info->response()->contact->email; $registrant_verification = $domains->registrantVerificationStatus()->response(); - if(!is_array($registrant_verification->email)) - $registrant_verification->email = array($registrant_verification->email); - foreach($registrant_verification->email as $registrant){ - if($registrant->email_address == $registrant_email) { + if (!is_array($registrant_verification->email)) { + $registrant_verification->email = [$registrant_verification->email]; + } + foreach ($registrant_verification->email as $registrant) { + if ($registrant->email_address == $registrant_email) { $vars->registrant_verification_info = $registrant; } } - } - - $this->view->set( "vars", $vars ); - $this->view->setDefaultView( self::$defaultModuleView ); - return $this->view->fetch(); - } - - /** - * Performs a whois lookup on the given domain - * - * @param string $domain The domain to lookup - * @return boolean true if available, false otherwise - */ - public function checkAvailability( $domain ) { - - $row = $this->getModuleRow(); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); - - $domains = new NamesiloDomains($api); - $result = $domains->check( array ( 'domains' => $domain ) ); - - if ( self::$codes[$result->status()][1] == "fail" ) { - return false; - } - - $response = $result->response(); - - $available = isset( $response->available->{'domain'} ) && $response->available->{'domain'} == $domain; - return $available; - } - - /** - * Builds and returns the rules required to add/edit a module row - * - * @param array $vars An array of key/value data pairs - * @return array An array of Input rules suitable for Input::setRules() - */ - private function getRowRules(&$vars) { - return array( - 'user' => array( - 'valid' => array( - 'rule' => "isEmpty", - 'negate' => true, - 'message' => Language::_("Namesilo.!error.user.valid", true) - ) - ), - 'key' => array( - 'valid' => array( - 'last' => true, - 'rule' => "isEmpty", - 'negate' => true, - 'message' => Language::_("Namesilo.!error.key.valid", true) - ), - 'valid_connection' => array( - 'rule' => array(array($this, "validateConnection"), $vars['user'], isset($vars['sandbox']) ? $vars['sandbox'] : "false"), - 'message' => Language::_("Namesilo.!error.key.valid_connection", true) - ) - ), - 'portfolio' => array( - 'valid' => array( - 'rule' => array(array($this, "validatePortfolio"), $vars['key'], $vars['user'], isset($vars['sandbox']) ? $vars['sandbox'] : "false"), - 'message' => Language::_("Namesilo.!error.portfolio.valid_portfolio", true) - ) - ), - 'payment_id' => array( - 'valid' => array( - 'rule' => array('matches', '/^[\s\d]*$/'), - 'message' => Language::_("Namesilo.!error.payment_id.valid_format", true) - ) - ) - ); - } - - /** - * Validates that the given connection details are correct by attempting to check the availability of a domain - * - * @param string $key The API key - * @param string $user The API user - * @param string $sandbox "true" if this is a sandbox account, false otherwise - * @return boolean True if the connection details are valid, false otherwise - */ - public function validateConnection($key, $user, $sandbox) { - $api = $this->getApi($user, $key, $sandbox == "true"); - $domains = new NamesiloDomains($api); - //$status = $domains->check( array( 'domains' => "example.com" ) )->status(); - $response = $domains->check( array( 'domains' => "example.com" ) ); - $this->processResponse( $api, $response ); - return true; - } - - public function validatePortfolio($portfolio, $key, $user, $sandbox){ - $api = $this->getApi($user, $key, $sandbox == "true"); + } + + $this->view->set('vars', $vars); + $this->view->setDefaultView(self::$defaultModuleView); + + return $this->view->fetch(); + } + + /** + * Performs a whois lookup on the given domain + * + * @param string $domain The domain to lookup + * @return bool true if available, false otherwise + */ + public function checkAvailability($domain) + { + $row = $this->getModuleRow(); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + + $domains = new NamesiloDomains($api); + $result = $domains->check(['domains' => $domain ]); + + if (self::$codes[$result->status()][1] == 'fail') { + return false; + } + + $response = $result->response(); + + $available = isset($response->available->{'domain'}) && $response->available->domain->{'0'} == $domain; + + return $available; + } + + /** + * Builds and returns the rules required to add/edit a module row + * + * @param array $vars An array reference of key/value data pairs + * @return array An array of Input rules suitable for Input::setRules() + */ + private function getRowRules(&$vars) + { + return [ + 'user' => [ + 'valid' => [ + 'rule' => 'isEmpty', + 'negate' => true, + 'message' => Language::_('Namesilo.!error.user.valid', true) + ] + ], + 'key' => [ + 'valid' => [ + 'last' => true, + 'rule' => 'isEmpty', + 'negate' => true, + 'message' => Language::_('Namesilo.!error.key.valid', true) + ], + 'valid_connection' => [ + 'rule' => [ + [$this, 'validateConnection'], + $vars['user'], + isset($vars['sandbox']) ? $vars['sandbox'] : 'false' + ], + 'message' => Language::_('Namesilo.!error.key.valid_connection', true) + ] + ], + 'portfolio' => [ + 'valid' => [ + 'rule' => [ + [$this, 'validatePortfolio'], + $vars['key'], + $vars['user'], + isset($vars['sandbox']) ? $vars['sandbox'] : 'false' + ], + 'message' => Language::_('Namesilo.!error.portfolio.valid_portfolio', true) + ] + ], + 'payment_id' => [ + 'valid' => [ + 'rule' => ['matches', '/^[\s\d]*$/'], + 'message' => Language::_('Namesilo.!error.payment_id.valid_format', true) + ] + ] + ]; + } + + /** + * Validates that the given connection details are correct by attempting to check the availability of a domain + * + * @param string $key The API key + * @param string $user The API user + * @param string $sandbox "true" if this is a sandbox account, false otherwise + * @return bool True if the connection details are valid, false otherwise + */ + public function validateConnection($key, $user, $sandbox) + { + $api = $this->getApi($user, $key, $sandbox == 'true'); + $domains = new NamesiloDomains($api); + $response = $domains->check(['domains' => 'example.com']); + $this->processResponse($api, $response); + + return true; + } + + /** + * Validates the portfolio is valid + * + * @param string $portfolio The portfolio name + * @param string $key The API key + * @param string $user The API user + * @param string $sandbox 'true' or 'false', whether to use the sandbox API + * @return bool True if the portfolio is valid, or false otherwise + */ + public function validatePortfolio($portfolio, $key, $user, $sandbox) + { + $api = $this->getApi($user, $key, $sandbox == 'true'); $domains = new NamesiloDomains($api); $response = $domains->portfolioList(); - $this->processResponse( $api, $response ); + $this->processResponse($api, $response); $response = $response->response(); - if(!is_array($response->portfolios->name)) + if ($response && isset($response->portfolios->name) && !is_array($response->portfolios->name)) { $response->portfolios->name = [$response->portfolios->name]; + } - if(isset($response->portfolios->name)){ - if(!in_array($portfolio,$response->portfolios->name) && $portfolio){ + if (isset($response->portfolios->name)) { + if (!in_array($portfolio, $response->portfolios->name) && $portfolio) { return false; } } + return true; } - /** - * Initializes the NamesiloApi and returns an instance of that object - * - * @param string $user The user to connect as - * @param string $key The key to use when connecting - * @param boolean $sandbox Whether or not to process in sandbox mode (for testing) - * @param string $username The username to execute an API command using + /** + * Initializes the NamesiloApi and returns an instance of that object + * + * @param string $user The user to connect as + * @param string $key The key to use when connecting + * @param bool $sandbox Whether or not to process in sandbox mode (for testing) + * @param string $username The username to execute an API command using * @param bool $batch use API batch mode - * @return NamesiloApi The NamesiloApi instance - */ - public function getApi( $user = null, $key = null, $sandbox = true, $username = null, $batch = false ) { - - Loader::load( __DIR__ . DS . "apis" . DS . "namesilo_api.php" ); - - if ( empty( $user ) || empty( $key ) ) { - $row = $this->getModuleRow(); - $user = $row->meta->user; - $key = $row->meta->key; - $sandbox = $row->meta->sandbox; - } - - return new NamesiloApi( $user, $key, $sandbox, $username, $batch ); - } - - /** - * Process API response, setting an errors, and logging the request - * - * @param NamesiloApi $api The Namesilo API object - * @param NamesiloResponse $response The Namesilo API response object - */ - private function processResponse( NamesiloApi $api, NamesiloResponse $response ) { - $this->logRequest( $api, $response ); - - $status = $response->status(); - - // Set errors if non-200 http code - if ($api->httpcode != 200) - $this->Input->setErrors( array('errors'=>['API returned non-200 HTTP code'])); - - // Set errors, if any - if ( self::$codes[$status][1] == "fail" ) { - //$errors = isset( $response->errors()->Error ) ? $response->errors()->Error : array(); - $errors = $response->errors() ? $response->errors() : array(); - $this->Input->setErrors( array( 'errors' => (array)$errors ) ); - } - } - - /** - * Logs the API request - * - * @param NamesiloApi $api The Namesilo API object - * @param NamesiloResponse $response The Namesilo API response object - */ - private function logRequest( NamesiloApi $api, NamesiloResponse $response ) { - $last_request = $api->lastRequest(); - $url = substr( $last_request['url'], 0, strpos( $last_request['url'], '?' ) ); - $this->log( $url, serialize( $last_request['args'] ), "input", true ); - $this->log( $url, $response->raw(), "output", self::$codes[$response->status()][1] == "success" ); - } - - /** - * Returns the TLD of the given domain - * - * @param string $domain The domain to return the TLD from + * @return NamesiloApi The NamesiloApi instance + */ + public function getApi($user = null, $key = null, $sandbox = true, $username = null, $batch = false) + { + Loader::load(__DIR__ . DS . 'apis' . DS . 'namesilo_api.php'); + + if (empty($user) || empty($key)) { + if (($row = $this->getModuleRow())) { + $user = $row->meta->user; + $key = $row->meta->key; + $sandbox = $row->meta->sandbox; + } + } + + return new NamesiloApi($user, $key, $sandbox, $username, $batch); + } + + /** + * Process API response, setting an errors, and logging the request + * + * @param NamesiloApi $api The Namesilo API object + * @param NamesiloResponse $response The Namesilo API response object + */ + private function processResponse(NamesiloApi $api, NamesiloResponse $response) + { + $this->logRequest($api, $response); + + $status = $response->status(); + + // Set errors if non-200 http code + if ($api->httpcode != 200) { + $this->Input->setErrors(['errors' => ['API returned non-200 HTTP code']]); + } + + // Set errors, if any + if (self::$codes[$status][1] == 'fail') { + $errors = $response->errors() ? $response->errors() : []; + $this->Input->setErrors(['errors' => (array)$errors ]); + } + } + + /** + * Logs the API request + * + * @param NamesiloApi $api The Namesilo API object + * @param NamesiloResponse $response The Namesilo API response object + */ + private function logRequest(NamesiloApi $api, NamesiloResponse $response) + { + $last_request = $api->lastRequest(); + $url = substr($last_request['url'], 0, strpos($last_request['url'], '?')); + $this->log($url, serialize($last_request['args']), 'input', true); + $this->log($url, $response->raw(), 'output', self::$codes[$response->status()][1] == 'success'); + } + + /** + * Returns the TLD of the given domain + * + * @param string $domain The domain to return the TLD from * @param stdClass module row object - * @return string The TLD of the domain - */ - private function getTld($domain,$row=null) { - if($row == null) - $row = $this->getNamesiloRow(); - - if($row == null){ - $row = $this->getNamesiloRow(); - } - - $tlds = $this->getTlds($row); - $domain = strtolower($domain); - - foreach ($tlds as $tld) { - if (substr($domain, -strlen($tld)) == $tld) - return $tld; - } - return strstr($domain, "."); - } - - private function getTlds($row) { - - $tlds = Cache::fetchCache( 'tld_cache', 'Namesilo' . DS ); - - if ( $tlds !== false ) { - return unserialize( base64_decode( $tlds ) ); - } - - $result = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == "true")->submit( 'getPrices' ); - - $tlds = array(); - foreach( $result->response() as $tld => $v ) { - if ( !is_object( $v ) ) { - continue; - } - $tlds[] = '.' . $tld; - } - - if ( count( $tlds ) > 0 ) { - - if ( Configure::get( 'Caching.on' ) && is_writable( CACHEDIR ) ) { - try { - Cache::writeCache( - 'tld_cache', - base64_encode( serialize( $tlds ) ), - strtotime( Configure::get( 'Blesta.cache_length' ) ) - time(), - 'Namesilo' . DS - ); - } catch ( Exception $e ) { - // Couldn't cache - error_log( $e ); - } - } - } - return $tlds; - } - - /** - * Formats a phone number into +NNN.NNNNNNNNNN - * - * @param string $number The phone number - * @param string $country The ISO 3166-1 alpha2 country code - * @return string The number in +NNN.NNNNNNNNNN - */ - private function formatPhone($number, $country) { - if (!isset($this->Contacts)) - Loader::loadModels($this, array("Contacts")); - - return $this->Contacts->intlNumber($number, $country, "."); - } - - private function checkDomainStatus($service, $package){ - $fields = $this->serviceFieldsToObject( $service->fields ); - $row = $this->getModuleRow( $package->module_row ); - $api = $this->getApi( $row->meta->user, $row->meta->key, $row->meta->sandbox == "true" ); + * @return string The TLD of the domain + */ + private function getTld($domain, $row = null) + { + if ($row == null) { + $row = $this->getRow(); + } + + if ($row == null) { + $row = $this->getRow(); + } + + $tlds = $this->getTlds($row); + $domain = strtolower($domain); + + foreach ($tlds as $tld) { + if (substr($domain, -strlen($tld)) == $tld) { + return $tld; + } + } + + return strstr($domain, '.'); + } + + /** + * Retrieves the TLDs from the API + * + * @param stdClass $row The module row object + * @return array An array of TLDs + */ + private function getTlds($row) + { + // Fetch the TLDs results from the cache, if they exist + $cache = Cache::fetchCache( + 'tlds', + Configure::get('Blesta.company_id') . DS . 'modules' . DS . 'namesilo' . DS + ); + + if ($cache) { + return unserialize(base64_decode($cache)); + } + + // Fetch namesilo TLDs + $tlds = []; + + if (empty($row)) { + return $tlds; + } + + $result = $this->getApi( + $row->meta->user, + $row->meta->key, + $row->meta->sandbox == 'true' + )->submit('getPrices'); + + foreach ($result->response() as $tld => $v) { + if (!is_object($v)) { + continue; + } + $tlds[] = '.' . $tld; + } + + // Save the TLDs results to the cache + if (count($tlds) > 0) { + if (Configure::get('Caching.on') && is_writable(CACHEDIR)) { + try { + Cache::writeCache( + 'tlds', + base64_encode(serialize($tlds)), + strtotime(Configure::get('Blesta.cache_length')) - time(), + Configure::get('Blesta.company_id') . DS . 'modules' . DS . 'namesilo' . DS + ); + } catch (Exception $e) { + // Write to cache failed, so disable caching + Configure::set('Caching.on', false); + } + } + } + + return $tlds; + } + + /** + * Formats a phone number into +NNN.NNNNNNNNNN + * + * @param string $number The phone number + * @param string $country The ISO 3166-1 alpha2 country code + * @return string The number in +NNN.NNNNNNNNNN + */ + private function formatPhone($number, $country) + { + if (!isset($this->Contacts)) { + Loader::loadModels($this, ['Contacts']); + } + + return $this->Contacts->intlNumber($number, $country, '.'); + } + + /** + * Retrieves the domain status view + * + * @param stdClass $service An stdClass object representing the service + * @param stdClass $package An stdClass object representing the package + * @return null|string The domain status view if available, otherwise void + */ + private function checkDomainStatus($service, $package) + { + $fields = $this->serviceFieldsToObject($service->fields); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); $domains = new NamesiloDomains($api); - $domain_info = $domains->getDomainInfo(array('domain'=>$fields->domain))->response(); - if(isset($domain_info->code) && $domain_info->code != 300){ + $domain_info = $domains->getDomainInfo(['domain' => $fields->domain])->response(); + + if (isset($domain_info->code) && $domain_info->code != 300) { $transfer = new NamesiloDomainsTransfer($api); - $transfer_info = $transfer->getStatus(array('domain'=>$fields->domain))->response(); - if(isset($transfer_info->code) && $transfer_info->code == 300){ - $this->view = new View('transferstatus', "default"); - $this->view->setDefaultView( self::$defaultModuleView ); + $transfer_info = $transfer->getStatus(['domain' => $fields->domain])->response(); + + if (isset($transfer_info->code) && $transfer_info->code == 300) { + $this->view = new View('transferstatus', 'default'); + $this->view->setDefaultView(self::$defaultModuleView); $this->view->set('transferstatus', $transfer_info); - Loader::loadHelpers( $this, array ( "Form", "Html" ) ); + Loader::loadHelpers($this, ['Form', 'Html']); return $this->view->fetch(); } } } - private function getRenewInfo($service_id,$api_object){ - $vars = array(); + /** + * Retrieves renew data information + * + * @param int $service_id The ID of the service + * @param NamesiloApi $api_object An instance of the API + * @return array An array of key/value pairs representing the renew data information + */ + private function getRenewInfo($service_id, $api_object) + { + $vars = []; - $service = $this->Services->get($service_id); - $api_response = $api_object->getDomainInfo(array( - 'domain'=>$service->name - ))->response(); + $service = $this->Services->get($service_id); + $api_response = $api_object->getDomainInfo([ + 'domain' => $service->name + ])->response(); - if($api_response->code != 300){ - $vars = array( + if ($api_response->code != 300) { + $vars = [ 'domain' => $service->name, - 'error' => array( + 'error' => [ 'code' => $api_response->code, 'detail' => $api_response->detail - ) - ); + ] + ]; + return $vars; - }elseif(strtotime($api_response->expires) < 946706400){ - $vars = array( + } elseif (strtotime($api_response->expires) < 946706400) { + $vars = [ 'domain' => $service->name, - 'error' => array( + 'error' => [ 'code' => $api_response->code, - 'detail' => $api_response->expires . "expires date from the API cannot possibly be valid" - ) - ); + 'detail' => $api_response->expires . 'expires date from the API cannot possibly be valid' + ] + ]; + return $vars; } @@ -2282,41 +2539,217 @@ private function getRenewInfo($service_id,$api_object){ $expires = new DateTime($api_response->expires); $client = $this->Clients->get($service->client_id); - $suspend_days = $this->ClientGroups->getSetting($client->client_group_id, 'suspend_services_days_after_due')->value; + $suspend_days = $this->ClientGroups->getSetting($client->client_group_id, 'suspend_services_days_after_due') + ->value; // take into account suspension threshold and a 3 day buffer - $target_date_obj = $expires->modify("- " . (3 + $suspend_days) . " days"); + $target_date_obj = $expires->modify('- ' . (3 + $suspend_days) . ' days'); $target_date = $target_date_obj->format('Y-m-d H:i:s'); - if($date_renews->diff($target_date_obj)->format('%a') > 0){ - $vars = array( + if ($date_renews->diff($target_date_obj)->format('%a') > 0) { + $vars = [ 'service_id' => $service_id, 'domain' => $service->name, 'date_before' => $date_renews->format('Y-m-d H:i:s'), 'date_after' => $target_date, 'error' => false - ); + ]; } return $vars; } - private function getNamesiloRow(){ - Loader::loadModels($this,array("ModuleManager")); + /** + * Retrieves all the Namesilo prices + * + * @return array An array containing all the TLDs with their respective prices + */ + protected function getPrices() + { + // Fetch the TLDs results from the cache, if they exist + $cache = Cache::fetchCache( + 'tlds_prices', + Configure::get('Blesta.company_id') . DS . 'modules' . DS . 'namesilo' . DS + ); + + if ($cache) { + return unserialize(base64_decode($cache)); + } + + Loader::loadModels($this, ['Currencies']); + + $row = $this->getRow(); + + $api = $this->getApi( + $row->meta->user, + $row->meta->key, + $row->meta->sandbox == 'true' + ); + $result = $api->submit('getPrices')->response(); + $tlds = []; + + if (isset($result->detail) && $result->detail == 'success') { + $tlds = (array)$result; + unset($tlds['code']); + unset($tlds['detail']); + } + + // Get all currencies + $currencies = $this->Currencies->getAll(Configure::get('Blesta.company_id')); + + // Convert namesilo prices to all currencies + $pricing = []; + + foreach ($tlds as $tld => $tld_pricing) { + $tld = '.' . trim($tld, '.'); + + foreach ($currencies as $currency) { + $pricing[$tld][$currency->code] = (object)[ + 'registration' => $this->Currencies->convert( + $tld_pricing->registration, + 'USD', + $currency->code, + Configure::get('Blesta.company_id') + ), + 'renew' => $this->Currencies->convert( + $tld_pricing->renew, + 'USD', + $currency->code, + Configure::get('Blesta.company_id') + ) + ]; + } + } + + // Save the TLDs results to the cache + if (count($pricing) > 0) { + if (Configure::get('Caching.on') && is_writable(CACHEDIR)) { + try { + Cache::writeCache( + 'tlds_prices', + base64_encode(serialize($pricing)), + strtotime(Configure::get('Blesta.cache_length')) - time(), + Configure::get('Blesta.company_id') . DS . 'modules' . DS . 'namesilo' . DS + ); + } catch (Exception $e) { + // Write to cache failed, so disable caching + Configure::set('Caching.on', false); + } + } + } + + return $pricing; + } + + /** + * Returns a string containing all package name tags available by default + * + * @return string A string containing all package name tags available by default + */ + private function getPackageNameTags() + { + // Fetch the parser options to determine the start and end characters for template variables + $parser_options = Configure::get('Blesta.parser_options'); + + // Build all tags available by default in the welcome email + $package_name_tags = ''; + + $tags = [ + 'domain' => ['tld', 'tld_uppercase'] + ]; + + if (!empty($tags)) { + $i = 0; + foreach ($tags as $group => $group_tags) { + foreach ($group_tags as $tag) { + $package_name_tags .= ($i++ > 0 ? ' ' : '') . + $parser_options['VARIABLE_START'] . $group . '.' . $tag . $parser_options['VARIABLE_END']; + } + } + } + + return $package_name_tags; + } + + /** + * Retrieves all the Namesilo module rows + * + * @return array An array containing all the module rows + */ + private function getRows() + { + Loader::loadModels($this, ['ModuleManager']); + $module_rows = []; $modules = $this->ModuleManager->getInstalled(); + foreach ($modules as $module) { $module_data = $this->ModuleManager->get($module->id); + foreach ($module_data->rows as $module_row) { - if(isset($module_row->meta->namesilo_module)) { - return $module_row; + if (isset($module_row->meta->namesilo_module)) { + $module_rows[] = $module_row; } } } + + return $module_rows; + } + + /** + * Retrieves the Namesilo module row + * + * @return null|stdClass An stdClass object representing the module row if found, otherwise void + */ + private function getRow() + { + $module_rows = $this->getRows(); + + return isset($module_rows[0]) ? $module_rows[0] : null; + } + + /** + * Retrieves all the Namesilo module row options + * + * @return array An array containing all the module row options + */ + private function getRowsOptions() + { + $rows_options = []; + $module_rows = $this->getRows(); + + foreach ($module_rows as $module_row) { + if (isset($module_row->meta->namesilo_module)) { + $rows_options[$module_row->id] = $module_row->meta->user; + } + } + + return $rows_options; + } + + /** + * Prints the given data as a JSON string + * + * @param mixed $data The array or object to be printed + */ + public function printJson($data = []) { + header('Content-type: application/json'); + echo $this->Json->encode($data); + exit; + } + + /** + * Sends an email to the debug address with the given data + * + * @param mixed $data The data to send + */ + public function debug($data) + { + mail( + self::$debug_to, + 'Namesilo Module Debug', + var_export($data, true), + "From: blesta@localhost\n\n" + ); } - - public function debug( $data ) { - mail( self::$debug_to, "Namesilo Module " /*. self::$version*/ . " Debug", var_export( $data, true ), "From: blesta@localhost\n\n" ); - } - } diff --git a/views/default/add_row.pdt b/views/default/add_row.pdt index 092f981..4846579 100644 --- a/views/default/add_row.pdt +++ b/views/default/add_row.pdt @@ -1,56 +1,56 @@ - Widget->clear(); - $this->Widget->create($this->_("Namesilo.add_row.box_title", true)); - ?> -
- Form->create(); - ?> -
-

_("Namesilo.add_row.basic_title");?>

-
-
- +
+ +
_('Namesilo.add_row.add_btn'); ?>
+ Form->end(); + ?> +
+ Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/audit_domains.pdt b/views/default/audit_domains.pdt index 6a92b37..c309b55 100644 --- a/views/default/audit_domains.pdt +++ b/views/default/audit_domains.pdt @@ -1,34 +1,34 @@ -Widget->clear(); -$this->Widget->create($this->_("Namesilo.add_row.audit_domains.box_title", true)); -?> -
-

_("Namesilo.manage.audit_domains.description", true); ?>

-
-

_("Namesilo.manage.audit_domains.results");?>

-
- domains) > 0){ ?> - - - - - - domains as $domain){ - ?> - - - - - Widget->clear(); + $this->Widget->create($this->_('Namesilo.add_row.audit_domains.box_title', true)); ?> -
_("Namesilo.domain.domain", true); ?>Issue/Return
Html->ifSet($service['domain']); ?>No corresponding billing record in Blesta.
- -

_("Namesilo.manage.audit_domains.no_issues", true); ?>

- -
-Widget->end(); -?> \ No newline at end of file +
+

_('Namesilo.manage.audit_domains.description', true); ?>

+
+

_('Namesilo.manage.audit_domains.results'); ?>

+
+ domains) > 0) { ?> + + + + + + + domains as $domain) { + ?> + + + + + +
_('Namesilo.domain.domain', true); ?>Issue/Return
Html->ifSet($service['domain']); ?>No corresponding billing record in Blesta.
+ +

_('Namesilo.manage.audit_domains.no_issues', true); ?>

+ +
+ Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/edit_row.pdt b/views/default/edit_row.pdt index fc31ae4..fb06595 100644 --- a/views/default/edit_row.pdt +++ b/views/default/edit_row.pdt @@ -1,56 +1,56 @@ - Widget->clear(); - $this->Widget->create($this->_("Namesilo.edit_row.box_title", true)); - ?> -
- Form->create(); - ?> -
-

_("Namesilo.edit_row.basic_title");?>

-
-
- +
+ +
_('Namesilo.edit_row.add_btn'); ?>
+ Form->end(); + ?> +
+ Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/manage.pdt b/views/default/manage.pdt index 4c15864..2f84ab7 100644 --- a/views/default/manage.pdt +++ b/views/default/manage.pdt @@ -1,71 +1,70 @@ - $this->_("Namesilo.add_module_row", true), 'attributes'=>array('href'=>$this->base_uri . "settings/company/modules/addrow/" . $module->id)); - - $this->Widget->clear(); - $this->Widget->setLinkButtons($link_buttons); - - $this->Widget->create($this->_("AdminCompanyModules.manage.boxtitle_manage", true, $this->Html->_($module->name, true)), array('id'=>"manage_namesilo")); - ?> - -
-

_("Namesilo.manage.module_rows_title");?>

-
- Html->ifSet($module->rows)); - if ($num_rows > 0) { - ?> - - - - - - - - - - > - - - - - - - -
_("Namesilo.manage.module_rows_heading.user");?>_("Namesilo.manage.module_rows_heading.key");?>_("Namesilo.manage.module_rows_heading.sandbox");?>_("Namesilo.manage.module_rows_heading.portfolio");?>_("Namesilo.manage.module_rows_heading.options");?>
Html->_($module->rows[$i]->meta->user);?>Html->_($module->rows[$i]->meta->key);?>_("Namesilo.row_meta.sandbox_" . $this->Html->ifSet($module->rows[$i]->meta->sandbox, "false"));?>Html->_($module->rows[$i]->meta->portfolio);?> - Html->ifSet($module->id) . "/" . $this->Html->ifSet($module->rows[$i]->id) . "/");?>">_("Namesilo.manage.module_rows.edit");?> - Form->create($this->base_uri . "settings/company/modules/deleterow/"); - $this->Form->fieldHidden("id", $this->Html->ifSet($module->id)); - $this->Form->fieldHidden("row_id", $this->Html->ifSet($module->rows[$i]->id)); - ?> - Html->ifSet($module->id) . "/" . $this->Html->ifSet($module->rows[$i]->id) . "/");?>" class="manage" rel="Html->safe($this->_("Namesilo.manage.module_rows.confirm_delete", true));?>">_("Namesilo.manage.module_rows.delete");?> - Form->end(); - ?> -
- -
-
- _("Namesilo.manage.module_rows_no_results");?> -
-
- + $this->_('Namesilo.add_module_row', true), 'attributes' => ['href' => $this->base_uri . 'settings/company/modules/addrow/' . $module->id]]; - Widget->end(); - ?> - - \ No newline at end of file + $this->Widget->clear(); + $this->Widget->setLinkButtons($link_buttons); + + $this->Widget->create($this->_('AdminCompanyModules.manage.boxtitle_manage', true, $this->Html->_($module->name, true)), ['id' => 'manage_namesilo']); + ?> + +
+

_('Namesilo.manage.module_rows_title'); ?>

+
+ Html->ifSet($module->rows)); + if ($num_rows > 0) { + ?> + + + + + + + + + + > + + + + + + + +
_('Namesilo.manage.module_rows_heading.user'); ?>_('Namesilo.manage.module_rows_heading.key'); ?>_('Namesilo.manage.module_rows_heading.sandbox'); ?>_('Namesilo.manage.module_rows_heading.portfolio'); ?>_('Namesilo.manage.module_rows_heading.options'); ?>
Html->_($module->rows[$i]->meta->user); ?>Html->_($module->rows[$i]->meta->key); ?>_('Namesilo.row_meta.sandbox_' . $this->Html->ifSet($module->rows[$i]->meta->sandbox, 'false')); ?>Html->_($module->rows[$i]->meta->portfolio); ?> + _('Namesilo.manage.module_rows.edit'); ?> + Form->create($this->base_uri . 'settings/company/modules/deleterow/'); + $this->Form->fieldHidden('id', $this->Html->ifSet($module->id)); + $this->Form->fieldHidden('row_id', $this->Html->ifSet($module->rows[$i]->id)); + ?> + _('Namesilo.manage.module_rows.delete'); ?> + Form->end(); + ?> +
+ +
+
+ _('Namesilo.manage.module_rows_no_results');?> +
+
+ + + Widget->end(); + ?> + + \ No newline at end of file diff --git a/views/default/manage_packages.pdt b/views/default/manage_packages.pdt new file mode 100644 index 0000000..529913b --- /dev/null +++ b/views/default/manage_packages.pdt @@ -0,0 +1,466 @@ + $message) { + if ($type == 'notice') { + $type = 'alert'; + } + ?> +
+
+ × +
+ + +

+ +
+
+
+ + + Widget->clear(); + $this->Widget->create($this->_('Namesilo.manage.manage_packages.box_title', true)); + + $this->Form->create(null, ['id' => 'add_packages', 'class' => 'disable-on-submit']); + ?> +
+
+

_('Namesilo.manage.manage_packages.heading_basic');?>

+
+
+ + +
+ +
+

_('Namesilo.manage.manage_packages.heading_module_options');?>

+
+
+ +
+ +
+

_('Namesilo.manage.manage_packages.heading_available_tlds');?>

+
+
+ $max_packages) { + ?> +

_('Namesilo.manage.manage_packages.text_manage_packages', false, $max_packages); ?>

+ + + +
+ +
+

_('Namesilo.manage.manage_packages.heading_pricing');?>

+
+
+ +
+ +
+

_('Namesilo.manage.manage_packages.heading_group');?>

+
+
+ +
+
+ +
+
+ Form->fieldSubmit('save', $this->_('Namesilo.manage.manage_packages.save_packages_btn', true), ['class' => 'btn btn-primary pull-right']); + ?> +
+
+ Form->end(); + + $this->Widget->end(); + ?> + + + + \ No newline at end of file diff --git a/views/default/pending.pdt b/views/default/pending.pdt index 4875f50..25730ff 100644 --- a/views/default/pending.pdt +++ b/views/default/pending.pdt @@ -1,2 +1 @@ - -

_("Namesilo.notice.StatusPending"); ?>

\ No newline at end of file +

_('Namesilo.notice.StatusPending'); ?>

\ No newline at end of file diff --git a/views/default/service_fields.pdt b/views/default/service_fields.pdt index 1aed6f3..ed5745a 100644 --- a/views/default/service_fields.pdt +++ b/views/default/service_fields.pdt @@ -1,62 +1,63 @@ Html->ifSet($fields) && !empty($fields)) { - ?> + ?> - - \ No newline at end of file + \ No newline at end of file diff --git a/views/default/service_fields_client.pdt b/views/default/service_fields_client.pdt index 35c2aad..63b865e 100644 --- a/views/default/service_fields_client.pdt +++ b/views/default/service_fields_client.pdt @@ -1,60 +1,60 @@ - Html->ifSet($fields) && !empty($fields)) { - ?> -
Html->ifSet($module->class), $this->Html->ifSet($module->id)));?>"> + ?> +
-
- Form, $field->type), $field->params); + ?> +
+ Form, $field->type], $field->params); - // Draw each form field associated with this label - $tooltips = array(); - foreach ($field->fields as $input) { + // Draw each form field associated with this label + $tooltips = []; + foreach ($field->fields as $input) { - // Collect all tooltips to be displayed at the end - if ($input->type == "tooltip") { - $tooltips[] = $input; - continue; - } + // Collect all tooltips to be displayed at the end + if ($input->type == 'tooltip') { + $tooltips[] = $input; + continue; + } - call_user_func_array(array($this->Form, $input->type), $input->params); + call_user_func_array([$this->Form, $input->type], $input->params); - // Draw the form field's secondary label if checkbox or radio item - if (($input->type == "fieldCheckbox" || $input->type == "fieldRadio") && isset($input->label)) { - if (isset($input->label->params['attributes']['class'])) { - if (is_array($input->label->params['attributes']['class'])) - $input->label->params['attributes']['class'][] = "inline"; - else - $input->label->params['attributes']['class'] .= " inline"; - } - else - $input->label->params['attributes']['class'] = "inline"; + // Draw the form field's secondary label if checkbox or radio item + if (($input->type == 'fieldCheckbox' || $input->type == 'fieldRadio') && isset($input->label)) { + if (isset($input->label->params['attributes']['class'])) { + if (is_array($input->label->params['attributes']['class'])) { + $input->label->params['attributes']['class'][] = 'inline'; + } else { + $input->label->params['attributes']['class'] .= ' inline'; + } + } else { + $input->label->params['attributes']['class'] = 'inline'; + } - call_user_func_array(array($this->Form, "label"), $input->label->params); + call_user_func_array([$this->Form, 'label'], $input->label->params); + } } - } - foreach ($tooltips as $tooltip) { - ?> - + foreach ($tooltips as $tooltip) { + ?> + + +
-
-
- - \ No newline at end of file + \ No newline at end of file diff --git a/views/default/suspended.pdt b/views/default/suspended.pdt index 89e0585..0c76e6e 100644 --- a/views/default/suspended.pdt +++ b/views/default/suspended.pdt @@ -1,2 +1 @@ - -

_("Namesilo.notice.StatusSuspended"); ?>

\ No newline at end of file +

_('Namesilo.notice.StatusSuspended'); ?>

\ No newline at end of file diff --git a/views/default/sync_renew_dates.pdt b/views/default/sync_renew_dates.pdt index 5771368..6daa3be 100644 --- a/views/default/sync_renew_dates.pdt +++ b/views/default/sync_renew_dates.pdt @@ -1,86 +1,85 @@ - -
-
- × -

-
-
Widget->clear(); -$this->Widget->create($this->_("Namesilo.manage.sync_renew_dates.box_title", true)); -?> -
-

_("Namesilo.manage.sync_renew_dates.description", true); ?>

- 0){ ?> -
-

_("Namesilo.manage.sync_renew_dates.out_of_sync");?>

-
- Form->create(); ?> - - - - - - - - - - - - - - - - +
+
+ × +

+
+
+ - -
_("Namesilo.domain.domain", true); ?>Old Renew DateNew Renew Date
- Form->fieldCheckbox("sync_services[]", $this->Html->ifSet($change['service_id']), "true"); - ?> - Html->ifSet($change['domain']); ?>Html->ifSet($change['date_before']); ?>Html->ifSet($change['date_after']); ?>
- - Form->end(); ?> - + } - 0){ ?> -
-

_("Namesilo.manage.sync_renew_dates.errors");?>

-
- - - - - - - - - - - - - -
_("Namesilo.domain.domain", true); ?>Result
Html->ifSet($change['domain']); ?>Html->ifSet($change['error']['detail']); ?>
- + $this->Widget->clear(); + $this->Widget->create($this->_('Namesilo.manage.sync_renew_dates.box_title', true)); + ?> +
+

_('Namesilo.manage.sync_renew_dates.description', true); ?>

+ 0) { ?> +
+

_('Namesilo.manage.sync_renew_dates.out_of_sync'); ?>

+
+ Form->create(); ?> + + + + + + + + + + + + + + + + + +
_('Namesilo.domain.domain', true); ?>Old Renew DateNew Renew Date
+ Form->fieldCheckbox('sync_services[]', $this->Html->ifSet($change['service_id']), 'true'); + ?> + Html->ifSet($change['domain']); ?>Html->ifSet($change['date_before']); ?>Html->ifSet($change['date_after']); ?>
+ + Form->end(); ?> + -
-Widget->end(); -?> \ No newline at end of file + 0) { ?> +
+

_('Namesilo.manage.sync_renew_dates.errors'); ?>

+
+ + + + + + + + + + + + + +
_('Namesilo.domain.domain', true); ?>Result
Html->ifSet($change['domain']); ?>Html->ifSet($change['error']['detail']); ?>
+ + +
+ Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/tab_admin_actions.pdt b/views/default/tab_admin_actions.pdt index 2903056..da0aff4 100644 --- a/views/default/tab_admin_actions.pdt +++ b/views/default/tab_admin_actions.pdt @@ -1,19 +1,19 @@
-
\ No newline at end of file diff --git a/views/default/tab_client_dnssec.pdt b/views/default/tab_client_dnssec.pdt index 7dfe374..5ce6cb8 100644 --- a/views/default/tab_client_dnssec.pdt +++ b/views/default/tab_client_dnssec.pdt @@ -1,89 +1,89 @@ -
-
-

_("Namesilo.tab_dnssec.title_disclaimer");?>

-
-

_("Namesilo.tab_dnssec.warning_message1"); ?>

-

_("Namesilo.tab_dnssec.warning_message2"); ?>

-
-

_("Namesilo.tab_dnssec.title_list");?>

-
- - - - - - - - - - - - records as $record) { +
+
+

_('Namesilo.tab_dnssec.title_disclaimer'); ?>

+
+

_('Namesilo.tab_dnssec.warning_message1'); ?>

+

_('Namesilo.tab_dnssec.warning_message2'); ?>

+
+

_('Namesilo.tab_dnssec.title_list'); ?>

+
+
_("Namesilo.dnssec.key_tag"); ?>_("Namesilo.dnssec.algorithm"); ?>_("Namesilo.dnssec.digest_type"); ?>_("Namesilo.dnssec.digest"); ?>_("Namesilo.tab_dnssec.field_delete"); ?>
+ + + + + + + + + + + records as $record) { ?> - - - - - - + + + + + - + $this->Form->end(); + ?> + + - -
_('Namesilo.dnssec.key_tag'); ?>_('Namesilo.dnssec.algorithm'); ?>_('Namesilo.dnssec.digest_type'); ?>_('Namesilo.dnssec.digest'); ?>_('Namesilo.tab_dnssec.field_delete'); ?>
Html->ifSet($record->key_tag); ?>Html->ifSet($record->algorithm); ?>Html->ifSet($record->digest_type); ?>Html->ifSet($record->digest); ?> - Form->create($this->base_uri . 'services/manage/' . $this->Html->ifSet($service_id) . '/tabClientDnssec'); +
Html->ifSet($record->key_tag); ?>Html->ifSet($record->algorithm); ?>Html->ifSet($record->digest_type); ?>Html->ifSet($record->digest); ?> + Form->create($this->base_uri . 'services/manage/' . $this->Html->ifSet($service_id) . '/tabClientDnssec'); - $this->Form->fieldHidden('digest', $this->Html->ifSet($record->digest)); - $this->Form->fieldHidden('key_tag', $this->Html->ifSet($record->key_tag)); - $this->Form->fieldHidden('algorithm', $this->Html->ifSet($record->algorithm)); - $this->Form->fieldHidden('digest_type', $this->Html->ifSet($record->digest_type)); + $this->Form->fieldHidden('digest', $this->Html->ifSet($record->digest)); + $this->Form->fieldHidden('key_tag', $this->Html->ifSet($record->key_tag)); + $this->Form->fieldHidden('algorithm', $this->Html->ifSet($record->algorithm)); + $this->Form->fieldHidden('digest_type', $this->Html->ifSet($record->digest_type)); - $button_attributes = [ - 'class' => 'btn', - 'value' => 'deleteDnssec', - 'type' => 'submit', - ]; + $button_attributes = [ + 'class' => 'btn', + 'value' => 'deleteDnssec', + 'type' => 'submit', + ]; - $this->Form->fieldButton('action', $this->_('Namesilo.tab_dnssec.field_delete', true), $button_attributes); + $this->Form->fieldButton('action', $this->_('Namesilo.tab_dnssec.field_delete', true), $button_attributes); - $this->Form->end(); - ?> -
-
-

_("Namesilo.tab_dnssec.title_add");?>

-
+ ?> + + +
+

_('Namesilo.tab_dnssec.title_add'); ?>

+
- Form->create($this->base_uri . 'services/manage/' . $this->Html->ifSet($service_id) . '/tabClientDnssec'); - ?> -
- Form->label( $this->_("Namesilo.dnssec.key_tag"), "key_tag" ); ?> - Form->fieldText("key_tag", null, array('class' => "form-control")); ?> + ?> +
+ Form->label( $this->_('Namesilo.dnssec.key_tag'), 'key_tag' ); ?> + Form->fieldText('key_tag', null, ['class' => 'form-control']); ?> - Form->label( $this->_("Namesilo.dnssec.algorithm"), "algorithm" ); ?> - Form->fieldSelect("algorithm", $vars->selects['algorithm']['options'], null, array('class' => "form-control")); ?> + Form->label( $this->_('Namesilo.dnssec.algorithm'), 'algorithm' ); ?> + Form->fieldSelect('algorithm', $vars->selects['algorithm']['options'], null, ['class' => 'form-control']); ?> - Form->label( $this->_("Namesilo.dnssec.digest_type"), "digest_type" ); ?> - Form->fieldSelect("digest_type", $vars->selects['digest_type']['options'], null, array('class' => "form-control")); ?> + Form->label( $this->_('Namesilo.dnssec.digest_type'), 'digest_type' ); ?> + Form->fieldSelect('digest_type', $vars->selects['digest_type']['options'], null, ['class' => 'form-control']); ?> - Form->label( $this->_("Namesilo.dnssec.digest"), "digest" ); ?> - Form->fieldText("digest", null, array('class' => "form-control")); ?> -
-
- 'btn btn-primary pull-right', - 'value' => 'addDnssec', - 'type' => 'submit', - ]; + Form->label( $this->_('Namesilo.dnssec.digest'), 'digest' ); ?> + Form->fieldText('digest', null, ['class' => 'form-control']); ?> +
+
+ 'btn btn-primary pull-right', + 'value' => 'addDnssec', + 'type' => 'submit', + ]; - $this->Form->fieldButton('action', $this->_('Namesilo.tab_dnssec.field_add', true), $button_attributes); + $this->Form->fieldButton('action', $this->_('Namesilo.tab_dnssec.field_add', true), $button_attributes); + ?> +
+ Form->end(); ?>
- Form->end(); - ?> -
diff --git a/views/default/tab_client_hosts.pdt b/views/default/tab_client_hosts.pdt index 764ef6a..5bee85e 100644 --- a/views/default/tab_client_hosts.pdt +++ b/views/default/tab_client_hosts.pdt @@ -1,59 +1,59 @@ -
-

_("Namesilo.tab_client_hosts.help_text"); ?>

- Form->create($this->base_uri . 'services/manage/' . $this->Html->ifSet($service_id) . '/tabClientHosts'); - ?> - - - - - - - +
+

_('Namesilo.tab_client_hosts.help_text'); ?>

hosts as $host) { + $this->Form->create($this->base_uri . 'services/manage/' . $this->Html->ifSet($service_id) . '/tabClientHosts'); + ?> +
_("Namesilo.tab_hosts.field_hostname");?>_("Namesilo.tab_hosts.field_ip");?>
+ + + + + + + hosts as $host) { ?> ip as $index=>$ip) { + foreach ($host->ip as $index => $ip) { ?> - + - + - + ?> + - - + + - + +
_('Namesilo.tab_hosts.field_hostname'); ?>_('Namesilo.tab_hosts.field_ip'); ?>
host . '.' . $domain : false; ?>Form->fieldText("hosts[" . $this->Html->ifSet($host->host) . "][]", $ip); ?>Form->fieldText('hosts[' . $this->Html->ifSet($host->host) . '][]', $ip); ?>
Form->fieldText("hosts[" . $this->Html->ifSet($host->host) . "][]"); ?>Form->fieldText('hosts[' . $this->Html->ifSet($host->host) . '][]'); ?>
Form->fieldText("new_host"); echo '.' . $domain; ?>Form->fieldText("new_host_ip"); ?>Form->fieldText('new_host'); + echo '.' . $domain; ?>Form->fieldText('new_host_ip'); ?>
+
+ 'btn btn-primary pull-right', + 'value' => 'manageHosts', + 'type' => 'submit', + ]; - -
+ $this->Form->fieldButton('action', $this->_('Namesilo.tab_hosts.field_submit', true), $button_attributes); + ?> +
'btn btn-primary pull-right', - 'value' => 'manageHosts', - 'type' => 'submit', - ]; - - $this->Form->fieldButton('action', $this->_('Namesilo.tab_hosts.field_submit', true), $button_attributes); + $this->Form->end(); ?>
- Form->end(); - ?> -
diff --git a/views/default/tab_client_nameservers.pdt b/views/default/tab_client_nameservers.pdt index caa5881..328f7e6 100644 --- a/views/default/tab_client_nameservers.pdt +++ b/views/default/tab_client_nameservers.pdt @@ -1,22 +1,21 @@ + Form->create(); ?> - Form->create(); ?> - -
-
- -
- Form->label( $this->_( "Namesilo.tab_nameserver.field_ns", true, $i+1 ), "ns" . $i+1 ); ?> - Form->fieldText( "ns[]", $this->Html->ifSet( $vars->ns[$i] ), array ( 'id' => "ns" . $i+1, 'class' => "form-control", 'placeholder' => $this->_( "Namesilo.tab_nameserver.field_ns", true, $i+1 ) ) ); ?> -
- -
-
- - - Form->end(); ?> \ No newline at end of file +
+
+ +
+ Form->label( $this->_( 'Namesilo.tab_nameserver.field_ns', true, $i+1 ), 'ns' . $i+1 ); ?> + Form->fieldText( 'ns[]', $this->Html->ifSet( $vars->ns[$i] ), [ 'id' => 'ns' . $i+1, 'class' => 'form-control', 'placeholder' => $this->_( 'Namesilo.tab_nameserver.field_ns', true, $i+1 ) ] ); ?> +
+ +
+
+ + + Form->end(); ?> \ No newline at end of file diff --git a/views/default/tab_client_settings.pdt b/views/default/tab_client_settings.pdt index 3603f16..5c699ca 100644 --- a/views/default/tab_client_settings.pdt +++ b/views/default/tab_client_settings.pdt @@ -1,26 +1,26 @@ - -
+
-

_("Namesilo.tab_settings.section_verification");?>

+

_('Namesilo.tab_settings.section_verification'); ?>

-

_("Namesilo.tab_settings.verification_text"); echo $this->Html->ifSet($vars->registrant_verification_info->email_address); ?>: - registrant_verification_info->verified == "Yes"){ ?> - _("Namesilo.tab_settings.verified"); ?>!

- - _("Namesilo.tab_settings.not_verified"); ?>!

-

_("Namesilo.tab_settings.not_verified_warning"); ?>

+

_('Namesilo.tab_settings.verification_text'); + echo $this->Html->ifSet($vars->registrant_verification_info->email_address); ?>: + registrant_verification_info->verified == 'Yes'){ ?> + _('Namesilo.tab_settings.verified'); ?>!

+ + _('Namesilo.tab_settings.not_verified'); ?>!

+

_('Namesilo.tab_settings.not_verified_warning'); ?>

Form->create(); ?>

Form->create(); - $this->Form->fieldHidden('resend_verification_email',$vars->registrant_verification_info->email_address); + $this->Form->fieldHidden('resend_verification_email', $vars->registrant_verification_info->email_address); ?> - Form->end(); - ?> + Form->end(); + ?>

@@ -30,51 +30,51 @@ $this->Form->create(); ?>
-

_("Namesilo.tab_settings.field_registrar_lock");?>

-
-
- -
-
- -
-
-
-
- -
-
+

_('Namesilo.tab_settings.field_registrar_lock'); ?>

+
+
+ +
+
+ +
+
+
+
+ +
+
-
+
Form->end(); ?> -
\ No newline at end of file +
\ No newline at end of file diff --git a/views/default/tab_client_whois.pdt b/views/default/tab_client_whois.pdt index 8a889a6..df74f17 100644 --- a/views/default/tab_client_whois.pdt +++ b/views/default/tab_client_whois.pdt @@ -1,102 +1,102 @@ - - Form->create(); - ?> -
-
+ ?> +
+
- +
$key) { - ?> -
" id="Html->_($key);?>"> - params['for'], 0, strlen($key)) != $key) - continue; ?> -
+
fields as $input) { - - // Collect all tooltips to be displayed at the end - if ($input->type == "tooltip") { - $tooltips[] = $input; + foreach ($fields as $field) { + if (substr($field->params['for'], 0, strlen($key)) != $key) { continue; } - - // Draw the form field's secondary label if checkbox or radio item - if (($input->type == "fieldCheckbox" || $input->type == "fieldRadio") && isset($input->label)) { - $type = ($input->type == "fieldCheckbox" ? "checkbox" : "radio"); ?> -
- - - +
fields as $input) { + + // Collect all tooltips to be displayed at the end + if ($input->type == 'tooltip') { + $tooltips[] = $input; + continue; + } + + // Draw the form field's secondary label if checkbox or radio item + if (($input->type == 'fieldCheckbox' || $input->type == 'fieldRadio') && isset($input->label)) { + $type = ($input->type == 'fieldCheckbox' ? 'checkbox' : 'radio'); + ?> +
+ + + + +
+ params['attributes']['class'])) { + if (is_array($input->params['attributes']['class'])) { + $input->params['attributes']['class'][] = 'form-control'; + } else { + $input->params['attributes']['class'] .= ' form-control'; + } + } else { + $input->params['attributes']['class'] = 'form-control'; + } + + $input->params['attributes']['placeholder'] = $this->Html->ifSet($field->params['name']); + + // Draw the primary label/field + call_user_func_array([$this->Form, $field->type], $field->params); + call_user_func_array([$this->Form, $input->type], $input->params); + //mail( "julian@netlink.ie", "API Debug", var_export( $input->params, true ), "From: blesta@localhost\n\n" ); + + foreach ($tooltips as $tooltip) { + ?> + +
params['attributes']['class'])) { - if (is_array($input->params['attributes']['class'])) - $input->params['attributes']['class'][] = "form-control"; - else - $input->params['attributes']['class'] .= " form-control"; - } - else - $input->params['attributes']['class'] = "form-control"; - - $input->params['attributes']['placeholder'] = $this->Html->ifSet($field->params['name']); - - // Draw the primary label/field - call_user_func_array(array($this->Form, $field->type), $field->params); - call_user_func_array(array($this->Form, $input->type), $input->params); - //mail( "julian@netlink.ie", "API Debug", var_export( $input->params, true ), "From: blesta@localhost\n\n" ); - - foreach ($tooltips as $tooltip) { - ?> - -
-
-
-
-
- - Form->end(); - ?> \ No newline at end of file +
+
+ + Form->end(); + ?> \ No newline at end of file diff --git a/views/default/tab_dnssec.pdt b/views/default/tab_dnssec.pdt index 2093f17..9b4fb4f 100644 --- a/views/default/tab_dnssec.pdt +++ b/views/default/tab_dnssec.pdt @@ -1,25 +1,24 @@ -
-

_("Namesilo.tab_dnssec.title_disclaimer");?>

+

_('Namesilo.tab_dnssec.title_disclaimer'); ?>

-

_("Namesilo.tab_dnssec.warning_message1"); ?>

-

_("Namesilo.tab_dnssec.warning_message2"); ?>

+

_('Namesilo.tab_dnssec.warning_message1'); ?>

+

_('Namesilo.tab_dnssec.warning_message2'); ?>

-

_("Namesilo.tab_dnssec.title_list");?>

+

_('Namesilo.tab_dnssec.title_list'); ?>

- - - - - + + + + + records) > 0 && $vars->records[0]) { + if (count($vars->records) > 0 && $vars->records[0]) { foreach ($vars->records as $record) { ?> @@ -58,7 +57,7 @@
_("Namesilo.dnssec.key_tag"); ?>_("Namesilo.dnssec.algorithm"); ?>_("Namesilo.dnssec.digest_type"); ?>_("Namesilo.dnssec.digest"); ?>_("Namesilo.tab_dnssec.field_delete"); ?>_('Namesilo.dnssec.key_tag'); ?>_('Namesilo.dnssec.algorithm'); ?>_('Namesilo.dnssec.digest_type'); ?>_('Namesilo.dnssec.digest'); ?>_('Namesilo.tab_dnssec.field_delete'); ?>
-

_("Namesilo.tab_dnssec.title_add");?>

+

_('Namesilo.tab_dnssec.title_add'); ?>

Form->create($this->base_uri . 'clients/servicetab/' . $this->Html->ifSet($client_id) . '/' . $this->Html->ifSet($service_id) . '/tabDnssec/'); @@ -67,32 +66,32 @@ - _("Namesilo.dnssec.key_tag"); ?> - _("Namesilo.dnssec.algorithm"); ?> - _("Namesilo.dnssec.digest_type"); ?> - _("Namesilo.dnssec.digest"); ?> + _('Namesilo.dnssec.key_tag'); ?> + _('Namesilo.dnssec.algorithm'); ?> + _('Namesilo.dnssec.digest_type'); ?> + _('Namesilo.dnssec.digest'); ?> - Form->fieldText("key_tag"); ?> - Form->fieldSelect("algorithm", $vars->selects['algorithm']['options']); ?> - Form->fieldSelect("digest_type", $vars->selects['digest_type']['options']); ?> - Form->fieldText("digest"); ?> + Form->fieldText('key_tag'); ?> + Form->fieldSelect('algorithm', $vars->selects['algorithm']['options']); ?> + Form->fieldSelect('digest_type', $vars->selects['digest_type']['options']); ?> + Form->fieldText('digest'); ?>
- 'btn btn-primary pull-right', - 'value' => 'addDnssec', - 'type' => 'submit', - ]; + 'btn btn-primary pull-right', + 'value' => 'addDnssec', + 'type' => 'submit', + ]; - $this->Form->fieldButton('action', $this->_('Namesilo.tab_dnssec.field_add', true), $button_attributes); - ?> -
+ $this->Form->fieldButton('action', $this->_('Namesilo.tab_dnssec.field_add', true), $button_attributes); + ?> +
Form->end(); ?> diff --git a/views/default/tab_hosts.pdt b/views/default/tab_hosts.pdt index 0b30715..f97c41e 100644 --- a/views/default/tab_hosts.pdt +++ b/views/default/tab_hosts.pdt @@ -1,6 +1,5 @@ -
-

_("Namesilo.tab_hosts.title");?>

+

_('Namesilo.tab_hosts.title'); ?>

hosts as $host) { + foreach ($vars->hosts as $host) { ?> - - + + ip as $index=>$ip) { + foreach ($host->ip as $index => $ip) { ?> - + ip) < 12) { + if (count($host->ip) < 12) { ?> - + - - + + - - + +
_("Namesilo.tab_hosts.field_hostname"); ?>_("Namesilo.tab_hosts.field_ip"); ?>_('Namesilo.tab_hosts.field_hostname'); ?>_('Namesilo.tab_hosts.field_ip'); ?>
host . '.' . $domain : false; ?>Form->fieldText("hosts[" . $this->Html->ifSet($host->host) . "][]", $ip); ?>Form->fieldText('hosts[' . $this->Html->ifSet($host->host) . '][]', $ip); ?>
Form->fieldText("hosts[" . $this->Html->ifSet($host->host) . "][]"); ?>Form->fieldText('hosts[' . $this->Html->ifSet($host->host) . '][]'); ?>
_("Namesilo.tab_hosts.field_hostname"); ?>_("Namesilo.tab_hosts.field_ip"); ?>_('Namesilo.tab_hosts.field_hostname'); ?>_('Namesilo.tab_hosts.field_ip'); ?>
Form->fieldText("new_host"); echo '.' . $domain; ?>Form->fieldText("new_host_ip"); ?>Form->fieldText('new_host'); + echo '.' . $domain; ?>Form->fieldText('new_host_ip'); ?>
- 'btn btn-primary pull-right', - 'value' => 'manageHosts', - 'type' => 'submit', - ]; + 'btn btn-primary pull-right', + 'value' => 'manageHosts', + 'type' => 'submit', + ]; - $this->Form->fieldButton('action', $this->_('Namesilo.tab_hosts.field_submit', true), $button_attributes); - ?> -
+ $this->Form->fieldButton('action', $this->_('Namesilo.tab_hosts.field_submit', true), $button_attributes); + ?> +
Form->end(); ?> diff --git a/views/default/tab_nameservers.pdt b/views/default/tab_nameservers.pdt index d420638..742f02e 100644 --- a/views/default/tab_nameservers.pdt +++ b/views/default/tab_nameservers.pdt @@ -1,24 +1,23 @@ - - Form->create(); - ?> -
-
    - -
  • - Form->label($this->_("Namesilo.tab_nameserver.field_ns", true, $i+1), "ns" . $i+1); - $this->Form->fieldText("ns[]", $this->Html->ifSet($vars->ns[$i]), array('id' => "ns" . $i+1)); - ?> -
  • - -
-
- - Form->end(); - ?> \ No newline at end of file + Form->create(); + ?> +
+
    + +
  • + Form->label($this->_('Namesilo.tab_nameserver.field_ns', true, $i + 1), 'ns' . $i + 1); + $this->Form->fieldText('ns[]', $this->Html->ifSet($vars->ns[$i]), ['id' => 'ns' . $i + 1]); + ?> +
  • + +
+
+ + Form->end(); + ?> \ No newline at end of file diff --git a/views/default/tab_settings.pdt b/views/default/tab_settings.pdt index bbadfac..b958625 100644 --- a/views/default/tab_settings.pdt +++ b/views/default/tab_settings.pdt @@ -1,26 +1,36 @@
-

_("Namesilo.tab_settings.section_verification");?>

+

_('Namesilo.tab_settings.section_verification'); ?>

Form->create(); ?>
    -
  • _("Namesilo.tab_settings.verification_text"); echo $this->Html->ifSet($vars->registrant_verification_info->email_address); ?>: - registrant_verification_info->verified == "Yes"){ ?> - _("Namesilo.tab_settings.verified"); ?>!
  • - - _("Namesilo.tab_settings.not_verified"); ?>! -
  • _("Namesilo.tab_settings.not_verified_warning"); ?>
  • +
  • + _('Namesilo.tab_settings.verification_text'); + echo $this->Html->ifSet($vars->registrant_verification_info->email_address); ?>: + Html->ifSet($vars->registrant_verification_info->verified) == 'Yes') { + ?> + _('Namesilo.tab_settings.verified'); ?>! +
  • + + _('Namesilo.tab_settings.not_verified'); ?>! + +
  • _('Namesilo.tab_settings.not_verified_warning'); ?>
  • - Form->fieldHidden('resend_verification_email',$vars->registrant_verification_info->email_address); ?> + Form->fieldHidden('resend_verification_email', $this->Html->ifSet($vars->registrant_verification_info->email_address)); ?>
  • - +
- registrant_verification_info->verified == "No") { ?> -
_("Namesilo.tab_settings.field_resend_verification_email"); ?> + Html->ifSet($vars->registrant_verification_info->verified) == 'No') { ?> +
-

_("Namesilo.tab_settings.title");?>

+

_('Namesilo.tab_settings.title'); ?>

- Form->create(); - ?> -
-
    -
  • - Form->label($this->_("Namesilo.tab_settings.field_registrar_lock", true), "registrar_lock"); - - $this->Form->fieldRadio("registrar_lock", "Yes", $this->Html->ifSet($vars->registrar_lock) == "Yes", array('id' => "registrar_lock_yes")); - $this->Form->label($this->_("Namesilo.tab_settings.field_registrar_lock_yes", true), "registrar_lock_yes", array('class' => "inline")); - - $this->Form->fieldRadio("registrar_lock", "No", $this->Html->ifSet($vars->registrar_lock) == "No", array('id' => "registrar_lock_no")); - $this->Form->label($this->_("Namesilo.tab_settings.field_registrar_lock_no", true), "registrar_lock_no", array('class' => "inline")); - ?> -
  • -
  • - Form->fieldCheckbox("request_epp", "true", $this->Html->ifSet($vars->request_epp) == "true", array('id' => "request_epp")); - $this->Form->label($this->_("Namesilo.tab_settings.field_request_epp", true), "request_epp", array('class' => "inline")); - ?> -
  • + Form->create(); + ?> +
    +
      +
    • + Form->label($this->_('Namesilo.tab_settings.field_registrar_lock', true), 'registrar_lock'); + + $this->Form->fieldRadio('registrar_lock', 'Yes', $this->Html->ifSet($vars->registrar_lock) == 'Yes', ['id' => 'registrar_lock_yes']); + $this->Form->label($this->_('Namesilo.tab_settings.field_registrar_lock_yes', true), 'registrar_lock_yes', ['class' => 'inline']); + + $this->Form->fieldRadio('registrar_lock', 'No', $this->Html->ifSet($vars->registrar_lock) == 'No', ['id' => 'registrar_lock_no']); + $this->Form->label($this->_('Namesilo.tab_settings.field_registrar_lock_no', true), 'registrar_lock_no', ['class' => 'inline']); + ?> +
    • Form->fieldHidden("whois_privacy_before", $this->Html->ifSet($vars->whois_privacy)); - $this->Form->fieldCheckbox("whois_privacy", "Yes", $this->Html->ifSet($vars->whois_privacy) == "Yes", array('id' => "whois_privacy")); - $this->Form->label($this->_("Namesilo.domain.WhoisPrivacy", true), "whois_privacy", array('class' => "inline")); + $this->Form->fieldCheckbox('request_epp', 'true', $this->Html->ifSet($vars->request_epp) == 'true', ['id' => 'request_epp']); + $this->Form->label($this->_('Namesilo.tab_settings.field_request_epp', true), 'request_epp', ['class' => 'inline']); ?>
    • -
    -
    - - Form->end(); - ?> \ No newline at end of file +
  • + Form->fieldHidden('whois_privacy_before', $this->Html->ifSet($vars->whois_privacy)); + $this->Form->fieldCheckbox('whois_privacy', 'Yes', $this->Html->ifSet($vars->whois_privacy) == 'Yes', ['id' => 'whois_privacy']); + $this->Form->label($this->_('Namesilo.domain.WhoisPrivacy', true), 'whois_privacy', ['class' => 'inline']); + ?> +
  • +
+
+ + Form->end(); + ?> \ No newline at end of file diff --git a/views/default/tab_whois.pdt b/views/default/tab_whois.pdt index 05cda35..077c100 100644 --- a/views/default/tab_whois.pdt +++ b/views/default/tab_whois.pdt @@ -1,78 +1,79 @@ - -
-

_("Namesilo.tab_whois.section_verification");?>

-
- - Form->create(); - ?> - - -
-

_("Namesilo.tab_whois.section_" . $key);?>

-
-
-
    - params['for'], 0, strlen($key)) != $key) - continue; - ?> -
  • - Form, $field->type), $field->params); - - // Draw each form field associated with this label - $tooltips = array(); - foreach ($field->fields as $input) { - - // Collect all tooltips to be displayed at the end - if ($input->type == "tooltip") { - $tooltips[] = $input; - continue; - } - - call_user_func_array(array($this->Form, $input->type), $input->params); - - // Draw the form field's secondary label if checkbox or radio item - if (($input->type == "fieldCheckbox" || $input->type == "fieldRadio") && isset($input->label)) { - if (isset($input->label->params['attributes']['class'])) { - if (is_array($input->label->params['attributes']['class'])) - $input->label->params['attributes']['class'][] = "inline"; - else - $input->label->params['attributes']['class'] .= " inline"; - } - else - $input->label->params['attributes']['class'] = "inline"; - - call_user_func_array(array($this->Form, "label"), $input->label->params); - } - } - - foreach ($tooltips as $tooltip) { - ?> - - _("AppController.tooltip.text");?> -
    Html->_($tooltip->params['message']);?>
    -
    - -
  • - -
-
- - - Form->end(); - ?> \ No newline at end of file +
+

_('Namesilo.tab_whois.section_verification'); ?>

+
+ + Form->create(); + ?> + + +
+

_('Namesilo.tab_whois.section_' . $key); ?>

+
+
+
    + params['for'], 0, strlen($key)) != $key) { + continue; + } + ?> +
  • + Form, $field->type], $field->params); + + // Draw each form field associated with this label + $tooltips = []; + foreach ($field->fields as $input) { + + // Collect all tooltips to be displayed at the end + if ($input->type == 'tooltip') { + $tooltips[] = $input; + continue; + } + + call_user_func_array([$this->Form, $input->type], $input->params); + + // Draw the form field's secondary label if checkbox or radio item + if (($input->type == 'fieldCheckbox' || $input->type == 'fieldRadio') && isset($input->label)) { + if (isset($input->label->params['attributes']['class'])) { + if (is_array($input->label->params['attributes']['class'])) { + $input->label->params['attributes']['class'][] = 'inline'; + } else { + $input->label->params['attributes']['class'] .= ' inline'; + } + } else { + $input->label->params['attributes']['class'] = 'inline'; + } + + call_user_func_array([$this->Form, 'label'], $input->label->params); + } + } + + foreach ($tooltips as $tooltip) { + ?> + + _('AppController.tooltip.text'); ?> +
    Html->_($tooltip->params['message']); ?>
    +
    + +
  • + +
+
+ + + Form->end(); + ?> \ No newline at end of file diff --git a/views/default/tld_rows.pdt b/views/default/tld_rows.pdt new file mode 100644 index 0000000..c028329 --- /dev/null +++ b/views/default/tld_rows.pdt @@ -0,0 +1,47 @@ +Html->ifSet($currencies, []) as $currency) { + ?> + + + Html->_($tld);?> + + + Html->_($currency);?> + + + + CurrencyFormat->format($this->Html->ifSet($vars->pricing[$tld][$currency]['previous_registration_price'], $pricing[$currency]->registration), $currency);?> + + + + + CurrencyFormat->format($this->Html->ifSet($vars->pricing[$tld][$currency]['previous_renewal_price'], $pricing[$currency]->renew), $currency);?> + + + + + CurrencyFormat->format($this->Html->ifSet($pricing[$currency]->registration), $currency);?> + + + + + CurrencyFormat->format($this->Html->ifSet($pricing[$currency]->renew), $currency);?> + + + + Form->fieldText('pricing[' . $tld . '][' . $currency . '][price]', $this->CurrencyFormat->format($this->Html->ifSet($vars->pricing[$tld][$currency]['price'], $pricing[$currency]->registration), $currency, ['prefix' => false, 'suffix' => false, 'with_separator' => false, 'code' => false, 'decimals' => 4]), ['class' => 'price stretch', 'data-locked' => 'false']);?> + + + Html->ifSet($vars->pricing[$tld][$currency]['price_enable_renews'], '1') == '0') { + $disabled = ['disabled' => 'disabled']; + } + $this->Form->fieldCheckbox('pricing[' . $tld . '][' . $currency . '][price_enable_renews]', '1', ($this->Html->ifSet($vars->pricing[$tld][$currency]['price_enable_renews'], '1') == '1'), ['class' => 'price_enable_renews']); + $this->Form->fieldText('pricing[' . $tld . '][' . $currency . '][price_renews]', $this->CurrencyFormat->format($this->Html->ifSet($vars->pricing[$tld][$currency]['price_renews'], $pricing[$currency]->renew), $currency, ['prefix' => false, 'suffix' => false, 'with_separator' => false, 'code' => false, 'decimals' => 4]), array_merge(['class' => 'price_renews stretch', 'data-locked' => 'false'], $disabled)); + ?> + + + diff --git a/views/default/transferstatus.pdt b/views/default/transferstatus.pdt index 0142c44..58627c9 100644 --- a/views/default/transferstatus.pdt +++ b/views/default/transferstatus.pdt @@ -1,5 +1,5 @@ -
-

_("Namesilo.notice.TransferPending"); ?>

-

Status: Html->ifSet($transferstatus->status) ?>

-

Status Message: Html->ifSet($transferstatus->message) ?>

-
\ No newline at end of file +
+

_('Namesilo.notice.TransferPending'); ?>

+

Status: Html->ifSet($transferstatus->status) ?>

+

Status Message: Html->ifSet($transferstatus->message) ?>

+
\ No newline at end of file diff --git a/views/default/whois_disabled.pdt b/views/default/whois_disabled.pdt index 68be6ba..9192e81 100644 --- a/views/default/whois_disabled.pdt +++ b/views/default/whois_disabled.pdt @@ -1,2 +1 @@ - -

This feature has been disabled on your account. Please contact us for more information.

\ No newline at end of file +

This feature has been disabled on your account. Please contact us for more information.

\ No newline at end of file