? pathauto_bulk_delete_granular.patch
Index: pathauto.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/Attic/pathauto.inc,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 pathauto.inc
--- pathauto.inc	14 Aug 2007 23:52:13 -0000	1.1.2.2
+++ pathauto.inc	21 Aug 2007 22:34:44 -0000
@@ -69,7 +69,7 @@ function pathauto_cleanstring($string) {
   // In preparation for pattern matching, 
   // escape the separator if and only if it is not alphanumeric)
   if (isset($separator)) {
-    if (preg_match('/^(\pL|\pN)+$/D', $separator)) {
+    if (ctype_alnum($separator)) {
       $seppattern = $separator;
     } 
     else {
Index: pathauto.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto.module,v
retrieving revision 1.44.4.21
diff -u -p -r1.44.4.21 pathauto.module
--- pathauto.module	14 Aug 2007 13:58:51 -0000	1.44.4.21
+++ pathauto.module	21 Aug 2007 22:34:44 -0000
@@ -50,10 +50,10 @@ function pathauto_menu($may_cache) {
       'type' => MENU_NORMAL_ITEM,
     );
     $items[] = array(
-      'path' => 'admin/build/path/delete_all', 
-      'title' => t('Delete all aliases'),
+      'path' => 'admin/build/path/delete_bulk', 
+      'title' => t('Delete aliases'),
       'callback' => 'drupal_get_form', 
-      'callback arguments' => array('pathauto_admin_delete_confirm'),
+      'callback arguments' => array('pathauto_admin_delete'),
       'access' => user_access('administer url aliases'), 
       'type' => MENU_LOCAL_TASK,
     );
@@ -85,8 +85,6 @@ function pathauto_admin_settings() {
     return system_settings_form($form);
   }
 
-  $output = '';
-
   // Default words to ignore
   $ignore_words = array(
     "a", "an", "as", "at", "before", "but", "by", "for", "from", "is", "in",
@@ -130,7 +128,7 @@ function pathauto_admin_settings() {
   $form["general"]["pathauto_max_bulk_update"] = array('#type' => 'textfield',
     '#title' => t('Maximum number of objects to alias in a bulk update'), '#size' => 3, '#maxlength' => 3,
     '#default_value' => variable_get('pathauto_max_bulk_update', 50),
-    '#description' => t('Maximum number of objects of a given type which should be aliased during a a bulk update. The default is 50 and the recommended number depends on the speed of your server.  If you bulk updates "time out" or result in a "white screen" then reduce the number.'));
+    '#description' => t('Maximum number of objects of a given type which should be aliased during a a bulk update. The default is 50 and the recommended number depends on the speed of your server.  If bulk updates "time out" or result in a "white screen" then reduce the number.'));
 
   $form["general"]["pathauto_update_action"] = array('#type' => 'radios',
     '#title' => t('Update action'), '#default_value' => variable_get('pathauto_update_action', 2),
@@ -300,24 +298,109 @@ function pathauto_token_list($type = 'al
 /**
  * Menu callback: confirm deletion of all aliases
  */
-function pathauto_admin_delete_confirm($aid = 0) {
-  $count = db_result(db_query("SELECT count(1) FROM {url_alias}"));
+function pathauto_admin_delete($aid = 0) {
+  // Get all the counts first
+
+
+  /*
+   1) all - done
+   2) all node aliases
+   4) all user aliases
+   5) all taxonomy aliases
+   6) by node type
+   7) by taxonomy vocabulary
+   8) where src like 'pattern'
+   9) where dst like 'pattern'
+   
+   
+   ++Step 1: count them
+   
+   SELECT count(1) AS counter FROM url_alias;
+   
+   SELECT count(1) AS counter FROM url_alias WHERE src LIKE 'node/%';
+   
+   SELECT count(1) FROM url_alias WHERE src LIKE 'user/%';
+   
+   SELECT count(1) FROM url_alias WHERE src LIKE 'taxonomy/%';
+   
+   
+   ++Step 2: delete them
+   
+   DELETE FROM url_alias;
+   
+   DELETE FROM url_alias WHERE src LIKE 'node/%';
+   
+   DELETE FROM url_alias WHERE src LIKE 'user/%';
+   
+   DELETE FROM url_alias WHERE src LIKE 'taxonomy/%';
+  */
+
   $form = array();
-  $output = confirm_form($form,
-                  t('Are you sure you want to delete ALL of your Path aliases?'),
-                  'admin/build/path',
-                  t('Continuing will delete %count aliases.  This action cannot be undone.', array('%count' => $count)),
-                  t('Delete all'),
-                  t('Cancel'));
-  return $output;
+  
+  $form["delete"] = array('#type' => 'fieldset',
+    '#title' => t('Choose Aliases to Delete'), '#collapsible' => FALSE,
+    '#collapsed' => FALSE);
+
+
+  // First we do the "all" case
+  $total_count = db_result(db_query("SELECT count(1) FROM {url_alias}"));
+  $form['delete']['all_aliases'] = array('#type' => 'checkbox',
+					 '#title' => t('all aliases'),
+					 '#default_value' => FALSE,
+					 '#description' => t('Delete all aliases.  Number of aliases which will be deleted: %count.', array('%count' => $total_count)));
+
+
+
+  $objects = _pathauto_objects_to_delete();
+  foreach ($objects as $internal_name => $label) {
+    $count = db_result(db_query("SELECT count(1) FROM {url_alias} WHERE src LIKE '%s%%'", $internal_name));
+    $form['delete'][$internal_name] = array('#type' => 'checkbox',
+					    '#title' => t($label),
+					    '#default_value' => FALSE,
+					    '#description' => t('Delete aliases for all @label. Number of aliases which will be deleted: %count.', array('@label' => $label, '%count' => $count)));
+  }
+
+  /*$output = confirm_form($form,
+   t('Are you sure you want to delete ALL of your Path aliases?'),
+   'admin/build/path',
+   t('Continuing will delete %count aliases.  This action cannot be undone.', array('%count' => $count)),
+   t('Delete all'),
+   t('Cancel'));
+  */
+
+  $form["warning"] = array('#value' => t('<p><strong>Note:</strong> there is no confirmation.  Be sure of your action before clicking the "Delete aliases now!" button.</p>'));
+
+  $form['buttons']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Delete aliases now!'),
+  );
+
+  return $form;
 }
 
-function pathauto_admin_delete_confirm_submit($form_id, $form_values) {
-  db_query('DELETE FROM {url_alias}');
-  drupal_set_message(t('All of your path aliases have been deleted.'));
-  return 'admin/build/path';
+function pathauto_admin_delete_submit($form_id, $form_values) {
+  drupal_set_message(dprint_r($form_values,true));
+  foreach ($form_values as $key => $value) {
+    if ($value) {
+      if ($key == 'all_aliases') {
+	db_query('DELETE FROM {url_alias}');
+	drupal_set_message(t('All of your path aliases have been deleted.'));
+      }
+      $objects = _pathauto_objects_to_delete();
+      if (array_key_exists($key, $objects)) {
+	drupal_set_message($key);
+	db_query("DELETE FROM {url_alias} WHERE src LIKE '%s%%'", $key);
+	drupal_set_message(t('All of your %type path aliases have been deleted.', array('%type' => $objects[$key])));
+      }
+      
+    }
+  }
+  return 'admin/build/path/delete_bulk';
 }
 
+function _pathauto_objects_to_delete(){
+  return array('user/' => t('users'), 'node/' => t('content') , 'taxonomy/' => t('vocabularies and terms'), 'blog/' => t('user blogs'), 'user/%/track' => t('user trackers'));
+}
 
 //==============================================================================
 // Some node related functions.
