/**
  * Unset array element with '__empty' key
  *
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
     }
     $arr = array();
     foreach ($value as $key => $val) {
         if (isset($val['min_order_qty']) && isset($val['max_order_qty']) && isset($val['point_value_referrer']) && isset($val['calculation_type_referrer']) && isset($val['point_value_referred']) && isset($val['calculation_type_referred']) && isset($val['date_from']) && isset($val['date_end'])) {
             if (is_float($val['point_value_referrer']) && (int) $val['point_value_referrer'] != 0) {
                 Mage::getSingleton('adminhtml/session')->addError('Referrer Point/Ratio values issue. Value must be an integer.');
             }
             if (is_float($val['point_value_referred']) && (int) $val['point_value_referred'] != 0) {
                 Mage::getSingleton('adminhtml/session')->addError('Referred Point/Ratio values issue. Value must be an integer.');
             }
             $fromDate = $toDate = null;
             $data = $this->_filterDates($val, array('date_from', 'date_end'));
             $fromDate = $data['date_from'];
             $toDate = $data['date_end'];
             if ($fromDate && $toDate) {
                 $fromDate = new Zend_Date($fromDate, Varien_Date::DATE_INTERNAL_FORMAT);
                 $toDate = new Zend_Date($toDate, Varien_Date::DATE_INTERNAL_FORMAT);
                 if ($fromDate->compare($toDate) === 1) {
                     Mage::getSingleton('adminhtml/session')->addError('End Date must be greater than Start Date.');
                 }
             }
             $arr[$key] = $data;
         }
     }
     $this->setValue($arr);
     //$this->setValue($value);
     parent::_beforeSave();
 }
Example #2
0
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (!isset($value['__save_data']) && isset($value['__type'])) {
         // save_data was not set by our Javascript.. let's better load the fail-safe database configuration instead of risking losing the mapping
         $dbData = unserialize(Mage::getStoreConfig('orderstatusimport/processor_' . $value['__type'] . '/import_mapping'));
         if (!empty($dbData)) {
             $value = $dbData;
         }
     }
     if (is_array($value)) {
         unset($value['__empty']);
         unset($value['__type']);
         unset($value['__save_data']);
         foreach ($value as $id => $data) {
             if (!isset($data['field'])) {
                 unset($value[$id]);
                 continue;
             }
             if ($data['field'] == '') {
                 unset($value[$id]);
             }
         }
     }
     $this->setValue($value);
     parent::_beforeSave();
 }
Example #3
0
 /**
  * Unset array element with '__empty' key
  *
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
     }
     $this->setValue($value);
     parent::_beforeSave();
 }
Example #4
0
 /**
  * Unset array element with '__empty' key
  *
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
     }
     usort($value, array($this, 'sortByPriority'));
     $this->setValue($value);
     parent::_beforeSave();
 }
Example #5
0
 protected function _beforeSave()
 {
     $udprodTypeOfProduct = $this->getValue();
     if (is_array($udprodTypeOfProduct) && !empty($udprodTypeOfProduct) && !empty($udprodTypeOfProduct['type_of_product']) && is_array($udprodTypeOfProduct['type_of_product'])) {
         reset($udprodTypeOfProduct['type_of_product']);
         $firstTitleKey = key($udprodTypeOfProduct['type_of_product']);
         if (!is_numeric($firstTitleKey)) {
             $newudprodTypeOfProduct = array();
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             foreach ($udprodTypeOfProduct['type_of_product'] as $_k => $_t) {
                 $newudprodTypeOfProduct[] = array('type_of_product' => $_t, 'attribute_set' => $udprodTypeOfProduct['attribute_set'][$_k]);
             }
             $this->setValue($newudprodTypeOfProduct);
         }
     }
     return parent::_beforeSave();
 }
 protected function _beforeSave()
 {
     // Clean given value by removing "__empty" and incomplete sub values
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
         foreach ($value as $key => $exception) {
             if (trim($exception['block_type']) == '') {
                 unset($value[$key]);
             }
         }
     } else {
         $value = array();
     }
     $this->setValue($value);
     parent::_beforeSave();
 }
Example #7
0
 /**
  * Unset array element with '__empty' key
  *
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
     }
     $arr = array();
     foreach ($value as $key => $val) {
         /*echo "$key = $value
           ";*/
         if (isset($val['min_value']) && isset($val['max_value']) && isset($val['duration'])) {
             $arr[$key] = $val;
         }
     }
     if (!$this->_checkOverlap($arr)) {
         Mage::getSingleton('adminhtml/session')->addError('Overlap issues. Please verify Customer Point Notifications values.');
     }
     //$this->setValue($value);
     $this->setValue($arr);
     parent::_beforeSave();
 }
