Index: pathauto_user.inc =================================================================== --- pathauto_user.inc (revision 1) +++ pathauto_user.inc (working copy) @@ -72,6 +72,29 @@ } /** + * Implementation of hook_pathauto() for user-tracker aliases + */ +function contact_pathauto($op) { + switch ($op) { + case 'settings': + $settings = array(); + $settings['module'] = 'contact'; + $settings['groupheader'] = t('User-contact path settings'); + $settings['patterndesc'] = t('Pattern for user-contact form paths'); + $settings['patterndefault'] = t('user/[user]/contact'); + $settings['placeholders'] = array( + t('[user]') => t('The name of the user.'), + t('[uid]') => t('The id number of the user.') + ); + $settings['bulkname'] = t('Bulk update user-contact form paths'); + $settings['bulkdescr'] = t('Generate aliases for all existing user-contact forms which do not already have aliases.'); + return (object) $settings; + default: + break; + } +} + +/** * Implementation of hook_user() for users, trackers, and blogs */ function pathauto_user($op, &$edit, &$user, $category=FALSE) { @@ -96,6 +119,10 @@ $src = 'user/'.$user->uid.'/track'; $alias = pathauto_create_alias('tracker', $op, $placeholders, $src); } + if (module_exist('contact')) { + $src = 'user/'.$user->uid.'/contact'; + $alias = pathauto_create_alias('contact', $op, $placeholders, $src); + } } break; case 'delete': @@ -189,4 +216,28 @@ "Bulk update of user tracker pages completed, %count aliases generated.")); } +function contact_pathauto_bulkupdate() { + $query = 'SELECT uid,name,src,dst FROM {users} '. + "LEFT JOIN {url_alias} ON CONCAT('user/', uid) = src ". + 'WHERE uid > 0'; + $result = db_query($query); + $user = db_fetch_object($result); + + $count = 0; + $placeholders = array(); + while ($user) { + $placeholders[t('[user]')] = pathauto_cleanstring($user->name); + $placeholders[t('[uid]')] = $user->uid; + $src = 'user/'.$user->uid.'/contact'; + if ($alias = pathauto_create_alias('contact', 'bulkupdate', $placeholders, $src)) { + $count++; + } + $user = db_fetch_object($result); + } + + drupal_set_message(format_plural($count, + "Bulk update of user-contact forms completed, one alias generated.", + "Bulk update of user-contact forms completed, %count aliases generated.")); +} + ?> \ No newline at end of file