Example #1
0
 private function getValueForDB($value)
 {
     $property = $this->property;
     if ($property['TYPE'] == 'FILE') {
         $value = Input\File::asMultiple($value);
         foreach ($value as $i => $file) {
             if (Input\File::isDeletedSingle($file)) {
                 unset($value[$i]);
             } else {
                 if (Input\File::isUploadedSingle($file) && ($fileId = \CFile::SaveFile(array('MODULE_ID' => 'sale') + $file, 'sale/order/properties')) && is_numeric($fileId)) {
                     $file = $fileId;
                 }
                 $value[$i] = Input\File::loadInfoSingle($file);
             }
         }
         $this->fields->set('VALUE', $value);
         $value = Input\File::getValue($property, $value);
         foreach (array_diff(Input\File::asMultiple(Input\File::getValue($property, $this->savedValue)), Input\File::asMultiple($value), Input\File::asMultiple(Input\File::getValue($property, $property['DEFAULT_VALUE']))) as $fileId) {
             \CFile::Delete($fileId);
         }
     }
     return $value;
 }
     }
     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');
     }
 }
 // insert/update database
 if (!$errors && ($_POST['save'] || $_POST['apply']) && $saleModulePermissions == 'W' && check_bitrix_sessid()) {
     // save uploaded files
     if ($property['TYPE'] == 'FILE') {
         $savedFiles = array();
         $files = Input\File::asMultiple($property['DEFAULT_VALUE']);
         foreach ($files as $i => $file) {
             if (Input\File::isDeletedSingle($file)) {
                 unset($files[$i]);
             } else {
                 if (Input\File::isUploadedSingle($file) && ($fileId = \CFile::SaveFile(array('MODULE_ID' => 'sale') + $file, 'sale/order/properties/default')) && is_numeric($fileId)) {
                     $file = $fileId;
                     $savedFiles[] = $fileId;
                 }
                 $files[$i] = Input\File::loadInfoSingle($file);
             }
         }
         $property['DEFAULT_VALUE'] = $files;
     }
     // prepare property for database & set defaults
     $propertyForDB = array();
     foreach ($commonSettings + $inputSettings + $stringSettings + $locationSettings as $name => $input) {
         $propertyForDB[$name] = Input\Manager::getValue($input, $property[$name]);