예제 #1
0
 /**
  * @param Mageplace_Freshdesk_Model_Field $field
  *
  * @return bool|mixed
  */
 public function isFieldVisible($field)
 {
     if (in_array($field->getName(), self::$HIDE_FIELDS)) {
         return false;
     } elseif (!$field->isVisible()) {
         return false;
     } elseif (!$field->isEditable()) {
         return false;
     }
     return true;
 }
예제 #2
0
 public function checkFieldValue($value, &$allValues, &$skipValues)
 {
     parent::checkFieldValue($value, $allValues, $skipValues);
     if ($value && !is_numeric($value)) {
         throw new Mageplace_Freshdesk_Exception(Mage::helper('freshdesk')->__('Field "%s" is not valid, please re-enter', $this->getLabel()));
     }
     return true;
 }
예제 #3
0
 public function checkFieldValue($value, &$allValues, &$skipValues)
 {
     parent::checkFieldValue($value, $allValues, $skipValues);
     if ($value !== '') {
         $check = false;
         foreach ($this->getChoices() as $choice) {
             if ($value == $choice[1]) {
                 $check = true;
                 break;
             }
         }
         if (!$check) {
             throw new Mageplace_Freshdesk_Exception(Mage::helper('freshdesk')->__('Field "%s" is not valid, please re-enter', $this->getLabel()));
         }
     }
     return true;
 }
예제 #4
0
 public function checkFieldValue($value, &$allValues, &$skipValues)
 {
     parent::checkFieldValue($value, $allValues, $skipValues);
     if ($value !== '') {
         $check = false;
         $approveSkipValues = array();
         $choices = $this->getNestedChoices();
         foreach ($choices as $level0) {
             if ($level0[1] == $value) {
                 if (empty($level0[2])) {
                     $check = true;
                 } else {
                     if (empty($skipValues[$this->getFirstLevelFieldName()])) {
                         if (!$this->isRequired()) {
                             $check = true;
                         }
                         break;
                     }
                     $level1value = $skipValues[$this->getFirstLevelFieldName()];
                     if (trim($level1value) === '') {
                         break;
                     } else {
                         foreach ($level0[2] as $level1) {
                             if ($level1[1] == $level1value) {
                                 $approveSkipValues[] = $this->getFirstLevelFieldName();
                                 if (empty($level1[2])) {
                                     $check = true;
                                 } else {
                                     if (empty($skipValues[$this->getSecondLevelFieldName()])) {
                                         if (!$this->isRequired()) {
                                             $check = true;
                                         }
                                         break 2;
                                     }
                                     $level2value = $skipValues[$this->getSecondLevelFieldName()];
                                     if (trim($level2value) !== '') {
                                         foreach ($level1[2] as $level2) {
                                             if ($level2[1] == $level2value) {
                                                 $approveSkipValues[] = $this->getSecondLevelFieldName();
                                                 $check = true;
                                                 break 3;
                                             }
                                         }
                                     }
                                 }
                                 break 2;
                             }
                         }
                     }
                 }
                 break;
             }
         }
         if (!$check) {
             throw new Mageplace_Freshdesk_Exception(Mage::helper('freshdesk')->__('Field "%s" is not valid, please re-enter', $this->getLabel()));
         }
     }
     if (!empty($approveSkipValues)) {
         return $approveSkipValues;
     }
     return true;
 }