You are here

function _photos_to_sub_submit in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 inc/photos.edit.inc \_photos_to_sub_submit()

Submit moving images to sub-album(s).

1 string reference to '_photos_to_sub_submit'
_photos_to_sub in inc/photos.edit.inc
Move to sub album form.

File

inc/photos.edit.inc, line 1240
Handles uploading and editing images.

Code

function _photos_to_sub_submit($form, &$form_state) {
  if (!$form_state['values']['fid']) {
    return;
  }
  $query = db_insert('photos_node')
    ->fields(array(
    'nid',
    'fid',
  ));
  $nids = array();
  foreach ($form_state['values']['sub'] as $key => $sub) {
    if ($sub) {
      $query
        ->values(array(
        'nid' => $key,
        'fid' => $form_state['values']['fid'],
      ));
      $nids[] = $key;
    }
  }
  if (!empty($nids)) {
    $query
      ->execute();
    foreach ($nids as $nid) {
      photos_set_count('node_node', $nid);
    }
    $count = count($nids);
    $msg = format_plural($count, 'Successfully sent to 1 sub-album.', 'Successfully sent to @count sub-albums.');
    drupal_set_message($msg);
  }
  $redirect = array(
    'photos/image/' . $form_state['values']['fid'],
  );
  $form_state['redirect'] = $redirect;
}