Example #8
0
 /**
  * Unset array element with '__empty' key
  *
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
     }
     $arr = array();
     foreach ($value as $key => $val) {
         if (isset($val['class_name']) && isset($val['model_id']) && isset($val['point_value']) && isset($val['use_end']) && isset($val['process_once']) && isset($val['max_point']) && isset($val['duration']) && isset($val['description']) && isset($val['verifications'])) {
             if (trim($val['class_name']) != "") {
                 $arr[$key] = array('class_name' => $val['class_name'], 'model_id' => (int) $val['model_id'], 'point_value' => (int) $val['point_value'], 'process_once' => (int) $val['process_once'], 'max_point' => (int) $val['max_point'], 'duration' => (int) $val['duration'], 'use_end' => (int) $val['use_end'], 'description' => $val['description'], 'verifications' => $val['verifications']);
             } else {
                 Mage::getSingleton('adminhtml/session')->addError('Event data issues. Please verify Customer Point Event values.');
             }
             //$arr[] = $val;
         }
     }
     $this->setValue($arr);
     //$this->setValue($value);
     parent::_beforeSave();
 }
Example #9
0
 protected function _beforeSave()
 {
     $udtcFixedConfig = $this->getValue();
     if (is_array($udtcFixedConfig) && !empty($udtcFixedConfig) && !empty($udtcFixedConfig['limit']) && is_array($udtcFixedConfig['limit'])) {
         reset($udtcFixedConfig['limit']);
         $firstTitleKey = key($udtcFixedConfig['limit']);
         if (!is_numeric($firstTitleKey)) {
             $newudtcFixedConfig = array();
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             foreach ($udtcFixedConfig['limit'] as $_k => $_t) {
                 if (($_limit = $filter->filter($udtcFixedConfig['limit'][$_k])) && false !== ($_value = $filter->filter($udtcFixedConfig['value'][$_k]))) {
                     $_limit = is_numeric($_limit) ? $_limit : '*';
                     $_sk = is_numeric($_limit) ? $_limit : '9999999999';
                     $_sk = 'str' . str_pad((string) $_sk, 20, '0', STR_PAD_LEFT);
                     $newudtcFixedConfig[$_sk] = array('limit' => $_limit, 'value' => $_value);
                 }
             }
             ksort($newudtcFixedConfig);
             $newudtcFixedConfig = array_values($newudtcFixedConfig);
             $this->setValue(array_values($newudtcFixedConfig));
         }
     }
     return parent::_beforeSave();
 }
 protected function _beforeSave()
 {
     // Clean given value by removing "__empty" and incomplete sub values
     $value = $this->getValue();
     $attributes = Mage::helper('fileattributes')->getFileAttributesCollection();
     $foundIds = array();
     if (is_array($value)) {
         if (isset($value['__empty'])) {
             unset($value['__empty']);
         }
         foreach ($value as $key => $config) {
             if (!isset($config['attribute_id']) || !$attributes->getItemById($config['attribute_id']) || isset($foundIds[$config['attribute_id']])) {
                 unset($value[$key]);
             } else {
                 $attributeId = $config['attribute_id'];
                 $foundIds[$attributeId] = true;
                 $value[$key] = array('attribute_id' => $attributeId, 'display_config' => isset($config['display_config']) ? (bool) $config['display_config'] : false, 'file_save_moment' => $this->_verifySourceValue($config, 'file_save_moment', 'file_save_moment'), 'file_max_size' => $this->_verifyIntValue($config, 'file_max_size'), 'image_only' => isset($config['image_only']) ? (bool) $config['image_only'] : false, 'image_min_width' => $this->_verifyIntValue($config, 'image_min_width'), 'image_max_width' => $this->_verifyIntValue($config, 'image_max_width'), 'image_min_height' => $this->_verifyIntValue($config, 'image_min_height'), 'image_max_height' => $this->_verifyIntValue($config, 'image_max_height'), 'allowed_mime_types' => isset($config['allowed_mime_types']) ? $config['allowed_mime_types'] : '', 'forbidden_mime_types' => isset($config['forbidden_mime_types']) ? $config['forbidden_mime_types'] : '', 'exceptions_handling_mode' => $this->_verifySourceValue($config, 'exceptions_handling_mode', 'exceptions_handling_mode'), 'allowed_file_extensions' => isset($config['allowed_file_extensions']) ? $config['allowed_file_extensions'] : '', 'forbidden_file_extensions' => isset($config['forbidden_file_extensions']) ? $config['forbidden_file_extensions'] : '');
             }
         }
     } else {
         $value = array();
     }
     $this->setValue($value);
     parent::_beforeSave();
 }