RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.module,v
retrieving revision 1.5.2.32
diff -u -p -r1.5.2.32 xmlsitemap_engines.module
--- xmlsitemap_engines.module	12 May 2009 00:05:19 -0000	1.5.2.32
+++ xmlsitemap_engines.module	12 May 2009 12:21:14 -0000
@@ -21,7 +21,7 @@
 function xmlsitemap_engines_cron() {
   if (!variable_get('site_offline', 0) && variable_get('xmlsitemap_engines_cron_submit_frequency', 3600) > 0 && variable_get('xmlsitemap_sitemap_is_changed', FALSE)) {
     if ((REQUEST_TIME - variable_get('xmlsitemap_engines_cron_timestamp_submit', REQUEST_TIME)) >= variable_get('xmlsitemap_engines_cron_submit_frequency', 3600)) {
-      xmlsitemap_engines_ping_sitemap();
+      xmlsitemap_engines_ping_sitemap(NULL, TRUE);
       variable_set('xmlsitemap_sitemap_is_changed', FALSE);
       variable_set('xmlsitemap_engines_cron_timestamp_submit', REQUEST_TIME);
     }
@@ -33,7 +33,7 @@ function xmlsitemap_engines_cron() {
  */
 function xmlsitemap_engines_init() {
   if (!variable_get('site_offline', 0) && arg(0) != 'batch' && variable_get('xmlsitemap_engines_submit', FALSE) && variable_get('xmlsitemap_sitemap_is_changed', FALSE)) {
-    xmlsitemap_engines_ping_sitemap();
+    xmlsitemap_engines_ping_sitemap(NULL, TRUE);
     variable_set('xmlsitemap_sitemap_is_changed', FALSE);
   }
 }
@@ -86,38 +86,53 @@ function xmlsitemap_engines_menu() {
 }
 
 /**
+ * Implementation of hook_form_FORM_ID_alter().
+ */
+function xmlsitemap_engines_form_xmlsitemap_tools_settings_alter(&$form, &$from_state) {
+  $options = array(
+    'ask' => t('Ask.com'),
+    'google' => t('Google'),
+    'moreover' => t('Moreover.com'),
+    'live' => t('Microsoft Live'),
+    'yahoo' => t('Yahoo!'),
+  );
+  foreach ($options as $id => $title) {
+    if (!variable_get("xmlsitemap_engines_{$id}_submit", FALSE)) {
+      unset($options[$id]);
+    }
+  }
+  $form['submit_to_search_engines'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Submit to search engines'),
+    '#collapsible' => TRUE,
+  );
+  if (count($options)) {
+    $form['submit_to_search_engines']['xmlsitemap_engine_parameter_search_engines'] = array(
+      '#type' => 'checkboxes', 
+      '#title' => t('Search engines'), 
+      '#default_value' => variable_get('xmlsitemap_engine_parameter_search_engines', array()),
+      '#options' => $options,
+      '#checkall' => count($options) > 1 ? TRUE : FALSE,
+    );
+  }
+  else {
+    $form['submit_to_search_engines']['message'] = array(
+      '#value' => t('None of the supported search engines has been enabled. You can enable them in the <a href="@search_engines">search engines</a> settings page.', array('@search_engines' => url('admin/settings/xmlsitemap/engines'))),
+      '#prefix' => '<div>',
+      '#suffix' => '</div>',
+    );
+  }
+  xmlsitemap_tools_settings_form($form);
+}
+
+/**
  * Implementation of hook_xmlsitemap_operations().
  */
 function xmlsitemap_engines_xmlsitemap_operations() {
   return array(
-    'submit_to_all' => array(
-      'label' => t('Submit the sitemap to all the active search engines'),
-      'callback' => 'xmlsitemap_engines_ping_sitemap',
-    ),
-    'submit_to_askcom' => array(
-      'label' => t('Submit the sitemap to Ask.com'),
-      'callback' => 'xmlsitemap_engines_ping_sitemap',
-      'callback arguments' => array('engine' => 'ask'),
-    ),
-    'submit_to_google' => array(
-      'label' => t('Submit the sitemap to Google'),
-      'callback' => 'xmlsitemap_engines_ping_sitemap',
-      'callback arguments' => array('engine' => 'google'),
-    ),
-    'submit_to_moreovercom' => array(
-      'label' => t('Submit the sitemap to Moreover.com'),
-      'callback' => 'xmlsitemap_engines_ping_sitemap',
-      'callback arguments' => array('engine' => 'moreover'),
-    ),
-    'submit_to_live' => array(
-      'label' => t('Submit the sitemap to Microsoft Live'),
-      'callback' => 'xmlsitemap_engines_ping_sitemap',
-      'callback arguments' => array('engine' => 'live'),
-    ),
-    'submit_to_yahoo' => array(
-      'label' => t('Submit the sitemap to Yahoo!'),
-      'callback' => 'xmlsitemap_engines_ping_sitemap',
-      'callback arguments' => array('engine' => 'yahoo'),
+    'submit_to_search_engines' => array(
+      'label' => t('Submit the sitemap to all the enabled search engines'),
+      'callback' => '_xmlsitemap_engines_operation_ping_sitemap',
     ),
   );
 }
@@ -128,9 +143,14 @@ function xmlsitemap_engines_xmlsitemap_o
 
 /**
  * Submit the sitemap to the selected engines.
+ * @param $engines
+ *   An array of search engine identifiers.
+ * @param $all
+ *   If $engines is an empty array, and $all is TRUE, the sitemap will be
+ *   submitted to all the enabled search engines.
  */
-function xmlsitemap_engines_ping_sitemap($engine = NULL) {
-  $engines = array(
+function xmlsitemap_engines_ping_sitemap($engines = array(), $all = FALSE) {
+  $engines_data = array(
     'ask' => array(
       'Ask.com',
       'http://submissions.ask.com/ping?sitemap=[sitemap]'
@@ -152,44 +172,41 @@ function xmlsitemap_engines_ping_sitemap
       'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=[sitemap]'
     ),
   );
-  if (!isset($engine)) {
-    foreach ($engines as $id => $info) {
-      if (variable_get("xmlsitemap_engines_{$id}_submit", FALSE)) {
-        xmlsitemap_engines_submit_sitemap($info[0], "xmlsitemap_engines_{$id}_url", $info[1]);
+  if (empty($engines) && $all) {
+    $engines = array('ask', 'google', 'moreover', 'live', 'yahoo');
+  }
+  if (!empty($engines)) {
+    foreach ($engines_data as $id => $info) {
+      if (in_array($id, $engines) && variable_get("xmlsitemap_engines_{$id}_submit", FALSE)) {
+        $url = strtr(
+          variable_get("xmlsitemap_engines_{$id}_url", $info[1]),
+          array('[sitemap]' => url('sitemap.xml', array('absolute' => TRUE)))
+        );
+        $result = drupal_http_request($url);
+        if ($result->code == 200) {
+          watchdog('xmlsitemap', 'The sitemap has been successfully submitted to !engine.', array('!engine' => $info[0]));
+        }
+        else {
+          watchdog('xmlsitemap', 'An error occurred while submitting the sitemap to !engine: !code.',
+            array('!engine' => $info[0], '!code' => 0 + $result->code), WATCHDOG_ERROR
+          );
+        }
       }
     }
   }
-  elseif (isset($engines[$engine])) {
-    xmlsitemap_engines_submit_sitemap($engines[$engine][0], "xmlsitemap_engines_{$engine}_url", $engines[$engine][1]);
-  }
 }
 
-/**
- * Helper function for xmlsitemap_engines_ping_sitemap().
- * Submit the sitemap to the engine passed as argument, and write a message in
- * Drupal log.
- *
- * @param $engine
- *  The identifier for the search engine.
- * @param $url_var
- *  The variable name containing the submission URL used by the search engine.
- * @param $default_url
- *  The default submission URL.
- */
-function xmlsitemap_engines_submit_sitemap($engine, $url_var, $default_url) {
-  $url = strtr(
-    variable_get($url_var, $default_url),
-    array('[sitemap]' => url('sitemap.xml', array('absolute' => TRUE)))
-  );
-  $result = drupal_http_request($url);
-  if ($result->code == 200) {
-    watchdog('xmlsitemap', 'The sitemap has been successfully submitted to !engine.', array('!engine' => $engine));
-  }
-  else {
-    watchdog('xmlsitemap', 'An error occurred while submitting the sitemap to !engine: !code.',
-      array('!engine' => $engine, '!code' => 0 + $result->code), WATCHDOG_ERROR
-    );
-  }
+/*****************************************************************************
+ * Private functions - sitemap operations.
+ ****************************************************************************/
+
+function _xmlsitemap_engines_operation_ping_sitemap() {
+  xmlsitemap_engines_ping_sitemap(
+    array_filter(
+      variable_get('xmlsitemap_engine_parameter_search_engines', array())
+    )
+  );
+  drupal_set_message(t('The sitemap has been submitted to the search engines'), 'status', FALSE);
 }
 
 /**
Index: /Users/Kiam/Sandbox/6.1-dev/contributions/modules/xmlsitemap/xmlsitemap/xmlsitemap.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap/Attic/xmlsitemap.admin.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 xmlsitemap.admin.inc
--- xmlsitemap.admin.inc	7 May 2009 09:21:54 -0000	1.1.2.6
+++ xmlsitemap.admin.inc	12 May 2009 12:21:17 -0000
@@ -97,7 +97,7 @@ function xmlsitemap_settings_submit($for
 /**
  * Form builder; return the tools form.
  */
-function xmlsitemap_tools() {
+function xmlsitemap_tools_basic() {
   $form['options'] = array(
     '#type' => 'fieldset',
     '#title' => t('Operations'),
@@ -119,7 +119,7 @@ function xmlsitemap_tools() {
   $form['options']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Apply'),
-    '#submit' => array('xmlsitemap_tools_submit'),
+    '#submit' => array('xmlsitemap_tools_basic_submit'),
   );
   return $form;
 }
@@ -127,7 +127,7 @@ function xmlsitemap_tools() {
 /**
  * Submit the tools form.
  */
-function xmlsitemap_tools_submit($form, &$form_state) {
+function xmlsitemap_tools_basic_submit($form, &$form_state) {
   $operations = module_invoke_all('xmlsitemap_operations');
   $operation = $operations[$form_state['values']['operation']];
   $function = $operation['callback'];
@@ -141,5 +141,20 @@ function xmlsitemap_tools_submit($form, 
 }
 
 /**
+ * Form builder; return the tools settings form.
+ */
+function xmlsitemap_tools_settings() {
+  $form['empty'] = array(
+    '#type' => 'fieldset',
+  );
+  $form['empty']['info'] = array(
+    '#value' => t('There are no settings currently defined.'),
+    '#prefix' => '<div>',
+    '#suffix' => '</div>',
+  );
+  return $form;
+}
+
+/**
  * @} End of "addtogroup xmlsitemap".
  */
Index: /Users/Kiam/Sandbox/6.1-dev/contributions/modules/xmlsitemap/xmlsitemap/xmlsitemap.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap/Attic/xmlsitemap.install,v
retrieving revision 1.1.2.56
diff -u -p -r1.1.2.56 xmlsitemap.install
--- xmlsitemap.install	11 May 2009 13:32:58 -0000	1.1.2.56
+++ xmlsitemap.install	12 May 2009 12:21:17 -0000
@@ -771,6 +771,13 @@ function xmlsitemap_update_6140() {
  * Implementation of hook_update_N().
  */
 function xmlsitemap_update_6141() {
+  return array();
+}
+
+/**
+ * Implementation of hook_update_N().
+ */
+function xmlsitemap_update_6142() {
   $ret = array();
   if (!variable_get('menu_rebuild_needed', FALSE)) {
     variable_set('menu_rebuild_needed', TRUE);
Index: /Users/Kiam/Sandbox/6.1-dev/contributions/modules/xmlsitemap/xmlsitemap/xmlsitemap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap/Attic/xmlsitemap.module,v
retrieving revision 1.1.2.114
diff -u -p -r1.1.2.114 xmlsitemap.module
--- xmlsitemap.module	12 May 2009 00:05:26 -0000	1.1.2.114
+++ xmlsitemap.module	12 May 2009 12:21:17 -0000
@@ -115,11 +115,26 @@ function xmlsitemap_menu() {
     'title' => 'Tools',
     'description' => 'Sitemap tools.',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('xmlsitemap_tools'),
+    'page arguments' => array('xmlsitemap_tools_basic'),
     'access arguments' => $access_config,
     'type' => MENU_LOCAL_TASK,
     'file' => 'xmlsitemap.admin.inc',
   );
+  $items['admin/settings/xmlsitemap/tools/basic'] = array(
+    'title' => 'Basic',
+    'description' => 'Sitemap tools.',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'file' => 'xmlsitemap.admin.inc',
+  );
+  $items['admin/settings/xmlsitemap/tools/settings'] = array(
+    'title' => 'Settings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('xmlsitemap_tools_settings'),
+    'access arguments' => $access_config,
+    'weight' => 5,
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'xmlsitemap.admin.inc',
+  );
   $items['sitemap.xml'] = array(
     'title' => 'Sitemap index',
     'page callback' => 'xmlsitemap_output',
@@ -165,11 +180,11 @@ function xmlsitemap_xmlsitemap_operation
   return array(
     'delete_cache_files' => array(
       'label' => t('Delete the sitemap cache files'),
-      'callback' => 'xmlsitemap_delete_cache_files',
+      'callback' => '_xmlsitemap_operation_delete_cache_files',
     ),
     'flag_sitemap' => array(
       'label' => t('Flag the sitemap as requiring update'),
-      'callback' => 'xmlsitemap_flag_sitemap',
+      'callback' => '_xmlsitemap_operation_flag_sitemap',
     ),
   );
 }
@@ -249,12 +264,22 @@ function xmlsitemap_cron_options() {
  * changed.
  */
 function xmlsitemap_delete_cache_files() {
-  file_scan_directory(
+  $result = TRUE;
+  $files = file_scan_directory(
     variable_get('xmlsitemap_cache_directory', file_directory_path() .'/xmlsitemap'),
-    'xsm-.*\.xml', array('.', '..', 'CVS'), 'file_delete', FALSE
+    'xsm-.*\.xml', array('.', '..', 'CVS'), 0, FALSE
   );
+  foreach ($files as $filename => $info) {
+    $result = $result && file_delete($filename);
+  }
   xmlsitemap_flag_sitemap();
-  watchdog('xmlsitemap', 'The sitemap cache files have been deleted.');
+  if ($result) {
+    watchdog('xmlsitemap', 'The sitemap cache files have been deleted.');
+  }
+  else {
+    watchdog('xmlsitemap', 'Some of the sitemap cache files have not been deleted.', WATCHDOG_WARNING);
+  }
+  return $result;
 }
 
 /**
@@ -321,6 +346,16 @@ function xmlsitemap_priority_options($op
 }
 
 /**
+ * Change the tools settings form, and remove the placeholder item.
+ */
+function xmlsitemap_tools_settings_form(&$form) {
+  if (isset($form['empty'])) {
+    unset($form['empty']);
+    $form = system_settings_form($form);
+  }
+}
+
+/**
  * Determine the frequency of updates to a link.
  * @param $interval
  *  The number of seconds since the last change, or the number of seconds
@@ -399,6 +434,24 @@ function xmlsitemap_user_form_fieldset()
 }
 
 /*****************************************************************************
+ * Private functions - sitemap operations.
+ ****************************************************************************/
+
+function _xmlsitemap_operation_delete_cache_files() {
+  if (xmlsitemap_delete_cache_files()) {
+    drupal_set_message(t('The sitemap cache files have been deleted.'), 'status', FALSE);
+  }
+  else {
+    drupal_set_message(t('Some of the sitemap cache files have not been deleted.'), 'warning', FALSE);
+  }
+}
+
+function _xmlsitemap_operation_flag_sitemap() {
+  xmlsitemap_flag_sitemap();
+  drupal_set_message(t('The sitemap has been flagged as needing update.'), 'status', FALSE);
+}
+
+/*****************************************************************************
  * Private functions.
  ****************************************************************************/
 
