Example #1
0
 /**
  * Prepares config array for saving
  * @param array $config array config to prepare
  * @return array
  */
 public function prepareFieldsForSaving(array $fields)
 {
     $strError = "";
     $structure = $fields["CLASS_NAME"]::getConfigStructure();
     foreach ($structure as $key1 => $rParams) {
         foreach ($rParams["ITEMS"] as $key2 => $iParams) {
             if ($iParams["TYPE"] == "DELIVERY_SECTION") {
                 continue;
             }
             $errors = \Bitrix\Sale\Internals\Input\Manager::getError($iParams, $fields["CONFIG"][$key1][$key2]);
             if (!empty($errors)) {
                 $strError .= Loc::getMessage("SALE_DLVR_BASE_FIELD") . " \"" . $iParams["NAME"] . "\": " . implode("<br>\n", $errors) . "<br>\n";
             }
         }
     }
     if ($strError != "") {
         throw new SystemException($strError);
     }
     return $fields;
 }
Example #2
0
     $params = isset($_REQUEST['params']) ? $_REQUEST['params'] : array();
     $sort = isset($_REQUEST['sort']) ? intval($_REQUEST['sort']) : 100;
     $deliveryId = isset($_REQUEST['deliveryId']) ? intval($_REQUEST['deliveryId']) : 0;
     $restrictionId = isset($_REQUEST['restrictionId']) ? intval($_REQUEST['restrictionId']) : 0;
     if (!$className) {
         throw new \Bitrix\Main\ArgumentNullException("className");
     }
     if (!$deliveryId) {
         throw new \Bitrix\Main\ArgumentNullException("deliveryId");
     }
     $restriction = Services\Manager::getRestrictionObject($className);
     if (!$restriction instanceof \Bitrix\Sale\Delivery\Restrictions\Base) {
         throw new \Bitrix\Main\SystemException($className . ' is not an instance of \\Bitrix\\Sale\\Delivery\\Restrictions\\Base');
     }
     foreach ($restriction->getParamsStructure() as $key => $rParams) {
         $errors = \Bitrix\Sale\Internals\Input\Manager::getError($rParams, $params[$key]);
         if (!empty($errors)) {
             $arResult["ERROR"] = "Field: \"" . $rParams["LABEL"] . "\" " . implode("<br>", $errors) . "<br>\n";
         }
     }
     $fields = array("DELIVERY_ID" => $deliveryId, "SORT" => $sort, "PARAMS" => $params);
     $res = $restriction->save($fields, $restrictionId);
     if (!$res->isSuccess()) {
         $arResult["ERROR"] .= implode(".", $res->getErrorMessages());
     }
     $arResult["HTML"] = getRestrictionHtml($deliveryId);
     break;
 case "delete_restriction":
     $restrictionId = isset($_REQUEST['restrictionId']) ? intval($_REQUEST['restrictionId']) : 0;
     $deliveryId = isset($_REQUEST['deliveryId']) ? intval($_REQUEST['deliveryId']) : 0;
     if (!$restrictionId) {
                     $errors[] = Loc::getMessage('INPUT_ENUM') . " {$index}: " . $input['LABEL'] . ': ' . implode(', ', $error);
                     $hasError = true;
                 }
             }
             if ($hasError) {
                 unset($defaultOptions[$row['VALUE']]);
             }
         }
     }
 }
 // validate relations
 $hasRelations = false;
 foreach ($relationsSettings as $name => $input) {
     if (($value = $relations[$name]) && $value != array('')) {
         $hasRelations = true;
         if ($error = Input\Manager::getError($input, $value)) {
             $errors[] = $input['LABEL'] . ': ' . implode(', ', $error);
         }
     } else {
         $relations[$name] = array();
     }
 }
 if ($hasRelations) {
     if ($property['IS_LOCATION4TAX'] == 'Y') {
         $errors[] = Loc::getMessage('ERROR_LOCATION4TAX_RELATION_NOT_ALLOWED');
     }
     if ($property['IS_EMAIL'] == 'Y') {
         $errors[] = Loc::getMessage('ERROR_EMAIL_RELATION_NOT_ALLOWED');
     }
     if ($property['IS_PROFILE_NAME'] == 'Y') {
         $errors[] = Loc::getMessage('ERROR_PROFILE_NAME_RELATION_NOT_ALLOWED');
Example #4
0
 function setValueFromPost(array $post)
 {
     $result = new Result();
     $property = $this->property;
     $key = isset($property["ID"]) ? $property["ID"] : "n" . $this->getId();
     $value = isset($post['PROPERTIES'][$key]) ? $post['PROPERTIES'][$key] : null;
     if (isset($post['PROPERTIES'][$key])) {
         $this->setValue($value);
     } else {
         $value = $this->getValue();
     }
     $error = Input\Manager::getError($property, $value);
     if ($property['IS_EMAIL'] == 'Y' && !check_email($value, true)) {
         $error['EMAIL'] = str_replace(array("#EMAIL#", "#NAME#"), array(htmlspecialcharsbx($value), htmlspecialcharsbx($property['NAME'])), Loc::getMessage("SALE_GOPE_WRONG_EMAIL"));
     }
     foreach ($error as $e) {
         $result->addError(new ResultError($property['NAME'] . ' ' . $e, "PROPERTIES[{$key}]"));
     }
     return $result;
 }
Example #5
0
         $codeDomain = $code['DOMAIN'];
         foreach ($maps as $personId => $map) {
             if (($personDomain = $personsDomainsWithCommon[$personId]) && $activeCodeDomains[$personDomain] && ($codeDomain == BusinessValue::COMMON_DOMAIN || $codeDomain == $personDomain)) {
                 if ($personId == BusinessValue::COMMON_PERSON_ID) {
                     $entityInput = $commonEntityInput;
                     $itemInputs['PROPERTY']['OPTIONS'] = array();
                 } else {
                     $entityInput = $personEntityInput;
                     $itemInputs['PROPERTY']['OPTIONS'] = $propertyOptions[$personId];
                 }
                 if (!$map['DELETE']) {
                     $mapEntity = $map['ENTITY'];
                     if ($error = Input\Manager::getError($entityInput, $mapEntity)) {
                         $errors['MAP'][$personId][$codeId]['ENTITY'] = $error;
                     }
                     if ($error = Input\Manager::getError($itemInputs[$mapEntity], $map['ITEM'])) {
                         $errors['MAP'][$personId][$codeId]['ITEM'] = $error;
                     }
                 }
             } else {
                 unset($maps[$personId]);
             }
         }
     } else {
         unset($postedCodes[$codeId]);
     }
 }
 unset($maps);
 // save maps
 if (!$errors && !$readOnly && check_bitrix_sessid() && ($_POST['save'] || $_POST['apply'])) {
     foreach ($postedCodes as $codeId => &$postedCode) {
Example #6
0
 public static function getErrorSingle(array $input, array $values)
 {
     $errors = array();
     foreach ($input["ITEMS"] as $key => $item) {
         if ($error = Input\Manager::getError($item, isset($values[$key]) ? $values[$key] : null)) {
             $errors[$key] = $error;
         }
     }
     return $errors;
 }