You are here

function photos_edit_cover in Album Photos 7.3

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

Update album cover.

1 string reference to 'photos_edit_cover'
photos_menu in ./photos.module
Implements hook_menu().

File

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

Code

function photos_edit_cover($node, $fid) {
  $pid = db_query('SELECT pid FROM {photos_image} WHERE fid = :fid', array(
    ':fid' => $fid,
  ))
    ->fetchField();
  if ($pid == $node->nid) {
    db_query('UPDATE {photos_album} SET fid = :fid WHERE pid = :pid', array(
      ':fid' => $fid,
      ':pid' => $node->nid,
    ));
    drupal_set_message(t('Cover successfully set.'));
    $goto = isset($_GET['destination']) ? $_GET['destination'] : 'node/' . $node->nid . '/photos';
    return drupal_goto($goto);
  }
  else {
    drupal_not_found();
  }
}