--- webcams.module	2008-04-18 18:06:24.000000000 -0700
+++ new-webcams.module	2008-07-05 07:38:29.000000000 -0700
@@ -35,13 +35,13 @@ function webcams_node_info() {
 /**
  * Implementation of hook_access().
  */
-function webcams_access($op, $node) {
+function webcams_access($op, $node, $account) {
   global $user;
 
   if (!user_access('access webcams')) {
     return FALSE;
   }
-  
+
   if ($op == 'create') {
     return user_access('create webcams');
   }
@@ -56,25 +56,16 @@ function webcams_access($op, $node) {
 /**
  * Implementation of hook_menu().
  */
-function webcams_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'node/add/webcam',
-      'title' => t('Webcam'),
-      'access' => user_access('create webcams'),
-      'type' => MENU_DYNAMIC_ITEM,
-    );
-    $items[] = array(
-      'path' => 'admin/settings/webcams',
-      'title' => t('Webcams'),
-      'description' => t('Configure webcam settings.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('webcams_admin_settings'),
-      'access' => user_access('administer site configuration'),
-    );
-  }
+function webcams_menu() {
+  $items['admin/settings/webcams'] = array(
+    'title' => 'Webcam',
+  'description' => 'Configure webcam settings.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('webcams_admin_settings'),
+    // NOTE: as of Drupal 6.2, all menu items are *required* to have
+    // access control.
+    'access arguments' => array('administer site configuration'),
+  );
 
   return $items;
 }
@@ -138,7 +129,7 @@ function webcams_form(&$node) {
     $form['webcams'][$i] = array(
       '#type' => 'fieldset',
       '#tree' => 1,
-      '#title' => t('Webcam').' '.($i+1),
+      '#title' => t('Webcam') .' '. ($i+1),
       '#required' => $i == 0,
       '#collapsible' => TRUE,
       '#collapsed' => $i > 0 && isset($node->webcams[$i]->disabled) && $node->webcams[$i]->disabled == TRUE,
@@ -290,7 +281,7 @@ function webcams_insert(&$node) {
 }
 
 function _webcams_insert_webcam($nid, $vid, &$webcam) {
-  $webcam->wid = db_next_id('{webcams}_wid');
+  $webcam->wid = db_last_insert_id('{webcams}_wid');
 
   db_query("INSERT INTO {webcams} (wid, nid, vid, name, default_url, url, width, height, thickbox, link, delay, timeout, weight) VALUES (%d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, %d)", $webcam->wid, $nid, $vid, $webcam->name, $webcam->default_url, $webcam->url, $webcam->width, $webcam->height, $webcam->thickbox, $webcam->link, $webcam->delay, $webcam->timeout, $webcam->weight);
 }
@@ -391,12 +382,12 @@ function webcams_view(&$node, $teaser, $
 
       $js .= "\n$.webcam.init('webcams{$webcam->nid}-webcam{$webcam->wid}', '{$webcam->name}', '{$webcam->url}', '{$webcam->default_url}', {$webcam->width}, {$webcam->height}, {$delay}, {$webcam->timeout}, 'webcams{$webcam->nid}-content', '{$errmsg}');";
 
-      $node->content['webcams-webcam'.$i] = array(
+      $node->content['webcams-webcam'. $i] = array(
         '#value' => theme('webcams_webcam', $webcam),
         '#weight' => $webcam->weight,
       );
     }
-    $node->content['body']['#value'] = '<div id="webcams'. $node->nid .'-content" class="webcams-content">'.$node->content['body']['#value'].'</div>'."\n";
+    $node->content['body']['#value'] = '<div id="webcams'. $node->nid .'-content" class="webcams-content">'. $node->content['body']['#value'] .'</div>'."\n";
 
     // Need to avoid loading webcam initialization javascript multiple times...
     if (!$loaded[$node->nid]) {
@@ -413,7 +404,7 @@ function webcams_view(&$node, $teaser, $
  */
 function webcams_diff(&$old_node, &$new_node) {
   global $form_values;
-  $op = isset($form_values['op']) ? $form_values['op'] : '';
+  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
 
   $result = array();
   if ($old_node->type == 'webcam') {
@@ -425,7 +416,7 @@ function webcams_diff(&$old_node, &$new_
           t('Name') .': '. $webcam->name,
           t('Default Image URL') .': '. $webcam->default_url,
           t('Webcam Image URL') .': '. $webcam->url,
-          t('Size') .': '. $webcam->width . " x " . $webcam->height,
+          t('Size') .': '. $webcam->width ." x ". $webcam->height,
           t('Enlarge with Thickbox') .': '. ($webcam->thickbox ? t('Yes') : t('No')),
           t('Link') .': '. $webcam->link,
           t('Delay')  .': '. $webcam->delay,
@@ -436,7 +427,7 @@ function webcams_diff(&$old_node, &$new_
         $old_webcams[] = array();
       }
     }
-    
+
     $new_webcams = array();
     for ($i = 0; $i < max(count($new_node->webcams), variable_get('webcams_max_webcams_per_page', 4)); $i++) {
       if ($i < count($new_node->webcams)) {
@@ -454,7 +445,7 @@ function webcams_diff(&$old_node, &$new_
             t('Name') .': '. $webcam->name,
             t('Default Image URL') .': '. $webcam->default_url,
             t('Webcam Image URL') .': '. $webcam->url,
-            t('Size') .': '. $webcam->width . " x " . $webcam->height,
+            t('Size') .': '. $webcam->width ." x ". $webcam->height,
             t('Enlarge with Thickbox') .': '. ($webcam->thickbox ? t('Yes') : t('No')),
             t('Link') .': '. $webcam->link,
             t('Delay')  .': '. $webcam->delay,
@@ -469,7 +460,7 @@ function webcams_diff(&$old_node, &$new_
         $new_webcams[] = array();
       }
     }
-    
+
     $max = max(count($old_webcams), count($new_webcams));
     for ($i = 0; $i < $max; $i++) {
       $result[] = array(
@@ -482,7 +473,7 @@ function webcams_diff(&$old_node, &$new_
       );
     }
   }
-  return $result;	
+  return $result;
 }
 
 function theme_webcams_webcam(&$webcam) {
@@ -491,7 +482,7 @@ function theme_webcams_webcam(&$webcam) 
   $img  = '<img src="'. $webcam->default_url .'" width="'. $webcam->width .'" height="'. $webcam->height .'" class="webcams-image" />';
   if (module_exists('thickbox') && $webcam->thickbox) {
     $zoom = '<img src="'. base_path() . drupal_get_path('module', 'webcams') .'/zoom.png" width="32" height="32" class="webcams-zoom iefix" />';
-    
+
     $output .= l($zoom, $webcam->default_url, array('title' => $webcam->name, 'class' => 'thickbox'), NULL, NULL, FALSE, TRUE);
     $output .= l($img, $webcam->default_url, array('title' => $webcam->name, 'class' => 'thickbox'), NULL, NULL, FALSE, TRUE);
   }
@@ -505,3 +496,13 @@ function theme_webcams_webcam(&$webcam) 
   $output .= '</div>'."\n";
   return $output;
 }
+/**
+ * Implementation of hook_theme().
+  */
+function webcams_webcam_theme(&$webcam) {
+  return array(
+    'webcams_webcam' => array(
+      'arguments' => array('webcam' => NULL),
+    ),
+  );
+}
\ No newline at end of file
