You are here

function photos_editlist_submit_node in Album Photos 7.3

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

Edit list form submit for sub-album.

1 string reference to 'photos_editlist_submit_node'
photos_editlist_form in inc/photos.edit.inc
Edit list form.

File

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

Code

function photos_editlist_submit_node($form, &$form_state) {
  foreach ($form_state['values']['photos'] as $fid => $key) {
    if (!empty($key['del'])) {
      $msg[] = db_query('DELETE FROM {photos_node} WHERE fid = :fid AND nid = :nid', array(
        ':fid' => $fid,
        ':nid' => $form_state['values']['nid'],
      ));
    }
    else {
      $update_fields = array(
        'des' => $key['des'],
      );
      if ($key['title'] != $key['oldtitle']) {
        $update_fields['title'] = $key['title'];
      }
      db_merge('photos_image')
        ->key(array(
        'fid' => $fid,
      ))
        ->fields($update_fields)
        ->execute();
      if ($key['wid']) {
        db_update('photos_node')
          ->fields(array(
          'wid' => $key['wid'],
        ))
          ->condition('fid', $fid)
          ->condition('nid', $form_state['values']['nid'])
          ->execute();
      }
    }
  }
  if (isset($msg)) {
    photos_set_count('node_node', $form_state['values']['nid']);
    drupal_set_message(t('%count images are move out.', array(
      '%count' => count($msg),
    )));
  }
}