Index: issue.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v
retrieving revision 1.203
diff -u -F^f -r1.203 issue.inc
--- issue.inc	22 Dec 2006 23:54:14 -0000	1.203
+++ issue.inc	23 Dec 2006 10:35:02 -0000
@@ -63,6 +63,61 @@ function project_issue_page() {
   }
 }
 
+function project_issue_update_project($pid, $cid = NULL, $rid = NULL) {
+
+  // Rids.
+  $return['rid'] = '';
+
+  if (module_exists('project_release')) {
+    $project->nid = $pid;
+    if ($releases = project_release_get_releases($project, 0)) {
+      $releases = array(t('<none>')) + $releases;
+      // Search labels for matching version.
+      $default = NULL;
+      foreach ($releases as $key => $label) {
+      	if ($rid == $label) {
+      	  $default = $key;
+      	}
+      }
+      $form = array();
+      $form['rid'] = array(
+        '#type' => 'select',
+        '#title' => t('Version'),
+        '#default_value' => $default,
+        '#options' => $releases,
+        '#required' => TRUE,
+      );
+      $form = form_builder('rid', $form);
+      $return['rid'] .= drupal_render($form);
+    }
+  }
+
+  // Components.
+  $return['component'] = '';
+  $project = db_fetch_object(db_query('SELECT * FROM {project_issue_projects} WHERE nid = %d', $pid));
+  $components = array();
+  if ($project->components) {
+    $components = array(t('<none>'));
+    foreach (unserialize($project->components) as $component) {
+      $components[$component] = $component;
+    }
+  }
+
+  $form = array();
+  $form['component'] = array(
+    '#type' => 'select',
+    '#title' => t('Component'),
+    '#default_value' => $cid,
+    '#options' => $components,
+    '#required' => TRUE,
+  );
+  $form = form_builder('component', $form);
+  $return['component'] .= drupal_render($form);
+
+  print drupal_to_js($return);
+  exit();
+}
+
 /**
  * Decides what to do with search page request.
  *
@@ -92,7 +147,7 @@ function project_issue_build_form_url($u
       return project_project_retrieve($url_arg);
     }
   }
-  
+
   // dispatch to hanlders based on value of $_POST['form_id']
   if ($_POST['form_id'] == 'project_issue_query_result_quick_search') {
     return project_issue_quick_search($url_arg, $filters);
@@ -103,7 +158,7 @@ function project_issue_build_form_url($u
 }
 
 /**
- * Handles quick search form 
+ * Handles quick search form
  *
  * @param $url_arg
  *   Value returned from arg(2)
@@ -127,11 +182,11 @@ function project_issue_quick_search($url
     }
     $destination = 'project/issues/'. $project->uri;
   }
-  
+
   // if 'q' is the only thing in $_GET, and it == destination, don't redirect
   if (count($_GET) == 1 && isset($_GET['q']) && $_GET['q'] == $destination) {
 
-    // put $_POST where pager will see them 
+    // put $_POST where pager will see them
     foreach ($filters as $filter) {
       if (!empty($_POST[$filter])) {
         $_REQUEST[$filter] = $_POST[$filter];
@@ -418,6 +473,8 @@ function theme_project_issue_subscribe($
 function project_issue_form($node, $param) {
   global $user;
 
+  drupal_add_js(drupal_get_path('module', 'project_issue') .'/project_issue.js');
+
   $default_state = variable_get('project_issue_default_state', 1);
   // Set form parameters so we can accept file uploads.
   $form['#attributes'] = array('enctype' => 'multipart/form-data');
@@ -489,6 +546,7 @@ function project_issue_form($node, $para
       '#default_value' => $node->pid,
       '#options' => $projects,
       '#required' => TRUE,
+      '#attributes' => array('onchange' => "mod_project('". base_path() ."project/issues/update_project/', this.value);"),
     );
     if ($releases) {
       $form['project_info']['rid'] = array(
@@ -496,13 +554,20 @@ function project_issue_form($node, $para
         '#title' => t('Version'),
         '#default_value' => $node->rid,
         '#options' => $releases,
+        '#prefix' => '<span id="project-issue-rid">',
+        '#suffix' => '</span>',
       );
     }
+    else {
+      $form['project_info']['rid'] = array('#value' => '<span id="project-issue-rid"></span>');
+    }
     $form['project_info']['component'] = array(
       '#type' => 'select',
       '#title' => t('Component'),
       '#default_value' => $node->component,
       '#options' => $components,
+      '#prefix' => '<span id="project-issue-component">',
+      '#suffix' => '</span>',
     );
 
     $form['issue_info'] = array(
@@ -597,7 +662,7 @@ function project_issue_form($node, $para
 function project_issue_form_pre_render($form_id, &$form) {
   if ($form_id == 'project_issue_node_form') {
 
-    // Only move to the next page if there were no form errors.  
+    // Only move to the next page if there were no form errors.
     // We don't want to keep incrementing page forever, since users
     // can successfully preview many times.  However, if we already
     // have a value for 'Project' (via a submit with project in the
@@ -735,7 +800,7 @@ function project_issue_comment_validate(
 
       // make sure this followup changes something or has a body
       if (!empty($_POST) && empty($node->body)) {
-        if (is_numeric(arg(3))) { 
+        if (is_numeric(arg(3))) {
           $issue = node_load(arg(3));
         }
         if (isset($issue)
@@ -1368,7 +1433,7 @@ function project_issue_query_result($que
   // array to map pids to project names. If we're using the project
   // taxonomy, it will really be an array of arrays, where each
   // project type is itself an array. So, we flatten the array once
-  // and then can use it safely in the rest of this method. 
+  // and then can use it safely in the rest of this method.
   if (project_use_taxonomy()) {
     $flat_projects = array();
     foreach ($projects as $tmp) {
@@ -1540,7 +1605,7 @@ function project_issue_query_url($query 
  * exists and contains some data. If the query was otherwise going to
  * be empty, this function will automatically add the default set of
  * issue states (active, fixed, patch needs work, etc).
- *  
+ *
  * @param $query
  *   The existing query object we're adding to. (This should probably
  *   be a reference, instead of returning the object again).
Index: project_issue.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v
retrieving revision 1.12
diff -u -F^f -r1.12 project_issue.module
--- project_issue.module	22 Dec 2006 23:54:14 -0000	1.12
+++ project_issue.module	23 Dec 2006 10:35:03 -0000
@@ -165,6 +165,12 @@ function project_issue_menu($may_cache) 
       'type' => MENU_NORMAL_ITEM,
     );
     $items[] = array(
+      'path' => 'project/issues/update_project',
+      'callback' => 'project_issue_update_project',
+      'access' => $access,
+      'type' => MENU_CALLBACK,
+    );
+    $items[] = array(
       'path' => 'project/issues/statistics',
       'title' => t('Statistics'),
       'callback' => 'project_issue_page',
@@ -178,7 +184,7 @@ function project_issue_menu($may_cache) 
       'access' => $access,
       'type' => MENU_NORMAL_ITEM,
     );
-    if (module_exists('search')) { 
+    if (module_exists('search')) {
       $items[] = array(
         'path' => 'search/issues',
         'title' => t('Issues'),
