Index: autopilot.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autopilot/autopilot.install,v
retrieving revision 1.1
diff -u -p -r1.1 autopilot.install
--- autopilot.install	20 Aug 2007 23:38:07 -0000	1.1
+++ autopilot.install	13 Sep 2007 12:27:53 -0000
@@ -1,7 +1,8 @@
 <?php
-	/* $Id */
-	function autopilot_install() {
-		db_query("CREATE TABLE autopilot_log ( bid int(11) NOT NULL auto_increment, tid int(11) NOT NULL, rid int(11) NOT NULL, timestamp int(11) default NULL, output mediumtext,status int(11) default NULL, name varchar(255) default NULL, PRIMARY KEY  (bid))");
-		db_query("CREATE TABLE autopilot_targets (bid int(11) NOT NULL auto_increment, name varchar(100) default NULL, host varchar(255) default NULL, active tinyint(1) default NULL, path varchar(255) default NULL, PRIMARY KEY  (bid))");
-	}
-?>
+// $Id$
+
+function autopilot_install() {
+  db_query("CREATE TABLE autopilot_log ( bid int(11) NOT NULL auto_increment, tid int(11) NOT NULL, rid int(11) NOT NULL, timestamp int(11) default NULL, output mediumtext,status int(11) default NULL, name varchar(255) default NULL, PRIMARY KEY  (bid))");
+  db_query("CREATE TABLE autopilot_targets (bid int(11) NOT NULL auto_increment, name varchar(100) default NULL, host varchar(255) default NULL, active tinyint(1) default NULL, path varchar(255) default NULL, PRIMARY KEY  (bid))");
+}
+
Index: autopilot.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autopilot/autopilot.module,v
retrieving revision 1.3
diff -u -p -r1.3 autopilot.module
--- autopilot.module	7 Sep 2007 18:46:19 -0000	1.3
+++ autopilot.module	13 Sep 2007 12:27:40 -0000
@@ -1,65 +1,67 @@
 <?php
-/* $Id */
+// $Id$
+
 define(AUTOPILOT_USER, "buildman");
 define(AUTOPILOT_SSH, "/usr/bin/ssh -x -n -i /var/www/.ssh/buildman-rsa ");
+
 function autopilot_menu($may_cache = "") {
   $items = array();
   $items[] = array("path" => "admin/autopilot/schedule",
-		   "title" => t("schedule"),
-		   "access" => user_access("schedule autopilot"),
-		   "callback" => "drupal_get_form",
-		   "callback arguments" => "autopilot_schedule_form",
-		   "type" => MENU_DEFAULT_LOCAL_TASK
-		   );
+    "title" => t("schedule"),
+    "access" => user_access("schedule autopilot"),
+    "callback" => "drupal_get_form",
+    "callback arguments" => "autopilot_schedule_form",
+    "type" => MENU_DEFAULT_LOCAL_TASK
+    );
   $items[] = array("path" => "admin/autopilot",
-		   "title" => t("Build Manager"),
-		   "access" => user_access("schedule autopilot"),
-		   "callback" => "drupal_get_form",
-		   "callback arguments" => "autopilot_schedule_form",
-		   "type" => MENU_NORMAL_ITEM
-		   );
+    "title" => t("Build Manager"),
+    "access" => user_access("schedule autopilot"),
+    "callback" => "drupal_get_form",
+    "callback arguments" => "autopilot_schedule_form",
+    "type" => MENU_NORMAL_ITEM
+    );
   $items[] = array("path" => "admin/autopilot/log",
-		   "title" => t("build log"),
-		   "access" => user_access("view autopilot log"),
-		   "callback" => "_autopilot_admin_log_page",
-		   "type" => MENU_LOCAL_TASK);
-
+    "title" => t("build log"),
+    "access" => user_access("view autopilot log"),
+    "callback" => "_autopilot_admin_log_page",
+    "type" => MENU_LOCAL_TASK);
+  
   $items[] = array("path" => "admin/autopilot/notifications",
-		   "title" => t("notifications"),
-		   "access" => user_access("administer autopilot"),
-		   "callback" => "drupal_get_form",
-		   "callback arguments" => "autopilot_notification_form",
-		   "type" => MENU_LOCAL_TASK);
-
+    "title" => t("notifications"),
+    "access" => user_access("administer autopilot"),
+    "callback" => "drupal_get_form",
+    "callback arguments" => "autopilot_notification_form",
+    "type" => MENU_LOCAL_TASK);
+  
   $items[] = array("path" => "admin/autopilot/log/view",
-		   "title" => t("build log"),
-		   "access" => user_access("view autopilot log"),
-		   "callback" => "_autopilot_admin_log_view_page",
-		   "type" => MENU_CALLBACK);
-
+    "title" => t("build log"),
+    "access" => user_access("view autopilot log"),
+    "callback" => "_autopilot_admin_log_view_page",
+    "type" => MENU_CALLBACK);
+  
   $items[] = array("path" => "admin/autopilot/configure",
-		   "title" => t("configure"),
-		   "access" => user_access("administer autopilot"),
-		   "callback" => "_autopilot_admin_configure_page",
-		   "type" => MENU_LOCAL_TASK);
+    "title" => t("configure"),
+    "access" => user_access("administer autopilot"),
+    "callback" => "_autopilot_admin_configure_page",
+    "type" => MENU_LOCAL_TASK);
   $items[] = array("path" => "admin/autopilot/target/add",
-		   "title" => t("Add Build Manager Target"),
-		   "access" => user_access("administer autopilot"),
-		   "callback" => "drupal_get_form",
-		   "callback arguments" => "autopilot_add_target_form",
-		   "type" => MENU_CALLBACK);
+    "title" => t("Add Build Manager Target"),
+    "access" => user_access("administer autopilot"),
+    "callback" => "drupal_get_form",
+    "callback arguments" => "autopilot_add_target_form",
+    "type" => MENU_CALLBACK);
   $items[] = array("path" => "admin/autopilot/target/edit",
-                   "title" => t("Edit Build Manager Target"),
-                   "access" => user_access("administer autopilot"),
-                   "callback" => "drupal_get_form",
-                   "callback arguments" => "autopilot_add_target_form",
-                   "type" => MENU_CALLBACK);
+    "title" => t("Edit Build Manager Target"),
+    "access" => user_access("administer autopilot"),
+    "callback" => "drupal_get_form",
+    "callback arguments" => "autopilot_add_target_form",
+    "type" => MENU_CALLBACK);
   $items[] = array("path" => "admin/autopilot/target/delete",
-		   "title" => t("Delete Build Manager Target"),
-	 	   "access" => user_access("administer autopilot"),
-		   "callback" => "drupal_get_form",
-		   "callback arguments" => "autopilot_delete_target_form",
-		   "type" => MENU_CALLBACK);                            
+    "title" => t("Delete Build Manager Target"),
+    "access" => user_access("administer autopilot"),
+    "callback" => "drupal_get_form",
+    "callback arguments" => "autopilot_delete_target_form",
+    "type" => MENU_CALLBACK);
   return $items;
 }
 
@@ -67,13 +69,12 @@ function autopilot_perm() {
   return array('administer autopilot', 'view autopilot log', 'schedule autopilot');
 }
 
