You are here

function pathauto_nodeapi in Pathauto 6.2

Same name and namespace in other branches
  1. 5.2 pathauto.module \pathauto_nodeapi()
  2. 5 pathauto_node.inc \pathauto_nodeapi()
  3. 6 pathauto.module \pathauto_nodeapi()

Implements hook_nodeapi().

4 calls to pathauto_nodeapi()
PathautoBookTokenTestCase::testBookPathAlias in ./pathauto.test
PathautoLocaleTestCase::testLanguageAliases in ./pathauto.test
Test that when an English node is updated, its old English alias is updated and its newer French alias is left intact.
PathautoUnitTestCase::testNoTokensNoAlias in ./pathauto.test
Test that pathauto_create_alias() will not create an alias for a pattern that does not get any tokens replaced.
PathautoUnitTestCase::testUpdateActions in ./pathauto.test
Test the different update actions in pathauto_create_alias().

File

./pathauto.module, line 316
Main file for the Pathauto module, which automatically generates aliases for content.

Code

function pathauto_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'presave':

      // About to be saved (before insert/update)
      if (!empty($node->pathauto_perform_alias) && isset($node->old_alias) && $node->path == '' && $node->old_alias != '') {

        /**
         * There was an old alias, but when pathauto_perform_alias was checked
         * the javascript disabled the textbox which led to an empty value being
         * submitted. Restoring the old path-value here prevents the Path module
         * from deleting any old alias before Pathauto gets control.
         */
        $node->path = $node->old_alias;
      }
      break;
    case 'insert':
    case 'update':
      pathauto_node_update_alias($node, $op);
      break;
    case 'delete':
      pathauto_path_delete_all("node/{$node->nid}");
      break;
  }
}