Index: contrib/basicevent.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/event/contrib/basicevent.module,v
retrieving revision 1.5
diff -u -r1.5 basicevent.module
--- contrib/basicevent.module	29 Oct 2005 13:15:25 -0000	1.5
+++ contrib/basicevent.module	18 Nov 2005 23:14:08 -0000
@@ -3,7 +3,7 @@
 
 /**
  * @file
- * A story-like module with event information built in.
+ * An extremly simple module to implement the event API.
  */
 
 /**
@@ -19,33 +19,34 @@
 }
 
 /**
- * Implementation of hook_node_name().
+ * Implementation of hook_node_info().
  */
-function event_node_name($node) {
-  return t('event');
+function basicevent_node_info() {
+  return array('event' => array('name' => t('event'), 'base' => 'basicevent'));
 }
 
 /**
  * Implementation of hook_perm().
  */
-function event_perm() {
+function basicevent_perm() {
   return array('create events', 'edit own events');
 }
 
 /**
  * Implementation of hook_access().
  */
-function event_access($op, $node) {
+function basicevent_access($op, $node) {
   global $user;
-
-  if ($op == 'create') {
-    return user_access('create events');
-  }
-
-  if ($op == 'update' || $op == 'delete') {
-    if (user_access('edit own events') && ($user->uid == $node->uid)) {
-      return TRUE;
-    }
+  switch($op) {
+    case 'create':
+      return user_access('create events');
+      break;
+    case 'update':
+    case 'delete':
+      if (user_access('edit own events') && ($user->uid == $node->uid)) {
+        return TRUE;
+      }
+      break;
   }
 }
 
@@ -66,81 +67,18 @@
 /**
  * Implementation of hook_form().
  */
-function event_form(&$node) {
-  $output = '';
-
-  if (function_exists('taxonomy_node_form')) {
-    $output .= implode('', taxonomy_node_form('event', $node));
+function basicevent_form(&$node) {
+  // warn them if this isn't set to appear in the calendar
+  if (variable_get('event_nodeapi_event', 'never') == 'never') {
+    $link = l(t('event content-type settings page'), 'admin/settings/content-types/event');
+    drupal_set_message(t('The event node is currently set to never appear in the calendar. You will not be able to set the start and end dates until an administrator changes the content-type settings. This is done using the %link.', array('%link' => $link)));
   }
-  $form['title'] = array('#type' => 'textfield', '#title' => t('Subject'), '#default_value' => $node->title, '#size' => 60, '#maxlength' => 128, '#required' => TRUE);
-  $form['body'] = array(
-    '#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#required' => TRUE
-  );
-  $form = array_merge($form, filter_form($node->format));
 
-  if (module_exist('location') || variable_get('location_event', 0)) {
+  $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $node->title, '#size' => 60, '#maxlength' => 128, '#required' => TRUE);
+  $form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#required' => TRUE);
 
-    $output .= '<div class="container-inline">';
-    $output .= form_textfield(t('Location Name'), 'location][name', $node->location['name'], 64, 64, t('e.g. a place of business, venue, meeting point'));
-    $output .= "</div>\n";
-  }
+  $form = array_merge($form, filter_form($node->format));
 
   return $form;
 }
-
-
-/** 
- * Implementation of hook_load()
- * 
- * Here is where we set $node->show_as_event
- * The event.module does the rest.
- */
-function event_load($node) {
-  if (!module_exist('location') || !variable_get('location_event', 0)) {
-    $additions = array('show_as_event', variable_get('event_nodeapi_basicevent', 'all'));
-    $result = db_fetch_array(db_query("SELECT name, street, additional, city, province, postal_code, country FROM {location} WHERE oid = %d and type='node'", $node->nid));
-    if (is_array($result)) {
-      foreach ($result as $name => $value) {
-        $additions['location'][$name] = $value;
-      }
-    }
-    return $additions;
-  }
-}
-
-function basicevent_insert($node) {
-  if (!module_exist('location') || !variable_get('location_event', 0)) {
-    db_query("INSERT INTO {location} (oid, type, name, street, additional, city, province, postal_code, country) VALUES (%d, 'node', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", 
-      $node->nid, $node->location['name'], $node->location['street'], $node->location['additional'], $node->location['city'], $node->location['province'], $node->location['postal_code'], $node->location['country']);
-  }
-}
-
-function basicevent_delete($node) {
-  if (!module_exist('location') || !variable_get('location_event', 0)) {
-    db_query("DELETE FROM {location} WHERE oid = %d and type='node'", $node->nid);
-  }
-}
-
-function event_update($node) {
-
-  if (!module_exist('location') || !variable_get('location_event', 0)) {
-    db_query('LOCK TABLES {location} WRITE');
-    basicevent_delete($node);
-    basicevent_insert($node);
-    db_query('UNLOCK TABLES');
-  }
-}
-
-function event_view(&$node, $teaser = FALSE, $page = FALSE) {
-  if (!module_exist('location') || !variable_get('location_event', 0)) {
-    $node->body .= theme('location_event', $node->location);
-  }
-  $node = node_prepare($node, $teaser);
-} 
-
-
-function theme_location_event($location) {
-  return "<div class='location'>" . $location->name . "</div>";
-}
-
 ?>
\ No newline at end of file

