Making sure you got the Events entered correctly

As a recent convert to the Event family, and hitting a small bug (that has been fixed now), I found it messy to make sure I had the events entered without weird starting/ending times or the right taxonomy terms or the right durations. So I decided to check up on myself and created this little snippet to show all my events in a little more concise way. This is just a simple table that summarizes all those fields. Feel free to use it.

Note: This snippet is for 5.x-1.x of Event.

<?php
  $header
= array('Title', 'Type', 'Term', 'Start', 'End', 'Length');
 
$rows = array();
 
$results = db_query("SELECT n.nid, n.title, n.type, td.name AS term, e.event_start AS start, e.event_end AS end FROM {node} n INNER JOIN {event} e ON e.nid = n.nid LEFT JOIN {term_node} tn ON tn.nid = n.nid LEFT JOIN {term_data} td ON td.tid = tn.tid ORDER BY start");
  while (
$node = db_fetch_object($results)) {
    if (
$node->end > $node->start) {
     
$duration = $node->end - $node->start;
      if (
$duration == 86340) { $duration = 'all day';}
      else {
$duration = format_interval($node->end - $node->start, 2); }
     }
    else {
$duration = NULL; }
   
$rows[] = array(l($node->title, 'node/'. $node->nid .'/edit'),
                             
$node->type,
                             
$node->term,
                             
format_date($node->start),
                             
$node->end == $node->start ? NULL : format_date($node->end),
                             
$duration,
                       );
   }
/* end while */
 
return theme_table($header, $rows);
?>

 
 

Drupal is a registered trademark of Dries Buytaert.