-
 function autopilot_delete_target_form($tid) {
-  $form = array();
-  $form['tid'] = array("#type" => "hidden", "#value" => $tid);
+  $form            = array();
+  $form['tid']     = array("#type" => "hidden", "#value" => $tid);
   $form['message'] = array("#type" => "markup", "#value" => "<p>Are you sure you want to delete this target?</p>");
-  $form['submit'] = array("#type" => "submit", "#value" => "Delete");
-  $form['cancel'] = array("#type" => "markup", "#value" => l("cancel", "admin/autopilot/configure"));
+  $form['submit']  = array("#type" => "submit", "#value" => "Delete");
+  $form['cancel']  = array("#type" => "markup", "#value" => l("cancel", "admin/autopilot/configure"));
   return $form;
 }
 
@@ -89,13 +90,13 @@ function autopilot_delete_target_form_su
 function autopilot_notification_form() {
   $form = array();
   $form['users'] = array("#type" => "fieldset",
-			 "#collapsible" => FALSE,
-			 "#collapsed" => FALSE,
-			 "#title" => t("Notification emails"));
+    "#collapsible" => FALSE,
+    "#collapsed" => FALSE,
+    "#title" => t("Notification emails"));
   $form['users']['emails'] = array("#type" => 'textarea',
-				   "#title" => t("Email Addresses to Notify"),
-				   "#default_value" => implode(", ", variable_get('autopilot_notification_emails', array())),
-				   "#description" => t("A list of email addresses to notify when a build is finished (separate multiple addresses by commas"));
+    "#title" => t("Email Addresses to Notify"),
+    "#default_value" => implode(", ", variable_get('autopilot_notification_emails', array())),
+    "#description" => t("A list of email addresses to notify when a build is finished (separate multiple addresses by commas"));
   $form['submit'] = array("#type" => "submit", "#value" => "Save");
   
   return $form;
@@ -108,39 +109,39 @@ function autopilot_notification_form_sub
 }
 
 function autopilot_add_target_form($tid = "") {
-  $form = array();
+  $form          = array();
   $form['#base'] = 'autopilot_add_target_form';
-  $name = "";
-  $host = "";
-  $path = "";
+  $name          = "";
+  $host          = "";
+  $path          = "";
   if ($tid) {
-    $target = autopilot_get_target($tid);
-    $name = $target['name'];
-    $host = $target['host'];
-    $path = $target['path'];
+    $target      = autopilot_get_target($tid);
+    $name        = $target['name'];
+    $host        = $target['host'];
+    $path        = $target['path'];
     $form['tid'] = array("#type" => 'hidden',
-			 "#value" => $tid);
+      "#value" => $tid);
   }
   $form['name'] = array("#type" => 'textfield',
-			"#title" => t("Target Name"),
-			"#default_value" => $name,
-			"#size" => 50,
-			"#description" => "Friendly name to identify this build target");
+    "#title" => t("Target Name"),
+    "#default_value" => $name,
+    "#size" => 50,
+    "#description" => "Friendly name to identify this build target");
   $form['host'] = array("#type" => 'textfield',
-			"#title" => t("Host"),
-			"#default_value" => $host,
-			"#size" => 50,
-			"#description" => "Host name or IP Address of target server.");
+    "#title" => t("Host"),
+    "#default_value" => $host,
+    "#size" => 50,
+    "#description" => "Host name or IP Address of target server.");
   $form['path'] = array("#type" => 'textfield',
-			"#title" => t("Remote Path"),
-			"#default_value" => $path,
-			"#size" => 80,
-			"#description" => "Path on remote (target) server to deploy to.");
+    "#title" => t("Remote Path"),
+    "#default_value" => $path,
+    "#size" => 80,
+    "#description" => "Path on remote (target) server to deploy to.");
   $form['active'] = array("#type" => "hidden",
-			  "#value" => "true");
+    "#value" => "true");
   $form['submit'] = array("#type" => "submit",
-			  "#value" => "Save Build Manager Target");
-
+    "#value" => "Save Build Manager Target");
+  
   return $form;
 }
 
@@ -156,83 +157,84 @@ function autopilot_add_target_form_submi
 }
 
 function _autopilot_admin_configure_page() {
-  $output = "";
+  $output        = "";
   $target_output = "";
-  $rows = array();
-  $targets = autopilot_get_targets();
-  $header = array("Target Name", "Host", "Active", array("data" => "Actions", "colspan" => 2));
+  $rows          = array();
+  $targets       = autopilot_get_targets();
+  $header        = array("Target Name", "Host", "Active", array("data" => "Actions", "colspan" => 2));
   if (count($targets) > 0) {
-    foreach($targets as $target) {
-      $rows[] = array($target['name'], 
-		      $target['host'], 
-		      $target['active'] ? "yes" : "no", 
-		      l(("edit"), "admin/autopilot/target/edit/{$target['tid']}"),
-		      l(t("delete"), "admin/autopilot/target/delete/{$target['tid']}"));
+    foreach ($targets as $target) {
+      $rows[] = array($target['name'],
+        $target['host'],
+        $target['active'] ? "yes" : "no",
+        l(("edit"), "admin/autopilot/target/edit/{$target['tid']}"),
+        l(t("delete"), "admin/autopilot/target/delete/{$target['tid']}"));
     }
-  } else {
+  }
+  else {
     $rows[] = array(array("data" => "no targets defined", "colspan" => 5));
   }
-
-  $rows[] = array(array("data" => l(t("add target"), "admin/autopilot/target/add"), "colspan" => 6, "align" => "right"));
-
+  
+  $rows[]        = array(array("data" => l(t("add target"), "admin/autopilot/target/add"), "colspan" => 6, "align" => "right"));
+  
   $target_output = theme("table", $header, $rows);
-  $element = array('#collapsible' => "false",
-		   "#title" => t("Build Manager Targets"),
-		   '#value' => $target_output);
+  $element       = array('#collapsible' => "false",
+    "#title" => t("Build Manager Targets"),
+    '#value' => $target_output);
   $output .= theme("fieldset", $element);
-  print(theme("page", $output));
+  print (theme("page", $output));
 }
 
 function autopilot_schedule_form($form_values = array()) {
-  drupal_add_js(drupal_get_path("module", "autopilot") . "/autopilot.js");
-
+  drupal_add_js(drupal_get_path("module", "autopilot") ."/autopilot.js");
+  
   $form = array();
-
+  
   $form['info'] = array("#type" => "fieldset",
-                        "#collapsible" => FALSE,
-                        "#collapsed" => FALSE,
-                        "#title" => t("Build Information")
-                        );
+    "#collapsible" => FALSE,
+    "#collapsed" => FALSE,
+    "#title" => t("Build Information")
+    );
   $form['info']['name'] = array("#type" => "textfield",
-                                "#title" => t("Build Name"),
-                                "#description" => t("Give this build a name that's easy to identify."),
-                                "#size" => 50
-                                );
+    "#title" => t("Build Name"),
+    "#description" => t("Give this build a name that's easy to identify."),
+    "#size" => 50
+    );
   
   $form['revisions'] = array("#type" => "fieldset",
-                             "#collapsible" => FALSE,
-                             "#collapsed" => FALSE,
-                             "#title" => t("Select a Revision to build")
-                             );
+    "#collapsible" => FALSE,
+    "#collapsed" => FALSE,
+    "#title" => t("Select a Revision to build")
+    );
   $revision_options = array();
-  $svid = variable_get("autopilot_svid", 5);
+  $svid             = variable_get("autopilot_svid", 5);
   
