From 5e9959f9dcaa3911a077236d20a4048ee5f308c8 Mon Sep 17 00:00:00 2001 From: Tyson Phillips Date: Mon, 16 Dec 2019 15:18:41 -0800 Subject: [PATCH 01/15] Formatted the source to PSR2 Fixed a couple issues with undefined variables and the use of old submit buttons --- .gitignore | 1 + CHANGELOG.md | 3 + README.md | 2 +- apis/codes.php | 88 +- apis/commands/domains.php | 451 +-- apis/commands/domains_dns.php | 192 +- apis/commands/domains_ns.php | 148 +- apis/commands/domains_transfer.php | 193 +- apis/commands/ssl.php | 414 +-- apis/commands/users.php | 352 +-- apis/commands/users_address.php | 238 +- apis/namesilo_api.php | 244 +- apis/namesilo_response.php | 193 +- config.json | 8 +- config/codes.php | 88 +- config/namesilo.php | 336 +-- config/notices.php | 12 +- includes/communication.php | 105 +- language/en_us/namesilo.php | 382 +-- language/en_us/notices.php | 17 +- namesilo.php | 3507 ++++++++++++---------- views/default/add_row.pdt | 54 +- views/default/audit_domains.pdt | 10 +- views/default/edit_row.pdt | 54 +- views/default/manage.pdt | 78 +- views/default/pending.pdt | 2 +- views/default/service_fields.pdt | 22 +- views/default/service_fields_client.pdt | 20 +- views/default/suspended.pdt | 2 +- views/default/sync_renew_dates.pdt | 18 +- views/default/tab_admin_actions.pdt | 10 +- views/default/tab_client_dnssec.pdt | 36 +- views/default/tab_client_hosts.pdt | 14 +- views/default/tab_client_nameservers.pdt | 14 +- views/default/tab_client_settings.pdt | 42 +- views/default/tab_client_whois.pdt | 42 +- views/default/tab_dnssec.pdt | 36 +- views/default/tab_hosts.pdt | 18 +- views/default/tab_nameservers.pdt | 48 +- views/default/tab_settings.pdt | 77 +- views/default/tab_whois.pdt | 156 +- views/default/transferstatus.pdt | 2 +- 42 files changed, 4039 insertions(+), 3690 deletions(-) diff --git a/.gitignore b/.gitignore index fa38ac0..893d4db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ _notes *.bak +/nbproject/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d74b8..bcca299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [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 ## [1.8.5] = 2018-11-19 ### Added diff --git a/README.md b/README.md index ec90278..c3a3aa4 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. 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/config.json b/config.json index 5ba94db..67fd6db 100644 --- a/config.json +++ b/config.json @@ -1,10 +1,14 @@ { - "version": "1.8.5", + "version": "1.9.0", "name": "NameSilo Domains Module", "description": "Resell domains through NameSilo.", "authors": [ + { + "name": "Phillips Data Inc.", + "url": "https://www.blesta.com" + }, { - "name": "KnownHost LLC &", + "name": "KnownHost LLC", "url": "https://www.knownhost.com" }, { 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/language/en_us/namesilo.php b/language/en_us/namesilo.php index f1e003d..12bae25 100644 --- a/language/en_us/namesilo.php +++ b/language/en_us/namesilo.php @@ -1,153 +1,153 @@ 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 +156,91 @@ //$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'; // 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.'; 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 +{ + private static $debug_to = 'root@localhost'; + + // Namesilo response codes (array) + private static $codes; + + // Pending statutes (array) + private static $pending = [ 'in_review', 'pending' ]; + + private static $defaultModuleView; + + private static $api; + + /** + * 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' ]); + # 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 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; - } - } - $whois_fields = Configure::get("Namesilo.whois_fields"); + 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'); // 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 ); + } else { + // Handle registration + $domains = new NamesiloDomains($api); - //$this->debug( $fields ); - //$this->Input->setErrors( array( 'errors' => array( 'Test' ) ) ); - //return; + //$this->debug( $fields ); + //$this->Input->setErrors( array( 'errors' => array( 'Test' ) ) ); + //return; - $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 +426,501 @@ 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")); + } + + /** + * 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 + ]; + } + } + + 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() + # + # + $link_buttons = []; + foreach ($module->rows as $row) { + if (isset($row->meta->key)) { + $link_buttons[] = [ + 'name' => Language::_('Namesilo.manage.sync_renew_dates', true), + 'attributes' => [ + 'href' => [ + 'href' => $this->base_uri . 'settings/company/modules/addrow/' + . $module->id . '?action=sync_renew_dates' + ] + ] + ]; + $link_buttons[] = [ + 'name' => Language::_('Namesilo.manage.audit_domains', true), + 'attributes' => [ + 'href' => $this->base_uri . 'settings/company/modules/addrow/' + . $module->id . '?action=audit_domains' + ] + ]; break; } } - $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"); + $this->view->set('module', $module); + $this->view->set('link_buttons', $link_buttons); + + // Load the helpers required for this view + Loader::loadHelpers($this, [ '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'); $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', 'Widget']); + Loader::loadModels($this, ['Services', 'Record', 'ModuleManager']); $module_row = $this->getNamesiloRow(); - $api = $this->getApi($module_row->meta->user, $module_row->meta->key, $module_row->meta->sandbox == "true", null, true); + $api = $this->getApi( + $module_row->meta->user, + $module_row->meta->key, + $module_row->meta->sandbox == 'true', + null, + true + ); $domains = new NamesiloDomains($api); - if($module_row->meta->portfolio) + if ($module_row->meta->portfolio) { $vars['portfolio'] = $module_row->meta->portfolio; + } $domain_list = $domains->getList($vars)->response()->domains->domain; $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') + 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){ + if (!$record) { $vars['domains'][] = $domain; } } - $this->view->set( "vars", (object)$vars ); + $this->view->set('vars', (object)$vars); return $this->view->fetch(); - }elseif($action == 'sync_renew_dates'){ - if(isset($_POST['sync_services'])) + } elseif ($action == 'sync_renew_dates') { + if (isset($_POST['sync_services'])) { $post['sync_services'] = $_POST['sync_services']; + } - $this->view = new View("sync_renew_dates", "default"); + $this->view = new View('sync_renew_dates', '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', 'Widget']); + Loader::loadModels($this, ['Services', 'Clients', 'Record', 'ModuleManager', 'ClientGroups']); $module_row = $this->getNamesiloRow(); - $api = $this->getApi($module_row->meta->user, $module_row->meta->key, $module_row->meta->sandbox == "true", null, true); + $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') + $services = $this->Record->select(['services.id', 'services.client_id']) + ->from('services') + ->where('module_row_id', '=', $module_row->id) + ->where('status', '=', 'active') ->fetchAll(); - $vars['changes'] = array(); + $vars['changes'] = []; - foreach($services as $service_id){ - $vars['changes'][] = $this->getRenewInfo($service_id->id,$domains); + foreach ($services as $service_id) { + $vars['changes'][] = $this->getRenewInfo($service_id->id, $domains); } - $this->view->set( "vars", $vars ); + $this->view->set('vars', $vars); return $this->view->fetch(); - }else{ + } 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 = new View('add_row', '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::loadHelpers($this, [ 'Form', 'Html', 'Widget' ]); // 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); + $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")); + } + + /** + * 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) + { + # + # TODO: this should be using $vars rather than $_POST + # + if (isset($_POST['sync_services'])) { + Loader::loadModels($this, ['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); + 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 + ); $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) + { + // Same as adding + 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 +943,69 @@ 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 +1216,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 +1242,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); @@ -1190,137 +1288,198 @@ private function buildDomainModuleFields($vars, $client = false) { } } - return (isset($module_fields) ? $module_fields : 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, [ '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 + * + * @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 tabHosts($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageHosts('tab_hosts', $package, $service, $get, $post, $files); + } + + /** + * Admin DNSSEC 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 tabDnssec($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageDnssec('tab_dnssec', $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, 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); - } + /** + * 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 @@ -1332,12 +1491,13 @@ 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 tabClientHosts($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageHosts('tab_client_hosts', $package, $service, $get, $post, $files); } /** - * Admin DNSSEC tab + * Client Dnssec tab * * @param stdClass $package A stdClass object representing the current package * @param stdClass $service A stdClass object representing the current service @@ -1346,26 +1506,13 @@ 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 tabClientDnssec($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageDnssec('tab_client_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 Hosts tab + * Admin Settings tab * * @param stdClass $package A stdClass object representing the current package * @param stdClass $service A stdClass object representing the current service @@ -1374,12 +1521,13 @@ 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 tabSettings($package, $service, array $get = null, array $post = null, array $files = null) + { + return $this->manageSettings('tab_settings', $package, $service, $get, $post, $files); } /** - * Client Dnssec tab + * Client Settings tab * * @param stdClass $package A stdClass object representing the current package * @param stdClass $service A stdClass object representing the current service @@ -1388,340 +1536,296 @@ 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 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'); + + Loader::loadHelpers($this, [ '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(); + } elseif ($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( $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 ); + $row = $this->getModuleRow($package->module_row); + $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); + $domains = new NamesiloDomains($api); - $sections = array( 'registrant', 'admin', 'tech', 'billing' ); + $sections = [ 'registrant', 'admin', 'tech', 'billing' ]; - $vars = new stdClass(); + $vars = new stdClass(); - $whois_fields = Configure::get( "Namesilo.whois_fields" ); - $fields = $this->serviceFieldsToObject( $service->fields ); + $whois_fields = Configure::get('Namesilo.whois_fields'); + $fields = $this->serviceFieldsToObject($service->fields); - $domainInfo = $domains->getDomainInfo( array( 'domain' => $fields->domain ) ); - if ( self::$codes[$domainInfo->status()][1] == "fail" ) { - $this->processResponse( $api, $domainInfo ); - return false; - } + $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']; + $contact_ids = $domainInfo->response(true)['contact_ids']; - if ( !empty( $post ) ) { - $new_ids = $delete_ids = array(); + if (!empty($post)) { + $new_ids = $delete_ids = []; - $params = array("domain" => $fields->domain); + $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") { + 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)); + foreach ($delete_ids as $id) { + $domains->deleteContacts(['contact_id' => $id]); + } $contact_ids = array_replace($contact_ids, $new_ids); } + } - //$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 ) { - - $vars = new stdClass(); + $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]; + } - if ( in_array( $service->status, self::$pending ) ) { - $this->view = new View( 'pending', "default" ); + // 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; + } + } + } } - else if ( $view == "tab_client_nameservers" && $service->status == "suspended" ) { - $this->view = new View( 'suspended', "default" ); + + $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; } - else { + $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(); + } + + /** + * 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 +1834,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; @@ -1752,61 +1856,75 @@ private function getRegisteredHosts($package,$service){ /** * 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,72 +1936,80 @@ 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); } @@ -1892,389 +2018,446 @@ private function manageDnssec( $view, $package, $service, array $get = null, arr 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'} == $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(); + * @return string The TLD of the domain + */ + private function getTld($domain, $row = null) + { + if ($row == null) { + $row = $this->getNamesiloRow(); + } - if($row == null){ + 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" ); + $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) + { + $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 = []; + 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, ['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 +2465,53 @@ 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 the Namesilo module row + * + * @return null|stdClass An stdClass object representing the module row if found, otherwise void + */ + private function getNamesiloRow() + { + Loader::loadModels($this, ['ModuleManager']); $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)) { + if (isset($module_row->meta->namesilo_module)) { return $module_row; } } } } - - public function debug( $data ) { - mail( self::$debug_to, "Namesilo Module " /*. self::$version*/ . " Debug", var_export( $data, true ), "From: blesta@localhost\n\n" ); - } - + + /** + * 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"); + } } diff --git a/views/default/add_row.pdt b/views/default/add_row.pdt index 092f981..7b0f73e 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)); - ?> + $this->Widget->clear(); + $this->Widget->create($this->_('Namesilo.add_row.box_title', true)); + ?>
Form->create(); - ?> + $this->Form->create(); + ?>
-

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

+

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

  • Form->label($this->_("Namesilo.row_meta.user", true), "user"); - $this->Form->fieldText("user", $this->Html->ifSet($vars->user), array('id' => "user")); - ?> + $this->Form->label($this->_('Namesilo.row_meta.user', true), 'user'); + $this->Form->fieldText('user', $this->Html->ifSet($vars->user), ['id' => 'user']); + ?>
  • Form->label($this->_("Namesilo.row_meta.key", true), "key"); - $this->Form->fieldText("key", $this->Html->ifSet($vars->key), array('id' => "key")); - ?> + $this->Form->label($this->_('Namesilo.row_meta.key', true), 'key'); + $this->Form->fieldText('key', $this->Html->ifSet($vars->key), ['id' => 'key']); + ?>
  • Form->label($this->_("Namesilo.row_meta.portfolio", true), "portfolio"); - $this->Form->fieldText("portfolio", $this->Html->ifSet($vars->portfolio), array('id' => "portfolio")); + $this->Form->label($this->_('Namesilo.row_meta.portfolio', true), 'portfolio'); + $this->Form->fieldText('portfolio', $this->Html->ifSet($vars->portfolio), ['id' => 'portfolio']); ?>
  • Form->label($this->_("Namesilo.row_meta.payment_id", true), "payment_id"); - $this->Form->fieldText("payment_id", $this->Html->ifSet($vars->payment_id), array('id' => "payment_id")); + $this->Form->label($this->_('Namesilo.row_meta.payment_id', true), 'payment_id'); + $this->Form->fieldText('payment_id', $this->Html->ifSet($vars->payment_id), ['id' => 'payment_id']); ?> -

    _("Namesilo.row_meta.payment_id.description", true); ?> https://www.namesilo.com/account_billing_profiles.php

    +

    _('Namesilo.row_meta.payment_id.description', true); ?> https://www.namesilo.com/account_billing_profiles.php

  • Form->fieldCheckbox("sandbox", "true", $this->Html->ifSet($vars->sandbox) == "true", array('id' => "sandbox")); - $this->Form->label($this->_("Namesilo.row_meta.sandbox", true), "sandbox", array('class' => "inline")); - ?> + $this->Form->fieldCheckbox('sandbox', 'true', $this->Html->ifSet($vars->sandbox) == 'true', ['id' => 'sandbox']); + $this->Form->label($this->_('Namesilo.row_meta.sandbox', true), 'sandbox', ['class' => 'inline']); + ?>
  • - Form->fieldHidden("namesilo_module",true); ?> + Form->fieldHidden('namesilo_module',true); ?>
- - + + Form->end(); - ?> + $this->Form->end(); + ?>
Widget->end(); - ?> \ No newline at end of file + $this->Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/audit_domains.pdt b/views/default/audit_domains.pdt index 6a92b37..c6913e7 100644 --- a/views/default/audit_domains.pdt +++ b/views/default/audit_domains.pdt @@ -1,17 +1,17 @@ Widget->clear(); -$this->Widget->create($this->_("Namesilo.add_row.audit_domains.box_title", true)); +$this->Widget->create($this->_('Namesilo.add_row.audit_domains.box_title', true)); ?>
-

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

+

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

-

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

+

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

domains) > 0){ ?> - + Widget->create($this->_("Namesilo.add_row.audit_domains.box_title", true) ?>
_("Namesilo.domain.domain", true); ?>_('Namesilo.domain.domain', true); ?> Issue/Return
-

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

+

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

Widget->clear(); - $this->Widget->create($this->_("Namesilo.edit_row.box_title", true)); - ?> + $this->Widget->clear(); + $this->Widget->create($this->_('Namesilo.edit_row.box_title', true)); + ?>
Form->create(); - ?> + $this->Form->create(); + ?>
-

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

+

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

  • Form->label($this->_("Namesilo.row_meta.user", true), "user"); - $this->Form->fieldText("user", $this->Html->ifSet($vars->user), array('id' => "user")); - ?> + $this->Form->label($this->_('Namesilo.row_meta.user', true), 'user'); + $this->Form->fieldText('user', $this->Html->ifSet($vars->user), ['id' => 'user']); + ?>
  • Form->label($this->_("Namesilo.row_meta.key", true), "key"); - $this->Form->fieldText("key", $this->Html->ifSet($vars->key), array('id' => "key")); - ?> + $this->Form->label($this->_('Namesilo.row_meta.key', true), 'key'); + $this->Form->fieldText('key', $this->Html->ifSet($vars->key), ['id' => 'key']); + ?>
  • Form->label($this->_("Namesilo.row_meta.portfolio", true), "portfolio"); - $this->Form->fieldText("portfolio", $this->Html->ifSet($vars->portfolio), array('id' => "portfolio")); + $this->Form->label($this->_('Namesilo.row_meta.portfolio', true), 'portfolio'); + $this->Form->fieldText('portfolio', $this->Html->ifSet($vars->portfolio), ['id' => 'portfolio']); ?>
  • Form->label($this->_("Namesilo.row_meta.payment_id", true), "payment_id"); - $this->Form->fieldText("payment_id", $this->Html->ifSet($vars->payment_id), array('id' => "payment_id")); + $this->Form->label($this->_('Namesilo.row_meta.payment_id', true), 'payment_id'); + $this->Form->fieldText('payment_id', $this->Html->ifSet($vars->payment_id), ['id' => 'payment_id']); ?> -

    _("Namesilo.row_meta.payment_id.description", true); ?> https://www.namesilo.com/account_billing_profiles.php

    +

    _('Namesilo.row_meta.payment_id.description', true); ?> https://www.namesilo.com/account_billing_profiles.php

  • Form->fieldCheckbox("sandbox", "true", $this->Html->ifSet($vars->sandbox) == "true", array('id' => "sandbox")); - $this->Form->label($this->_("Namesilo.row_meta.sandbox", true), "sandbox", array('class' => "inline")); - ?> + $this->Form->fieldCheckbox('sandbox', 'true', $this->Html->ifSet($vars->sandbox) == 'true', ['id' => 'sandbox']); + $this->Form->label($this->_('Namesilo.row_meta.sandbox', true), 'sandbox', ['class' => 'inline']); + ?>
  • - Form->fieldHidden("namesilo_module",true); ?> + Form->fieldHidden('namesilo_module',true); ?>
- - + + Form->end(); - ?> + $this->Form->end(); + ?>
Widget->end(); - ?> \ No newline at end of file + $this->Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/manage.pdt b/views/default/manage.pdt index 4c15864..9198399 100644 --- a/views/default/manage.pdt +++ b/views/default/manage.pdt @@ -1,71 +1,71 @@ $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")); - ?> + $link_buttons[] = ['name'=>$this->_('Namesilo.add_module_row', true), 'attributes'=>['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)), ['id'=>'manage_namesilo']); + ?>
-

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

+

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

Html->ifSet($module->rows)); - if ($num_rows > 0) { - ?> + $num_rows = count($this->Html->ifSet($module->rows)); + if ($num_rows > 0) { + ?> - - - - - + + + + + - > + for ($i=0; $i<$num_rows; $i++) { + ?> + > - + + } + ?>
_("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");?>_('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"));?>_('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");?> + _('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");?> + $this->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(); - ?> + $this->Form->end(); + ?>
+ } + else { + ?>
- _("Namesilo.manage.module_rows_no_results");?> + _('Namesilo.manage.module_rows_no_results');?>
+ } + ?> Widget->end(); - ?> + $this->Widget->end(); + ?> \ No newline at end of file diff --git a/views/default/pending.pdt b/views/default/pending.pdt index 4875f50..616709e 100644 --- a/views/default/pending.pdt +++ b/views/default/pending.pdt @@ -1,2 +1,2 @@ -

_("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..d65edde 100644 --- a/views/default/service_fields.pdt +++ b/views/default/service_fields.pdt @@ -6,42 +6,42 @@ $i = 0; foreach ($fields as $field) { ?> -
  • "> +
  • Form, $field->type), $field->params); + call_user_func_array([$this->Form, $field->type], $field->params); // Draw each form field associated with this label - $tooltips = array(); + $tooltips = []; foreach ($field->fields as $input) { // Collect all tooltips to be displayed at the end - if ($input->type == "tooltip") { + 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 (($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"; + $input->label->params['attributes']['class'][] = 'inline'; else - $input->label->params['attributes']['class'] .= " inline"; + $input->label->params['attributes']['class'] .= ' inline'; } else - $input->label->params['attributes']['class'] = "inline"; + $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) { ?> - _("AppController.tooltip.text");?> + _('AppController.tooltip.text');?>
    Html->_($tooltip->params['message']);?>
    Html->ifSet($fields) && !empty($fields)) { ?> -
    Html->ifSet($module->class), $this->Html->ifSet($module->id)));?>"> +
    Form, $field->type), $field->params); + call_user_func_array([$this->Form, $field->type], $field->params); // Draw each form field associated with this label - $tooltips = array(); + $tooltips = []; foreach ($field->fields as $input) { // Collect all tooltips to be displayed at the end - if ($input->type == "tooltip") { + 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 (($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"; + $input->label->params['attributes']['class'][] = 'inline'; else - $input->label->params['attributes']['class'] .= " inline"; + $input->label->params['attributes']['class'] .= ' inline'; } else - $input->label->params['attributes']['class'] = "inline"; + $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); } } diff --git a/views/default/suspended.pdt b/views/default/suspended.pdt index 89e0585..48fa524 100644 --- a/views/default/suspended.pdt +++ b/views/default/suspended.pdt @@ -1,2 +1,2 @@ -

    _("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..77d2f81 100644 --- a/views/default/sync_renew_dates.pdt +++ b/views/default/sync_renew_dates.pdt @@ -5,7 +5,7 @@ if(isset($_REQUEST['msg'])) {
    Widget->clear(); -$this->Widget->create($this->_("Namesilo.manage.sync_renew_dates.box_title", true)); +$this->Widget->create($this->_('Namesilo.manage.sync_renew_dates.box_title', true)); ?>
    -

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

    +

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

    0){ ?>
    -

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

    +

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

    Form->create(); ?> - + @@ -37,7 +37,7 @@ $this->Widget->create($this->_("Namesilo.manage.sync_renew_dates.box_title", tru @@ -50,18 +50,18 @@ $this->Widget->create($this->_("Namesilo.manage.sync_renew_dates.box_title", tru ?>
    _("Namesilo.domain.domain", true); ?>_('Namesilo.domain.domain', true); ?> Old Renew Date New Renew Date
    Form->fieldCheckbox("sync_services[]", $this->Html->ifSet($change['service_id']), "true"); + $this->Form->fieldCheckbox('sync_services[]', $this->Html->ifSet($change['service_id']), 'true'); ?> Html->ifSet($change['domain']); ?>
    - + Form->end(); ?> 0){ ?>
    -

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

    +

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

    - + Form->create(); ?>
  • - Form->label( "What would you like to send?", "notice" ); ?> - Form->fieldSelect( "notice", $vars->options, $this->Html->ifSet( $test ) == "Yes", array ( 'id' => "notice" ) ); ?> - + Form->label( 'What would you like to send?', 'notice' ); ?> + Form->fieldSelect( 'notice', $vars->options, $this->Html->ifSet( $test ) == 'Yes', [ 'id' => 'notice' ] ); ?> +
  • Form->end(); $this->Form->create(); ?>
  • - Form->fieldHidden("action", "sync_date"); ?> - + Form->fieldHidden('action', 'sync_date'); ?> +
  • diff --git a/views/default/tab_client_dnssec.pdt b/views/default/tab_client_dnssec.pdt index 7dfe374..3808297 100644 --- a/views/default/tab_client_dnssec.pdt +++ b/views/default/tab_client_dnssec.pdt @@ -1,20 +1,20 @@
    -

    _("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');?>

    _("Namesilo.domain.domain", true); ?>_('Namesilo.domain.domain', true); ?> Result
    - - - - - + + + + + @@ -53,24 +53,24 @@
    _("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 . '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")); ?> + Form->label( $this->_('Namesilo.dnssec.digest'), 'digest' ); ?> + Form->fieldText('digest', null, ['class' => 'form-control']); ?>
    -

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

    +

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

    Form->create($this->base_uri . 'services/manage/' . $this->Html->ifSet($service_id) . '/tabClientHosts'); ?> - - + + - + - + - - + + diff --git a/views/default/tab_client_nameservers.pdt b/views/default/tab_client_nameservers.pdt index caa5881..d3a28c9 100644 --- a/views/default/tab_client_nameservers.pdt +++ b/views/default/tab_client_nameservers.pdt @@ -4,19 +4,19 @@
    + for ($i=0; $i<5; $i++) { + ?>
    - 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->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..e77a359 100644 --- a/views/default/tab_client_settings.pdt +++ b/views/default/tab_client_settings.pdt @@ -1,14 +1,14 @@
    -

    _("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.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.not_verified'); ?>!

    +

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

    Form->create(); ?>

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

    -

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

    +

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

    @@ -53,9 +53,9 @@
    @@ -63,16 +63,16 @@
    Form->end(); diff --git a/views/default/tab_client_whois.pdt b/views/default/tab_client_whois.pdt index 8a889a6..32b608e 100644 --- a/views/default/tab_client_whois.pdt +++ b/views/default/tab_client_whois.pdt @@ -1,14 +1,14 @@ Form->create(); - ?> + ?>
    _("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) . '][]'); ?>
    Form->fieldText("new_host"); echo '.' . $domain; ?>Form->fieldText("new_host_ip"); ?>Form->fieldText('new_host'); echo '.' . $domain; ?>Form->fieldText('new_host_ip'); ?>
    - - - - - + + + + +
    -

    _("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,18 +67,18 @@ - - - - + + + + - - - - + + + +
    _("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.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'); ?>
    diff --git a/views/default/tab_hosts.pdt b/views/default/tab_hosts.pdt index 0b30715..44941c8 100644 --- a/views/default/tab_hosts.pdt +++ b/views/default/tab_hosts.pdt @@ -1,6 +1,6 @@
    -

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

    +

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

    - _("Namesilo.tab_hosts.field_hostname"); ?> - _("Namesilo.tab_hosts.field_ip"); ?> + _('Namesilo.tab_hosts.field_hostname'); ?> + _('Namesilo.tab_hosts.field_ip'); ?> @@ -23,7 +23,7 @@ ?> 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'); ?> diff --git a/views/default/tab_nameservers.pdt b/views/default/tab_nameservers.pdt index d420638..d690d86 100644 --- a/views/default/tab_nameservers.pdt +++ b/views/default/tab_nameservers.pdt @@ -1,24 +1,24 @@ - - 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..7c8439d 100644 --- a/views/default/tab_settings.pdt +++ b/views/default/tab_settings.pdt @@ -1,26 +1,35 @@
    -

    _("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"); ?>
    • -
    • - Form->fieldHidden('resend_verification_email',$vars->registrant_verification_info->email_address); ?> -
    • - +
    • + _('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', $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(); - ?> + $this->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")); - ?> + $this->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->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")); - ?> + $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->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->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 + $this->Form->end(); + ?> \ No newline at end of file diff --git a/views/default/tab_whois.pdt b/views/default/tab_whois.pdt index 05cda35..1902315 100644 --- a/views/default/tab_whois.pdt +++ b/views/default/tab_whois.pdt @@ -1,78 +1,78 @@ - -
    -

    _("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/transferstatus.pdt b/views/default/transferstatus.pdt index 0142c44..565b17a 100644 --- a/views/default/transferstatus.pdt +++ b/views/default/transferstatus.pdt @@ -1,5 +1,5 @@
    -

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

    +

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

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

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

    \ No newline at end of file From 1a9f7a1634e63d4afc72399b907044db19d0b083 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Wed, 18 Dec 2019 16:38:11 -0600 Subject: [PATCH 02/15] Fixed a "Undefined property" error, when there are no domains available in Audit Domains --- .gitignore | 1 + CHANGELOG.md | 1 + namesilo.php | 69 +++++++++++++++++++++++++++++++++------------------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 893d4db..a4465a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ _notes *.bak /nbproject/ +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index bcca299..6b8d927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - 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/namesilo.php b/namesilo.php index 94be165..4487b5c 100644 --- a/namesilo.php +++ b/namesilo.php @@ -11,12 +11,19 @@ */ class Namesilo extends Module { + /** + * @var string Debug email address + */ private static $debug_to = 'root@localhost'; - // Namesilo response codes (array) + /** + * @var array Namesilo response codes + */ private static $codes; - // Pending statutes (array) + /** + * @var array Pending statutes + */ private static $pending = [ 'in_review', 'pending' ]; private static $defaultModuleView; @@ -28,17 +35,22 @@ class Namesilo extends Module */ public function __construct() { - # Load config.json + // Load config.json $this->loadConfig(__DIR__ . DS . 'config.json'); - # Load components required by this module - Loader::loadComponents($this, [ 'Input' ]); - # Load the language required by this module + + // Load components required by this module + Loader::loadComponents($this, ['Input']); + + // Load the language required by this module Language::loadLang('namesilo', null, __DIR__ . DS . 'language' . DS); - # Load configuration + + // Load configuration Configure::load('namesilo', __DIR__ . DS . 'config' . DS); - # Get Namesilo response codes + + // Get Namesilo response codes self::$codes = Configure::get('Namesilo.status.codes'); - # Set default module view + + // Set default module view self::$defaultModuleView = 'components' . DS . 'modules' . DS . 'namesilo' . DS; } @@ -301,7 +313,6 @@ public function addService( unset($input_fields['private']); } - if (isset($vars['use_module']) && $vars['use_module'] == 'true') { if ($package->meta->type == 'domain') { $vars['years'] = 1; @@ -492,7 +503,7 @@ public function suspendService($package, $service, $parent_package = null, $pare if ($package->meta->type == 'domain') { $fields = $this->serviceFieldsToObject($service->fields); - # Make sure auto renew is off + // Make sure auto renew is off $domains = new NamesiloDomains($api); $response = $domains->setAutoRenewal($fields->{'domain'}, false); $this->processResponse($api, $response); @@ -701,7 +712,6 @@ public function manageAddRow(array &$vars) Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); Loader::loadModels($this, ['Services', 'Record', 'ModuleManager']); - $module_row = $this->getNamesiloRow(); $api = $this->getApi( @@ -717,22 +727,28 @@ public function manageAddRow(array &$vars) $vars['portfolio'] = $module_row->meta->portfolio; } - $domain_list = $domains->getList($vars)->response()->domains->domain; + $response = $domains->getList($vars)->response(); + $domain_list = $this->Html->ifSet($response->domains->domain); $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', ['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; + + 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; + } } } + // Set view $this->view->set('vars', (object)$vars); return $this->view->fetch(); @@ -772,7 +788,9 @@ public function manageAddRow(array &$vars) $vars['changes'][] = $this->getRenewInfo($service_id->id, $domains); } + // Set view $this->view->set('vars', $vars); + return $this->view->fetch(); } else { // Load the view into this object, so helpers can be automatically added to the view @@ -781,7 +799,7 @@ public function manageAddRow(array &$vars) $this->view->setDefaultView(self::$defaultModuleView); // Load the helpers required for this view - Loader::loadHelpers($this, [ 'Form', 'Html', 'Widget' ]); + Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); // Set unspecified checkboxes if (!empty($vars)) { @@ -790,7 +808,9 @@ public function manageAddRow(array &$vars) } } + // Set view $this->view->set('vars', (object)$vars); + return $this->view->fetch(); } } @@ -1852,7 +1872,6 @@ private function getRegisteredHosts($package, $service) return $hosts; } - /** * Handle updating host information * From 74faefb35772224d6cb3d2af8271779a5d7199fe Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Wed, 18 Dec 2019 16:52:20 -0600 Subject: [PATCH 03/15] Formatted all views to match standards for Blesta --- views/default/add_row.pdt | 48 +++---- views/default/audit_domains.pdt | 64 ++++----- views/default/edit_row.pdt | 48 +++---- views/default/manage.pdt | 111 ++++++++------- views/default/pending.pdt | 3 +- views/default/service_fields.pdt | 87 ++++++------ views/default/service_fields_client.pdt | 84 ++++++------ views/default/suspended.pdt | 3 +- views/default/sync_renew_dates.pdt | 163 +++++++++++------------ views/default/tab_admin_actions.pdt | 16 +-- views/default/tab_client_dnssec.pdt | 148 ++++++++++---------- views/default/tab_client_hosts.pdt | 62 ++++----- views/default/tab_client_nameservers.pdt | 37 +++-- views/default/tab_client_settings.pdt | 68 +++++----- views/default/tab_client_whois.pdt | 142 ++++++++++---------- views/default/tab_dnssec.pdt | 27 ++-- views/default/tab_hosts.pdt | 30 ++--- views/default/tab_nameservers.pdt | 33 +++-- views/default/tab_settings.pdt | 51 +++---- views/default/tab_whois.pdt | 115 ++++++++-------- views/default/transferstatus.pdt | 10 +- views/default/whois_disabled.pdt | 3 +- 22 files changed, 674 insertions(+), 679 deletions(-) diff --git a/views/default/add_row.pdt b/views/default/add_row.pdt index 7b0f73e..4846579 100644 --- a/views/default/add_row.pdt +++ b/views/default/add_row.pdt @@ -1,28 +1,28 @@ - Widget->clear(); $this->Widget->create($this->_('Namesilo.add_row.box_title', true)); ?> -
    - + Form->create(); ?> -
    -

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

    -
    -
    -
      -
    • - +

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

      +
    +
    +
      +
    • + Form->label($this->_('Namesilo.row_meta.user', true), 'user'); $this->Form->fieldText('user', $this->Html->ifSet($vars->user), ['id' => 'user']); ?> -
    • -
    • - +
    • + Form->label($this->_('Namesilo.row_meta.key', true), 'key'); $this->Form->fieldText('key', $this->Html->ifSet($vars->key), ['id' => 'key']); ?> -
    • +
    • Form->label($this->_('Namesilo.row_meta.portfolio', true), 'portfolio'); @@ -36,21 +36,21 @@ ?>

      _('Namesilo.row_meta.payment_id.description', true); ?> https://www.namesilo.com/account_billing_profiles.php

    • -
    • - + Form->fieldCheckbox('sandbox', 'true', $this->Html->ifSet($vars->sandbox) == 'true', ['id' => 'sandbox']); $this->Form->label($this->_('Namesilo.row_meta.sandbox', true), 'sandbox', ['class' => 'inline']); ?> -
    • - Form->fieldHidden('namesilo_module',true); ?> -
    -
    +
  • + Form->fieldHidden('namesilo_module', true); ?> + + -
    _('Namesilo.add_row.add_btn');?>
    - _('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 c6913e7..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 fd691a5..fb06595 100644 --- a/views/default/edit_row.pdt +++ b/views/default/edit_row.pdt @@ -1,28 +1,28 @@ - Widget->clear(); $this->Widget->create($this->_('Namesilo.edit_row.box_title', true)); ?> -
    - + Form->create(); ?> -
    -

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

    -
    -
    -
      -
    • - +

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

      +
    +
    +
      +
    • + Form->label($this->_('Namesilo.row_meta.user', true), 'user'); $this->Form->fieldText('user', $this->Html->ifSet($vars->user), ['id' => 'user']); ?> -
    • -
    • - +
    • + Form->label($this->_('Namesilo.row_meta.key', true), 'key'); $this->Form->fieldText('key', $this->Html->ifSet($vars->key), ['id' => 'key']); ?> -
    • +
    • Form->label($this->_('Namesilo.row_meta.portfolio', true), 'portfolio'); @@ -36,21 +36,21 @@ ?>

      _('Namesilo.row_meta.payment_id.description', true); ?> https://www.namesilo.com/account_billing_profiles.php

    • -
    • - + Form->fieldCheckbox('sandbox', 'true', $this->Html->ifSet($vars->sandbox) == 'true', ['id' => 'sandbox']); $this->Form->label($this->_('Namesilo.row_meta.sandbox', true), 'sandbox', ['class' => 'inline']); ?> -
    • - Form->fieldHidden('namesilo_module',true); ?> -
    -
    + + Form->fieldHidden('namesilo_module', true); ?> + +
    -
    _('Namesilo.edit_row.add_btn');?>
    - _('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 9198399..2f84ab7 100644 --- a/views/default/manage.pdt +++ b/views/default/manage.pdt @@ -1,71 +1,70 @@ - $this->_('Namesilo.add_module_row', true), 'attributes'=>['href'=>$this->base_uri . 'settings/company/modules/addrow/' . $module->id]]; + $this->_('Namesilo.add_module_row', true), 'attributes' => ['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)), ['id'=>'manage_namesilo']); + $this->Widget->create($this->_('AdminCompanyModules.manage.boxtitle_manage', true, $this->Html->_($module->name, true)), ['id' => 'manage_namesilo']); ?> - -
    -

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

    -
    - +

    _('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_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');?> -
    -
    - +
    + _('Namesilo.manage.module_rows_no_results');?> +
    + + - Widget->end(); ?> - - \ No newline at end of file + + \ No newline at end of file diff --git a/views/default/pending.pdt b/views/default/pending.pdt index 616709e..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 d65edde..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 784bcf1..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)) { - ?> -
    + ?> +
    -
    - Form, $field->type], $field->params); + ?> +
    + Form, $field->type], $field->params); - // Draw each form field associated with this label - $tooltips = []; - 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([$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([$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 48fa524..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 77d2f81..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 2408c5e..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 3808297..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, ['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, ['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, ['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, ['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 1ebe6f5..5bee85e 100644 --- a/views/default/tab_client_hosts.pdt +++ b/views/default/tab_client_hosts.pdt @@ -1,21 +1,21 @@ -
    -

    _('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) { ?> @@ -31,29 +31,29 @@ - + ?> + - + - + +
    _('Namesilo.tab_hosts.field_hostname'); ?>_('Namesilo.tab_hosts.field_ip'); ?>
    host . '.' . $domain : false; ?>
    Form->fieldText('new_host'); echo '.' . $domain; ?>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 d3a28c9..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] ), [ 'id' => 'ns' . $i+1, 'class' => 'form-control', 'placeholder' => $this->_( 'Namesilo.tab_nameserver.field_ns', true, $i+1 ) ] ); ?> -
    - +
    + +
    + 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 +
    +
    + + + 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 e77a359..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.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,35 +30,35 @@ $this->Form->create(); ?>
    -

    _('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 32b608e..df74f17 100644 --- a/views/default/tab_client_whois.pdt +++ b/views/default/tab_client_whois.pdt @@ -1,102 +1,102 @@ - - Form->create(); ?> -
    -
    +
    +
    - +
    $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([$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) { - ?> - -
    -
    -
    -
    -
    - - +
    + + Form->end(); ?> \ No newline at end of file diff --git a/views/default/tab_dnssec.pdt b/views/default/tab_dnssec.pdt index 919892b..9b4fb4f 100644 --- a/views/default/tab_dnssec.pdt +++ b/views/default/tab_dnssec.pdt @@ -1,12 +1,11 @@ -
    -

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

    +

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

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

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

    -

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

    +

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

    @@ -19,7 +18,7 @@ records) > 0 && $vars->records[0]) { + if (count($vars->records) > 0 && $vars->records[0]) { foreach ($vars->records as $record) { ?> @@ -58,7 +57,7 @@
    -

    _('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/'); @@ -83,16 +82,16 @@
    - '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 44941c8..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) { ?> @@ -19,7 +18,7 @@ ip as $index=>$ip) { + foreach ($host->ip as $index => $ip) { ?> @@ -27,7 +26,7 @@ ip) < 12) { + if (count($host->ip) < 12) { ?> @@ -49,22 +48,23 @@ - +
    host . '.' . $domain : false; ?>
    Form->fieldText('new_host'); echo '.' . $domain; ?>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 d690d86..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]), ['id' => 'ns' . $i+1]); +
      +
        + - - + 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 7c8439d..b958625 100644 --- a/views/default/tab_settings.pdt +++ b/views/default/tab_settings.pdt @@ -1,5 +1,5 @@
    -

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

    +

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

    Form->create(); @@ -7,23 +7,24 @@
    • - _('Namesilo.tab_settings.verification_text'); echo $this->Html->ifSet($vars->registrant_verification_info->email_address); ?>: + _('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'); ?>!
    • + } else { + ?> _('Namesilo.tab_settings.not_verified'); ?>! - -
    • _('Namesilo.tab_settings.not_verified_warning'); ?>
    • -
    • - Form->fieldHidden('resend_verification_email', $this->Html->ifSet($vars->registrant_verification_info->email_address)); ?> -
    • - +
    • _('Namesilo.tab_settings.not_verified_warning'); ?>
    • +
    • + Form->fieldHidden('resend_verification_email', $this->Html->ifSet($vars->registrant_verification_info->email_address)); ?> +
    • +
    @@ -37,16 +38,16 @@ ?>
    -

    _('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', ['id' => 'registrar_lock_yes']); @@ -55,13 +56,13 @@ $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->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->fieldHidden('whois_privacy_before', $this->Html->ifSet($vars->whois_privacy)); @@ -69,9 +70,9 @@ $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 1902315..077c100 100644 --- a/views/default/tab_whois.pdt +++ b/views/default/tab_whois.pdt @@ -1,78 +1,79 @@ -
    -

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

    +

    _('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; + ?> +
      +

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

      +
      +
      +
        + params['for'], 0, strlen($key)) != $key) { continue; } + ?> +
      • + Form, $field->type], $field->params); - call_user_func_array([$this->Form, $input->type], $input->params); + // Draw each form field associated with this label + $tooltips = []; + foreach ($field->fields as $input) { - // 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'; + // Collect all tooltips to be displayed at the end + if ($input->type == 'tooltip') { + $tooltips[] = $input; + continue; + } - call_user_func_array([$this->Form, 'label'], $input->label->params); - } - } + call_user_func_array([$this->Form, $input->type], $input->params); - foreach ($tooltips as $tooltip) { - ?> - - _('AppController.tooltip.text');?> -
        Html->_($tooltip->params['message']);?>
        -
        - 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']); ?>
        +
        + +
      • + - - -
      -
      - +
    + - - _('Namesilo.tab_whois.field_submit'); ?>
    + Form->end(); ?> \ No newline at end of file diff --git a/views/default/transferstatus.pdt b/views/default/transferstatus.pdt index 565b17a..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 From c07e1b9afb42e92f805573fff35c621a60e91f18 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Wed, 18 Dec 2019 19:28:19 -0600 Subject: [PATCH 04/15] Fixed a "Trying to get property of non-object" error when creating a package --- namesilo.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/namesilo.php b/namesilo.php index 4487b5c..3ff674c 100644 --- a/namesilo.php +++ b/namesilo.php @@ -230,7 +230,7 @@ public function validateService($package, array $vars = null) 'valid' => [ 'rule' => ['array_key_exists', Configure::get('Namesilo.domain_fields.ca')['cawd']['options']], 'message' => Language::_('Namesilo.!error.CA.CIRAWhoisDisplay.invalid', true) - ] + ] ], 'caln' => [ 'empty' => [ @@ -243,7 +243,7 @@ public function validateService($package, array $vars = null) 'valid' => [ '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); @@ -989,6 +989,7 @@ public function getPackageFields($vars = null) $tlds = $this->getTlds($module_row); sort($tlds); + foreach ($tlds as $tld) { $tld_label = $fields->label($tld, 'tld_' . $tld); $tld_options->attach( @@ -2371,9 +2372,18 @@ private function getTlds($row) return unserialize(base64_decode($tlds)); } - $result = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true')->submit('getPrices'); - $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; @@ -2396,6 +2406,7 @@ private function getTlds($row) } } } + return $tlds; } From b352638d65be35f9c469926dcd27b38590c50025 Mon Sep 17 00:00:00 2001 From: Temporary Date: Thu, 23 Jan 2020 10:29:32 -0800 Subject: [PATCH 05/15] Updated config, updated readme, updated description --- README.md | 9 +++- config.json | 24 +++++++++-- language/en_us/namesilo.php | 3 +- namesilo.php | 85 ------------------------------------- 4 files changed, 30 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index c3a3aa4..89bcd4b 100644 --- a/README.md +++ b/README.md @@ -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/config.json b/config.json index 67fd6db..146c991 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { - "version": "1.9.0", - "name": "NameSilo Domains Module", - "description": "Resell domains through NameSilo.", + "version": "1.10.0", + "name": "Namesilo.name", + "description": "Namesilo.description", "authors": [ { "name": "Phillips Data Inc.", @@ -15,5 +15,21 @@ "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/language/en_us/namesilo.php b/language/en_us/namesilo.php index 12bae25..9b3972d 100644 --- a/language/en_us/namesilo.php +++ b/language/en_us/namesilo.php @@ -1,6 +1,7 @@ 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. * From 7f9b3fa5ad2261b4cf648f009f53fdb0d475d06a Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Sat, 1 Feb 2020 02:52:43 -0600 Subject: [PATCH 06/15] Added the "Create Packages" Function --- includes/namesilo_packages.php | 296 ++++++++++++++++++++ language/en_us/namesilo.php | 66 +++++ namesilo.php | 288 +++++++++++++++---- views/default/create_packages.pdt | 446 ++++++++++++++++++++++++++++++ views/default/edit_packages.pdt | 446 ++++++++++++++++++++++++++++++ 5 files changed, 1492 insertions(+), 50 deletions(-) create mode 100644 includes/namesilo_packages.php create mode 100644 views/default/create_packages.pdt create mode 100644 views/default/edit_packages.pdt diff --git a/includes/namesilo_packages.php b/includes/namesilo_packages.php new file mode 100644 index 0000000..d27859f --- /dev/null +++ b/includes/namesilo_packages.php @@ -0,0 +1,296 @@ +post = $_POST; + } + + public function process($vars) + { + Loader::loadModels($this, ['Languages']); + + $vars = array_merge($vars, $this->post); + unset($vars['_csrf_token']); + + // Fetch packages map + $module_row_id = isset($vars['module_row']) ? $vars['module_row'] : 0; + $packages_map = $this->getPackagesMap($module_row_id); + + // Process packages + foreach ($vars['pricing'] as $tld => $pricing) { + if (isset($pricing['tld']) && (bool)$pricing['tld']) { + // Get price rows for the current package + $price_rows = $this->getPriceRows($pricing); + + // Get module row + $module_row = $this->ModuleManager->getRow($module_row_id); + + // 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' => isset($vars['upgrades_use_renewal']) ? $vars['upgrades_use_renewal'] : 0, + 'module_id' => $module_row->module_id, + 'module_row' => $module_row_id, + 'pricing' => $price_rows, + 'taxable' => isset($vars['taxable']) ? $vars['taxable'] : 0, + 'meta' => [ + 'type' => 'domain', + 'tlds' => [$tld] + ], + 'select_group_type' => 'existing', + 'groups' => [ + isset($vars['package_group']) ? $vars['package_group'] : 0 + ], + '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 + $packages_map[$tld] = $this->savePackage($params, isset($packages_map[$tld]) ? $packages_map[$tld] : null); + + if (!empty($this->Packages->Input->errors())) { + return $this->Packages->Input->errors(); + } + } else { + unset($vars['pricing'][$tld]); + } + } + + $this->savePackagesMap($packages_map, $module_row_id); + $this->savePackagesVars($vars, $module_row_id); + + return true; + } + + public function getPackagesMap($module_row_id) + { + $query = $this->Record->select('value') + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'packages_map') + ->fetch(); + + if (!empty($query->value)) { + return json_decode($query->value, true); + } + + return []; + } + + public function savePackagesMap($packages_map, $module_row_id) + { + $query = $this->Record->select() + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'packages_map') + ->numResults(); + + $fields = [ + 'module_row_id' => $module_row_id, + 'key' => 'packages_map', + 'value' => json_encode($packages_map) + ]; + + if ($query) { + return $this->Record->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'packages_map') + ->update('module_row_meta', $fields); + } + + return $this->Record->insert('module_row_meta', $fields); + } + + public function getPackagesVars($module_row_id) + { + $query = $this->Record->select('value') + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'packages_vars') + ->fetch(); + + if (!empty($query->value)) { + return json_decode($query->value, true); + } + + return []; + } + + public function savePackagesVars($vars, $module_row_id) + { + $query = $this->Record->select() + ->from('module_row_meta') + ->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'packages_vars') + ->numResults(); + + // Get TLD prices + $prices = $this->getPrices(); + + foreach ($vars['pricing'] as $tld => $pricing) { + foreach ($pricing as $currency => $price_row) { + if ($currency !== 'tld') { + $vars['pricing'][$tld][$currency]['previous_registration_price'] = $prices[$tld][$currency]->registration; + $vars['pricing'][$tld][$currency]['previous_renewal_price'] = $prices[$tld][$currency]->renew; + } + } + } + + $fields = [ + 'module_row_id' => $module_row_id, + 'key' => 'packages_vars', + 'value' => json_encode($vars) + ]; + + + if ($query) { + return $this->Record->where('module_row_meta.module_row_id', '=', $module_row_id) + ->where('module_row_meta.key', '=', 'packages_vars') + ->update('module_row_meta', $fields); + } + + return $this->Record->insert('module_row_meta', $fields); + } + + private function savePackage($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; + } + + private function getPriceRows($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; + } + + 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; + } + + 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; + } +} diff --git a/language/en_us/namesilo.php b/language/en_us/namesilo.php index 12bae25..8a70168 100644 --- a/language/en_us/namesilo.php +++ b/language/en_us/namesilo.php @@ -17,6 +17,7 @@ $lang['Namesilo.manage.module_rows.delete'] = 'Delete'; $lang['Namesilo.manage.module_rows.confirm_delete'] = 'Are you sure you want to delete this account?'; $lang['Namesilo.manage.module_rows_no_results'] = 'There are no accounts.'; +$lang['Namesilo.manage.create_packages'] = 'Create Packages'; $lang['Namesilo.manage.sync_renew_dates'] = 'Sync Renew Dates'; $lang['Namesilo.manage.audit_domains'] = 'Audit Domains'; @@ -26,6 +27,66 @@ $lang['Namesilo.manage.audit_domains.no_issues'] = 'No issues detected.'; $lang['Namesilo.manage.audit_domains.results'] = 'Audit Results'; +// Create packages +$lang['Namesilo.manage.create_packages.box_title'] = 'Create Domain Packages'; +$lang['Namesilo.manage.create_packages.heading_basic'] = 'Basic'; +$lang['Namesilo.manage.create_packages.heading_module_options'] = 'Module Options'; +$lang['Namesilo.manage.create_packages.heading_available_tlds'] = 'Available TLDs'; +$lang['Namesilo.manage.create_packages.heading_pricing'] = 'Pricing'; +$lang['Namesilo.manage.create_packages.heading_group'] = 'Group Membership'; +$lang['Namesilo.manage.create_packages_heading.price_markup'] = 'Price Markup (%)'; +$lang['Namesilo.manage.create_packages_heading.renew_price_markup'] = 'Renewal Price Markup (%)'; +$lang['Namesilo.manage.create_packages_heading.options'] = 'Options'; +$lang['Namesilo.manage.create_packages_heading.tld'] = 'TLD'; +$lang['Namesilo.manage.create_packages_heading.currency'] = 'Currency'; +$lang['Namesilo.manage.create_packages_heading.previous_registration_price'] = 'Previous Registration Price'; +$lang['Namesilo.manage.create_packages_heading.previous_renewal_price'] = 'Previous Renewal Price'; +$lang['Namesilo.manage.create_packages_heading.current_registration_price'] = 'Current Registration Price'; +$lang['Namesilo.manage.create_packages_heading.current_renewal_price'] = 'Current Renewal Price'; +$lang['Namesilo.manage.create_packages_heading.price'] = 'Price'; +$lang['Namesilo.manage.create_packages_heading.renew_price'] = 'Renewal Price'; +$lang['Namesilo.manage.create_packages.text_tags'] = 'Tags:'; +$lang['Namesilo.manage.create_packages.field_packagename'] = 'Package Name'; +$lang['Namesilo.manage.create_packages.field_description'] = 'Description'; +$lang['Namesilo.manage.create_packages.field_description_html'] = 'HTML'; +$lang['Namesilo.manage.create_packages.field_description_text'] = 'Text'; +$lang['Namesilo.manage.create_packages.field_upgrades_use_renewal'] = 'Use renewal prices for package upgrades'; +$lang['Namesilo.manage.create_packages.field_price_enable_renews_all'] = 'Enable All Renewal Prices'; +$lang['Namesilo.manage.create_packages.field_taxable'] = 'Taxable'; +$lang['Namesilo.manage.create_packages.field_package_group'] = 'Package Group'; +$lang['Namesilo.manage.create_packages.text_create_packages'] = 'In order to prevent timeouts a maximum of %1$s packages can be saved at a time. Run this as many times as needed to create all packages.'; +$lang['Namesilo.manage.create_packages.create_packages_btn'] = 'Create Packages'; + +// Edit packages +$lang['Namesilo.manage.edit_packages.box_title'] = 'Edit Domain Packages'; +$lang['Namesilo.manage.edit_packages.heading_basic'] = 'Basic'; +$lang['Namesilo.manage.edit_packages.heading_module_options'] = 'Module Options'; +$lang['Namesilo.manage.edit_packages.heading_available_tlds'] = 'Available TLDs'; +$lang['Namesilo.manage.edit_packages.heading_pricing'] = 'Pricing'; +$lang['Namesilo.manage.edit_packages.heading_group'] = 'Group Membership'; +$lang['Namesilo.manage.edit_packages_heading.price_markup'] = 'Price Markup (%)'; +$lang['Namesilo.manage.edit_packages_heading.renew_price_markup'] = 'Renewal Price Markup (%)'; +$lang['Namesilo.manage.edit_packages_heading.options'] = 'Options'; +$lang['Namesilo.manage.edit_packages_heading.tld'] = 'TLD'; +$lang['Namesilo.manage.edit_packages_heading.currency'] = 'Currency'; +$lang['Namesilo.manage.edit_packages_heading.previous_registration_price'] = 'Previous Registration Price'; +$lang['Namesilo.manage.edit_packages_heading.previous_renewal_price'] = 'Previous Renewal Price'; +$lang['Namesilo.manage.edit_packages_heading.current_registration_price'] = 'Current Registration Price'; +$lang['Namesilo.manage.edit_packages_heading.current_renewal_price'] = 'Current Renewal Price'; +$lang['Namesilo.manage.edit_packages_heading.price'] = 'Price'; +$lang['Namesilo.manage.edit_packages_heading.renew_price'] = 'Renewal Price'; +$lang['Namesilo.manage.edit_packages.text_tags'] = 'Tags:'; +$lang['Namesilo.manage.edit_packages.field_packagename'] = 'Package Name'; +$lang['Namesilo.manage.edit_packages.field_description'] = 'Description'; +$lang['Namesilo.manage.edit_packages.field_description_html'] = 'HTML'; +$lang['Namesilo.manage.edit_packages.field_description_text'] = 'Text'; +$lang['Namesilo.manage.edit_packages.field_upgrades_use_renewal'] = 'Use renewal prices for package upgrades'; +$lang['Namesilo.manage.edit_packages.field_price_enable_renews_all'] = 'Enable All Renewal Prices'; +$lang['Namesilo.manage.edit_packages.field_taxable'] = 'Taxable'; +$lang['Namesilo.manage.edit_packages.field_package_group'] = 'Package Group'; +$lang['Namesilo.manage.edit_packages.text_edit_packages'] = 'In order to prevent timeouts a maximum of %1$s packages can be saved at a time. Run this as many times as needed to edit all packages.'; +$lang['Namesilo.manage.edit_packages.edit_packages_btn'] = 'Edit Packages'; + // Sync renew dates $lang['Namesilo.manage.sync_renew_dates.box_title'] = 'Sync Domain Renewal Dates'; $lang['Namesilo.manage.sync_renew_dates.description'] = "This tool synchronizes a service's renewal date with the domain's actual expiration date, taking into account the suspension threshold (as to ensure auto-renewal doesn't renew the domain if the customer hasn't paid)."; @@ -217,6 +278,9 @@ $lang['Namesilo.domain.CIRALanguage.en'] = 'English'; $lang['Namesilo.domain.CIRALanguage.fr'] = 'French'; +// Success messages +$lang['Namesilo.!success.packages_created'] = 'The packages have been successfully created.'; +$lang['Namesilo.!success.packages_updated'] = 'The packages have been successfully updated.'; // Errors $lang['Namesilo.!error.FRLegalType.format'] = 'Please select a valid Legal Type'; @@ -242,5 +306,7 @@ $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/namesilo.php b/namesilo.php index 3ff674c..ef283a0 100644 --- a/namesilo.php +++ b/namesilo.php @@ -39,7 +39,7 @@ public function __construct() $this->loadConfig(__DIR__ . DS . 'config.json'); // Load components required by this module - Loader::loadComponents($this, ['Input']); + Loader::loadComponents($this, ['Input', 'Record']); // Load the language required by this module Language::loadLang('namesilo', null, __DIR__ . DS . 'language' . DS); @@ -646,49 +646,126 @@ public function editPackage($package, array $vars = null) */ 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); + $action = isset($_GET['action']) ? $_GET['action'] : null; - # - # - # 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.sync_renew_dates', true), - 'attributes' => [ - 'href' => [ - 'href' => $this->base_uri . 'settings/company/modules/addrow/' - . $module->id . '?action=sync_renew_dates' + if ($action == 'create_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(); + $packages_vars = $this->NamesiloPackages->getPackagesVars($module_row->id); + + $vars = []; + $this->view = new View((!empty($packages_vars) ? 'edit_packages' : 'create_packages'), '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', 'Javascript', 'Widget', 'CurrencyFormat']); + Loader::loadModels($this, ['Languages', 'Settings', 'Currencies', 'Packages']); + + // Fetch TLD prices + $tlds = $this->getPrices(); + + // Get all currencies + $currencies = $this->Form->collapseObjectArray($this->Currencies->getAll(Configure::get('Blesta.company_id')), 'code', 'code'); + + // Fetch module rows + $module_rows = $this->getRowsOptions(); + + // Fetch all available package groups + $package_groups = $this->Form->collapseObjectArray( + $this->Packages->getAllGroups(Configure::get('Blesta.company_id')), + 'name', + 'id' + ); + + // Calculate maximum packages that can be created at a time + $max_packages = round((ini_get('max_input_vars') - 30) / ((count($currencies) * 3) + 1), 0, PHP_ROUND_HALF_DOWN); + + // Create packages + if (!empty($_POST)) { + $result = $this->NamesiloPackages->process($vars); + + if (is_array($result)) { + $error = reset($result); + $this->setMessage('error', $error); + } else { + $this->setMessage('success', Language::_('Namesilo.!success.packages_' . (!empty($packages_vars) ? 'updated' : 'created'), true)); + } + } + + // 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 : (!empty($packages_vars) ? (object)$packages_vars : (object)$vars)); + + $this->view->set('messages', $this->getMessages()); + $this->view->set('package_name_tags', $this->getPackageNameTags()); + + return $this->view->fetch(); + } 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); + + # + # + # 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.create_packages', true), + 'attributes' => [ + 'href' => [ + 'href' => $this->base_uri . 'settings/company/modules/manage/' + . $module->id . '?action=create_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' + ] ] - ] - ]; - $link_buttons[] = [ - 'name' => Language::_('Namesilo.manage.audit_domains', true), - 'attributes' => [ - 'href' => $this->base_uri . 'settings/company/modules/addrow/' - . $module->id . '?action=audit_domains' - ] - ]; - break; + ]; + break; + } } - } - $this->view->set('module', $module); - $this->view->set('link_buttons', $link_buttons); + $this->view->set('module', $module); + $this->view->set('link_buttons', $link_buttons); - // Load the helpers required for this view - Loader::loadHelpers($this, [ 'Form', 'Html', 'Widget' ]); + // Load the helpers required for this view + Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); - $this->view->set('module', $module); + $this->view->set('module', $module); - return $this->view->fetch(); + return $this->view->fetch(); + } } /** @@ -710,9 +787,9 @@ public function manageAddRow(array &$vars) // Load the helpers required for this view Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); - Loader::loadModels($this, ['Services', 'Record', 'ModuleManager']); + Loader::loadModels($this, ['Services', 'ModuleManager']); - $module_row = $this->getNamesiloRow(); + $module_row = $this->getRow(); $api = $this->getApi( $module_row->meta->user, @@ -734,7 +811,8 @@ public function manageAddRow(array &$vars) if (!empty($domain_list)) { foreach ($domain_list as $domain) { - $record = $this->Record->select('*')->from('services') + $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) @@ -763,9 +841,9 @@ public function manageAddRow(array &$vars) // Load the helpers required for this view Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); - Loader::loadModels($this, ['Services', 'Clients', 'Record', 'ModuleManager', 'ClientGroups']); + Loader::loadModels($this, ['Services', 'Clients', 'ModuleManager', 'ClientGroups']); - $module_row = $this->getNamesiloRow(); + $module_row = $this->getRow(); $api = $this->getApi( $module_row->meta->user, @@ -865,7 +943,7 @@ public function addModuleRow(array &$vars) if (isset($_POST['sync_services'])) { Loader::loadModels($this, ['ModuleManager', 'Services', 'Clients', 'ClientGroups']); - $module_row = $this->getNamesiloRow(); + $module_row = $this->getRow(); foreach ($_POST['sync_services'] as $service_id) { $api = $this->getApi( @@ -926,7 +1004,6 @@ public function addModuleRow(array &$vars) */ public function editModuleRow($module_row, array &$vars) { - // Same as adding return $this->addModuleRow($vars); } @@ -2340,11 +2417,11 @@ private function logRequest(NamesiloApi $api, NamesiloResponse $response) private function getTld($domain, $row = null) { if ($row == null) { - $row = $this->getNamesiloRow(); + $row = $this->getRow(); } if ($row == null) { - $row = $this->getNamesiloRow(); + $row = $this->getRow(); } $tlds = $this->getTlds($row); @@ -2516,23 +2593,134 @@ private function getRenewInfo($service_id, $api_object) } /** - * Retrieves the Namesilo module row + * Retrieves all the Namesilo prices * - * @return null|stdClass An stdClass object representing the module row if found, otherwise void + * @return array An array containing all the TLDs with their respective prices + */ + protected function getPrices() + { + 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')) + ]; + } + } + + 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 getNamesiloRow() + 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; + $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; } /** diff --git a/views/default/create_packages.pdt b/views/default/create_packages.pdt new file mode 100644 index 0000000..3ef353e --- /dev/null +++ b/views/default/create_packages.pdt @@ -0,0 +1,446 @@ + $message) { + if ($type == 'notice') { + $type = 'alert'; + } + ?> +
    +
    + × +
    + + +

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

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

    +
    +
    +
      +
    • + Form->label($this->_('Namesilo.manage.create_packages.text_tags', true)); + ?> +
      + Html->_($package_name_tags);?> +
      +
    • +
    +
      +
    • +
      +
        + + Html->ifSet($lang->code) == Configure::get('Blesta.language') ? ' class="current"' : '');?>> + Html->_($lang->name);?> + + +
      +
      + $lang) { + $found = false; + foreach ((array) $this->Html->ifSet($vars->names) as $name) { + $name = (object) $name; + + if ($this->Html->ifSet($name->lang) == $lang->code) { + $found = true; + break; + } + } + + $show_description = false; + $current_text_description = false; + foreach ((array)$this->Html->ifSet($vars->descriptions) as $description) { + $description = (object) $description; + + if ($this->Html->ifSet($description->lang) == $lang->code) { + if (!empty($description->text) || !empty($description->html)) { + $show_description = true; + $current_text_description = !empty($description->html); + } + break; + } + } + ?> +
      + +
      + +
      +
      +
    • +
    • + Form->fieldCheckbox('upgrades_use_renewal', '1', ($this->Html->ifSet($vars->upgrades_use_renewal, '1') == '1'), ['id' => 'upgrades_use_renewal']); + $this->Form->label($this->_('Namesilo.manage.create_packages.field_upgrades_use_renewal', true), 'upgrades_use_renewal', ['class' => 'inline']); + ?> + _('AppController.tooltip.text');?>
      _('Namesilo.!tooltip.upgrades_use_renewal');?>
      +
    • +
    +
    + +
    +

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

    +
    +
    +
      +
    • + Form->label($this->_('Namesilo.module_row', true), 'module_row'); + $this->Form->fieldSelect('module_row', $module_rows, $this->Html->ifSet($vars->module_row)); + ?> +
    • + +
    • + Form->label($this->_('Namesilo.package_fields.ns' . $i, true), 'namesilo_ns' . $i); + $this->Form->fieldText('meta[ns][]', $this->Html->ifSet($vars->meta['ns'][$i - 1]), ['id' => 'namesilo_ns' . $i]); + ?> +
    • + +
    +
    + +
    +

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

    +
    +
    + $max_packages) { + ?> +

    _('Namesilo.manage.create_packages.text_create_packages', false, $max_packages); ?>

    + + +
      +
    • +
      + $pricing) { + ?> +
      + Form->fieldCheckbox('pricing[' . $tld . '][tld]', '1', ($this->Html->ifSet($vars->pricing[$tld]['tld'], '0') == '1'), ['class' => 'tld', 'id' => trim($tld, '.')]); + $this->Form->label($tld, 'tld', ['class' => 'inline']); + ?> +
      + +
      +
    • +
    +
    + +
    +

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

    +
    +
    +
      +
    • + + + + + + + + + + + + + + + +
      _('Namesilo.manage.create_packages_heading.price_markup');?>_('Namesilo.manage.create_packages_heading.renew_price_markup');?>_('Namesilo.manage.create_packages_heading.options');?>
      + Form->fieldText('price_markup', $this->Html->ifSet($vars->price_markup), ['class' => 'stretch']);?> + + Form->fieldText('renew_price_markup', $this->Html->ifSet($vars->renew_price_markup), ['class' => 'stretch']);?> + + Form->fieldCheckbox('price_enable_renews_all', '1', ($this->Html->ifSet($vars->price_enable_renews_all, '1') == '1'), ['id' => 'price_enable_renews_all']); + $this->Form->label($this->_('Namesilo.manage.create_packages.field_price_enable_renews_all', true), 'price_enable_renews_all', ['class' => 'inline']); + ?> +
      +
        +
      • + Form->fieldCheckbox('taxable', '1', ($this->Html->ifSet($vars->taxable, '0') == '1'), ['id' => 'taxable']); + $this->Form->label($this->_('Namesilo.manage.create_packages.field_taxable', true), 'taxable', ['class' => 'inline']); + ?> +
      • +
      +
    • +
    • + + + + + + + + + + + + + + + $pricing) { + foreach ($currencies as $currency) { + ?> + + + + + + + + + + + + +
      _('Namesilo.manage.create_packages_heading.tld');?>_('Namesilo.manage.create_packages_heading.currency');?>_('Namesilo.manage.create_packages_heading.previous_registration_price');?>_('Namesilo.manage.create_packages_heading.previous_renewal_price');?>_('Namesilo.manage.create_packages_heading.current_registration_price');?>_('Namesilo.manage.create_packages_heading.current_renewal_price');?>_('Namesilo.manage.create_packages_heading.price');?>_('Namesilo.manage.create_packages_heading.renew_price');?>
      + Html->safe($tld);?> + + Html->safe($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']);?> + + 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]), ['class' => 'price_renews stretch']); + ?> +
      +
    • +
    +
    + +
    +

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

    +
    +
    +
      +
    • + Form->label($this->_('Namesilo.manage.create_packages.field_package_group', true), 'package_group'); + $this->Form->fieldSelect('package_group', $package_groups, $this->Html->ifSet($vars->package_group)); + ?> +
    • +
    +
    +
    + +
    +
    + Form->fieldSubmit('save', $this->_('Namesilo.manage.create_packages.create_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/edit_packages.pdt b/views/default/edit_packages.pdt new file mode 100644 index 0000000..a78a677 --- /dev/null +++ b/views/default/edit_packages.pdt @@ -0,0 +1,446 @@ + $message) { + if ($type == 'notice') { + $type = 'alert'; + } + ?> +
    +
    + × +
    + + +

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

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

    +
    +
    +
      +
    • + Form->label($this->_('Namesilo.manage.edit_packages.text_tags', true)); + ?> +
      + Html->_($package_name_tags);?> +
      +
    • +
    +
      +
    • +
      +
        + + Html->ifSet($lang->code) == Configure::get('Blesta.language') ? ' class="current"' : '');?>> + Html->_($lang->name);?> + + +
      +
      + $lang) { + $found = false; + foreach ((array) $this->Html->ifSet($vars->names) as $name) { + $name = (object) $name; + + if ($this->Html->ifSet($name->lang) == $lang->code) { + $found = true; + break; + } + } + + $show_description = false; + $current_text_description = false; + foreach ((array)$this->Html->ifSet($vars->descriptions) as $description) { + $description = (object) $description; + + if ($this->Html->ifSet($description->lang) == $lang->code) { + if (!empty($description->text) || !empty($description->html)) { + $show_description = true; + $current_text_description = !empty($description->html); + } + break; + } + } + ?> +
      + +
      + +
      +
      +
    • +
    • + Form->fieldCheckbox('upgrades_use_renewal', '1', ($this->Html->ifSet($vars->upgrades_use_renewal, '1') == '1'), ['id' => 'upgrades_use_renewal']); + $this->Form->label($this->_('Namesilo.manage.edit_packages.field_upgrades_use_renewal', true), 'upgrades_use_renewal', ['class' => 'inline']); + ?> + _('AppController.tooltip.text');?>
      _('Namesilo.!tooltip.upgrades_use_renewal');?>
      +
    • +
    +
    + +
    +

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

    +
    +
    +
      +
    • + Form->label($this->_('Namesilo.module_row', true), 'module_row'); + $this->Form->fieldSelect('module_row', $module_rows, $this->Html->ifSet($vars->module_row)); + ?> +
    • + +
    • + Form->label($this->_('Namesilo.package_fields.ns' . $i, true), 'namesilo_ns' . $i); + $this->Form->fieldText('meta[ns][]', $this->Html->ifSet($vars->meta['ns'][$i - 1]), ['id' => 'namesilo_ns' . $i]); + ?> +
    • + +
    +
    + +
    +

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

    +
    +
    + $max_packages) { + ?> +

    _('Namesilo.manage.edit_packages.text_edit_packages', false, $max_packages); ?>

    + + +
      +
    • +
      + $pricing) { + ?> +
      + Form->fieldCheckbox('pricing[' . $tld . '][tld]', '1', ($this->Html->ifSet($vars->pricing[$tld]['tld'], '0') == '1'), ['class' => 'tld', 'id' => trim($tld, '.')]); + $this->Form->label($tld, 'tld', ['class' => 'inline']); + ?> +
      + +
      +
    • +
    +
    + +
    +

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

    +
    +
    +
      +
    • + + + + + + + + + + + + + + + +
      _('Namesilo.manage.edit_packages_heading.price_markup');?>_('Namesilo.manage.edit_packages_heading.renew_price_markup');?>_('Namesilo.manage.edit_packages_heading.options');?>
      + Form->fieldText('price_markup', $this->Html->ifSet($vars->price_markup), ['class' => 'stretch']);?> + + Form->fieldText('renew_price_markup', $this->Html->ifSet($vars->renew_price_markup), ['class' => 'stretch']);?> + + Form->fieldCheckbox('price_enable_renews_all', '1', ($this->Html->ifSet($vars->price_enable_renews_all, '1') == '1'), ['id' => 'price_enable_renews_all']); + $this->Form->label($this->_('Namesilo.manage.edit_packages.field_price_enable_renews_all', true), 'price_enable_renews_all', ['class' => 'inline']); + ?> +
      +
        +
      • + Form->fieldCheckbox('taxable', '1', ($this->Html->ifSet($vars->taxable, '0') == '1'), ['id' => 'taxable']); + $this->Form->label($this->_('Namesilo.manage.edit_packages.field_taxable', true), 'taxable', ['class' => 'inline']); + ?> +
      • +
      +
    • +
    • + + + + + + + + + + + + + + + $pricing) { + foreach ($currencies as $currency) { + ?> + + + + + + + + + + + + +
      _('Namesilo.manage.edit_packages_heading.tld');?>_('Namesilo.manage.edit_packages_heading.currency');?>_('Namesilo.manage.edit_packages_heading.previous_registration_price');?>_('Namesilo.manage.edit_packages_heading.previous_renewal_price');?>_('Namesilo.manage.edit_packages_heading.current_registration_price');?>_('Namesilo.manage.edit_packages_heading.current_renewal_price');?>_('Namesilo.manage.edit_packages_heading.price');?>_('Namesilo.manage.edit_packages_heading.renew_price');?>
      + Html->safe($tld);?> + + Html->safe($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']);?> + + 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]), ['class' => 'price_renews stretch']); + ?> +
      +
    • +
    +
    + +
    +

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

    +
    +
    +
      +
    • + Form->label($this->_('Namesilo.manage.edit_packages.field_package_group', true), 'package_group'); + $this->Form->fieldSelect('package_group', $package_groups, $this->Html->ifSet($vars->package_group)); + ?> +
    • +
    +
    +
    + +
    +
    + Form->fieldSubmit('save', $this->_('Namesilo.manage.edit_packages.edit_packages_btn', true), ['class' => 'btn btn-primary pull-right']); + ?> +
    +
    + Form->end(); + + $this->Widget->end(); + ?> + + + + \ No newline at end of file From 1231f0740a7cd56dce366aaa884ecc04befb2157 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Thu, 2 Apr 2020 10:37:51 -0600 Subject: [PATCH 07/15] Added AJAX Support and Improved Code Quality --- includes/namesilo_packages.php | 335 +++++++++++++++++++----------- namesilo.php | 275 ++++++++++++++++-------- views/default/create_packages.pdt | 127 ++++++----- views/default/edit_packages.pdt | 127 ++++++----- views/default/tld_rows.pdt | 39 ++++ 5 files changed, 592 insertions(+), 311 deletions(-) create mode 100644 views/default/tld_rows.pdt diff --git a/includes/namesilo_packages.php b/includes/namesilo_packages.php index d27859f..e7df957 100644 --- a/includes/namesilo_packages.php +++ b/includes/namesilo_packages.php @@ -3,16 +3,11 @@ * Namesilo Packages Management * * @copyright Copyright (c) 2020, Phillips Data, Inc. - * @license http://opensource.org/licenses/mit-license.php MIT License - * @package blesta.components.modules.namesilo.packages + * @license http://opensource.org/licenses/mit-license.php MIT License + * @package blesta.components.modules.namesilo.packages */ class NamesiloPackages extends Namesilo { - /** - * @var array All POST data - */ - public $post; - /** * Initializes the class */ @@ -24,172 +19,232 @@ public function __construct() // Load the required models Loader::loadModels($this, ['ModuleManager', 'Packages']); - - // Set the post fields - $this->post = $_POST; } - public function process($vars) + /** + * Creates or updates the packages for each of the enabled TLDs + * + * @param array $vars An array containing the posted data + * @return bool True if all the packages has been created/updated successfully + */ + public function process(array $vars) { Loader::loadModels($this, ['Languages']); - $vars = array_merge($vars, $this->post); - unset($vars['_csrf_token']); - // Fetch packages map $module_row_id = isset($vars['module_row']) ? $vars['module_row'] : 0; - $packages_map = $this->getPackagesMap($module_row_id); + $tld_packages_map = $this->getPackagesMap($module_row_id); // Process packages - foreach ($vars['pricing'] as $tld => $pricing) { - if (isset($pricing['tld']) && (bool)$pricing['tld']) { - // Get price rows for the current package - $price_rows = $this->getPriceRows($pricing); - - // Get module row - $module_row = $this->ModuleManager->getRow($module_row_id); - - // 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' => isset($vars['upgrades_use_renewal']) ? $vars['upgrades_use_renewal'] : 0, - 'module_id' => $module_row->module_id, - 'module_row' => $module_row_id, - 'pricing' => $price_rows, - 'taxable' => isset($vars['taxable']) ? $vars['taxable'] : 0, - 'meta' => [ - 'type' => 'domain', - 'tlds' => [$tld] - ], - 'select_group_type' => 'existing', - 'groups' => [ - isset($vars['package_group']) ? $vars['package_group'] : 0 - ], - '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 + 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); + + // 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' => isset($vars['upgrades_use_renewal']) ? $vars['upgrades_use_renewal'] : 0, + 'module_id' => $module_row->module_id, + 'module_row' => $module_row_id, + 'pricing' => $price_rows, + 'taxable' => isset($vars['taxable']) ? $vars['taxable'] : 0, + 'meta' => [ + 'type' => 'domain', + 'tlds' => [$tld] + ], + 'select_group_type' => 'existing', + 'groups' => [ + isset($vars['package_group']) ? $vars['package_group'] : 0 + ], + '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]); } + } - // Add or update the package - $packages_map[$tld] = $this->savePackage($params, isset($packages_map[$tld]) ? $packages_map[$tld] : null); - if (!empty($this->Packages->Input->errors())) { - return $this->Packages->Input->errors(); - } - } else { - unset($vars['pricing'][$tld]); - } - } + $this->savePackagesMap($tld_packages_map, $module_row_id); + $this->saveSettings($vars, $module_row_id); - $this->savePackagesMap($packages_map, $module_row_id); - $this->savePackagesVars($vars, $module_row_id); + return true; + } - 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) { - $query = $this->Record->select('value') + $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', '=', 'packages_map') + ->where('module_row_meta.key', '=', 'tld_packages_map') ->fetch(); - if (!empty($query->value)) { - return json_decode($query->value, true); - } - - return []; + return !empty($tld_packages_map->value) ? json_decode($tld_packages_map->value, true) : []; } - public function savePackagesMap($packages_map, $module_row_id) + /** + * 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) { - $query = $this->Record->select() - ->from('module_row_meta') - ->where('module_row_meta.module_row_id', '=', $module_row_id) - ->where('module_row_meta.key', '=', 'packages_map') - ->numResults(); - $fields = [ 'module_row_id' => $module_row_id, - 'key' => 'packages_map', - 'value' => json_encode($packages_map) + 'key' => 'tld_packages_map', + 'value' => json_encode($vars) ]; - if ($query) { - return $this->Record->where('module_row_meta.module_row_id', '=', $module_row_id) - ->where('module_row_meta.key', '=', 'packages_map') - ->update('module_row_meta', $fields); - } - - return $this->Record->insert('module_row_meta', $fields); + return $this->Record->duplicate('module_row_meta.value', '=', $fields['value']) + ->insert('module_row_meta', $fields);; } - public function getPackagesVars($module_row_id) + /** + * 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) { - $query = $this->Record->select('value') + $settings = $this->Record->select('value') ->from('module_row_meta') ->where('module_row_meta.module_row_id', '=', $module_row_id) - ->where('module_row_meta.key', '=', 'packages_vars') + ->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($query->value)) { - return json_decode($query->value, true); + if (!empty($settings)) { + $settings['pricing'] = []; + foreach ($tld_pricing as $pricing) { + $settings['pricing'] = array_merge($settings['pricing'], json_decode($pricing->value, true)); + } } - return []; + return $settings; } - public function savePackagesVars($vars, $module_row_id) + /** + * 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) { - $query = $this->Record->select() - ->from('module_row_meta') - ->where('module_row_meta.module_row_id', '=', $module_row_id) - ->where('module_row_meta.key', '=', 'packages_vars') - ->numResults(); - - // Get TLD prices + // Save TLD pricing rows $prices = $this->getPrices(); foreach ($vars['pricing'] as $tld => $pricing) { + $tld_pricing = []; + foreach ($pricing as $currency => $price_row) { if ($currency !== 'tld') { - $vars['pricing'][$tld][$currency]['previous_registration_price'] = $prices[$tld][$currency]->registration; - $vars['pricing'][$tld][$currency]['previous_renewal_price'] = $prices[$tld][$currency]->renew; + $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' => 'packages_vars', + 'key' => 'tld_packages_settings', 'value' => json_encode($vars) ]; - - if ($query) { - return $this->Record->where('module_row_meta.module_row_id', '=', $module_row_id) - ->where('module_row_meta.key', '=', 'packages_vars') - ->update('module_row_meta', $fields); - } - - return $this->Record->insert('module_row_meta', $fields); + return $this->Record->duplicate('module_row_meta.value', '=', $fields['value']) + ->insert('module_row_meta', $fields); } - private function savePackage($params, $package_id = null) + /** + * 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 cancelation 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 @@ -217,7 +272,17 @@ private function savePackage($params, $package_id = null) return $package_id; } - private function getPriceRows($pricing) + /** + * 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 = []; @@ -241,6 +306,15 @@ private function getPriceRows($pricing) 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 @@ -265,6 +339,15 @@ private function parseNameTags(array $names, $tld) 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 @@ -287,10 +370,26 @@ private function parseDescriptionTags(array $descriptions, $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); + $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/namesilo.php b/namesilo.php index ef283a0..29c368b 100644 --- a/namesilo.php +++ b/namesilo.php @@ -24,12 +24,13 @@ class Namesilo extends Module /** * @var array Pending statutes */ - private static $pending = [ 'in_review', 'pending' ]; + private static $pending = ['in_review', 'pending']; + /** + * @var string Default module view path + */ private static $defaultModuleView; - private static $api; - /** * Initializes the module */ @@ -77,6 +78,7 @@ public function getServiceName($service) return $field->value; } } + return null; } @@ -136,6 +138,7 @@ public function getPackageServiceName($packages, array $vars = null) if (isset($vars['domain'])) { return $vars['domain']; } + return null; } @@ -253,6 +256,7 @@ public function validateService($package, array $vars = null) $this->Input->setRules($rules); return $this->Input->validates($vars); } + return true; } @@ -305,7 +309,7 @@ public function addService( (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 ] + ['years' => true, 'transfer' => isset($vars['transfer']) ? $vars['transfer'] : 1 ] ); // .ca and .us domains can't have traditional whois privacy @@ -328,10 +332,10 @@ public function addService( // Set all whois info from client ($vars['client_id']) if (!isset($this->Clients)) { - Loader::loadModels($this, [ 'Clients' ]); + Loader::loadModels($this, ['Clients']); } if (!isset($this->Contacts)) { - Loader::loadModels($this, [ 'Contacts' ]); + Loader::loadModels($this, ['Contacts']); } $client = $this->Clients->get($vars['client_id']); @@ -391,10 +395,6 @@ public function addService( // Handle registration $domains = new NamesiloDomains($api); - //$this->debug( $fields ); - //$this->Input->setErrors( array( 'errors' => array( 'Test' ) ) ); - //return; - $response = $domains->create($fields); $this->processResponse($api, $response); @@ -465,6 +465,7 @@ public function editService($package, $service, array $vars = [], $parent_packag $this->renewService($package, $service, $parent_package, $parent_service, $renew); unset($vars['renew']); } + return null; // All this handled by admin/client tabs instead } @@ -488,6 +489,7 @@ public function cancelService($package, $service, $parent_package = null, $paren return; } } + return; } @@ -512,6 +514,7 @@ public function suspendService($package, $service, $parent_package = null, $pare return; } } + return; } @@ -648,6 +651,9 @@ 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 == 'create_packages') { // Load Namesilo packages Loader::load(__DIR__ . DS . 'includes' . DS . 'namesilo_packages.php'); @@ -655,22 +661,27 @@ public function manageModule($module, array &$vars) // Fetch stored packages vars, if available $module_row = $this->getRow(); - $packages_vars = $this->NamesiloPackages->getPackagesVars($module_row->id); + $settings = $this->NamesiloPackages->getSettings($module_row->id); + $post = $vars; $vars = []; - $this->view = new View((!empty($packages_vars) ? 'edit_packages' : 'create_packages'), 'default'); + + $this->view = new View((!empty($settings) ? 'edit_packages' : 'create_packages'), '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', 'Javascript', 'Widget', 'CurrencyFormat']); - Loader::loadModels($this, ['Languages', 'Settings', 'Currencies', 'Packages']); // Fetch TLD prices $tlds = $this->getPrices(); // Get all currencies - $currencies = $this->Form->collapseObjectArray($this->Currencies->getAll(Configure::get('Blesta.company_id')), 'code', 'code'); + $currencies = $this->Form->collapseObjectArray( + $this->Currencies->getAll(Configure::get('Blesta.company_id')), + 'code', + 'code' + ); // Fetch module rows $module_rows = $this->getRowsOptions(); @@ -683,17 +694,26 @@ public function manageModule($module, array &$vars) ); // Calculate maximum packages that can be created at a time - $max_packages = round((ini_get('max_input_vars') - 30) / ((count($currencies) * 3) + 1), 0, PHP_ROUND_HALF_DOWN); + $max_packages = round( + (ini_get('max_input_vars') - 30) / ((count($currencies) * 3) + 1), + 0, + PHP_ROUND_HALF_DOWN + ); // Create packages - if (!empty($_POST)) { - $result = $this->NamesiloPackages->process($vars); + if (!empty($post)) { + $this->NamesiloPackages->process($post); - if (is_array($result)) { - $error = reset($result); - $this->setMessage('error', $error); + if (($errors = $this->NamesiloPackages->errors())) { + $this->setMessage('error', reset($errors)); } else { - $this->setMessage('success', Language::_('Namesilo.!success.packages_' . (!empty($packages_vars) ? 'updated' : 'created'), true)); + $this->setMessage( + 'success', + Language::_( + 'Namesilo.!success.packages_' . (!empty($settings) ? 'updated' : 'created'), + true + ) + ); } } @@ -704,18 +724,57 @@ public function manageModule($module, array &$vars) $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 : (!empty($packages_vars) ? (object)$packages_vars : (object)$vars)); + $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 == 'tld_rows') { + // 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); + + $this->view = new View('tld_rows', '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', 'CurrencyFormat']); + + // Fetch TLD prices + $tlds = $this->getPrices(); + + // Get all currencies + $currencies = $this->Form->collapseObjectArray( + $this->Currencies->getAll(Configure::get('Blesta.company_id')), + 'code', + 'code' + ); + + // Set view + $this->view->set('tlds', $tlds); + $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... @@ -758,10 +817,6 @@ public function manageModule($module, array &$vars) $this->view->set('module', $module); $this->view->set('link_buttons', $link_buttons); - - // Load the helpers required for this view - Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); - $this->view->set('module', $module); return $this->view->fetch(); @@ -779,16 +834,17 @@ public function manageAddRow(array &$vars) { $action = isset($_GET['action']) ? $_GET['action'] : null; - if ($action == 'audit_domains') { - $vars = []; - $this->view = new View('audit_domains', 'default'); - $this->view->base_uri = $this->base_uri; - $this->view->setDefaultView(self::$defaultModuleView); + // 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 required for this view - Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); - Loader::loadModels($this, ['Services', 'ModuleManager']); + // 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( @@ -831,18 +887,10 @@ public function manageAddRow(array &$vars) return $this->view->fetch(); } elseif ($action == 'sync_renew_dates') { - if (isset($_POST['sync_services'])) { - $post['sync_services'] = $_POST['sync_services']; + if (isset($vars['sync_services'])) { + $post['sync_services'] = $vars['sync_services']; } - $this->view = new View('sync_renew_dates', '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']); - Loader::loadModels($this, ['Services', 'Clients', 'ModuleManager', 'ClientGroups']); - $module_row = $this->getRow(); $api = $this->getApi( @@ -871,14 +919,6 @@ public function manageAddRow(array &$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); - - // Load the helpers required for this view - Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); - // Set unspecified checkboxes if (!empty($vars)) { if (empty($vars['sandbox'])) { @@ -909,7 +949,7 @@ public function manageEditRow($module_row, array &$vars) $this->view->setDefaultView(self::$defaultModuleView); // Load the helpers required for this view - Loader::loadHelpers($this, [ 'Form', 'Html', 'Widget' ]); + Loader::loadHelpers($this, ['Form', 'Html', 'Widget']); if (empty($vars)) { $vars = $module_row->meta; @@ -937,15 +977,12 @@ public function manageEditRow($module_row, array &$vars) */ public function addModuleRow(array &$vars) { - # - # TODO: this should be using $vars rather than $_POST - # - if (isset($_POST['sync_services'])) { + if (isset($vars['sync_services'])) { Loader::loadModels($this, ['ModuleManager', 'Services', 'Clients', 'ClientGroups']); $module_row = $this->getRow(); - foreach ($_POST['sync_services'] as $service_id) { + foreach ($vars['sync_services'] as $service_id) { $api = $this->getApi( $module_row->meta->user, $module_row->meta->key, @@ -962,6 +999,7 @@ public function addModuleRow(array &$vars) header('Location:' . $url[0].'?action=sync_renew_dates&msg=success'); exit(); } + $meta_fields = ['user', 'key', 'sandbox', 'portfolio', 'payment_id', 'namesilo_module']; $encrypted_fields = ['key']; @@ -1147,7 +1185,7 @@ public function getEmailTags() */ public function getAdminAddFields($package, $vars = null) { - Loader::loadHelpers($this, [ 'Form', 'Html' ]); + Loader::loadHelpers($this, ['Form', 'Html']); if ($package->meta->type == 'domain') { // Set default name servers @@ -1399,7 +1437,7 @@ private function buildDomainModuleFields($vars, $client = false) */ public function getAdminEditFields($package, $vars = null) { - Loader::loadHelpers($this, [ 'Html' ]); + Loader::loadHelpers($this, ['Html']); $fields = new ModuleFields(); @@ -1637,7 +1675,7 @@ public function tabSettings($package, $service, array $get = null, array $post = public function tabClientSettings($package, $service, array $get = null, array $post = null, array $files = null) { if (!isset($this->Clients)) { - Loader::loadModels($this, [ 'Clients' ]); + Loader::loadModels($this, ['Clients']); } foreach ($this->Clients->getCustomFieldValues($service->{'client_id'}) as $key => $value) { if ($value->{'name'} == 'Disable Domain Transfers' @@ -1697,7 +1735,7 @@ public function tabAdminActions($package, $service, array $get = null, array $po $this->view = new View('tab_admin_actions', 'default'); - Loader::loadHelpers($this, [ 'Form', 'Html' ]); + Loader::loadHelpers($this, ['Form', 'Html']); $this->view->set('vars', $vars); $this->view->setDefaultView(self::$defaultModuleView); @@ -1738,20 +1776,20 @@ private function manageWhois($view, $package, $service, array $get = null, array $this->view = new View($view, 'default'); // Load the helpers required for this view - Loader::loadHelpers($this, [ '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); - $sections = [ 'registrant', 'admin', 'tech', 'billing' ]; + $sections = ['registrant', 'admin', 'tech', 'billing']; $vars = new stdClass(); $whois_fields = Configure::get('Namesilo.whois_fields'); $fields = $this->serviceFieldsToObject($service->fields); - $domainInfo = $domains->getDomainInfo([ 'domain' => $fields->domain ]); + $domainInfo = $domains->getDomainInfo(['domain' => $fields->domain ]); if (self::$codes[$domainInfo->status()][1] == 'fail') { $this->processResponse($api, $domainInfo); return false; @@ -1786,7 +1824,7 @@ private function manageWhois($view, $package, $service, array $get = null, array $contacts = $temp = []; foreach ($contact_ids as $type => $id) { if (!isset($temp[$id])) { - $response = $domains->getContacts([ 'contact_id' => $id ]); + $response = $domains->getContacts(['contact_id' => $id ]); if (self::$codes[$response->status()][1] != 'fail') { $temp[$id] = $response->response()->contact; $contacts[$type] = $temp[$id]; @@ -1859,7 +1897,7 @@ private function manageNameservers( $this->view = new View($view, 'default'); // Load the helpers required for this view - Loader::loadHelpers($this, [ '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'); @@ -1885,7 +1923,7 @@ private function manageNameservers( $vars = (object)$post; } else { - $response = $dns->getList([ 'domain' => $fields->domain ])->response(); + $response = $dns->getList(['domain' => $fields->domain ])->response(); if (isset($response->nameservers)) { $vars->ns = []; @@ -1915,7 +1953,7 @@ private function getRegisteredHosts($package, $service) $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); $ns = new NamesiloDomainsNs($api); - $response = $ns->getInfo([ 'domain' => $fields->domain ])->response(); + $response = $ns->getInfo(['domain' => $fields->domain ])->response(); $host_obj = new stdClass(); $hosts = []; @@ -1978,7 +2016,7 @@ private function manageHosts($view, $package, $service, array $get = null, array $this->view = new View($view, 'default'); $this->view->base_uri = $this->base_uri; // Load the helpers required for this view - Loader::loadHelpers($this, [ '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'); @@ -2058,7 +2096,7 @@ private function manageDnssec($view, $package, $service, array $get = null, arra $this->view = new View($view, 'default'); $this->view->base_uri = $this->base_uri; // Load the helpers required for this view - Loader::loadHelpers($this, [ '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'); @@ -2112,6 +2150,7 @@ private function manageDnssec($view, $package, $service, array $get = null, arra } $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); } @@ -2187,7 +2226,7 @@ private function manageSettings( $vars = (object)$post; } } else { - $response = $domains->getRegistrarLock([ 'domain' => $fields->domain ])->response(); + $response = $domains->getRegistrarLock(['domain' => $fields->domain ])->response(); if (isset($response->locked)) { $vars->registrar_lock = $response->locked; } @@ -2219,6 +2258,7 @@ private function manageSettings( $this->view->set('vars', $vars); $this->view->setDefaultView(self::$defaultModuleView); + return $this->view->fetch(); } @@ -2234,7 +2274,7 @@ public function checkAvailability($domain) $api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true'); $domains = new NamesiloDomains($api); - $result = $domains->check([ 'domains' => $domain ]); + $result = $domains->check(['domains' => $domain ]); if (self::$codes[$result->status()][1] == 'fail') { return false; @@ -2243,6 +2283,7 @@ public function checkAvailability($domain) $response = $result->response(); $available = isset($response->available->{'domain'}) && $response->available->{'domain'} == $domain; + return $available; } @@ -2310,8 +2351,9 @@ public function validateConnection($key, $user, $sandbox) { $api = $this->getApi($user, $key, $sandbox == 'true'); $domains = new NamesiloDomains($api); - $response = $domains->check([ 'domains' => 'example.com' ]); + $response = $domains->check(['domains' => 'example.com']); $this->processResponse($api, $response); + return true; } @@ -2341,6 +2383,7 @@ public function validatePortfolio($portfolio, $key, $user, $sandbox) return false; } } + return true; } @@ -2389,7 +2432,7 @@ private function processResponse(NamesiloApi $api, NamesiloResponse $response) // Set errors, if any if (self::$codes[$status][1] == 'fail') { $errors = $response->errors() ? $response->errors() : []; - $this->Input->setErrors([ 'errors' => (array)$errors ]); + $this->Input->setErrors(['errors' => (array)$errors ]); } } @@ -2432,6 +2475,7 @@ private function getTld($domain, $row = null) return $tld; } } + return strstr($domain, '.'); } @@ -2443,12 +2487,17 @@ private function getTld($domain, $row = null) */ private function getTlds($row) { - $tlds = Cache::fetchCache('tld_cache', 'Namesilo' . DS); + // 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 ($tlds !== false) { - return unserialize(base64_decode($tlds)); + if ($cache) { + return unserialize(base64_decode($cache)); } + // Fetch namesilo TLDs $tlds = []; if (empty($row)) { @@ -2468,18 +2517,19 @@ private function getTlds($row) $tlds[] = '.' . $tld; } + // Save the TLDs results to the cache if (count($tlds) > 0) { if (Configure::get('Caching.on') && is_writable(CACHEDIR)) { try { Cache::writeCache( - 'tld_cache', + 'tlds', base64_encode(serialize($tlds)), strtotime(Configure::get('Blesta.cache_length')) - time(), - 'Namesilo' . DS + Configure::get('Blesta.company_id') . DS . 'modules' . DS . 'namesilo' . DS ); } catch (Exception $e) { - // Couldn't cache - error_log($e); + // Write to cache failed, so disable caching + Configure::set('Caching.on', false); } } } @@ -2556,6 +2606,7 @@ private function getRenewInfo($service_id, $api_object) 'detail' => $api_response->detail ] ]; + return $vars; } elseif (strtotime($api_response->expires) < 946706400) { $vars = [ @@ -2565,6 +2616,7 @@ private function getRenewInfo($service_id, $api_object) 'detail' => $api_response->expires . 'expires date from the API cannot possibly be valid' ] ]; + return $vars; } @@ -2599,6 +2651,16 @@ private function getRenewInfo($service_id, $api_object) */ 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(); @@ -2628,12 +2690,39 @@ protected function getPrices() 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')) + '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; } @@ -2723,6 +2812,17 @@ private function getRowsOptions() 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 * @@ -2730,6 +2830,11 @@ private function getRowsOptions() */ public function debug($data) { - mail(self::$debug_to, 'Namesilo Module ' . ' Debug', var_export($data, true), "From: blesta@localhost\n\n"); + mail( + self::$debug_to, + 'Namesilo Module Debug', + var_export($data, true), + "From: blesta@localhost\n\n" + ); } } diff --git a/views/default/create_packages.pdt b/views/default/create_packages.pdt index 3ef353e..6f4de21 100644 --- a/views/default/create_packages.pdt +++ b/views/default/create_packages.pdt @@ -239,7 +239,7 @@
  • - +
    @@ -253,45 +253,6 @@ - $pricing) { - foreach ($currencies as $currency) { - ?> - - - - - - - - - - -
    _('Namesilo.manage.create_packages_heading.tld');?>
    - Html->safe($tld);?> - - Html->safe($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']);?> - - 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]), ['class' => 'price_renews stretch']); - ?> -
  • @@ -330,6 +291,30 @@ - - \ No newline at end of file diff --git a/views/default/create_packages.pdt b/views/default/manage_packages.pdt similarity index 96% rename from views/default/create_packages.pdt rename to views/default/manage_packages.pdt index 0fb4c17..c4ec39f 100644 --- a/views/default/create_packages.pdt +++ b/views/default/manage_packages.pdt @@ -277,7 +277,7 @@
    Form->fieldSubmit('save', $this->_('Namesilo.manage.create_packages.create_packages_btn', true), ['class' => 'btn btn-primary pull-right']); + $this->Form->fieldSubmit('save', $this->_('Namesilo.manage.create_packages.save_packages_btn', true), ['class' => 'btn btn-primary pull-right']); ?>
    @@ -385,28 +385,23 @@ if (this.checked) { $('.price_enable_renews').each(function() { $(this).prop('checked', true); - $(this).parent().find('.price_renews').prop('disabled', false).css('background', '#FFF').data('locked', false); + $(this).parent().find('.price_renews').prop('disabled', false).css('background', '#FFF'); }); $('input[name="renew_price_markup"]').trigger('input'); } else { $('.price_enable_renews').each(function() { - var price = $(this).parent().parent().find('.price').val(); - $(this).prop('checked', false); - $(this).parent().find('.price_renews').val(price).prop('disabled', true).css('background', '#FFF').data('locked', false); + $(this).parent().find('.price_renews').prop('disabled', true).css('background', '#FFF').data('locked', false); }); } }); $('#tld_rows').on('change', '.price_enable_renews', function() { if (this.checked) { - $(this).parent().find('.price_renews').prop('disabled', false).css('background', '#FFF').data('locked', false); - $('input[name="renew_price_markup"]').trigger('input'); + $(this).parent().find('.price_renews').prop('disabled', false).css('background', '#FFF'); } else { - var price = $(this).parent().parent().find('.price').val(); - - $(this).parent().find('.price_renews').val(price).prop('disabled', true).css('background', '#FFF').data('locked', false); + $(this).parent().find('.price_renews').prop('disabled', true).css('background', '#FFF').data('locked', false); } }); From 24b89f3b537b49314dc7e84d2058e37a2c4fad08 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Thu, 9 Apr 2020 13:26:32 -0600 Subject: [PATCH 11/15] Fixed a bug where unchecked checkboxes are not saved --- includes/namesilo_packages.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/includes/namesilo_packages.php b/includes/namesilo_packages.php index b568965..6330911 100644 --- a/includes/namesilo_packages.php +++ b/includes/namesilo_packages.php @@ -45,6 +45,15 @@ public function process(array $vars) // 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 = [ @@ -52,19 +61,17 @@ public function process(array $vars) 'descriptions' => $this->parseDescriptionTags($vars['descriptions'], $tld), 'status' => 'active', 'qty_unlimited' => 'true', - 'upgrades_use_renewal' => isset($vars['upgrades_use_renewal']) ? $vars['upgrades_use_renewal'] : 0, + 'upgrades_use_renewal' => $vars['upgrades_use_renewal'], 'module_id' => $module_row->module_id, 'module_row' => $module_row_id, 'pricing' => $price_rows, - 'taxable' => isset($vars['taxable']) ? $vars['taxable'] : 0, + 'taxable' => $vars['taxable'], 'meta' => [ 'type' => 'domain', 'tlds' => [$tld] ], 'select_group_type' => 'existing', - 'groups' => [ - isset($vars['package_group']) ? $vars['package_group'] : 0 - ], + 'groups' => [$vars['package_group']], 'company_id' => Configure::get('Blesta.company_id') ]; $params['meta'] = array_merge($params['meta'], $vars['meta']); @@ -190,6 +197,11 @@ public function saveSettings(array $vars, $module_row_id) 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; From 330cf20824d0dbd95d0bdb734483a4c86529e67b Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Thu, 9 Apr 2020 15:42:17 -0600 Subject: [PATCH 12/15] Updated language definitions and disabled unchecked renewal fields --- language/en_us/namesilo.php | 61 +++++++++++++++---------------- namesilo.php | 6 +-- views/default/manage_packages.pdt | 56 ++++++++++++++-------------- views/default/tld_rows.pdt | 6 ++- 4 files changed, 66 insertions(+), 63 deletions(-) diff --git a/language/en_us/namesilo.php b/language/en_us/namesilo.php index ef6e4a8..726140d 100644 --- a/language/en_us/namesilo.php +++ b/language/en_us/namesilo.php @@ -27,35 +27,35 @@ $lang['Namesilo.manage.audit_domains.no_issues'] = 'No issues detected.'; $lang['Namesilo.manage.audit_domains.results'] = 'Audit Results'; -// Create packages -$lang['Namesilo.manage.create_packages.box_title'] = 'Create Domain Packages'; -$lang['Namesilo.manage.create_packages.heading_basic'] = 'Basic'; -$lang['Namesilo.manage.create_packages.heading_module_options'] = 'Module Options'; -$lang['Namesilo.manage.create_packages.heading_available_tlds'] = 'Available TLDs'; -$lang['Namesilo.manage.create_packages.heading_pricing'] = 'Pricing'; -$lang['Namesilo.manage.create_packages.heading_group'] = 'Group Membership'; -$lang['Namesilo.manage.create_packages_heading.price_markup'] = 'Price Markup (%)'; -$lang['Namesilo.manage.create_packages_heading.renew_price_markup'] = 'Renewal Price Markup (%)'; -$lang['Namesilo.manage.create_packages_heading.options'] = 'Options'; -$lang['Namesilo.manage.create_packages_heading.tld'] = 'TLD'; -$lang['Namesilo.manage.create_packages_heading.currency'] = 'Currency'; -$lang['Namesilo.manage.create_packages_heading.previous_registration_price'] = 'Previous Registration Price'; -$lang['Namesilo.manage.create_packages_heading.previous_renewal_price'] = 'Previous Renewal Price'; -$lang['Namesilo.manage.create_packages_heading.current_registration_price'] = 'Current Registration Price'; -$lang['Namesilo.manage.create_packages_heading.current_renewal_price'] = 'Current Renewal Price'; -$lang['Namesilo.manage.create_packages_heading.price'] = 'Price'; -$lang['Namesilo.manage.create_packages_heading.renew_price'] = 'Renewal Price'; -$lang['Namesilo.manage.create_packages.text_tags'] = 'Tags:'; -$lang['Namesilo.manage.create_packages.field_packagename'] = 'Package Name'; -$lang['Namesilo.manage.create_packages.field_description'] = 'Description'; -$lang['Namesilo.manage.create_packages.field_description_html'] = 'HTML'; -$lang['Namesilo.manage.create_packages.field_description_text'] = 'Text'; -$lang['Namesilo.manage.create_packages.field_upgrades_use_renewal'] = 'Use renewal prices for package upgrades'; -$lang['Namesilo.manage.create_packages.field_price_enable_renews_all'] = 'Enable All Renewal Prices'; -$lang['Namesilo.manage.create_packages.field_taxable'] = 'Taxable'; -$lang['Namesilo.manage.create_packages.field_package_group'] = 'Package Group'; -$lang['Namesilo.manage.create_packages.text_create_packages'] = 'In order to prevent timeouts a maximum of %1$s packages can be saved at a time. Run this as many times as needed to create all packages.'; -$lang['Namesilo.manage.create_packages.save_packages_btn'] = 'Save Packages'; +// Manage packages +$lang['Namesilo.manage.manage_packages.box_title'] = 'Manage Domain Packages'; +$lang['Namesilo.manage.manage_packages.heading_basic'] = 'Basic'; +$lang['Namesilo.manage.manage_packages.heading_module_options'] = 'Module Options'; +$lang['Namesilo.manage.manage_packages.heading_available_tlds'] = 'Available TLDs'; +$lang['Namesilo.manage.manage_packages.heading_pricing'] = 'Pricing'; +$lang['Namesilo.manage.manage_packages.heading_group'] = 'Group Membership'; +$lang['Namesilo.manage.manage_packages_heading.price_markup'] = 'Price Markup (%)'; +$lang['Namesilo.manage.manage_packages_heading.renew_price_markup'] = 'Renewal Price Markup (%)'; +$lang['Namesilo.manage.manage_packages_heading.options'] = 'Options'; +$lang['Namesilo.manage.manage_packages_heading.tld'] = 'TLD'; +$lang['Namesilo.manage.manage_packages_heading.currency'] = 'Currency'; +$lang['Namesilo.manage.manage_packages_heading.previous_registration_price'] = 'Previous Registration Price'; +$lang['Namesilo.manage.manage_packages_heading.previous_renewal_price'] = 'Previous Renewal Price'; +$lang['Namesilo.manage.manage_packages_heading.current_registration_price'] = 'Current Registration Price'; +$lang['Namesilo.manage.manage_packages_heading.current_renewal_price'] = 'Current Renewal Price'; +$lang['Namesilo.manage.manage_packages_heading.price'] = 'Price'; +$lang['Namesilo.manage.manage_packages_heading.renew_price'] = 'Renewal Price'; +$lang['Namesilo.manage.manage_packages.text_tags'] = 'Tags:'; +$lang['Namesilo.manage.manage_packages.field_packagename'] = 'Package Name'; +$lang['Namesilo.manage.manage_packages.field_description'] = 'Description'; +$lang['Namesilo.manage.manage_packages.field_description_html'] = 'HTML'; +$lang['Namesilo.manage.manage_packages.field_description_text'] = 'Text'; +$lang['Namesilo.manage.manage_packages.field_upgrades_use_renewal'] = 'Use renewal prices for package upgrades'; +$lang['Namesilo.manage.manage_packages.field_price_enable_renews_all'] = 'Enable All Renewal Prices'; +$lang['Namesilo.manage.manage_packages.field_taxable'] = 'Taxable'; +$lang['Namesilo.manage.manage_packages.field_package_group'] = 'Package Group'; +$lang['Namesilo.manage.manage_packages.text_manage_packages'] = 'In order to prevent timeouts a maximum of %1$s packages can be saved at a time. Run this as many times as needed to save all packages.'; +$lang['Namesilo.manage.manage_packages.save_packages_btn'] = 'Save Packages'; // Sync renew dates $lang['Namesilo.manage.sync_renew_dates.box_title'] = 'Sync Domain Renewal Dates'; @@ -249,8 +249,7 @@ $lang['Namesilo.domain.CIRALanguage.fr'] = 'French'; // Success messages -$lang['Namesilo.!success.packages_created'] = 'The packages have been successfully created.'; -$lang['Namesilo.!success.packages_updated'] = 'The packages have been successfully updated.'; +$lang['Namesilo.!success.packages_saved'] = 'The packages have been successfully saved.'; // Errors $lang['Namesilo.!error.FRLegalType.format'] = 'Please select a valid Legal Type'; diff --git a/namesilo.php b/namesilo.php index ec59957..9ae759f 100644 --- a/namesilo.php +++ b/namesilo.php @@ -693,14 +693,14 @@ public function manageModule($module, array &$vars) 'id' ); - // Calculate maximum packages that can be created at a time + // 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 ); - // Create packages + // Save packages if (!empty($post)) { $this->NamesiloPackages->process($post); @@ -710,7 +710,7 @@ public function manageModule($module, array &$vars) $this->setMessage( 'success', Language::_( - 'Namesilo.!success.packages_' . (!empty($settings) ? 'updated' : 'created'), + 'Namesilo.!success.packages_saved', true ) ); diff --git a/views/default/manage_packages.pdt b/views/default/manage_packages.pdt index c4ec39f..529913b 100644 --- a/views/default/manage_packages.pdt +++ b/views/default/manage_packages.pdt @@ -29,19 +29,19 @@ Widget->clear(); - $this->Widget->create($this->_('Namesilo.manage.create_packages.box_title', true)); + $this->Widget->create($this->_('Namesilo.manage.manage_packages.box_title', true)); $this->Form->create(null, ['id' => 'add_packages', 'class' => 'disable-on-submit']); ?>
    -

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

    +

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

    • Form->label($this->_('Namesilo.manage.create_packages.text_tags', true)); + $this->Form->label($this->_('Namesilo.manage.manage_packages.text_tags', true)); ?>
      Html->_($package_name_tags);?> @@ -93,13 +93,13 @@
      -

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

      +

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

        @@ -167,13 +167,13 @@
      -

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

      +

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

      $max_packages) { ?> -

      _('Namesilo.manage.create_packages.text_create_packages', false, $max_packages); ?>

      +

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

      @@ -199,7 +199,7 @@
      -

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

      +

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

        @@ -207,9 +207,9 @@ - - - + + + @@ -223,7 +223,7 @@ @@ -233,7 +233,7 @@
      • Form->fieldCheckbox('taxable', '1', ($this->Html->ifSet($vars->taxable, '0') == '1'), ['id' => 'taxable']); - $this->Form->label($this->_('Namesilo.manage.create_packages.field_taxable', true), 'taxable', ['class' => 'inline']); + $this->Form->label($this->_('Namesilo.manage.manage_packages.field_taxable', true), 'taxable', ['class' => 'inline']); ?>
      • @@ -242,14 +242,14 @@
        _('Namesilo.manage.create_packages_heading.price_markup');?>_('Namesilo.manage.create_packages_heading.renew_price_markup');?>_('Namesilo.manage.create_packages_heading.options');?>_('Namesilo.manage.manage_packages_heading.price_markup');?>_('Namesilo.manage.manage_packages_heading.renew_price_markup');?>_('Namesilo.manage.manage_packages_heading.options');?>
        Form->fieldCheckbox('price_enable_renews_all', '1', ($this->Html->ifSet($vars->price_enable_renews_all, '1') == '1'), ['id' => 'price_enable_renews_all']); - $this->Form->label($this->_('Namesilo.manage.create_packages.field_price_enable_renews_all', true), 'price_enable_renews_all', ['class' => 'inline']); + $this->Form->label($this->_('Namesilo.manage.manage_packages.field_price_enable_renews_all', true), 'price_enable_renews_all', ['class' => 'inline']); ?>
        - - - - - - - - + + + + + + + + @@ -260,13 +260,13 @@
        -

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

        +

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

        • Form->label($this->_('Namesilo.manage.create_packages.field_package_group', true), 'package_group'); + $this->Form->label($this->_('Namesilo.manage.manage_packages.field_package_group', true), 'package_group'); $this->Form->fieldSelect('package_group', $package_groups, $this->Html->ifSet($vars->package_group)); ?>
        • @@ -277,7 +277,7 @@
          Form->fieldSubmit('save', $this->_('Namesilo.manage.create_packages.save_packages_btn', true), ['class' => 'btn btn-primary pull-right']); + $this->Form->fieldSubmit('save', $this->_('Namesilo.manage.manage_packages.save_packages_btn', true), ['class' => 'btn btn-primary pull-right']); ?>
          diff --git a/views/default/tld_rows.pdt b/views/default/tld_rows.pdt index 84bb5d5..c028329 100644 --- a/views/default/tld_rows.pdt +++ b/views/default/tld_rows.pdt @@ -33,8 +33,12 @@ foreach ($this->Html->ifSet($currencies, []) as $currency) {
        From 0a73f96f0893ce27c61deee5e93b60a347801cd3 Mon Sep 17 00:00:00 2001 From: Jonathan Reissmueller Date: Fri, 1 May 2020 11:15:28 -0700 Subject: [PATCH 13/15] Added new composer file --- composer.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e3e763a --- /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": "you@youremail.com" + }, + { + "name": "KnownHost LLC", + "email": "you@youremail.com" + }, + { + "name": "NETLINK IT SERVICES", + "email": "you@youremail.com" + } + ] +} From 4a5f887448329ded850f6aa69f559acaec967005 Mon Sep 17 00:00:00 2001 From: Jonathan Reissmueller Date: Mon, 4 May 2020 08:50:54 -0700 Subject: [PATCH 14/15] Fixed whitespace Added email addresses to composer file --- composer.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index e3e763a..f2ef508 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,15 @@ "authors": [ { "name": "Phillips Data, Inc.", - "email": "you@youremail.com" + "email": "jonathan@phillipsdata.com" }, - { - "name": "KnownHost LLC", - "email": "you@youremail.com" - }, - { - "name": "NETLINK IT SERVICES", - "email": "you@youremail.com" - } + { + "name": "KnownHost LLC", + "email": "support@knownhost.com" + }, + { + "name": "NETLINK IT SERVICES", + "email": "info@netlink.ie" + } ] } From f47da68a3a3ef5f25c5c5e1042c7ceb59ea01d53 Mon Sep 17 00:00:00 2001 From: Dipendra Date: Tue, 12 May 2020 20:33:21 +0545 Subject: [PATCH 15/15] Fixed Check Availability error --- namesilo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/namesilo.php b/namesilo.php index 8ec2a7d..753c656 100644 --- a/namesilo.php +++ b/namesilo.php @@ -2197,7 +2197,7 @@ public function checkAvailability($domain) $response = $result->response(); - $available = isset($response->available->{'domain'}) && $response->available->{'domain'} == $domain; + $available = isset($response->available->{'domain'}) && $response->available->domain->{'0'} == $domain; return $available; }
        _('Namesilo.manage.create_packages_heading.tld');?>_('Namesilo.manage.create_packages_heading.currency');?>_('Namesilo.manage.create_packages_heading.previous_registration_price');?>_('Namesilo.manage.create_packages_heading.previous_renewal_price');?>_('Namesilo.manage.create_packages_heading.current_registration_price');?>_('Namesilo.manage.create_packages_heading.current_renewal_price');?>_('Namesilo.manage.create_packages_heading.price');?>_('Namesilo.manage.create_packages_heading.renew_price');?>_('Namesilo.manage.manage_packages_heading.tld');?>_('Namesilo.manage.manage_packages_heading.currency');?>_('Namesilo.manage.manage_packages_heading.previous_registration_price');?>_('Namesilo.manage.manage_packages_heading.previous_renewal_price');?>_('Namesilo.manage.manage_packages_heading.current_registration_price');?>_('Namesilo.manage.manage_packages_heading.current_renewal_price');?>_('Namesilo.manage.manage_packages_heading.price');?>_('Namesilo.manage.manage_packages_heading.renew_price');?>
        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]), ['class' => 'price_renews stretch', 'data-locked' => 'false']); + $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)); ?>