### Eclipse Workspace Patch 1.0
#P drupal-contrib-cvs
Index: modules/gotwo/gotwo.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gotwo/gotwo.module,v
retrieving revision 1.7
diff -u -r1.7 gotwo.module
--- modules/gotwo/gotwo.module	5 May 2007 13:51:40 -0000	1.7
+++ modules/gotwo/gotwo.module	10 Jun 2007 10:55:43 -0000
@@ -25,6 +25,7 @@
       break;
     case 'admin/help#gotwo':
       $output = gotwo_filter_tips(0, '', true);
+      break;
   }
 
   return $output;
@@ -118,13 +119,13 @@
   $src = implode("/", $args);
 
   // $src may be an Go ID or a source attribute
-  $res = db_fetch_object(db_query("SELECT * FROM {gotwo} WHERE src = '%s' OR gid = '%d'", $src, intval($src)));
+  $res = db_fetch_object(db_query("SELECT * FROM {gotwo} WHERE src = '%s' OR gid = %d", $src, intval($src)));
 
   if (!$res) {
     drupal_not_found();
   }
   else {
-    db_query(db_rewrite_sql("UPDATE {gotwo} SET cnt = cnt+1 WHERE gid = '%d'", $res->gid));
+    db_query("UPDATE {gotwo} SET cnt = cnt+1 WHERE gid = %d", $res->gid);
     if (variable_get('gotwo_disclaimer_boolean',FALSE)) {
     	//Display the Disclaimer
 	$disclaimer_text = variable_get('gotwo_disclaimer_text','');
@@ -173,10 +174,16 @@
   if (preg_match_all('#\s*([^=]*)\s*=\s*("([^"]*)")|(\'([^\']*)\')\s*#', $args, $_args)) {
     $lst = array();
     for ($i = 0; $i < count($_args[1]); $i++) {
-      if (!empty($_args[3][$i])) $lst[$_args[1][$i]] = $_args[3][$i];
-      else if (!empty($_args[5][$i])) $lst[$_args[1][$i]] = $_args[5][$i];
+      if (!empty($_args[3][$i])) { 
+        $lst[$_args[1][$i]] = $_args[3][$i];
+      }
+      elseif (!empty($_args[5][$i])) {
+        $lst[$_args[1][$i]] = $_args[5][$i];
+      }
+    }
+    if (isset($lst['href'])) {
+      $lst['href'] = gotwo_get_url($lst['href'], isset($lst['title'])?$lst['title']:false);
     }
-    if (isset($lst['href'])) $lst['href'] = gotwo_get_url($lst['href'], isset($lst['title'])?$lst['title']:false);
     $args = "";
     foreach ($lst as $key => $value) {
       $args .= $key.'="'.htmlspecialchars($value).'" ';
@@ -190,7 +197,9 @@
  */
 function gotwo_get_url($url, $src=false, $flags=gotwo_CREATE) {
   $res = gotwo_get($url, $src, $flags);
-  if (!$res) return url($url);
+  if (!$res) {
+    return url($url);
+  }
   if (variable_get('gotwo_numeric', false)) return url('go/'.$res->gid);
   return url('go/'.$res->src);
 }
@@ -198,19 +207,23 @@
 /**
  * Return the GO object url for a given link
  */
-function gotwo_get($url, $src=false, $flags=gotwo_CREATE) {
-  if (!$src) $src = preg_replace('#^(http(s)?://)#', '', $url);
+function gotwo_get($url, $src = false, $flags = gotwo_CREATE) {
+  if (!$src) {
+    $src = preg_replace('#^(http(s)?://)#', '', $url);
+  }
   $src = __gotwo_mangle_src($src);
 
   $maxlength = min(variable_get('gotwo_max_length', 128), 128);
 
   $res = db_fetch_object(db_query("SELECT * FROM {gotwo} WHERE src = '%s' AND dst = '%s'", $src, $url));
-  if ($res === false) {
+  if (!$res) {
     $res = db_fetch_object(db_query("SELECT * FROM {gotwo} WHERE src = gid+'/%s' AND dst = '%s'", $src, $url));
     $src_alt = substr($res->gid.'/'.$src, 0, $maxlength);
-    if ($src_alt != $res->src) $res == false;
+    if ($src_alt != $res->src) {
+      $res == false;
+    }
   }
-  if ($res === false) {
+  if (!$res) {
     if ($flags & gotwo_CREATE) {
       // force unique src
       $gid = db_next_id('gotwo_gid');
@@ -225,7 +238,7 @@
       $res->gid = $gid;
       $res->dst = $url;
       $res->cnt = 0;
-      db_query("INSERT INTO {gotwo} (gid, src, dst) VALUES ('%d', '%s', '%s')", $res->gid, $res->src, $res->dst);
+      db_query("INSERT INTO {gotwo} (gid, src, dst) VALUES (%d, '%s', '%s')", $res->gid, $res->src, $res->dst);
     }
     else {
       return false;
@@ -393,7 +406,7 @@
  * Reset a counter
  */
 function __gotwo_reset($gid) {
-  db_query("UPDATE {gotwo} SET cnt = 0 WHERE gid = '%d'", $gid);
+  db_query("UPDATE {gotwo} SET cnt = 0 WHERE gid = %d", $gid);
   drupal_goto('admin/build/gotwo');
 }
 
@@ -413,7 +426,7 @@
   $res = db_fetch_object(db_query('SELECT * FROM {gotwo} WHERE gid = %d', $gid));
   $form['gid'] = array('#type' => 'value', '#value' => $gid);
   return confirm_form( $form,
-    t('Are you sure you want to remove the go entry with the label %label ?', array('%label' => theme('placeholder', $res->src))), 
+    t('Are you sure you want to remove the go entry with the label %label ?', array('%label' => $res->src)), 
     'admin/build/gotwo', t('This action cannot be undone. The link will become broken, a new one might be automatically created when a node linking to it is edited.'),
     t('Delete'), t('Cancel'));
 }