-  $revisions = autpilot_svn_get_revisions($svid);
+  $revisions        = autpilot_svn_get_revisions($svid);
   foreach ($revisions as $revision) {
-    $revision_options["{$revision['revision_number']}"] = $revision['revision_number'] . ": " . substr($revision['message'], 0, 80);
+    $revision_options["{$revision['revision_number']}"] = $revision['revision_number'] .": ". substr($revision['message'], 0, 80);
   }
   $form['revisions']['revision'] = array("#type" => "select",
-                                         "#title" => t("Select a revision"),
-                                         "#attributes" => array("onchange" => "revision_select(this)"),
-                                         "#options" => $revision_options
-                                         );
-  $targets = autopilot_get_targets();
-  $target_options = array();
+    "#title" => t("Select a revision"),
+    "#attributes" => array("onchange" => "revision_select(this)"),
+    "#options" => $revision_options
+    );
+  $targets             = autopilot_get_targets();
+  $target_options      = array();
   $target_options["0"] = "Select...";
   if (count($targets) == 0) {
-    form_set_error("revisions][target", "No Build Manager targets defined. " . l("Click here", "admin/autopilot/target/add") . " to add one.");
+    form_set_error("revisions][target", "No Build Manager targets defined. ". l("Click here", "admin/autopilot/target/add") ." to add one.");
   }
-  foreach($targets as $target) {
+  foreach ($targets as $target) {
     $target_options[$target['tid']] = $target['name'];
   }
   $form['revisions']['target'] = array("#type" => "select",
-                                       "#title" => t("Target"),
-                                       "#description" => "Choose the target system for this deployment.",
-                                       "#options" => $target_options,
-                                       "#default_value" => "0"
-                                       );
+    "#title" => t("Target"),
+    "#description" => "Choose the target system for this deployment.",
+    "#options" => $target_options,
+    "#default_value" => "0"
+    );
   $form['submit'] = array("#type" => "submit",
-                          "#value" => "Run Build Now");
+    "#value" => "Run Build Now");
   return $form;
 }
 
@@ -248,50 +250,50 @@ function autopilot_schedule_form_validat
   }
 }
 
-
 function autopilot_schedule_form_submit($form_id, $form_values) {
   autopilot_save_build($form_values);
 }
 
 function _autopilot_admin_log_page() {
-  $output = "";
-  $query = "SELECT al.bid as build_id, al.name as build_name, at.name as target_name, rid, from_unixtime(timestamp) as timestamp, status from {autopilot_log} al, {autopilot_targets} at where at.tid=autopilot_log.tid order by timestamp desc";
+  $output    = "";
+  $query     = "SELECT al.bid as build_id, al.name as build_name, at.name as target_name, rid, from_unixtime(timestamp) as timestamp, status from {autopilot_log} al, {autopilot_targets} at where at.tid=autopilot_log.tid order by timestamp desc";
   $resultset = db_query($query);
-  $header = array("Name", "Target", "Revision", "Date", "Status", "Actions");
-  $rows = array();
+  $header    = array("Name", "Target", "Revision", "Date", "Status", "Actions");
+  $rows      = array();
   while ($row = db_fetch_array($resultset)) {
-    $rows[] = array($row['build_name'], 
-                    $row['target_name'], 
-                    $row['rid'], 
-                    $row['timestamp'], 
-                    ($row['status'] === "0") ? "<span style=\"color:#00ff00;font-weight:bold;\">Succeeded</span>" : "<span style=\"color:#ff0000;font-weight:bold;\">Failed</span>",
-                    l("view", "admin/autopilot/log/view/{$row['build_id']}"));
+    $rows[] = array($row['build_name'],
+      $row['target_name'],
+      $row['rid'],
+      $row['timestamp'],
+      ($row['status'] === "0") ? "<span style=\"color:#00ff00;font-weight:bold;\">Succeeded</span>" : "<span style=\"color:#ff0000;font-weight:bold;\">Failed</span>",
+      l("view", "admin/autopilot/log/view/{$row['build_id']}"));
   }
   $output .= theme("table", $header, $rows);
-  print(theme("page", $output));
+  print (theme("page", $output));
 }
 
 function _autopilot_admin_log_view_page($build_id) {
   drupal_add_js("misc/collapse.js");
-  $output = "";
-  $query = "SELECT al.bid as build_id, al.name as build_name, at.name as target_name, rid, from_unixtime(timestamp) as timestamp, status, output from {autopilot_log} al, {autopilot_targets} at where at.tid=al.tid AND al.bid=" . $build_id . " order by timestamp desc";
+  $output    = "";
+  $query     = "SELECT al.bid as build_id, al.name as build_name, at.name as target_name, rid, from_unixtime(timestamp) as timestamp, status, output from {autopilot_log} al, {autopilot_targets} at where at.tid=al.tid AND al.bid=". $build_id ." order by timestamp desc";
   $resultset = db_query($query);
   
-  $row = db_fetch_array($resultset);
+  $row       = db_fetch_array($resultset);
   if ($row['status'] == "0") {
-    $thankyou_header="<p>Your build was completed successfully.  The result of the build is shown below.</p>";
-    print(theme("page", $thankyou_header . $row['output']));
-  } else {
-    print(theme("page", "<p>Your build returned a non-zero result code.  This usally means that it failed.  Output was:</p>" . $row['output']));
+    $thankyou_header = "<p>Your build was completed successfully.  The result of the build is shown below.</p>";
+    print (theme("page", $thankyou_header . $row['output']));
+  }
+  else {
+    print (theme("page", "<p>Your build returned a non-zero result code.  This usally means that it failed.  Output was:</p>". $row['output']));
   }
 }
 
 function autopilot_get_targets() {
-  $query = "SELECT * from {autopilot_targets}";
+  $query     = "SELECT * from {autopilot_targets}";
   $resultset = db_query($query);
-  $targets = array();
+  $targets   = array();
   while ($target = db_fetch_array($resultset)) {
-  	$targets[] = $target;  
+    $targets[] = $target;
   }
   return $targets;
 }
@@ -304,8 +306,8 @@ function autopilot_get_target($values) {
     foreach ($values as $key => $value) {
       $array_where[] = "{$key}='{$value}'";
     }
-    
-  } else {
+  }
+  else {
     $array_where[] = "tid=$values";
   }
   $where .= implode(" AND ", $array_where);
@@ -315,16 +317,16 @@ function autopilot_get_target($values) {
 }
 
 function autopilot_save_target($target) {
-  $values = array(db_escape_string($target['name']), 
-		  db_escape_string($target['host']), 
-		  db_escape_string($target['path']), 
-		  db_escape_string($target['active']));
+  $values = array(db_escape_string($target['name']),
+    db_escape_string($target['host']),
+    db_escape_string($target['path']),
+    db_escape_string($target['active']));
   $query = "INSERT INTO {autopilot_targets} (name, host, path, active) values('%s', '%s', '%s', '%s')";
   if ($target['tid']) {
     $query = "UPDATE {autopilot_targets} set name='%s', host='%s', path='%s', active='%s' where tid=%s";
     $values[] = $target['tid'];
   }
-
+  
   $resultset = db_query($query, $values);
 }
 
