Changeset 10589 for trunk/admin/include/functions_upload.inc.php
- Timestamp:
- Apr 23, 2011, 10:51:53 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r10570 r10589 177 177 ); 178 178 } 179 } 180 181 function save_upload_form_config($data, &$errors=array()) 182 { 183 if (!is_array($data) or empty($data)) 184 { 185 return false; 186 } 187 188 $upload_form_config = get_upload_form_config(); 189 $updates = array(); 190 191 foreach ($data as $field => $value) 192 { 193 if (!isset($upload_form_config[$field])) 194 { 195 continue; 196 } 197 if (is_bool($upload_form_config[$field]['default'])) 198 { 199 if (isset($value)) 200 { 201 $value = true; 202 } 203 else 204 { 205 $value = false; 206 } 207 208 $updates[] = array( 209 'param' => 'upload_form_'.$field, 210 'value' => boolean_to_string($value) 211 ); 212 } 213 elseif ($upload_form_config[$field]['can_be_null'] and empty($value)) 214 { 215 $updates[] = array( 216 'param' => 'upload_form_'.$field, 217 'value' => 'false' 218 ); 219 } 220 else 221 { 222 $min = $upload_form_config[$field]['min']; 223 $max = $upload_form_config[$field]['max']; 224 $pattern = $upload_form_config[$field]['pattern']; 225 226 if (preg_match($pattern, $value) and $value >= $min and $value <= $max) 227 { 228 $updates[] = array( 229 'param' => 'upload_form_'.$field, 230 'value' => $value 231 ); 232 } 233 else 234 { 235 array_push( 236 $errors, 237 sprintf( 238 $upload_form_config[$field]['error_message'], 239 $min, 240 $max 241 ) 242 ); 243 } 244 } 245 } 246 247 if (count($errors) == 0) 248 { 249 mass_updates( 250 CONFIG_TABLE, 251 array( 252 'primary' => array('param'), 253 'update' => array('value') 254 ), 255 $updates 256 ); 257 return true; 258 } 259 260 return false; 179 261 } 180 262
Note: See TracChangeset
for help on using the changeset viewer.