Index: issue.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v
retrieving revision 1.249
diff -u -p -u -p -r1.249 issue.inc
--- issue.inc	19 Aug 2007 23:23:37 -0000	1.249
+++ issue.inc	20 Sep 2007 16:36:24 -0000
@@ -5,7 +5,7 @@
 function project_issue_page() {
   global $user;
 
-  switch ($_POST['op'] ? $_POST['op'] : arg(2)) {
+  switch (!empty($_POST['op']) ? $_POST['op'] : arg(2)) {
     case 'rss':
       $project = project_project_retrieve(arg(3));
       if ($project->nid && node_access('view', $project)) {
@@ -1125,7 +1125,7 @@ function project_issue_count($pid) {
 
 function project_issue_search_page($project_name = NULL, $query = NULL) {
   $project = project_project_retrieve($project_name);
-  if ($project->nid && node_access('view', $project)) {
+  if (isset($project) && $project->nid && node_access('view', $project)) {
     return drupal_get_form('project_issue_query', $project, $query);
   }
   else {
@@ -1135,8 +1135,9 @@ function project_issue_search_page($proj
 
 function project_issue_query($project = 0, $query = NULL) {
   $categories = project_issue_category();
+  $projects = array();
   $components = array();
-  if ($project->nid) {
+  if (!empty($project->nid)) {
     drupal_set_title(t('Search issues for %name', array('%name' => $project->title)));
     project_project_set_breadcrumb($project, TRUE);
     foreach ($project->components as $component) {
@@ -1153,12 +1154,24 @@ function project_issue_query($project = 
     drupal_set_title(t('Search issues for all projects'));
   }
   if (is_null($query)) {
-    $query = new StdClass();
+    $query = (object) array(
+      'projects' => '',
+      'summary' => '',
+      'attachment' => '',
+      'versions' => '',
+      'components' => '',
+      'categories' => '',
+      'priorities' => '',
+      'states' => '',
+      'submitted' => '',
+      'assigned' => '',
+      'users' => '',
+    );
   }
   $states = project_issue_state();
   $priorities = project_issue_priority();
 
-  $form['#action'] = url($project->uri ? "project/issues/$project->uri" : 'project/issues');
+  $form['#action'] = url(isset($project->uri) ? "project/issues/$project->uri" : 'project/issues');
   $form['text'] = array(
     '#type' => 'textfield',
     '#title' => t('Search for'),
@@ -1172,7 +1185,6 @@ function project_issue_query($project = 
   );
 
   if ($projects) {
-
     $form['projects'] = array(
       '#type' => 'select',
       '#title' => t('Projects'),
@@ -1273,7 +1285,7 @@ function theme_project_issue_query($form
   $rows[] = array(
     array('data' => drupal_render($form['attachment']), 'colspan' => 3)
   );
-  if ($form['projects']) {
+  if (isset($form['projects'])) {
     $rows[] = array(
       drupal_render($form['projects']),
       drupal_render($form['categories']),
@@ -1489,7 +1501,7 @@ function project_issue_delete_state_conf
   }
 }
 
-function project_issue_query_result($query = NULL, $format = 'html', $search = true, $set_title = true) {
+function project_issue_query_result($query = NULL, $format = 'html', $show_search = true, $set_title = true) {
   global $user;
   $query = project_issue_query_parse($query);
   // $query must have a real value now, or the rest of this function fails.
@@ -1592,7 +1604,7 @@ function project_issue_query_result($que
   $header[] = array('data' => t('Status'), 'field' => 'p.sid');
   $header[] = array('data' => t('Priority'), 'field' => 'p.priority');
   $header[] = array('data' => t('Category'), 'field' => 'p.category');
-  if (count($releases)) {
+  if (!empty($releases)) {
     $header[] = array('data' => t('Version'), 'field' => 'p.rid');
   }
   $header[] = array('data' => t('Last updated'), 'field' => 'n.changed', 'sort' => 'desc');
@@ -1601,10 +1613,10 @@ function project_issue_query_result($que
   $sql = project_issue_query_sql($query);
   $result = pager_query($sql['sql'] . tablesort_sql($header), 20, 0, $sql['count']);
 
-  if ($search) {
+  if ($show_search) {
     // Action links:
-    $group = theme('links', $links);
-    $group .= drupal_get_form('project_issue_query_result_quick_search', $query, $projects, $states, $priorities);
+    $search = theme('links', $links);
+    $search .= drupal_get_form('project_issue_query_result_quick_search', $query, $projects, $states, $priorities);
   }
 
   $rows = array();
@@ -1624,6 +1636,8 @@ function project_issue_query_result($que
     $projects = $flat_projects;
   }
 
+  $rss = '';
+  $link = '';
   if ($format == 'rss') {
     project_issue_query_rss($result, $project);
   }
@@ -1669,10 +1683,18 @@ function project_issue_query_result($que
 
   $output = '<div class="project-issue">';
   $output .= '<div class="quick-search">';
-  $output .= $group;
+  if (!empty($search)) {
+    $output .= $search;
+  }
   $output .= '</div>';
   $output .= theme('table', $header, $rows);
-  $output .= "$rss $link";
+  if (!empty($rss)) {
+    $output .= $rss;
+  }
+  $output = ' ';
+  if (!empty($link)) {
+    $output .= $link;
+  }
   $output .= '</div>';
   return $output;
 }
@@ -1687,7 +1709,10 @@ function project_issue_query_result_quic
   // Convert array fields to single select form items.
   $fields = array('projects', 'states', 'priorities', 'categories', 'users');
   foreach ($fields as $field) {
-    if (is_array($query->$field)) {
+    if (!isset($query->$field)) {
+      $query->$field = '';
+    }
+    else if (is_array($query->$field)) {
       $option = array();
 
       // $query is untrusted, user submitted data
@@ -1859,6 +1884,7 @@ function project_issue_query_pager($quer
 }
 
 function project_issue_query_sql($query) {
+  $comments = 0;
   foreach ($query as $key => $value) {
     switch ($key) {
       case 'projects':
