function filefield_paths_form_submit in File (Field) Paths 5
Same name and namespace in other branches
- 8 filefield_paths.module \filefield_paths_form_submit()
- 6 filefield_paths.module \filefield_paths_form_submit()
- 7 filefield_paths.module \filefield_paths_form_submit()
Implementation of hook_form_submit().
File
- ./
filefield_paths.module, line 209 - Adds extra functionality to FileFields Path settings.
Code
function filefield_paths_form_submit($form, $form_values) {
$ffp = array();
// Invoke hook_filefield_paths_form_submit().
foreach (module_implements('filefield_paths_form_submit') as $module) {
$function = $module . '_filefield_paths_form_submit';
$function($form_values, $ffp);
}
if (count($ffp) > 0) {
$fields = module_invoke_all('filefield_paths_field_settings');
foreach ($ffp as $field_name => $field_data) {
$cols = $vals = $data = array();
foreach ($fields as $name => &$field) {
$field['settings'] = array(
'value' => isset($form_values['ffp_' . $field_name][$name]) ? $form_values['ffp_' . $field_name][$name] : $form_values['ffp_' . $field_name]['image_path'],
'tolower' => $form_values['ffp_' . $field_name][$name . '_cleanup'][$name . '_tolower'],
'pathauto' => $form_values['ffp_' . $field_name][$name . '_cleanup'][$name . '_pathauto'],
'transliterate' => $form_values['ffp_' . $field_name][$name . '_cleanup'][$name . '_transliterate'],
);
// Store additional settings from addon modules.
if (isset($field['data'])) {
foreach ($field['data'] as $key => $value) {
$field['settings'][$key] = $form_values['ffp_' . $field_name][$value];
}
}
$cols[] = $field['sql'];
$vals[] = "'%s'";
$data[] = serialize($field['settings']);
}
$result = db_fetch_object(db_query("SELECT * FROM {filefield_paths} WHERE type = '%s' AND field = '%s'", $field_data['type'], $field_name));
if (!empty($result)) {
foreach ($cols as &$col) {
$col .= " = '%s'";
}
db_query("UPDATE {filefield_paths} SET " . implode(', ', $cols) . " WHERE type = '%s' AND field = '%s'", array_merge($data, array(
$field_data['type'],
$field_name,
)));
}
else {
db_query("INSERT INTO {filefield_paths} (type, field, " . implode(', ', $cols) . ") VALUES ('%s', '%s', " . implode(', ', $vals) . ")", array_merge(array(
$field_data['type'],
$field_name,
), $data));
}
if ($form_values['ffp_' . $field_name]['retroactive_update']) {
filefield_paths_update(arg(5), $field_name, arg(3));
}
}
}
}