@@ -333,42 +335,43 @@ function autopilot_save_target($target) 
  */
 function autopilot_save_build($build) {
   drupal_add_js("misc/collapse.js");
-  $tid = $build['target'];
-  $target = autopilot_get_target($tid);
-  $host = $target['host'];
-  $name = $build['name'];
-  $revision = $build['revision'];
-  $path = $target['path']; 
-  $db_suffix = $target['db_suffix'];
-  $svn_root = $target['svn_root'];
-  $output = array();
-  $cmd = AUTOPILOT_SSH . AUTOPILOT_USER . "@" . $host  . " /home/buildman/bin/runbuild.sh {$revision} {$path} {$svn_root} {$target['name']} {$db_suffix} 2>&1";
+  $tid        = $build['target'];
+  $target     = autopilot_get_target($tid);
+  $host       = $target['host'];
+  $name       = $build['name'];
+  $revision   = $build['revision'];
+  $path       = $target['path'];
+  $db_suffix  = $target['db_suffix'];
+  $svn_root   = $target['svn_root'];
+  $output     = array();
+  $cmd        = AUTOPILOT_SSH . AUTOPILOT_USER ."@". $host ." /home/buildman/bin/runbuild.sh {$revision} {$path} {$svn_root} {$target['name']} {$db_suffix} 2>&1";
   
   $result_val = 0;
-    drupal_set_message("running command $cmd", "info");
+  drupal_set_message("running command $cmd", "info");
   exec($cmd, &$output, $result_val);
   $output = implode("\n", $output);
-  $query = "INSERT INTO autopilot_log (timestamp, name, tid, rid, status, output) values (%s, '%s', '%s', '%s', '%s', '%s')";
-  $args = array(mktime(), 
-                db_escape_string($name),
-                db_escape_string($tid), 
-                db_escape_string($revision), 
-                db_escape_string($result_val),
-                db_escape_string($output));
-
+  $query  = "INSERT INTO autopilot_log (timestamp, name, tid, rid, status, output) values (%s, '%s', '%s', '%s', '%s', '%s')";
+  $args   = array(mktime(),
+    db_escape_string($name),
+    db_escape_string($tid),
+    db_escape_string($revision),
+    db_escape_string($result_val),
+    db_escape_string($output));
+  
   $emails = variable_get('autopilot_notification_emails', array());
   if (count($emails) > 0) {
     // strip html out of email before mailing.
     $message = preg_replace("/<[^>]+>/", "", $output);
     _autopilot_notify_emails($target['name'], $message, $emails);
   }
-
+  
   $resultset = db_query($query, $args);
   if ($result_val == "0") {
-    $thankyou_header="<p>Your build has completed.  The result of the build is shown below.</p>";
-    print(theme("page", $thankyou_header . $output));
-  } else {
-    print(theme("page", "<p>Your build returned a non-zero result code.  This usally means that it failed.  Output was:</p>" . $output));
+    $thankyou_header = "<p>Your build has completed.  The result of the build is shown below.</p>";
+    print (theme("page", $thankyou_header . $output));
+  }
+  else {
+    print (theme("page", "<p>Your build returned a non-zero result code.  This usally means that it failed.  Output was:</p>". $output));
   }
 }
 
@@ -379,12 +382,12 @@ function _autopilot_notify_emails($targe
   //TODO: retrieve "FROM" email from settings
   //
   $from_address = variable_get("autopilot_from_address", "aaron@firebright.com");
-  $header = "From: {$from_address}\r\n";
+  $header       = "From: {$from_address}\r\n";
   
-  $address = array();
+  $address      = array();
   foreach ($emails as $email) {
     $address .= "{$email} <{$email}>\r\n";
   }
-  drupal_mail("autopilot_notification", $address, "[{$target}] Build released.", "A new build has been released to {$target}.  Output was:\r\n" . $message, $header);
+  drupal_mail("autopilot_notification", $address, "[{$target}] Build released.", "A new build has been released to {$target}.  Output was:\r\n". $message, $header);
 }
-?>
+
Index: autopilot_svn.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autopilot/autopilot_svn.install,v
retrieving revision 1.1
diff -u -p -r1.1 autopilot_svn.install
--- autopilot_svn.install	7 Sep 2007 18:46:19 -0000	1.1
+++ autopilot_svn.install	13 Sep 2007 12:26:33 -0000
@@ -2,12 +2,13 @@
 /* $Id */
 function autopilot_svn_install() {
   $queries = array("CREATE TABLE {autopilot_svn_notifications} (lid int(11) NOT NULL auto_increment, svid int(11) NOT NULL default '0', created_date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, description varchar(255) default NULL, message tinytext, PRIMARY KEY(lid)",
-                   "CREATE TABLE {autopilot_svn_repositories} (svid int(11) NOT NULL auto_increment, name varchar(255) default NULL, path varchar(255) default NULL, local_path varchar(255) default NULL, created_date timestamp NOT NULL default CURRENT_TIMESTAMP, password varchar(255) default NULL, username varchar(255) default NULL,islocal tinyint(1) default NULL, local_revision int(11) default NULL,PRIMARY KEY(svid)",
-                   "CREATE TABLE {autopilot_svn_revisions} (rvid int(11) NOT NULL auto_increment,svid int(11) NOT NULL default '0',revision_number int(11) NOT NULL default '0',revision_message varchar(255) default NULL,revision_date varchar(255) default NULL,owner varchar(100) default NULL,islocal tinyint(1) default NULL,PRIMARY KEY(rvid),KEY autopilot_svn_revisions_revision_number (revision_number)",
-                   "CREATE TABLE {autopilot_svn_revisions_paths} (pid int(11) NOT NULL auto_increment,revision_number int(11) NOT NULL default '0',path varchar(255) default NULL,action char(2) default NULL,svid int(11) NOT NULL default '0',PRIMARY KEY(pid),KEY autopilot_svn_revisions_paths_revision_number (revision_number)"
-                   );
+    "CREATE TABLE {autopilot_svn_repositories} (svid int(11) NOT NULL auto_increment, name varchar(255) default NULL, path varchar(255) default NULL, local_path varchar(255) default NULL, created_date timestamp NOT NULL default CURRENT_TIMESTAMP, password varchar(255) default NULL, username varchar(255) default NULL,islocal tinyint(1) default NULL, local_revision int(11) default NULL,PRIMARY KEY(svid)",
+    "CREATE TABLE {autopilot_svn_revisions} (rvid int(11) NOT NULL auto_increment,svid int(11) NOT NULL default '0',revision_number int(11) NOT NULL default '0',revision_message varchar(255) default NULL,revision_date varchar(255) default NULL,owner varchar(100) default NULL,islocal tinyint(1) default NULL,PRIMARY KEY(rvid),KEY autopilot_svn_revisions_revision_number (revision_number)",
+    "CREATE TABLE {autopilot_svn_revisions_paths} (pid int(11) NOT NULL auto_increment,revision_number int(11) NOT NULL default '0',path varchar(255) default NULL,action char(2) default NULL,svid int(11) NOT NULL default '0',PRIMARY KEY(pid),KEY autopilot_svn_revisions_paths_revision_number (revision_number)"
+    );
   foreach ($queries as $query) {
     db_query($query);
   }
 }
-?>
+
+
Index: autopilot_svn.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autopilot/autopilot_svn.module,v
retrieving revision 1.1
diff -u -p -r1.1 autopilot_svn.module
--- autopilot_svn.module	7 Sep 2007 18:46:19 -0000	1.1
+++ autopilot_svn.module	13 Sep 2007 12:26:33 -0000
@@ -1,78 +1,77 @@
-<?
+<?php
 /* $Id */
