Index: branches/groups/template.php
===================================================================
--- branches/groups/template.php	(revision 33)
+++ branches/groups/template.php	(working copy)
@@ -22,28 +22,40 @@
 
 // an implementation of theme specific variables. see _phptemplate_callback()
 function _phptemplate_variables($hook, $variables) {
-	switch ($hook)  {
-		case 'page':
-			$variables['site'] = _get_site();
-			//MW: for javascript agggregator: http://drupal.org/project/javascript_aggregator
-			if(module_exists('javascript_aggregator') && $variables['scripts']) {
+  static $type;
+
+  switch ($hook)  {
+    case 'page':
+      $variables['site'] = _get_site();
+
+      // MW: for javascript agggregator: http://drupal.org/project/javascript_aggregator
+      if (module_exists('javascript_aggregator') && $variables['scripts']) {
         $variables['scripts'] = javascript_aggregator_cache($variables['scripts']);
       }
       
-      //MW: horrible hack for og_panels tab not saying 'view'. See og_panels_menu().
+      // MW: horrible hack for og_panels tab not saying 'view'. See og_panels_menu().
       if (isset($GLOBALS['og_panels_view_tab_fix'])) {
         $variables['tabs'] = str_replace('>View<', '>'. $GLOBALS['og_panels_view_tab_fix']. '<', $variables['tabs']);
       }
       
-      // This hack is in OG for D6 so as long as Bluebeach honors body_classes we can remove this upon upgrade.
+      // MW: This hack is in OG for D6 so as long as Bluebeach honors body_classes we can remove this upon upgrade.
       $variables['body_classes'] = '';
-      if ($groupnode = og_get_group_context()) {
+      if (function_exists('og_get_group_context') && ($groupnode = og_get_group_context())) {
         $variables['body_classes'] = "class = \"og-context og-context-$groupnode->nid\"";
       }
-      
-			break;
-	}
-	return $variables ? $variables : array();
+      break;
+    case 'node':
+      $type = $variables['node']->type; 
+      if ($type == 'book') {
+        $variables['modified'] = t('Last modified: !date', array('!date' => format_date($variables['node']->changed)));
+      }
+      break;
+    case 'comment':
+      // Collapse unpublished comments on issue nodes.
+      $variables['collapse_comment'] = isset($type) && $type == 'project_issue' && $variables['comment']->status == COMMENT_NOT_PUBLISHED;
+      break;
+  }
+  return $variables ? $variables : array();
 }
 
 function _get_site() {
@@ -75,10 +87,12 @@
 
 function phptemplate_links($links) {
   $html_links = array();
-  
-  // MW debugging
-  if (!is_array($links)) watchdog('mw', serialize(debug_backtrace()));
 
+  // MW: debugging
+  if (_is_groups_site() && !is_array($links)) {
+    watchdog('mw', serialize(debug_backtrace()));
+  }
+
   foreach ($links as $link) {
     $html_links[] = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $link['html']);
   }
@@ -150,6 +164,16 @@
 }
 
 /**
+ * Render the links at the top of the issue query results page.
+ */
+function phptemplate_project_issue_query_result_links($links) {
+  if (!empty($links['create']['href'])) {
+    $links['create']['title'] = t('Create a new issue');
+  }
+  return theme('links', $links);
+}
+
+/**
  * Format a list of nearby pages with additional query results.
  *
  * @param $limit
Index: branches/5/template.php
===================================================================
--- branches/5/template.php	(revision 33)
+++ branches/5/template.php	(working copy)
@@ -27,6 +27,22 @@
   switch ($hook)  {
     case 'page':
       $variables['site'] = _get_site();
+
+      // MW: for javascript agggregator: http://drupal.org/project/javascript_aggregator
+      if (module_exists('javascript_aggregator') && $variables['scripts']) {
+        $variables['scripts'] = javascript_aggregator_cache($variables['scripts']);
+      }
+      
+      // MW: horrible hack for og_panels tab not saying 'view'. See og_panels_menu().
+      if (isset($GLOBALS['og_panels_view_tab_fix'])) {
+        $variables['tabs'] = str_replace('>View<', '>'. $GLOBALS['og_panels_view_tab_fix']. '<', $variables['tabs']);
+      }
+      
+      // MW: This hack is in OG for D6 so as long as Bluebeach honors body_classes we can remove this upon upgrade.
+      $variables['body_classes'] = '';
+      if (function_exists('og_get_group_context') && ($groupnode = og_get_group_context())) {
+        $variables['body_classes'] = "class = \"og-context og-context-$groupnode->nid\"";
+      }
       break;
     case 'node':
       $type = $variables['node']->type; 
@@ -71,6 +87,12 @@
 
 function phptemplate_links($links) {
   $html_links = array();
+
+  // MW: debugging
+  if (_is_groups_site() && !is_array($links)) {
+    watchdog('mw', serialize(debug_backtrace()));
+  }
+
   foreach ($links as $link) {
     $html_links[] = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $link['html']);
   }
