Index: spaces_calendar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/spaces/spaces_calendar/spaces_calendar.module,v
retrieving revision 1.2
diff -u -p -r1.2 spaces_calendar.module
--- spaces_calendar.module	18 Jun 2008 21:30:02 -0000	1.2
+++ spaces_calendar.module	14 Jul 2008 16:01:22 -0000
@@ -8,15 +8,16 @@
  * We need to document the feed api integration as well.
  */
 
-define(SPACES_EVENT_TYPE, 'event');
-define(SPACES_EVENT_FEED_TYPE, 'feed_ical');
-define(SPACES_EVENT_FEED_ITEM_TYPE, 'feed_ical_item');
-define(SPACES_EVENT_DATE_FIELD, 'field_date');
+define(SPACES_EVENT_TYPE, variable_get('spaces_calendar_nodetype', 'event'));
+define(SPACES_EVENT_FEED_TYPE, variable_get('spaces_calendar_feed_nodetype', 'feed_ical'));
+define(SPACES_EVENT_FEED_ITEM_TYPE, variable_get('spaces_calendar_feed_itemtype', 'feed_ical_item'));
+define(SPACES_EVENT_DATE_FIELD, variable_get('spaces_calendar_datefield', 'field_date'));
 
 /**
  * Implementation of hook_menu()
  */
 function spaces_calendar_menu($may_cache) {
+  $items = array();
   if ($may_cache) {
     if (module_exists('feedapi') && module_exists('feedapi_mapper')) {
       if (!variable_get('feedapi_mapper_mapping_'. SPACES_EVENT_FEED_TYPE, array())) {
@@ -27,7 +28,18 @@ function spaces_calendar_menu($may_cache
         variable_set('feedapi_mapper_mapping_'. SPACES_EVENT_FEED_TYPE, $mapping);
       }
     }
+    $items[] = array(
+      'path' => 'admin/settings/spaces/calendar',
+      'title' => t('Spaces calendar settings'),
+      'description' => t('Spaces calendar feature defaults.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('spaces_calendar_settings_form'),
+      'access' => user_access('administer group features'),
+      'type' => MENU_LOCAL_TASK,
+      'weight' => 1,
+    );    
   }
+  return $items;
 }
 
 /**
@@ -74,6 +86,72 @@ function spaces_calendar_form_alter($for
   }
 }
 
+function spaces_calendar_settings_form() {
+  $form = array();
+  $types = array();
+  $nodetypes = node_get_types();
+  foreach ($nodetypes as $ntype => $nname) {
+    $types[$ntype] = $nname->name;
+  }
+  
+  $fields = content_fields();
+  $fieldtypes = array();
+  foreach ($fields as $field) {
+    $fieldtypes[$field['field_name']] = t($field['widget']['label']) .' ('. $field['field_name'] .')';
+  }
+  
+  $form['spaces_calendar_default_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => 'Spaces calendar default settings',
+  );
+  
+  $form['spaces_calendar_default_settings']['spaces_calendar_nodetype'] = array(
+    '#type' => 'select',
+    '#title' => t('Event node types'),
+    '#description' => t('Select the designated node type for events.'),
+    '#options' => $types,
+    '#default_value' => variable_get('spaces_calendar_nodetype', 'event'),
+    '#multiple' => FALSE,
+  );
+  
+  $form['spaces_calendar_default_settings']['spaces_calendar_datefield'] = array(
+    '#type' => 'select',
+    '#title' => t('Event date field'),
+    '#description' => t('Select the designated cck date field to use for events events.'),
+    '#options' => $fieldtypes,
+    '#default_value' => variable_get('spaces_calendar_datefield', 'field_date'),
+    '#multiple' => FALSE,
+  );
+  
+  if (module_exists('feedapi') && module_exists('feedapi_mapper')) {
+    
+    $form['spaces_calendar_feedapi_settings'] = array(
+      '#type' => 'fieldset',
+      '#title' => 'Spaces calendar feedapi/ical integration settings',
+    );
+  
+    $form['spaces_calendar_feedapi_settings']['spaces_calendar_feed_nodetype'] = array(
+      '#type' => 'select',
+      '#title' => t('FeedAPI feed node type'),
+      '#description' => t('Select the type of node that will hold ical feeds.'),
+      '#options' => $types,
+      '#default_value' => variable_get('spaces_calendar_feed_nodetype', 'feed_ical'),
+      '#multiple' => FALSE,
+    );
+    
+    $form['spaces_calendar_feedapi_settings']['spaces_calendar_feed_itemtype'] = array(
+      '#type' => 'select',
+      '#title' => t('FeedAPI node item type'),
+      '#description' => t('Select the type of node that events from ical feeds should be created into.'),
+      '#options' => $types,
+      '#default_value' => variable_get('spaces_calendar_feed_itemtype', 'feed_ical_item'),
+      '#multiple' => FALSE,
+    );
+  }
+  
+  return system_settings_form($form);
+}
+
 /**
  *  Implementation of hook_default_views
  */