-require_once(dirname(__FILE__) . '/xmltoarray.php');
-
+require_once (dirname(__FILE__) .'/xmltoarray.php');
 function svn_menu($may_cache = TRUE) {
   $items = array();
   $items[] = array('path' => 'admin/settings/autopilot_svn/list',
-		   'callback' => '_autopilot_svn_page_admin_list',
-		   'title' => t('list'),
-		   'access' => user_access('administer autopilot_svn'),
-		   'type' => MENU_DEFAULT_LOCAL_TASK
-		   );
-
+    'callback' => '_autopilot_svn_page_admin_list',
+    'title' => t('list'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_DEFAULT_LOCAL_TASK
+    );
+  
   $items[] = array('path' => 'admin/settings/autopilot_svn',
-		   'callback' => '_svn_page_admin_list',
-		   'title' => t('SVN Repositories'),
-		   'access' => user_access('administer autopilot_svn'),
-		   'type' => MENU_NORMAL_ITEM
-		   );
-
+    'callback' => '_svn_page_admin_list',
+    'title' => t('SVN Repositories'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_NORMAL_ITEM
+    );
+  
   $items[] = array('path' => 'admin/settings/autopilot_svn/edit',
-		   'callback' => 'drupal_get_form',
-		   'callback arguments' => array('autopilot_svn_admin_edit'),
-		   'title' => t('edit'),
-		   'access' => user_access('administer autopilot_svn'),
-		   'type' => MENU_CALLBACK
-		   );
-
+    'callback' => 'drupal_get_form',
+    'callback arguments' => array('autopilot_svn_admin_edit'),
+    'title' => t('edit'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_CALLBACK
+    );
+  
   $items[] = array('path' => 'admin/settings/autopilot_svn/add',
-		   'callback' => 'drupal_get_form',
-		   'callback arguments' => array('autopilot_svn_admin_edit'),
-		   'title' => t('add'),
-		   'access' => user_access('administer autopilot_svn'),
-		   'type' => MENU_LOCAL_TASK);
-
+    'callback' => 'drupal_get_form',
+    'callback arguments' => array('autopilot_svn_admin_edit'),
+    'title' => t('add'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_LOCAL_TASK);
+  
   $items[] = array('path' => 'autopilot_svn/view',
-		   'callback' => '_autopilot_svn_page_view',
-		   'title' => t('SVN View'),
-		   'access' => user_access('view autopilot_svn'),
-		   'type' => MENU_CALLBACK
-		   );
+    'callback' => '_autopilot_svn_page_view',
+    'title' => t('SVN View'),
+    'access' => user_access('view autopilot_svn'),
+    'type' => MENU_CALLBACK
+    );
   $items[] = array('path' => 'admin/settings/autopilot_svn/checkout',
-		   'callback' => '_svn_page_checkout',
-		   'title' => t('Checkout Subversion repository'),
-		   'access' => user_access('administer autopilot_svn'),
-		   'type' => MENU_CALLBACK
-		   );
+    'callback' => '_svn_page_checkout',
+    'title' => t('Checkout Subversion repository'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_CALLBACK
+    );
   $items[] = array('path' => 'admin/settings/autopilot_svn/delete',
-                   'callback' => 'drupal_get_form',
-                   'callback arguments' => array('autopilot_svn_page_delete'),
-                   'title' => t('Delete Subversion repository'),
-                   'access' => user_access('administer autopilot_svn'),
-                   'type' => MENU_CALLBACK);
-
+    'callback' => 'drupal_get_form',
+    'callback arguments' => array('autopilot_svn_page_delete'),
+    'title' => t('Delete Subversion repository'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_CALLBACK);
+  
   $items[] = array('path' => 'admin/settings/autopilot_svn/update',
-		   'callback' => '_autopilot_svn_page_update',
-		   'title' => t('Update Subversion repository'),
-		   'access' => user_access('administer autopilot_svn'),
-		   'type' => MENU_CALLBACK);
+    'callback' => '_autopilot_svn_page_update',
+    'title' => t('Update Subversion repository'),
+    'access' => user_access('administer autopilot_svn'),
+    'type' => MENU_CALLBACK);
   return $items;
 }
 
 function autopilot_svn_page_delete($svid = 0) {
-  $form = array();
-  $form['svid'] = array('#type' => 'hidden', '#value' => $svid);
+  $form            = array();
+  $form['svid']    = array('#type' => 'hidden', '#value' => $svid);
   $form['message'] = array('#type' => 'markup', '#value' => '<p>Are you sure you want to delete this subversion repository? This will NOT affect the repository itself, only the connection to Drupal.</p>');
-  $form['submit'] = array('#type' => 'submit', '#value' => 'Delete');
-  $form['cancel'] = array('#type' => 'markup', '#value' => l('cancel', 'admin/settings/autopilot_svn/view/' . $svid));
+  $form['submit']  = array('#type' => 'submit', '#value' => 'Delete');
+  $form['cancel']  = array('#type' => 'markup', '#value' => l('cancel', 'admin/settings/autopilot_svn/view/'. $svid));
   return $form;
 }
 
 function autopilot_svn_page_delete_submit($form_id, $form_values) {
-  $queries = array('DELETE FROM {autopilot_svn_repositories} WHERE svid=%s', 
-                   'DELETE FROM {autopilot_svn_revisions} WHERE svid=%s', 
-                   'DELETE FROM {autopilot_svn_revisions_paths} WHERE svid=%s');
+  $queries = array('DELETE FROM {autopilot_svn_repositories} WHERE svid=%s',
+    'DELETE FROM {autopilot_svn_revisions} WHERE svid=%s',
+    'DELETE FROM {autopilot_svn_revisions_paths} WHERE svid=%s');
   foreach ($queries as $query) {
     $resultset = db_query($query, $form_values['svid']);
   }
@@ -102,10 +101,10 @@ function autopilot_svn_cron() {
     $info = autopilot_svn_get_info(NULL, $repo);
     
     $head_revision = $info['revision'];
-
+    
     watchdog('cron', "autopilot_svn fetching revisions {$last_revision} through {$head_revision}");
     $last_revision = variable_get('autopilot_svn_last_revision', 0) + 1;
-  
+    
     for ($i = $last_revision; $i <= $head_revision; $i++) {
       
       $log = autopilot_svn_do_log(NULL, $repo, $i);
@@ -114,73 +113,73 @@ function autopilot_svn_cron() {
     }
   }
 }
-  
+
 function _autopilot_svn_page_view($svid = 0) {
   $repo = autopilot_svn_get_repo($svid);
   drupal_set_title($repo['name']);
-
-  $output = '';
-  $info = autopilot_svn_get_info(NULL, $repo);
+  
+  $output  = '';
+  $info    = autopilot_svn_get_info(NULL, $repo);
   $element = array('#collapsible' => TRUE,
-		   '#collapsed' => FALSE,
-		   '#title' => t('Subversion Revision Info'));
-  $items = array();
-  $items[] = 'Path: ' . $info['url'];
-  $items[] = 'Current Remote Revision: ' . $info['revision'];
-  $local = 'Current Local Revision: ';
-  $local.= ($repo['local_revision']) ? $repo['local_revision'] : 'none';
+    '#collapsed' => FALSE,
+    '#title' => t('Subversion Revision Info'));
+  $items   = array();
+  $items[] = 'Path: '. $info['url'];
+  $items[] = 'Current Remote Revision: '. $info['revision'];
+  $local   = 'Current Local Revision: ';
+  $local .= ($repo['local_revision']) ? $repo['local_revision'] : 'none';
   
   $items[] = $local;
-  $items[] = 'Last Updated: ' . $info['last_changed_date'] . ' by ' . $info['last_changed_author'];
+  $items[] = 'Last Updated: '. $info['last_changed_date'] .' by '. $info['last_changed_author'];
   $element['#children'] = theme_item_list($items, NULL, 'ul');
-
+  
   $output = theme_fieldset($element);
-
+  
   $revisions = autopilot_svn_get_revisions($svid);
   if (count($revisions) == 0) {
     drupal_set_message('This repository contains no revisions or has not yet been indexed.  Is your cron running?');
   }
   drupal_add_css(drupal_get_path('module', 'autopilot_svn') .'/autopilot_svn.css');
-
+  
   foreach ($revisions as $rid => $revision) {
     $revision['islocal'] = ($revision['revision_number'] == $repo['local_revision']);
     $output .= theme('autopilot_svn_revision', $revision);
   }
-
-  print(theme('page', $output));
-
+  
+  print (theme('page', $output));
 }
 
 function theme_autopilot_svn_revision($revision) {
-    if ($revision['islocal']) {
-      $class = 'autopilot_svn_active';
-      drupal_set_message('Revision ' . $revision['revision_number'] . ' is local.');
-    }
-    $element = array('#collapsible' => TRUE,
-		     '#collapsed' => FALSE,
-		     '#title' => t("Revision number {$rid}: {$revision['date']} by {$revision['owner']}"));
-    $element['#attributes']['class'] = $class;
-
-    $children = '';
-    $rows = array();
-    $children = "<pre>{$revision['message']}</pre>";
-
-    $items = array();
-    foreach ($revision['paths'] as $path => $action) {
-      $items[] = "$action <b>$path</b>";
-    }
-    if (!$revision['islocal']) {
-      $update_button = '<div style=\"float:right;\">';
-      $update_button.= l('update local to this revision', 'admin/settings/autopilot_svn/update/' . $revision['svid'] . '/' . $revision['revision_number'], 
-                         array(), 
-                         drupal_get_destination());
-      $update_button.= '&#160;&#160;</div>';
-    } else {
-      $update_button = '<div style=\"float:right;\">local is synced to this revision&#160;&#160;</div>';
-    }
-    $element['#children'] .= $children . theme_item_list($items, 'Files Changed', 'ul') . $update_button;
-    $output .= theme_fieldset($element);
-    return $output;
+  if ($revision['islocal']) {
+    $class = 'autopilot_svn_active';
+    drupal_set_message('Revision '. $revision['revision_number'] .' is local.');
+  }
+  $element = array('#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#title' => t("Revision number {$rid}: {$revision['date']} by {$revision['owner']}"));
+  $element['#attributes']['class'] = $class;
+  
+  $children = '';
+  $rows = array();
+  $children = "<pre>{$revision['message']}</pre>";
+  
+  $items = array();
+  foreach ($revision['paths'] as $path => $action) {
+    $items[] = "$action <b>$path</b>";
+  }
+  if (!$revision['islocal']) {
+    $update_button = '<div style=\"float:right;\">';
+    $update_button .= l('update local to this revision', 'admin/settings/autopilot_svn/update/'. $revision['svid'] .'/'. $revision['revision_number'],
+      array(),
+      drupal_get_destination());
+    $update_button .= '&#160;&#160;</div>';
+  }
+  else {
+    $update_button = '<div style=\"float:right;\">local is synced to this revision&#160;&#160;</div>';
+  }
+  $element['#children'] .= $children . theme_item_list($items, 'Files Changed', 'ul') . $update_button;
+  $output .= theme_fieldset($element);
+  return $output;
 }
 
 function autopilot_svn_get_revisions($svid) {
@@ -189,7 +188,7 @@ function autopilot_svn_get_revisions($sv
   $query .= 'AND sr.svid=srp.svid ';
   $query .= 'WHERE sr.svid=%d ORDER BY sr.revision_number DESC';
   $resultset = db_query($query, $svid);
-
+  
   $results = array();
   while ($row = db_fetch_array($resultset)) {
     $rNum = $row['revision_number'];
@@ -221,16 +220,16 @@ function autopilot_svn_co($svid, $repo =
   if ($svid) {
     $repo = autopilot_svn_get_repo($svid);
   }
-  $cmd = dirname(__FILE__) . '/scripts/checkout.sh ';
-  $cmd .= $repo['path'] . ' ';
+  $cmd = dirname(__FILE__) .'/scripts/checkout.sh ';
+  $cmd .= $repo['path'] .' ';
   if (!is_writable($repo['local_path'])) {
     watchdog('error', "Local path '{$repo['local_path']}' for autopilot_svn checkout is not writable.");
   }
   $cmd .= $repo['local_path'];
-
-  $result = `$cmd`;
-  $lines = explode("\n", trim($result));
-  $lastline = $lines[count($lines)-1];
+  
+  $result          = `$cmd`;
+  $lines           = explode("\n", trim($result));
+  $lastline        = $lines[count($lines) - 1];
   $revision_number = preg_replace('/[^0-9]/', '', $lastline);
   _autopilot_svn_save_update_notification($repo, 'checkout', $revision_number, $result);
   $repo['islocal'] = 'true';
@@ -241,30 +240,30 @@ function autopilot_svn_co($svid, $repo =
 function _autopilot_svn_save_update_notification($repo, $type, $revision_number, $message) {
   $query = 'UPDATE {autopilot_svn_repositories} SET islocal=true, local_revision=%d WHERE svid=%d';
   db_query($query, $revision_number, $repo['svid']);
-
+  
   // TODO: save a log entry of the update
   //
   $query = "INSERT INTO {autopilot_svn_notifications} (svid, created_date, description, message) VALUES(%s, now(), '%s', '%s')";
   $description = "Repository was updated to revision number:  {$revision_number} by action '{$type}'\n";
-  db_query($query, 
-           $repo['svid'], 
-           db_escape_string($description),
-           db_escape_string($message)
-           );
+  db_query($query,
+    $repo['svid'],
+    db_escape_string($description),
+    db_escape_string($message)
+    );
 }
 
 function autopilot_svn_do_update($svid, $repo = NULL, $revision_number = NULL) {
   if ($svid) {
     $repo = autopilot_svn_get_repo($svid);
   }
-  $cmd = dirname(__FILE__) . '/scripts/update.sh ';
+  $cmd = dirname(__FILE__) .'/scripts/update.sh ';
   $cmd .= $repo['local_path'];
   if ($revision_number != NULL) {
-    $cmd .= ' ' . $revision_number;
+    $cmd .= ' '. $revision_number;
   }
-  $result = `$cmd`;
-  $lines = explode("\n", trim($result));
-  $lastline = $lines[count($lines)-1];
+  $result          = `$cmd`;
+  $lines           = explode("\n", trim($result));
+  $lastline        = $lines[count($lines) - 1];
   $revision_number = preg_replace('/[^0-9]/', '', $lastline);
   _autopilot_svn_save_update_notification($repo, 'update', $revision_number, $result);
   $repo['islocal'] = 'true';
@@ -276,7 +275,7 @@ function autopilot_svn_get_info($svid, $
   if ($svid) {
     $repo = autopilot_svn_get_repo($svid);
   }
-  $info_script = dirname(__FILE__) . '/scripts/getinfo.sh';
+  $info_script = dirname(__FILE__) .'/scripts/getinfo.sh';
   if (!file_exists($info_script)) {
     drupal_set_error("File $info_script does not exist.");
     return;
@@ -286,12 +285,12 @@ function autopilot_svn_get_info($svid, $
     return;
   }
   $cmd = $info_script .' ';
-
+  
   //  $cmd .= ' info --non-interactive ';
   if ($repo['username'] && $repo['password']) {
     $cmd .= "--username {$repo['username']} --password {$repo['password']} ";
   }
-  $cmd .= $repo['path'] . ' 2>&1';
+  $cmd .= $repo['path'] .' 2>&1';
   $result = `$cmd`;
   return _autopilot_svn_parse_output(trim($result));
 }
@@ -300,31 +299,31 @@ function autopilot_svn_do_log($svid, $re
   if ($svid) {
     $repo = autopilot_svn_get_repo($svid);
   }
-  $cmd = dirname(__FILE__) . '/scripts/getlog.sh ';
+  $cmd = dirname(__FILE__) .'/scripts/getlog.sh ';
   if ($repo['username'] && $repo['password']) {
     $cmd .= "--username {$repo['username']} --password {$repo['password']} ";
   }
   $cmd .= $repo['path'];
-  $cmd .= ' ' . $revision_number;
+  $cmd .= ' '. $revision_number;
   $result = `$cmd`;
-  print($result);
+  print ($result);
   return _autopilot_svn_parse_log_output(trim($result));
 }
 
 function autopilot_svn_get_repo($svid) {
   $repo_query = 'SELECT svid, name, path, local_path, username, password, local_revision FROM {autopilot_svn_repositories} WHERE svid=%d';
-  $resultset = db_query($repo_query, $svid);
-  $row = db_fetch_array($resultset);
+  $resultset  = db_query($repo_query, $svid);
+  $row        = db_fetch_array($resultset);
   if ($row == null) {
     watchdog('error', "No repository with id {$svid}");
-  }		
+  }
   return $row;
 }
 
 function autopilot_svn_get_repos() {
   $repo_query = 'SELECT svid, name, path, local_path, islocal, local_revision FROM {autopilot_svn_repositories}';
-  $resultset = db_query($repo_query);
-  $repos = array();
+  $resultset  = db_query($repo_query);
+  $repos      = array();
   while ($row = db_fetch_array($resultset)) {
     $repos[] = $row;
   }
@@ -346,91 +345,94 @@ function _autopilot_svn_page_admin_list(
   $output = '';
   if (count($repos) == 0) {
     $output .= 'No repositories defined.';
-  } else {
+  }
+  else {
     $rows = array();
     $header = array('Name', 'Path', array('data' => 'Actions', 'colspan' => 3));
-
+    
     foreach ($repos as $repo) {
       $checkout_action = ($repo['islocal'] == 1) ? 'update' : 'checkout';
-      $rows[] = array(l($repo['name'], "admin/settings/autopilot_svn/view/{$repo['svid']}"), 
-		      $repo['path'], 
-		      l('view', "autopilot_svn/view/{$repo['svid']}"), 
-		      l('edit', "admin/settings/autopilot_svn/edit/{$repo['svid']}"), 
-		      l('delete', "admin/settings/autopilot_svn/delete/{$repo['svid']}"), 
-		      l($checkout_action, "admin/settings/autopilot_svn/{$checkout_action}/{$repo['svid']}")
-		      );
-    } 
-    $output.= theme_table($header, $rows);
+      $rows[] = array(l($repo['name'], "admin/settings/autopilot_svn/view/{$repo['svid']}"),
+        $repo['path'],
+        l('view', "autopilot_svn/view/{$repo['svid']}"),
+        l('edit', "admin/settings/autopilot_svn/edit/{$repo['svid']}"),
+        l('delete', "admin/settings/autopilot_svn/delete/{$repo['svid']}"),
+        l($checkout_action, "admin/settings/autopilot_svn/{$checkout_action}/{$repo['svid']}")
+        );
+    }
+    $output .= theme_table($header, $rows);
   }
-  print(theme('page', $output));
+  print (theme('page', $output));
 }
 
 function autopilot_svn_admin_edit($svid = 0) {
   if ($svid != 0) {
     $repo = autopilot_svn_get_repo($svid);
     return autopilot_svn_admin_form($repo);
-  } else {
+  }
+  else {
     return autopilot_svn_admin_form();
   }
 }
+
 function autopilot_svn_admin_form($repo = NULL) {
   $form = array();
   $form['#base'] = 'autopilot_svn_admin_form';
   if ($repo['svid'] != 0) {
     $form['svid'] = array('#type' => 'hidden',
-			 '#value' => $repo['svid']);
+      '#value' => $repo['svid']);
   }
   $form['islocal'] = array('#type' => 'hidden',
-			   '#value' => $repo['islocal'] ? $repo['islocal'] : 'false');
-
+    '#value' => $repo['islocal'] ? $repo['islocal'] : 'false');
+  
   $form['info'] = array('#type' => 'fieldset',
-			'#title' => 'Repository Information',
-			'#collapsible' => FALSE,
-			'#collapsed' => FALSE
-			);
+    '#title' => 'Repository Information',
+    '#collapsible' => FALSE,
+    '#collapsed' => FALSE
+    );
   $form['info']['name'] = array('#type' => 'textfield',
-				'#title' => t('Repository Name'),
-				'#size' => 50,
-				'#default_value' => $repo['name'],
-				'#description' => t('The 'friendly name' of this repository.')
-				);
+    '#title' => t('Repository Name'),
+    '#size' => 50,
+    '#default_value' => $repo['name'],
+    '#description' => t('The 'friendlyname' of this repository.')
+    );
   $form['pathinfo'] = array('#type' => 'fieldset',
-			    '#title' => t('Path Information'),
-			    '#collapsible' => FALSE,
-			    '#collapsed' => FALSE,
-			    );
+    '#title' => t('Path Information'),
+    '#collapsible' => FALSE,
+    '#collapsed' => FALSE,
+  );
   $form['pathinfo']['path'] = array('#type' => 'textfield',
-				    '#title' => t('Repository Path'),
-				    '#size' => 50,
-				    '#default_value' => $repo['path'],
-				    '#description' => t('The subversion repository path.  This can be anything you would normally specify in a 'svn co' from the command line.')
-				    );
+    '#title' => t('Repository Path'),
+    '#size' => 50,
+    '#default_value' => $repo['path'],
+    '#description' => t('The subversion repository path.  This can be anything you would normally specify in a 'svnco' from the command line.')
+    );
   $form['pathinfo']['local_path'] = array('#type' => 'textfield',
-					  '#title' => t('Local Path'),
-					  '#size' => 50,
-					  '#required' => FALSE,
-					  '#default_value' => $repo['local_path'],
-					  '#description' => t('(optional) Where to place the local repository. If this field is left blank, a directory will be created in /tmp/drupal_svn/')
-					  );
+    '#title' => t('Local Path'),
+    '#size' => 50,
+    '#required' => FALSE,
+    '#default_value' => $repo['local_path'],
+    '#description' => t('(optional) Where to place the local repository. If this field is left blank, a directory will be created in /tmp/drupal_svn/')
+    );
   $form['advanced'] = array('#type' => 'fieldset',
-			    '#title' => t('Advanced Options'),
-			    '#collapsible' => TRUE,
-			    '#collapsed' => TRUE
-			    );
+    '#title' => t('Advanced Options'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE
+    );
   $form['advanced']['username'] = array('#type' => 'textfield',
-					'#title' => t('User Name'),
-					'#required' => FALSE,
-					'#default_value' => $repo['username'],
-					'#description' => t('If this subversion server requires a username, enter it here.')
-					);
+    '#title' => t('User Name'),
+    '#required' => FALSE,
+    '#default_value' => $repo['username'],
+    '#description' => t('If this subversion server requires a username, enter it here.')
+    );
   $form['advanced']['password'] = array('#type' => 'password',
-					'#title' => t('Password'),
-					'#required' => FALSE,
-					'#default_value' => $repo['password'],
-					'#description' => t('If this subversion server requires a password, enter it here.')
-					);
+    '#title' => t('Password'),
+    '#required' => FALSE,
+    '#default_value' => $repo['password'],
+    '#description' => t('If this subversion server requires a password, enter it here.')
+    );
   $form['submit'] = array('#type' => 'submit',
-			  '#value' => 'Save');
+    '#value' => 'Save');
   return $form;
 }
 
