--- pathauto_node.inc Fri Oct 13 18:02:00 2006 +++ pathauto_node.inc Sun Oct 29 15:33:18 2006 @@ -275,3 +275,33 @@ return $output; } +/** + * Implementation of hook_pathauto_user(). + * As we use [user], we need to update the links when username changes... + */ +function node_pathauto_userupdate($edit=NULL,$user=NULL) { + $edit = (object) $edit; + if($edit->name) { + // get the nodes belonging to this user... + $query = "SELECT n.nid, p.src, p.dst FROM {node} n LEFT JOIN {url_alias} p ON CONCAT('node/', n.nid) = p.src WHERE n.uid = %d"; + $result = db_query($query,$user->uid); + $node_ref = db_fetch_object($result); + $placeholders = array(); + while ($node_ref) { + $node = node_load($node_ref->nid); + $node->src = $node_ref->src; + $node->dst = $node_ref->dst; + if (module_exist('taxonomy')) { + // Must populate the terms for the node here for the category + // placeholders to work + $node->taxonomy = array_keys(taxonomy_node_get_terms($node->nid)); + } + $placeholders = node_get_placeholders($node); + // user is not updated in the database yet... so take the $edit one... + $placeholders[t('[user]')] = pathauto_cleanstring($edit->name); + $src = "node/$node->nid"; + pathauto_create_alias('node', 'update', $placeholders, $src, $node->type); + $node_ref = db_fetch_object($result); + } + } +}