/** * Check request for errors found by Helper and Observer. It will print error messages if errors found and * in that case set value to 0. * * @return FACTFinder_Core_Model_System_Config_Backend_Enabled */ public function save() { parent::save(); Mage::app()->cleanCache(); $this->_checkConfiguration(); return $this; }
public function save() { $enabled = $this->getValue(); //get the value from our config $resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $writeConnection = $resource->getConnection('core_write'); //die($enabled); $query = 'SELECT attribute_id FROM eav_attribute WHERE `attribute_code` = \'telephone\''; $attribute_id = $readConnection->fetchOne($query); $query = 'UPDATE eav_attribute SET `is_required` = \'' . $enabled . '\' WHERE `attribute_code` = \'telephone\''; $writeConnection->query($query); if ($enabled == 1) { $validationRules = 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}'; $query = 'UPDATE customer_eav_attribute SET `validate_rules` = \'' . $validationRules . '\' WHERE `attribute_id` = \'' . $attribute_id . '\''; $writeConnection->query($query); } else { $query = 'UPDATE customer_eav_attribute SET `validate_rules` = NULL WHERE `attribute_id` = \'' . $attribute_id . '\''; $writeConnection->query($query); } //die($attribute_id); return parent::save(); //call original save method so whatever happened //before still happens (the value saves) }
/** * Perform API call to Amazon to validate Client ID/Secret * */ public function save() { $data = $this->getFieldsetData(); $isEnabled = $this->getValue(); if ($data['client_id'] && $data['client_secret']) { $_api = Mage::getModel('amazon_login/api'); // REST API params $params = array('grant_type' => 'authorization_code', 'code' => 'SplxlOBeZQQYbYS6WxSbIA', 'client_id' => trim($data['client_id']), 'client_secret' => trim($data['client_secret'])); $response = $_api->request('auth/o2/token', $params); if (!$response) { Mage::getSingleton('core/session')->addError('Error: Unable to perform HTTP request to Amazon API.'); } else { if ($response && isset($response['error'])) { if ($response['error'] == 'invalid_client') { Mage::getSingleton('core/session')->addError('Client authentication failed. Please verify your Client ID and Client Secret.'); $this->setValue(0); // Set "Enabled" to "No" } else { Mage::getSingleton('core/session')->addSuccess('Successfully connected to Amazon API with Client ID and Client Secret.'); } } } } return parent::save(); }
public function save() { $fdata = array(); foreach ($this->groups['account']['fields'] as $name => $field) { $fdata[$name] = $field['value']; } if ($fdata['embed']) { $obj = json_decode($fdata['embed']); $fdata['embed'] = $obj->embed; $fdata['guid'] = $obj->guid; } include_once dirname(__FILE__) . '/JustunoAccess.php'; $params = array('apiKey' => JUSTUNO_KEY, 'email' => $fdata['email'], 'domain' => $fdata['domain'], 'guid' => $fdata['guid']); if ($fdata['password']) { $params['password'] = $fdata['password']; } $jAccess = new JustunoAccess($params); try { $justuno = $jAccess->getWidgetConfig(); $jusdata = array(); $jusdata['dashboard'] = (string) $jAccess->getDashboardLink(); $jusdata['guid'] = (string) $justuno['guid']; $jusdata['embed'] = (string) $justuno['embed']; $this->setValue((string) json_encode($jusdata)); } catch (JustunoAccessException $e) { Mage::throwException($e->getMessage()); } return parent::save(); }
public function save() { if ($value = $this->getValue()) { $value = implode(',', array_unique(explode(',', $this->getValue()))); } $this->setValue($value); return parent::save(); }
function save() { if ($this->getFieldsetDataValue('active')) { $merchantId = $this->getFieldsetDataValue("merchant_id"); Litle_CreditCard_Model_ValidateMerchantId::validate($merchantId); } return parent::save(); }
public function save() { if (!Mage::getModel($this->getValue())) { Mage::throwException(sprintf('Invalid Access Class: Could not instantiate a [%s]', $this->getValue())); } else { parent::save(); } }
/** * Disable saving if multiselect fields are disabled * * @return $this|Mage_Core_Model_Abstract */ public function save() { $helper = Mage::helper('netzarbeiter_groupscatalog2'); if ($helper->getConfig('show_multiselect_field')) { parent::save(); } return $this; }
public function save() { $v = $this->getValue(); if ($v == 'rgba(0, 0, 0, 0)') { $this->setValue('transparent'); } return parent::save(); }
public function save() { $value = $this->getValue(); if ($value && !is_numeric($value)) { Mage::throwException("Fields specifying 'Numeric' must have numeric values only!"); } return parent::save(); }
public function save() { // Validate number. Should be a whole number greater than 0. if (!ctype_digit((string) $this->getValue()) || (int) $this->getValue() <= 0) { Mage::throwException("Invalid entry for attempts. Must be a positive whole number, such as 20"); } return parent::save(); }
public function save() { // Validate email. Do not allow invalid emails if (!Zend_Validate::is($this->getValue(), 'EmailAddress')) { Mage::throwException("Invalid email format. Recipient and sender emails must be valid emails"); } return parent::save(); }
public function save() { //Get the value from config $v = $this->getValue(); if ($v == 'rgba(0, 0, 0, 0)') { $this->setValue('transparent'); } return parent::save(); }
public function save() { //Get the value from config $v = $this->getValue(); if ($v == 'rgba(0, 0, 0, 0)') { $this->setValue('transparent'); //Mage::getSingleton('adminhtml/session')->addNotice("value == rgba(0, 0, 0, 0)"); } return parent::save(); }
/** * Checks the entered value before saving it to the configuration. Setting to default (DE only) if * another country than Germany was choosen. * * @return Mage_Core_Model_Abstract */ public function save() { if ($this->getValue() != '1') { $translateMessage = Mage::helper('barzahlen')->__('bz_adm_specificcountry_exception'); Mage::getSingleton('adminhtml/session')->addError($translateMessage); Mage::helper('barzahlen')->bzLog('adminexceptions/country: Setting DE as allowed country'); $this->setValue(1); } return parent::save(); }
public function save() { $group = $this->getData('groups'); $fields = $group['messages']['fields']; if ($fields['activate']['value'] == 1) { if ($fields['mode']['value'] == 1) { $productionpublickey = $fields['productionpublickey']['value']; $productionprikey = $fields['productionprikey']['value']; if ($productionpublickey == NULL || $productionpublickey == ' ' || !isset($productionpublickey)) { Mage::throwException(Mage::helper('core')->__('Production Public key is required')); die; } if ($productionprikey == NULL || $productionprikey == ' ' || !isset($productionprikey)) { Mage::throwException(Mage::helper('core')->__('Production Private key is required')); die; } if (strlen($productionpublickey) != 11) { Mage::throwException(Mage::helper('core')->__('Public key lenth must be 11 characters')); die; } if (strlen($productionprikey) != 21) { Mage::throwException(Mage::helper('core')->__('Private key length must be 21 characters')); die; } if (substr($productionprikey, 0, 1) != "P" || substr($productionpublickey, 0, 1) != "P") { Mage::throwException(Mage::helper('core')->__('Please enter a valid Production key')); die; } } elseif ($fields['mode']['value'] == 0) { $sandboxpublickey = $fields['sandboxpublickey']['value']; $sandboxprikey = $fields['sandboxprikey']['value']; if ($sandboxpublickey == NULL || $sandboxpublickey == ' ' || !isset($sandboxpublickey)) { Mage::throwException(Mage::helper('core')->__('Sandbox Public key is required')); die; } if ($sandboxprikey == NULL || $sandboxprikey == ' ' || !isset($sandboxprikey)) { Mage::throwException(Mage::helper('core')->__('Sandbox Private key is required')); die; } if (strlen($sandboxpublickey) != 11) { Mage::throwException(Mage::helper('core')->__('Public key lenth must be 11 characters')); die; } if (strlen($sandboxprikey) != 21) { Mage::throwException(Mage::helper('core')->__('Private key length must be 21 characters')); die; } if (substr($sandboxprikey, 0, 1) != "T" || substr($sandboxpublickey, 0, 1) != "T") { Mage::throwException(Mage::helper('core')->__('Please enter a valid Sandbox key')); die; } } } return parent::save(); }
/** * Checks the entered value before saving it to the configuration. Setting to default if string * length is lower than 1. * * @return Mage_Core_Model_Abstract */ public function save() { $title = $this->getValue(); if (strlen($title) < 1) { $translateMessage = Mage::helper('barzahlen')->__('bz_adm_co_exception'); Mage::getSingleton('adminhtml/session')->addError($translateMessage); Mage::helper('barzahlen')->bzLog('adminexceptions/title: Empty string given. Setting default title.'); $this->setValue('Barzahlen'); } return parent::save(); }
public function save() { $value = $this->getValue(); if (strlen($value) == 0) { Mage::throwException(Mage::helper("mailup")->__("Please fill the web service username")); } if (!preg_match("/a[0-9]+/", $value)) { Mage::throwException(Mage::helper("mailup")->__("Web service username is not in the right format")); } return parent::save(); }
/** * Validate data */ public function save() { $data = $this->getFieldsetData(); $isEnabled = $this->getValue(); if ($isEnabled) { if ($data['seller_id'] && !ctype_alnum($data['seller_id'])) { Mage::getSingleton('core/session')->addError('Error: Please verify your Seller ID (alphanumeric characters only).'); } } return parent::save(); }
public function save() { $pattern = '#^(\\d+)?\\-\\d+;(\\d+\\-\\d+;)*\\d+\\-(\\d+)?$#'; $value = $this->getValue(); if ('' !== $value && !preg_match($pattern, $value)) { $message = "Provided Layered Navigation Price Ranges are incorrect."; $message = Mage::helper('aurmil_customizepricefilter')->__($message); Mage::throwException($message); } return parent::save(); }
/** * Saves our url to our SMARTBEAR ALERTSITE account * * @throws Exception * @return Mage_Core_Model_Abstract */ public function save() { $enable = $this->getValue(); $api = $this->getApi(); $result = $api->enableMonitor($enable); if (!$result) { /** @var $session Mage_Admin_Model_Session */ $session = Mage::getSingleton('admin/session'); $session->addError('You have disabled the Alertsite extension but there was a problem with disabling Alertsite monitoring - please contact <a href="http://help.alertsite.com/MagentoHelp">support</a>.'); } return parent::save(); }
public function save() { $fields = $_POST['groups']['connection']['fields']; $url = $fields['url']['value']; $clientId = $fields['client_id']['value']; $clientSecret = $fields['client_secret']['value']; $api = Mage::helper('octahedron_pos/api'); $api->setClientCredentials($url, $clientId, $clientSecret); $token = $api->getAccessToken('client-credentials'); Mage::getConfig()->saveConfig('octahedron_pos/api/token', $token); return parent::save(); }
public function save() { $value = $this->getValue(); if (strlen($value) == 0) { Mage::throwException(Mage::helper("mailup")->__("Please fill the admin console URL")); } $validator = new Zend_Validate_Hostname(); if (!$validator->isValid($value)) { Mage::throwException(Mage::helper("mailup")->__("Admin console URL is not in the right format")); } return parent::save(); }
public function save() { // Read subdomain. $subdomain = trim($this->getValue()); // Full domain entered. if (preg_match("/([a-z0-9\\-]+)\\.api\\.oneall\\.com/i", $subdomain, $matches)) { $subdomain = $matches[1]; } // Use new value. $this->setValue($subdomain); // Save. return parent::save(); }
public function save() { $frontName = Mage::getConfig()->getNode('frontend/routers/blogfeed/args/frontName'); $id_path = $frontName . '/list'; $target_path = $frontName . '/posts/list'; //delete if already exists $exists = Mage::getModel('core/url_rewrite')->setStoreId(Mage::app()->getStore()->getId())->loadByIdPath($id_path); if ($exists && $exists->getIdPath()) { $exists->delete(); } //save new Mage::getModel('core/url_rewrite')->setIsSystem(0)->setOptions('')->setIdPath($id_path)->setTargetPath($target_path)->setRequestPath($this->getValue())->save(); return parent::save(); }
/** * oAuth config validation * * @return Mage_Core_Model_Abstract * @throws Exception * @throws Mage_Core_Exception */ public function save() { $storeName = Mage::app()->getRequest()->getParam('store'); $storeId = $this->_getStoreIdByName($storeName); $oauth = $this->_getHelper()->getOauthToken($storeId); //when saving config on website level if (!$storeName && !$oauth) { $this->setValue(0); Mage::getSingleton('core/session')->addWarning(Mage::helper('shopgate')->__('Store disabled. Please connect to Shopgate first.')); } elseif (!$oauth) { Mage::throwException(Mage::helper('shopgate')->__('You need to connect to Shopgate before saving the configuration')); } return parent::save(); }
public function save() { $limit = Mage::app()->getWebsite()->getConfig('mybuys_datafeeds/advanced/attribute_limit'); if (!$limit) { $limit = self::ATTRIBUTE_LIMIT; } $selections = $this->getValue(); //get the value from our config if (sizeof($selections) > $limit) { Mage::getSingleton('core/session')->addWarning(Mage::helper('mybuys')->__("WARNING - Too many Product Custom Attributes selected for the product data feed.<br/>Only the first %s selected attributes were saved and applied to the feed.", $limit)); } $this->setValue(array_slice($selections, 0, $limit, true)); //only keep the first 15 items the user selected return parent::save(); }
public function save() { $value = $this->getValue(); if ($value) { $valArr = explode(',', $value); foreach ($valArr as $val) { if (!is_numeric(trim($val))) { Mage::throwException("Fields specifying 'Numeric' must have numeric values only!"); } } } $newVal = explode(',', trim($value)); $this->setValue($newVal); return parent::save(); }
public function save() { $data = $this->_getData('fieldset_data'); $obj = Mage::helper('whatsappshare'); if ($data['serial_key'] != '') { $serialkey = $data['serial_key']; if ($obj->canRun($serialkey)) { return parent::save(); } else { Mage::throwException($obj->getAdminMessage()); } } else { Mage::throwException($obj->getAdminMessage()); } }
public function save() { $value = $this->getValue(); $Oldvalue = $this->getOldValue(); parent::save(); if ($value != $Oldvalue && $value == 1 && count($this->_getStores()) > 0) { $readCon = $this->_getResource()->getReadConnection(); $writeCon = Mage::getSingleton('core/resource')->getConnection('core_write'); /* @var $readCon Varien_Db_Adapter_Interface */ /* @var $writeCon Varien_Db_Adapter_Interface */ $readCon->delete($this->_getResource()->getTable('urlindexer/url_rewrite'), 'store_id IN(' . implode(',', $this->_getStores()) . ')'); $cols = explode(',', 'store_id,id_path,request_path,target_path,is_system,options,description,category_id,product_id'); $select = $writeCon->select()->from($this->_getResource()->getTable('core/url_rewrite'), $cols)->where('store_id IN(' . implode(',', $this->_getStores()) . ')')->where('product_id IS NULL')->where('category_id IS NOT NULL')->where('is_system = ?', 1)->where("id_path LIKE 'category/%'")->where('options IS NULL'); $writeCon->query($select->insertFromSelect($this->_getResource()->getTable('urlindexer/url_rewrite'), explode(',', 'store_id,id_path,request_path,target_path,is_system,options,description,category_id,product_id'), true)); } return $this; }