@@ -440,109 +442,113 @@ function autopilot_svn_admin_form_submit
     // create a directory in /tmp
     //
     mkdir('/tmp/drupal_svn');
-    $tmpdir = '/tmp/drupal_svn/svn.' . md5(uniqid(rand(), true));
-    $message = t("Creating directory for repository '" . db_escape_string($form_values['name']) . "': {$tmpdir}");
+    $tmpdir = '/tmp/drupal_svn/svn.'. md5(uniqid(rand(), true));
+    $message = t("Creating directory for repository '". db_escape_string($form_values['name']) ."': {$tmpdir}");
     drupal_set_message($message);
     watchdog('info', $message);
     $form_values['local_path'] = $tmpdir;
     mkdir($tmpdir);
-  } else if (file_exists($normalized_path)) {
+  }
+  else if (file_exists($normalized_path)) {
     watchdog('warning', t("Local path {$normalized_path} already exists."));
-  } else {
+  }
+  else {
     mkdir($normalized_path);
   }
   autopilot_svn_save_repo($form_values);
-
+  
   drupal_set_message(t("Repository {$form_values['name']} saved."));
   return 'admin/settings/autopilot_svn/list';
 }
 
 function autopilot_svn_save_repo($repo) {
-  $query = 'INSERT INTO {autopilot_svn_repositories} (name, path, local_path, username, password, created_date, islocal) VALUES('%s','%s','%s','%s','%s', now(), %s)';
+  $query = 'INSERT INTO {autopilot_svn_repositories} (name, path, local_path, username, password, created_date, islocal) VALUES(' % s',' % s',' % s',' % s',' % s', now(), %s)';
   $args = array(db_escape_string($repo['name']),
-                db_escape_string($repo['path']),
-                db_escape_string($repo['local_path']),
-                db_escape_string($repo['username']),
-                db_escape_string($repo['password']),
-                db_escape_string($repo['islocal']));
+    db_escape_string($repo['path']),
+    db_escape_string($repo['local_path']),
+    db_escape_string($repo['username']),
+    db_escape_string($repo['password']),
+    db_escape_string($repo['islocal']));
   if (isset($repo['svid'])) {
-    $query = "UPDATE {autopilot_svn_repositories} SET name='%s', path='%s', local_path='%s', username='%s', password='%s',islocal=%s WHERE svid=%s";      
+    $query = "UPDATE {autopilot_svn_repositories} SET name='%s', path='%s', local_path='%s', username='%s', password='%s',islocal=%s WHERE svid=%s";
     $args[] = db_escape_string($repo['svid']);
   }
