You are here

function photos_node_delete in Album Photos 7.3

Same name and namespace in other branches
  1. 8.5 photos.module \photos_node_delete()
  2. 8.4 photos.module \photos_node_delete()
  3. 6.0.x photos.module \photos_node_delete()

Implements hook_node_delete().

File

./photos.module, line 837
Implementation of photos.module.

Code

function photos_node_delete($node) {
  if ($node->type == 'photos') {
    if ($node->album['count'] || !variable_get('photos_user_count_cron', 0)) {
      $result = db_query('SELECT f.fid, f.uri FROM {file_managed} f INNER JOIN {photos_image} p ON f.fid = p.fid WHERE p.pid = :nid', array(
        ':nid' => $node->nid,
      ));
      foreach ($result as $file) {
        $msg[] = photos_file_del($file->fid, $file->uri);
      }
      if (isset($msg[0])) {
        photos_set_count('user_image', $node->uid);
        drupal_set_message(t('%count images are deleted.', array(
          '%count' => COUNT($msg),
        )));
      }
    }
    db_query("DELETE FROM {photos_album} WHERE pid = :nid", array(
      ':nid' => $node->nid,
    ));
    photos_set_count('user_album', $node->uid);
  }
  if (variable_get('photos_node_' . $node->type, 0)) {
    db_query("DELETE FROM {photos_node} WHERE nid = :nid", array(
      ':nid' => $node->nid,
    ));
    db_query("DELETE FROM {photos_count} WHERE cid = :nid AND type = :type", array(
      ':nid' => $node->nid,
      ':type' => 'node_node',
    ));
  }
}