Index: modules/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block.module,v
retrieving revision 1.183
diff -u -r1.183 block.module
--- modules/block.module	11 Oct 2005 19:44:34 -0000	1.183
+++ modules/block.module	25 Oct 2005 23:33:18 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: block.module,v 1.183 2005/10/11 19:44:34 dries Exp $
+// $Id: block.module,v 1.184 2005/10/22 15:14:46 dries Exp $
 
 /**
  * @file
@@ -96,6 +96,8 @@
 function block_block($op = 'list', $delta = 0, $edit = array()) {
   switch ($op) {
     case 'list':
+      $blocks = array();
+
       $result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title');
       while ($block = db_fetch_object($result)) {
         $blocks[$block->bid]['info'] = $block->info ? check_plain($block->info) : check_plain($block->title);
@@ -455,8 +457,8 @@
  * Menu callback; displays the block overview page.
  */
 function block_admin() {
-  $edit = $_POST['edit'];
-  $op = $_POST['op'];
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
 
   if ($op == t('Save blocks')) {
     block_admin_save($edit);
@@ -526,7 +528,7 @@
   if (!count($blocks)) {
     $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key);
     while ($block = db_fetch_object($result)) {
-      if(!isset($blocks[$block->region])) {
+      if (!isset($blocks[$block->region])) {
         $blocks[$block->region] = array();
       }
       // Use the user's block visibility setting, if necessary
@@ -574,7 +576,7 @@
     }
   }
   // Create an empty array if there were no entries
-  if(!isset($blocks[$region])) {
+  if (!isset($blocks[$region])) {
     $blocks[$region] = array();
   }
   return $blocks[$region];
Index: modules/blogapi.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blogapi.module,v
retrieving revision 1.60
diff -u -r1.60 blogapi.module
--- modules/blogapi.module	11 Oct 2005 19:44:34 -0000	1.60
+++ modules/blogapi.module	25 Oct 2005 23:33:22 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: blogapi.module,v 1.60 2005/10/11 19:44:34 dries Exp $
+// $Id: blogapi.module,v 1.62 2005/10/25 03:43:57 unconed Exp $
 
 /**
  * @file
@@ -600,6 +600,7 @@
   $base = url('', NULL, NULL, TRUE);
   $blogid = 1; # until we figure out how to handle multiple bloggers
 
+  drupal_set_header('Content-Type: application/rsd+xml; charset=utf-8');
   print <<<__RSD__
 <?xml version="1.0"?>
 <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
Index: modules/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book.module,v
retrieving revision 1.323
diff -u -r1.323 book.module
--- modules/book.module	11 Oct 2005 19:44:34 -0000	1.323
+++ modules/book.module	25 Oct 2005 23:33:24 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: book.module,v 1.323 2005/10/11 19:44:34 dries Exp $
+// $Id: book.module,v 1.325 2005/10/24 19:03:09 dries Exp $
 
 /**
  * @file
@@ -249,7 +249,7 @@
   $form = array_merge($form, filter_form($node->format));
 
   $form['log'] = array(
-    '#type' => 'textarea', '#title' => t('Log message'), '#default_value' => $node->log, '#rows' => 5, '#weight' => 19,
+    '#type' => 'textarea', '#title' => t('Log message'), '#default_value' => $node->log, '#rows' => 5, '#weight' => 18,
     '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
   );
 
@@ -444,7 +444,17 @@
           foreach ($book as $key => $value) {
             $node->$key = $value;
           }
-          $node = theme('book_navigation', $node);
+
+          $path = book_location($node);
+          // Construct the breadcrumb:
+          $node->breadcrumb = array(); // Overwrite the trail with a book trail.
+          foreach ($path as $level) {
+            $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' =>  $level->title);
+          }
+          $node->breadcrumb[] = array('path' => 'node/'. $node->nid);
+
+          $node->body .= theme('book_navigation', $node);
+
           if ($page) {
             menu_set_location($node->breadcrumb);
           }
@@ -461,16 +471,6 @@
  * @ingroup themeable
  */
 function theme_book_navigation($node) {
-  $path = book_location($node);
-
-  // Construct the breadcrumb:
-
-  $node->breadcrumb = array(); // Overwrite the trail with a book trail.
-  foreach ($path as $level) {
-    $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' =>  $level->title);
-  }
-  $node->breadcrumb[] = array('path' => 'node/'. $node->nid);
-
   if ($node->nid) {
     $output .= '<div class="book">';
 
@@ -509,9 +509,7 @@
     $output .= '</div>';
   }
 
-  $node->body = $node->body.$output;
-
-  return $node;
+  return $output;
 }
 
 /**
@@ -657,7 +655,6 @@
  *
  */
 function book_export($type = 'html', $nid = FALSE) {
-  global $base_url;
   $type = drupal_strtolower($type);
   $node = node_load($nid);
   if ($node) {
@@ -684,14 +681,7 @@
           for ($i = 1; $i < $depth; $i++) {
             $output .= "</div>\n";
           }
-          $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
-          $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
-          $html .= "<head>\n<title>". check_plain($node->title) ."</title>\n";
-          $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
-          $html .= '<base href="'. $base_url .'/" />' . "\n";
-          $html .= "<style type=\"text/css\">\n@import url(misc/print.css);\n</style>\n";
-          $html .= "</head>\n<body>\n". $output . "\n</body>\n</html>\n";
-          print $html;
+          print theme('book_export_html', check_plain($node->title), $output);
         }
         else {
           drupal_access_denied();
@@ -721,6 +711,23 @@
 }
 
 /**
+ * How the book's HTML export should be themed
+ *
+ * @ingroup themeable
+ */
+function theme_book_export_html($title, $content) {
+  global $base_url;
+  $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
+  $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
+  $html .= "<head>\n<title>". $title ."</title>\n";
+  $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+  $html .= '<base href="'. $base_url .'/" />' . "\n";
+  $html .= "<style type=\"text/css\">\n@import url(misc/print.css);\n</style>\n";
+  $html .= "</head>\n<body>\n". $content . "\n</body>\n</html>\n";
+  return $html;
+}
+
+/**
  * Given a node, this function returns the depth of the node in its hierarchy.
  * A root node has depth 1, and children of a node of depth n have depth (n+1).
  *
Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.381
diff -u -r1.381 comment.module
--- modules/comment.module	11 Oct 2005 19:44:34 -0000	1.381
+++ modules/comment.module	25 Oct 2005 23:33:28 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: comment.module,v 1.381 2005/10/11 19:44:34 dries Exp $
+// $Id: comment.module,v 1.384 2005/10/20 09:27:36 unconed Exp $
 
 /**
  * @file
@@ -249,7 +249,7 @@
       return format_plural($comments, '1 comment', '%count comments');
 
     case 'rss item':
-      return array(array('key' => 'comments', 'value' => url('node/'.$node->nid, NULL, 'comment', TRUE)));
+      return array(array('key' => 'comments', 'value' => url('node/'. $node->nid, NULL, 'comment', TRUE)));
   }
 }
 
@@ -762,7 +762,7 @@
 
       if ($comment = db_fetch_object($result)) {
         $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
-        $output .= theme('comment_view', $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
+        $output .= theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 1));
       }
     }
     else {
@@ -1226,12 +1226,12 @@
 }
 
 function theme_comment($comment, $links = 0) {
-  $output  = "<div class=\"comment\">\n";
+  $output  = '<div class="comment">';
   $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."</div>\n";
   $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n";
-  $output .= "<div class=\"body\">$comment->comment</div>\n";
-  $output .= "<div class=\"links\">$links</div>\n";
-  $output .= "</div>\n";
+  $output .= '<div class="body">'. $comment->comment .'</div>';
+  $output .= '<div class="links">'. theme('links', $links) .'</div>';
+  $output .= '</div>';
   return $output;
 }
 
@@ -1249,7 +1249,7 @@
 }
 
 function theme_comment_flat_expanded($comment) {
-  return theme('comment_view', $comment, theme('links', module_invoke_all('link', 'comment', $comment, 0)));
+  return theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 0));
 }
 
 function theme_comment_thread_min($comment, $pid = 0) {
@@ -1265,7 +1265,7 @@
     $output .= '<div style="margin-left:'. ($comment->depth * 25) ."px;\">\n";
   }
 
-  $output .= theme('comment_view', $comment, theme('links', module_invoke_all('link', 'comment', $comment, 0)));
+  $output .= theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 0));
 
   if ($comment->depth) {
     $output .= "</div>\n";
Index: modules/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter.module,v
retrieving revision 1.76
diff -u -r1.76 filter.module
--- modules/filter.module	11 Oct 2005 19:44:34 -0000	1.76
+++ modules/filter.module	25 Oct 2005 23:33:30 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: filter.module,v 1.76 2005/10/11 19:44:34 dries Exp $
+// $Id: filter.module,v 1.77 2005/10/22 15:14:46 dries Exp $
 
 /**
  * @file
@@ -284,7 +284,7 @@
     $roles = array();
     foreach (user_roles() as $rid => $name) {
       //prepare a roles array with roles that may access the filter
-      if (strstr($format->roles, ",$rid,")){
+      if (strstr($format->roles, ",$rid,")) {
         $roles[] = $name;
       }
     }
Index: modules/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum.module,v
retrieving revision 1.276
diff -u -r1.276 forum.module
--- modules/forum.module	11 Oct 2005 19:44:34 -0000	1.276
+++ modules/forum.module	25 Oct 2005 23:33:32 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: forum.module,v 1.276 2005/10/11 19:44:34 dries Exp $
+// $Id: forum.module,v 1.277 2005/10/21 11:12:46 unconed Exp $
 
 /**
  * @file
@@ -434,6 +434,10 @@
   return $links;
 }
 
+function forum_term_path($term) {
+  return 'forum/'. $term->tid;
+}
+
 /**
  * Implementation of hook_menu().
  */
Index: modules/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu.module,v
retrieving revision 1.39
diff -u -r1.39 menu.module
--- modules/menu.module	18 Oct 2005 14:40:00 -0000	1.39
+++ modules/menu.module	25 Oct 2005 23:33:33 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: menu.module,v 1.39 2005/10/18 14:40:00 dries Exp $
+// $Id: menu.module,v 1.40 2005/10/22 15:14:46 dries Exp $
 
 /**
  * @file
@@ -99,8 +99,8 @@
   if (user_access('administer menu')) {
     switch ($op) {
       case 'form':
-        $edit = $_POST['edit'];
-        $edit['nid'] = $node->nid;
+        $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+        $edit['nid'] = isset($node->nid) ? $node->nid : '';
         return menu_node_form($edit);
         break;
 
@@ -145,7 +145,7 @@
  * Menu callback; clear the database, resetting the menu to factory defaults.
  */
 function menu_reset() {
-  $op = $_POST['op'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
   switch ($op) {
     case t('Reset all'):
       db_query('DELETE FROM {menu}');
@@ -164,8 +164,8 @@
  * Menu callback; handle the adding of a new menu.
  */
 function menu_add_menu() {
-  $op = $_POST['op'];
-  $edit = $_POST['edit'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
   $output = '';
 
   switch ($op) {
@@ -189,7 +189,7 @@
  * Menu callback; reset a single modified item.
  */
 function menu_reset_item($mid) {
-  $op = $_POST['op'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
   switch ($op) {
     case t('Reset'):
       db_query('DELETE FROM {menu} WHERE mid = %d', $mid);
@@ -209,7 +209,7 @@
  * Menu callback; delete a single custom item.
  */
 function menu_delete_item($mid) {
-  $op = $_POST['op'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
   $result = db_query('SELECT type, title FROM {menu} WHERE mid = %d', $mid);
   $menu = db_fetch_object($result);
   if (!$menu) {
@@ -255,8 +255,8 @@
  * Menu callback; dispatch to the appropriate menu item edit function.
  */
 function menu_edit_item($mid = 0) {
-  $op = $_POST['op'];
-  $edit = $_POST['edit'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
 
   $output = '';
 
@@ -419,7 +419,7 @@
 
   $rows = array();
 
-  if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) {
+  if (isset($menu['items'][$pid]) && isset($menu['items'][$pid]['children'])) {
 
     usort($menu['items'][$pid]['children'], '_menu_sort');
     foreach ($menu['items'][$pid]['children'] as $mid) {
Index: modules/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node.module,v
retrieving revision 1.537
diff -u -r1.537 node.module
--- modules/node.module	18 Oct 2005 14:41:27 -0000	1.537
+++ modules/node.module	25 Oct 2005 23:33:36 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: node.module,v 1.537 2005/10/18 14:41:27 unconed Exp $
+// $Id: node.module,v 1.538 2005/10/22 15:14:46 dries Exp $
 
 /**
  * @file
@@ -120,7 +120,7 @@
     $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = '$user->uid' AND nid = %d", $nid));
   }
 
-  return ($history[$nid]->timestamp ? $history[$nid]->timestamp : 0);
+  return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
 }
 
 /**
@@ -353,7 +353,7 @@
 
   if (is_numeric($param)) {
     $cachable = $revision == NULL;
-    if ($cachable && $nodes[$param]) {
+    if ($cachable && isset($nodes[$param])) {
       return $nodes[$param];
     }
     $cond = 'n.nid = '. $param;
@@ -1314,7 +1314,7 @@
   global $user;
 
   if (user_access('administer nodes')) {
-    if($title = db_fetch_object(db_query('SELECT title, timestamp FROM {node_revisions} WHERE nid = %d AND vid = %d', $nid, $revision))) {
+    if ($title = db_fetch_object(db_query('SELECT title, timestamp FROM {node_revisions} WHERE nid = %d AND vid = %d', $nid, $revision))) {
       db_query('UPDATE {node} SET vid = %d, changed = %d WHERE nid = %d', $revision, $title->timestamp, $nid);
 
       drupal_set_message(t('%title has been rolled back to the revision from %revision-date', array('%revision-date' => theme('placeholder', format_date($title->timestamp)), '%title' => theme('placeholder', check_plain($title->title)))));
@@ -1362,8 +1362,8 @@
  * Menu callback; presents the content administration overview.
  */
 function node_admin() {
-  $op = $_POST['op'];
-  $edit = $_POST['edit'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
 
   if (empty($op)) {
     $op = arg(2);
@@ -1500,23 +1500,14 @@
   // Auto-generate the teaser, but only if it hasn't been set (e.g. by a
   // module-provided 'teaser' form item).
   if (!isset($node->teaser)) {
-    $node->teaser = node_teaser($node->body, $node->format);
+    $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
   }
 
-  if (node_last_changed($node->nid) > $node->changed) {
+  if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
     form_set_error('changed', t('This content has been modified by another user, unable to save changes.'));
   }
 
   if (user_access('administer nodes')) {
-    // Set up default values, if required.
-    if (!$node->created) {
-      $node->created = time();
-    }
-
-    if (!$node->date) {
-      $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
-    }
-
     // Validate the "authored by" field.
     if (empty($node->name)) {
       // The use of empty() is mandatory in the context of usernames
@@ -1574,15 +1565,32 @@
   }
 }
 
+function node_form_validate($form_id, $edit) {
+  node_validate($edit);
+}
+
+function node_object_prepare(&$node) {
+  if (user_access('administer nodes')) {
+    // Set up default values, if required.
+    if (!isset($node->created)) {
+      $node->created = time();
+    }
+
+    if (!isset($node->date)) {
+      $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
+    }
+  }
+  node_invoke($node, 'prepare');
+  node_invoke_nodeapi($node, 'prepare');
+}
+
 /**
  * Generate the node editing form.
  */
 function node_form($node) {
-  $op = $_POST['op'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
 
-  if (!$node->validated) {
-    $node = node_validate($node);
-  }
+  node_object_prepare($node);
 
   // Set the id of the top-level form tag
   $form['#attributes']['id'] = 'node-form';
@@ -1598,10 +1606,6 @@
   $form['changed'] = array('#type' => 'value', '#value' => $node->changed);
   $form['type']    = array('#type' => 'value', '#value' => $node->type);
 
-  if ($op == t('Preview')) {
-    $form['node_preview'] = array('#value' => node_preview(array2object($_POST['edit'])), '#weight' => -100);
-  }
-
   // Get the node-specific bits.
   // We can't use node_invoke() because $param must be passed by reference.
   $function = node_get_base($node) .'_form';
@@ -1649,22 +1653,25 @@
   // Add the buttons.
   $form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 19);
 
-  if ($node->type) {
-    if (!form_get_errors()) {
-      if ($_POST['op'] == t('Preview')|| !variable_get('node_preview', 0)) {
-
-      }
-    }
-  }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 20);
   if ($node->nid && node_access('delete', $node)) {
     $form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 21);
   }
+
+  if ($op == t('Preview')) {
+    $form['#post_process'] = 'node_form_add_preview';
+  }
+
   return drupal_get_form($node->type . '_node_form', $form, 'node_form');
 }
 
+function node_form_add_preview($form_id, $form, $edit) {
+  $form['node_preview'] = array('#value' => node_preview(node_validate($edit)), '#weight' => -100);
+  return $form;
+}
+
 function theme_node_form($form) {
-  $output .= '<div class="node-form">';
+  $output = '<div class="node-form">';
   if (isset($form['node_preview'])) {
     $output .= form_render($form['node_preview']);
   }
@@ -1690,7 +1697,7 @@
 function node_add($type) {
   global $user;
 
-  $edit = $_POST['edit'];
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
 
   // If a node type has been specified, validate its existence.
   if (array_key_exists($type, node_get_types()) && node_access('create', $type)) {
@@ -1733,10 +1740,6 @@
  * Generate a node preview.
  */
 function node_preview($node) {
-  if (!$node->validated) {
-    $node = node_validate($node);
-  }
-
   if (node_access('create', $node) || node_access('update', $node)) {
     // Load the user's name when needed:
     if (isset($node->name)) {
@@ -1919,8 +1922,6 @@
  * Menu callback; dispatches control to the appropriate operation handler.
  */
 function node_page() {
-  $edit = $_POST['edit'];
-
   $op = arg(1);
 
   if (is_numeric($op)) {
Index: modules/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile.module,v
retrieving revision 1.114
diff -u -r1.114 profile.module
--- modules/profile.module	13 Oct 2005 10:02:31 -0000	1.114
+++ modules/profile.module	25 Oct 2005 23:33:37 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: profile.module,v 1.114 2005/10/13 10:02:31 unconed Exp $
+// $Id: profile.module,v 1.115 2005/10/21 11:14:55 unconed Exp $
 
 /**
  * @file
@@ -252,9 +252,9 @@
       case 'textarea':
         return check_markup($value);
       case 'selection':
-        return $browse ? l($value, "profile/$field->name/$value") : check_plain($value);
+        return $browse ? l($value, 'profile/'. drupal_urlencode($field->name) .'/'. drupal_urlencode($value)) : check_plain($value);
       case 'checkbox':
-        return $browse ? l($field->title, "profile/$field->name") : check_plain($field->title);
+        return $browse ? l($field->title, 'profile/'. drupal_urlencode($field->name)) : check_plain($field->title);
       case 'url':
         return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
       case 'date':
@@ -273,7 +273,7 @@
         $fields = array();
         foreach ($values as $value) {
           if ($value = trim($value)) {
-            $fields[] = $browse ? l($value, "profile/". urlencode($field->name) ."/". urlencode($value)) : check_plain($value);
+            $fields[] = $browse ? l($value, "profile/". drupal_urlencode($field->name) ."/". drupal_urlencode($value)) : check_plain($value);
           }
         }
         return implode(', ', $fields);
Index: modules/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search.module,v
retrieving revision 1.137
diff -u -r1.137 search.module
--- modules/search.module	18 Oct 2005 14:41:27 -0000	1.137
+++ modules/search.module	25 Oct 2005 23:33:38 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: search.module,v 1.137 2005/10/18 14:41:27 unconed Exp $
+// $Id: search.module,v 1.139 2005/10/22 15:14:46 dries Exp $
 
 /**
  * @file
@@ -452,7 +452,7 @@
           // None of the tags we look for make sense when nested identically.
           // If they are, it's probably broken HTML.
           $tagstack = array();
-          $score = 1;          
+          $score = 1;
         }
         else {
           // Add to open tag stack and increment score
@@ -811,7 +811,7 @@
       $type = 'node';
     }
     $keys = module_invoke($type, 'search', 'post', $_POST['edit']['keys']);
-    drupal_goto('search/'. urlencode($type) .'/'. urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
+    drupal_goto('search/'. drupal_urlencode($type) .'/'. drupal_urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
   }
   else if ($type == '') {
     // Note: search/node can not be a default tab because it would take on the
@@ -828,7 +828,7 @@
       watchdog('search',
         t('Search: %keys (%type).', array('%keys' => theme('placeholder', $keys), '%type' => module_invoke($type, 'search', 'name'))),
         WATCHDOG_NOTICE,
-        l(t('results'), 'search/'. urlencode($type) .'/'. urlencode($keys))
+        l(t('results'), 'search/'. drupal_urlencode($type) .'/'. drupal_urlencode($keys))
         );
 
       // Collect the search results:
Index: modules/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system.module,v
retrieving revision 1.243
diff -u -r1.243 system.module
--- modules/system.module	19 Oct 2005 09:28:21 -0000	1.243
+++ modules/system.module	25 Oct 2005 23:33:40 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: system.module,v 1.243 2005/10/19 09:28:21 unconed Exp $
+// $Id: system.module,v 1.246 2005/10/25 05:42:20 dries Exp $
 
 /**
  * @file
@@ -206,6 +206,7 @@
     $rows[] = $row;
   }
 
+  $header = array(t('Screenshot'), t('Name'), t('Selected'));
   $output = theme('table', $header, $rows);
   return $output;
 }
@@ -524,7 +525,7 @@
   foreach ($themes as $theme) {
     foreach (file_scan_directory(dirname($theme->filename), 'style.css$') as $style) {
       $style->style = TRUE;
-      $style->template = $theme->template;
+      $style->template = isset($theme->template) ? $theme->template : FALSE;
       $style->name = basename(dirname($style->filename));
       $style->owner = $theme->filename;
       $style->prefix = $theme->template ? $theme->prefix : $theme->name;
@@ -559,7 +560,7 @@
 function system_region_list($theme_key) {
   static $list = array();
 
-  if(!array_key_exists($theme_key, $list)) {
+  if (!array_key_exists($theme_key, $list)) {
 
     $result = db_query("SELECT * FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key);
     $theme = db_fetch_object($result);
@@ -681,6 +682,24 @@
   return drupal_get_form($form_id, $form, 'system_settings_form');
 }
 
+function system_theme_settings_execute($form_id, $values) {
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
+  $key = $values['var'];
+    
+  if ($op == t('Reset to defaults')) {
+    variable_del($key);
+  }
+  else {
+    variable_set($key, $values);
+  }
+  if ($op == t('Reset to defaults')) {
+    drupal_set_message(t('The configuration options have been reset to their default values.'));
+  }
+  else {
+    drupal_set_message(t('The configuration options have been saved.'));
+  }
+}
+
 /**
  * Execute the system_settings_form.
  *
@@ -691,6 +710,7 @@
 function system_settings_form_execute($form_id, $values) {
   $op = isset($_POST['op']) ? $_POST['op'] : '';
 
+      
   foreach ($values as $key => $value) {
     if ($op == t('Reset to defaults')) {
       variable_del($key);
@@ -704,7 +724,8 @@
   }
   if ($op == t('Reset to defaults')) {
     drupal_set_message(t('The configuration options have been reset to their default values.'));
-  } else {
+  }
+  else {
     drupal_set_message(t('The configuration options have been saved.'));
   }
 }
@@ -785,14 +806,18 @@
   db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'");
 
   if ($_POST['op'] == t('Save configuration')) {
-    variable_set('theme_default', $values['theme_default']);
     if (is_array($values['status'])) {
       foreach ($values['status'] as $key => $choice) {
         if ($choice) {
+          // If theme status is being set to 1 from 0, initialize block data for this theme if necessary.
+          if (db_num_rows(db_query("SELECT status FROM {system} WHERE type = 'theme' AND name = '%s' AND status = 0", $key))) {
+            system_initialize_theme_blocks($key);
+          }
           db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key);
         }
       }
     }
+    variable_set('theme_default', $values['theme_default']);
   }
   else {
     variable_del('theme_default');
@@ -1059,7 +1084,7 @@
     $disabled['toggle_search'] = true;
   }
 
-  $form['theme_settings'] = array('#type' => 'fieldset', '#title' => t('Toggle display'), '#description' => t('Enable or disable the display of certain page elements.'), '#tree' => TRUE);
+  $form['theme_settings'] = array('#type' => 'fieldset', '#title' => t('Toggle display'), '#description' => t('Enable or disable the display of certain page elements.'));
   foreach ($toggles as $name => $title) {
     if ((!$key) || in_array($name, $features)) {
       // disable search box if search.module is disabled
Index: modules/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy.module,v
retrieving revision 1.231
diff -u -r1.231 taxonomy.module
--- modules/taxonomy.module	19 Oct 2005 09:46:22 -0000	1.231
+++ modules/taxonomy.module	25 Oct 2005 23:33:41 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: taxonomy.module,v 1.231 2005/10/19 09:46:22 unconed Exp $
+// $Id: taxonomy.module,v 1.232 2005/10/21 11:12:46 unconed Exp $
 
 /**
  * @file
@@ -30,18 +30,26 @@
     if (array_key_exists('taxonomy', $node)) {
       foreach ($node->taxonomy as $tid) {
         $term = taxonomy_get_term($tid);
-        $links[] = l($term->name, 'taxonomy/term/'. $term->tid);
+        $links[] = l($term->name, taxonomy_term_path($term));
       }
     }
     else {
       foreach (taxonomy_node_get_terms($node->nid) as $term) {
-        $links[] = l($term->name, 'taxonomy/term/'. $term->tid);
+        $links[] = l($term->name, taxonomy_term_path($term));
       }
     }
     return $links;
   }
 }
 
+function taxonomy_term_path($term) {
+  $vocabulary = taxonomy_get_vocabulary($term->vid);
+  if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
+    return $path;
+  }
+  return 'taxonomy/term/'. $term->tid;
+}
+
 /**
  * Implementation of hook_menu().
  */
@@ -866,16 +874,20 @@
  * Return the vocabulary object matching a vocabulary ID.
  */
 function taxonomy_get_vocabulary($vid) {
-  $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
-  $node_types = array();
-  while ($voc = db_fetch_object($result)) {
-    $node_types[] = $voc->type;
-    unset($voc->type);
-    $voc->nodes = $node_types;
-    $vocabulary = $voc;
+  static $vocabularies = array();
+
+  if (!array_key_exists($vid, $vocabularies)) {
+    $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
+    $node_types = array();
+    while ($voc = db_fetch_object($result)) {
+      $node_types[] = $voc->type;
+      unset($voc->type);
+      $voc->nodes = $node_types;
+      $vocabularies[$vid] = $voc;
+    }
   }
 
-  return $vocabulary;
+  return $vocabularies[$vid];
 }
 
 /**
Index: modules/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user.module,v
retrieving revision 1.520
diff -u -r1.520 user.module
--- modules/user.module	13 Oct 2005 10:39:56 -0000	1.520
+++ modules/user.module	25 Oct 2005 23:33:44 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: user.module,v 1.520 2005/10/13 10:39:56 dries Exp $
+// $Id: user.module,v 1.523 2005/10/22 15:14:46 dries Exp $
 
 /**
  * @file
@@ -182,7 +182,7 @@
     // Build and save the serialized data field now
     $data = array();
     foreach ($array as $key => $value) {
-      if ((substr($key, 0, 4) !== 'auth') && (!in_array($key, $user_fields)) && ($value !== null)) {
+      if ((substr($key, 0, 4) !== 'auth') && ($key != 'roles') && (!in_array($key, $user_fields)) && ($value !== null)) {
         $data[$key] = $value;
       }
     }
@@ -601,10 +601,10 @@
       $picture = variable_get('user_picture_default', '');
     }
 
-    if ($picture) {
+    if (isset($picture)) {
       $alt = t('%user\'s picture', array('%user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
       $picture = theme('image', $picture, $alt, $alt, '', false);
-      if ($account->uid) {
+      if (!empty($account->uid)) {
         $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
       }
 
@@ -963,7 +963,7 @@
 
 function user_pass() {
   global $base_url;
-  $edit = $_POST['edit'];
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
 
   if ($edit['name'] && !($account = user_load(array('name' => $edit['name'], 'status' => 1)))) {
     form_set_error('name', t('Sorry. The username %name is not recognized.', array('%name' => theme('placeholder', $edit['name']))));
@@ -1044,12 +1044,12 @@
   drupal_access_denied();
 }
 
-function user_pass_reset_url($account){
+function user_pass_reset_url($account) {
   $timestamp = time();
   return url("user/reset/$account->uid/$timestamp/".user_pass_rehash($account->pass, $timestamp, $account->login), NULL, NULL, TRUE);
 }
 
-function user_pass_rehash($password, $timestamp, $login){
+function user_pass_rehash($password, $timestamp, $login) {
   return md5($timestamp . $password . $login);
 }
 
@@ -1086,7 +1086,7 @@
         user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n  username: %username\n  password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
         // This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password.
         $form['instructions'] = array('#type' => 'markup', '#value' => "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access.  All future registrants will receive their passwords via e-mail, so please configure your e-mail settings using the Administration pages.</p><p> Your password is <strong>$pass</strong>. You may change your password on the next page.</p><p>Please login below.</p>");
-        $form['#action'] = url("user/$account->uid/edit");
+        $form['#action'] = url('user/1/edit', 'destination=user/1/edit');
         $form['name'] = array('#type' => 'hidden', '#value' => $account->name);
         $form['pass'] = array('#type' => 'hidden', '#value' => $pass);
         $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
@@ -1278,7 +1278,7 @@
   $form = _user_forms($edit, $account, $category);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 30);
   if (user_access('administer users')) {
-    $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'), '#weight' => 30);
+    $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'), '#weight' => 31);
   }
   $form['#attributes'] = array('enctype' => 'multipart/form-data');
 
@@ -1310,8 +1310,8 @@
 function user_page() {
   global $user;
 
-  $edit = $_POST['edit'];
-  $op = $_POST['op'];
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
 
   if (empty($op)) {
     $op = arg(2) ? arg(2) : arg(1);
@@ -1372,13 +1372,11 @@
  * Menu callback: check an access rule
  */
 function user_admin_access_check() {
-  if ($_POST['op']) {
-    $op = $_POST['op'];
-  }
-  $edit = $_POST['edit'];
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
 
-  if ($op) {
-    if ($edit['user']) {
+  if (!empty($op)) {
+    if (!empty($edit['user']['test'])) {
       if (drupal_is_denied('user', $edit['user']['test'])) {
         drupal_set_message(t('The username %name is not allowed.', array('%name' => theme('placeholder', $edit['user']['test']))));
       }
@@ -1386,7 +1384,7 @@
         drupal_set_message(t('The username %name is allowed.', array('%name' => theme('placeholder', $edit['user']['test']))));
       }
     }
-    if ($edit['mail']) {
+    if (!empty($edit['mail']['test'])) {
       if (drupal_is_denied('mail', $edit['mail']['test'])) {
         drupal_set_message(t('The e-mail address %mail is not allowed.', array('%mail' => theme('placeholder', $edit['mail']['test']))));
       }
@@ -1394,7 +1392,7 @@
         drupal_set_message(t('The e-mail address %mail is allowed.', array('%mail' => theme('placeholder', $edit['mail']['test']))));
       }
     }
-    if ($edit['host']) {
+    if (!empty($edit['host']['test'])) {
       if (drupal_is_denied('host', $edit['host']['test'])) {
         drupal_set_message(t('The hostname %host is not allowed.', array('%host' => theme('placeholder', $edit['host']['test']))));
       }
@@ -1600,7 +1598,8 @@
       if (is_numeric($key)) {
         $row[] = array('data' => form_render($form['permission'][$key]), 'class' => 'module', 'colspan' => count($form['role_names']) + 1);
       // Permissions
-      } else {
+      }
+      else {
         $row[] = array('data' => form_render($form['permission'][$key]), 'class' => 'permission');
         foreach (element_children($form['checkboxes']) as $rid) {
           if (is_array($form['checkboxes'][$rid])) {
@@ -1652,8 +1651,8 @@
  * Menu callback: administer roles.
  */
 function user_admin_role() {
-  $edit = $_POST['edit'];
-  $op = $_POST['op'];
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
   $id = arg(4);
 
   if ($op == t('Save role')) {
@@ -1788,8 +1787,8 @@
 }
 
 function user_admin() {
-  $op = $_POST['op'];
-  $edit = $_POST['edit'];
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+  $op = isset($_POST['op']) ? $_POST['op'] : '';
 
   if (empty($op)) {
     $op = arg(2);
Index: modules/watchdog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/watchdog.module,v
retrieving revision 1.130
diff -u -r1.130 watchdog.module
--- modules/watchdog.module	11 Oct 2005 19:44:35 -0000	1.130
+++ modules/watchdog.module	25 Oct 2005 23:33:45 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: watchdog.module,v 1.130 2005/10/11 19:44:35 dries Exp $
+// $Id: watchdog.module,v 1.131 2005/10/21 10:50:03 unconed Exp $
 
 /**
  * @file
@@ -32,22 +32,15 @@
 
   if ($may_cache) {
     $items[] = array('path' => 'admin/logs', 'title' => t('logs'),
-      'callback' => 'watchdog_overview', 'access' => user_access('administer watchdog'));
+      'callback' => 'watchdog_overview');
     $items[] = array('path' => 'admin/logs/event', 'title' => t('details'),
-      'callback' => 'watchdog_event', 'access' => user_access('administer watchdog'),
+      'callback' => 'watchdog_event',
       'type' => MENU_CALLBACK);
   }
   return $items;
 }
 
 /**
- * Implementation of hook_perm().
- */
-function watchdog_perm() {
-  return array('administer watchdog');
-}
-
-/**
  * Implementation of hook_cron().
  *
  * Remove expired log messages and flood control events.
@@ -87,6 +80,7 @@
     '#options' => $names,
     '#default_value' => $_SESSION['watchdog_overview_filter']
   );
+  $form['#action'] = 'admin/logs';
 
   $form['submit'] = array('#type' => 'submit', '#value' =>t('Filter'));
   $output = drupal_get_form('watchdog_form_overview', $form);