-  db_query($query, $args);  
+  db_query($query, $args);
 }
 
 function _autopilot_svn_save_revision($repo, $log) {
   $revision_query = "INSERT INTO {autopilot_svn_revisions} (svid, revision_number, owner, revision_message, revision_date, islocal) VALUES(%s, %s, '%s', '%s', '%s', %s)";
-  db_query($revision_query, 
-           db_escape_string($repo['svid']),
-           db_escape_string($log['revision']), 
-           db_escape_string($log['owner']),
-           db_escape_string(trim($log['message'])),
-           db_escape_string($log['date']),
-           "false"
-           );
+  db_query($revision_query,
+    db_escape_string($repo['svid']),
+    db_escape_string($log['revision']),
+    db_escape_string($log['owner']),
+    db_escape_string(trim($log['message'])),
+    db_escape_string($log['date']),
+    "false"
+    );
   db_query($query);
   foreach ($log['paths'] as $path => $action) {
     $paths_query = "INSERT INTO {autopilot_svn_revisions_paths} (revision_number, path, action, svid) VALUES(%s, '%s', '%s', '%s')";
     db_query($paths_query,
-             db_escape_string($log['revision']),
-             db_escape_string($path),
-             db_escape_string($action),
-             db_escape_string($repo['svid']));
-  }	   
+      db_escape_string($log['revision']),
+      db_escape_string($path),
+      db_escape_string($action),
+      db_escape_string($repo['svid']));
+  }
 }
 
 function _autopilot_svn_parse_output($output) {
   $result_lines = explode("\n", $output);
   $results = array();
-  foreach($result_lines as $line) {
+  foreach ($result_lines as $line) {
     $split_results = explode(': ', $line, 2);
     $results[strtolower(str_replace(' ', '_', $split_results[0]))] = $split_results[1];
   }
   return $results;
 }
- 
+
 function _autopilot_svn_parse_log_output($output) {
-  $result_lines = explode("\n", $output);
-  $parse_first = true;
-  $results = array();
-  $parse_paths = false;
+  $result_lines  = explode("\n", $output);
+  $parse_first   = true;
+  $results       = array();
+  $parse_paths   = false;
   $parse_message = false;
   foreach ($result_lines as $line) {
     if ($parse_first) {
       $elements = explode(' | ', $line);
       $keys = array('revision', 'owner', 'date', 'size');
       for ($i = 0; $i < count($keys); $i++) {
-	$results[$keys[$i]] = $elements[$i];
+        $results[$keys[$i]] = $elements[$i];
       }
       $parse_first = false;
       continue;
     }
     if ($parse_paths) {
       if ($parse_message) {
-	$line = trim($line);
-	if ($line != '') {
-	  $results['message'] .= trim($line) . "\n";
-	}
-	continue;
+        $line = trim($line);
+        if ($line != '') {
+          $results['message'] .= trim($line) ."\n";
+        }
+        continue;
       }
       if (trim($line) == '') {
-	$parse_message = true;
-	$results['message'] = '';
-	continue;
+        $parse_message = true;
+        $results['message'] = '';
+        continue;
       }
     }
     if ($line == 'Changed paths:') {
       $parse_paths = true;
       $results['paths'] = array();
       continue;
-    } else {
+    }
+    else {
       $path = explode(' ', trim($line), 2);
       $results['paths'][$path[1]] = $path[0];
     }
   }
   $results['revision'] = str_replace('r', '', $results['revision']);
   return $results;
-}   
-?>
+}
+
+
