function media_watermark_form_submit in Media watermark 7
Form submission handler for media_watermark_form().
See also
media_watermark_form_validate()
File
- includes/
media_watermark_add.admin.inc, line 113 - Media watermark module integration.
Code
function media_watermark_form_submit(&$form, &$form_state) {
if (isset($form_state['values']['watermark_image'])) {
$data = array(
'fid' => $form_state['values']['watermark_image'],
'name' => $form_state['values']['name'],
'hor_position' => $form_state['values']['hor_position'],
'ver_position' => $form_state['values']['ver_position'],
'hor_margin' => $form_state['values']['hor_margin'],
'ver_margin' => $form_state['values']['ver_margin'],
);
$file = file_load($form_state['values']['watermark_image']);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
global $user;
file_usage_add($file, 'media_watermark', 'image', $user->uid);
if (arg(5)) {
db_update('media_watermark')
->fields($data)
->condition('wid', arg(5))
->execute();
drupal_set_message(t("Watermark has been updated."));
}
else {
db_insert('media_watermark')
->fields($data)
->execute();
drupal_set_message(t("Watermark has been added."));
}
}
$form_state['redirect'] = 'admin/config/media/watermark';
}