function andromeda_slideshow_image_form_submit in Andromeda Slideshow 7.2
Same name and namespace in other branches
- 7 includes/andromeda_slideshow.forms.inc \andromeda_slideshow_image_form_submit()
Submit handler for andromeda_slideshow_image_form
File
- includes/
andromeda_slideshow.forms.inc, line 286 - Form definitions for andromeda slideshow module
Code
function andromeda_slideshow_image_form_submit($form, &$form_state) {
$settings = $form_state['values'];
$image = $form['#image'];
$slideshow = $form['#slideshow'];
$slideshow_images = andromeda_slideshow_load_slideshow_images($slideshow->sid);
$image->title = check_plain($settings['title']);
$image->caption = check_plain($settings['caption']);
//save the file permanently
$file = file_load($settings['fid']);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
file_usage_add($file, 'andromeda_slideshow', 'slideshow', $slideshow->sid);
$image->fid = $file->fid;
//unset some values that are not needed
unset($settings['title'], $settings['fid'], $settings['caption'], $settings['submit'], $settings['form_build_id'], $settings['form_id'], $settings['form_token'], $settings['op']);
$image->settings = $settings;
$image = andromeda_slideshow_save_image($image);
if ($image->siid) {
//insert image as last position
$image->position = sizeof($slideshow_images) + 1;
//add the image to this slideshow
andromeda_slideshow_add_image($slideshow, $image);
drupal_set_message(t('Image added to slideshow.'));
$form_state['redirect'] = 'admin/structure/slideshows/manage/' . $slideshow->sid;
}
}