Advertisement
johnburn

Decoded for: [email protected]

May 31st, 2011
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. <?php
  2. class TBT_Bss_Model_System_Config_Backend_License extends Mage_Core_Model_Config_Data {
  3.     public function _afterSave() {
  4.         $this->_validateLicense($this->getValue());
  5.         return parent::_afterSave();
  6.     }
  7.     private function _validateLicense($license) {
  8.         if ($this->isValueChanged()) {
  9.             $this->_checkLicenseOverServer($license);
  10.         } else {
  11.             if ($this->getValue()) {
  12.                 return $this;
  13.             } else {
  14.                 throw new Exception("Please specify your license key.");
  15.             }
  16.         }
  17.         return $this;
  18.     }
  19.     private function _checkLicenseOverServer($license) {
  20.         $response = Mage::helper('bss/loyalty_checker')->fetchValidationResponse($license);
  21.         if ($response == 'license_valid') {
  22.             Mage::getSingleton('core/session')->addSuccess("License key has been validated.");
  23.         } else {
  24.             if (empty($response)) {
  25.                 throw new Exception("Sweet Tooth was unable to contact the license registration server to validate your license.  This could be due to many things, but it's most likely because either:
  26.                   (A) your server is blocking traffic to our servers, OR (B) because your server is not configured properly as to the specifications of Magento.  
  27.                   Please run the Sweet Tooth 'Test Sweet' diagnostics utility, contact your webhost and/or contact our support department so we can help you get back on your feet!");
  28.             } else {
  29.                 throw new Exception("License key is invalid. ({$response})");
  30.             }
  31.         }
  32.         return $this;
  33.     }
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement