You are here

function path_redirect_nodeapi in Path redirect 6

Same name and namespace in other branches
  1. 5 path_redirect.module \path_redirect_nodeapi()

Implements hook_nodeapi().

File

./path_redirect.module, line 242

Code

function path_redirect_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'presave':
      if (!empty($node->nid) && !empty($node->path)) {
        path_redirect_check_alias_changed('node/' . $node->nid, $node->path, $node->language);
      }
      break;
    case 'delete':

      // When a node is deleted, also delete the redirects to it (they will result in a 404).
      path_redirect_delete_multiple(NULL, array(
        'source' => 'node/' . $node->nid,
      ));
      path_redirect_delete_multiple(NULL, array(
        'redirect' => 'node/' . $node->nid,
      ));
      break;
  }
}