Index: service_links.module
===================================================================
--- service_links.module	(revision 108)
+++ service_links.module	(working copy)
@@ -164,6 +164,25 @@
     '#default_value' => variable_get('service_links_show_icerocket', 0),
   );
 
+  $form['tiny_urls'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Tiny URL integration'),
+  );
+  $form['tiny_urls']['service_links_tinyurl_all'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Create Tiny URLs for <strong>ALL</strong> service link submissions'),
+    '#description' => t('Note: this makes an HTTP request to tinyurl.com for each set of service links displayed'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('service_links_tinyurl_all', 0),
+  );
+  $form['tiny_urls']['service_links_tinyurl_twitter'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Create Tiny URLs for all Twitter submissions'),
+    '#description' => t('Note: this makes an HTTP request to tinyurl.com for each set of service links displayed'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('service_links_tinyurl_twitter', 0),
+  );
+  
   $form['how_to_show_the_links'] = array(
     '#type' => 'fieldset',
     '#title' => t('When and how to show the links'),
@@ -364,79 +383,91 @@
   $url = urlencode($url);
   $title = urlencode($node->title);
   $summary = urlencode(strip_tags($node->teaser));
+  
+  if (variable_get('service_links_tinyurl_all', 0)) {
+    $turl = drupal_http_request('http://tinyurl.com/api-create.php?url='. $url);
+    if ($turl->result == 200 && $turl->data) {
+      $url = $turl->data;
+    }
+  }
 
   if (variable_get('service_links_show_delicious', 0)) {
-    $links['service_links_delicious'] = theme('service_links_build_link', t('Delicious'), "http://del.icio.us/post?url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png', $nodelink);
+    $links['service_links_delicious'] = theme('service_links_build_link', t('Delicious'), "http://del.icio.us/post", "url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png', $nodelink);
   }
   if (variable_get('service_links_show_digg', 0)) {
-    $links['service_links_digg'] = theme('service_links_build_link', t('Digg'), "http://digg.com/submit?phase=2&url=$url&title=$title", t('Digg this post on digg.com.'), 'digg.png', $nodelink);
+    $links['service_links_digg'] = theme('service_links_build_link', t('Digg'), "http://digg.com/submit", "phase=2&url=$url&title=$title", t('Digg this post on digg.com.'), 'digg.png', $nodelink);
   }
   if (variable_get('service_links_show_stumbleupon', 0)) {
-    $links['service_links_stumbleupon'] = theme('service_links_build_link', t('StumbleUpon'), "http://www.stumbleupon.com/submit?url=$url&title=$title", t('Thumb this up at StumbleUpon.'), 'stumbleit.png', $nodelink);
+    $links['service_links_stumbleupon'] = theme('service_links_build_link', t('StumbleUpon'), "http://www.stumbleupon.com/submit", "url=$url&title=$title", t('Thumb this up at StumbleUpon.'), 'stumbleit.png', $nodelink);
   }
   if (variable_get('service_links_show_propeller', 0)) {
-    $links['service_links_propeller'] = theme('service_links_build_link', t('Propeller'), "http://www.propeller.com/submit/?U=$url&T=$title", t('Submit to Propeller.'), 'propeller.png', $nodelink);
+    $links['service_links_propeller'] = theme('service_links_build_link', t('Propeller'), "http://www.propeller.com/submit/", "U=$url&T=$title", t('Submit to Propeller.'), 'propeller.png', $nodelink);
   }
   if (variable_get('service_links_show_reddit', 0)) {
-    $links['service_links_reddit'] = theme('service_links_build_link', t('Reddit'), "http://reddit.com/submit?url=$url&title=$title", t('Submit this post on reddit.com.'), 'reddit.png', $nodelink);
+    $links['service_links_reddit'] = theme('service_links_build_link', t('Reddit'), "http://reddit.com/submit", "url=$url&title=$title", t('Submit this post on reddit.com.'), 'reddit.png', $nodelink);
   }
   if (variable_get('service_links_show_magnoliacom', 0)) {
-    $links['service_links_magnoliacom'] = theme('service_links_build_link', t('Magnoliacom'), "http://ma.gnolia.com/bookmarklet/add?url=$url&title=$title", t('Submit this post on ma.gnolia.com.'), 'magnoliacom.png', $nodelink);
+    $links['service_links_magnoliacom'] = theme('service_links_build_link', t('Magnoliacom'), "http://ma.gnolia.com/bookmarklet/add", "url=$url&title=$title", t('Submit this post on ma.gnolia.com.'), 'magnoliacom.png', $nodelink);
   }
   if (variable_get('service_links_show_newsvine', 0)) {
-    $links['service_links_newsvine'] = theme('service_links_build_link', t('Newsvine'), "http://www.newsvine.com/_tools/seed&save?u=$url&h=$title", t('Submit this post on newsvine.com.'), 'newsvine.png', $nodelink);
+    $links['service_links_newsvine'] = theme('service_links_build_link', t('Newsvine'), "http://www.newsvine.com/_tools/seed&save", "u=$url&h=$title", t('Submit this post on newsvine.com.'), 'newsvine.png', $nodelink);
   }
   if (variable_get('service_links_show_furl', 0)) {
-    $links['service_links_furl'] = theme('service_links_build_link', t('Furl'), "http://www.furl.net/storeIt.jsp?u=$url&t=$title", t('Submit this post on furl.net.'), 'furl.png', $nodelink);
+    $links['service_links_furl'] = theme('service_links_build_link', t('Furl'), "http://www.furl.net/storeIt.jsp", "u=$url&t=$title", t('Submit this post on furl.net.'), 'furl.png', $nodelink);
   }
   if (variable_get('service_links_show_facebook', 0)) {
-    $links['service_links_facebook'] = theme('service_links_build_link', t('Facebook'), "http://www.facebook.com/sharer.php?u=$url&t=$title", t('Share on Facebook.'), 'facebook.png', $nodelink);
+    $links['service_links_facebook'] = theme('service_links_build_link', t('Facebook'), "http://www.facebook.com/sharer.php", "u=$url&t=$title", t('Share on Facebook.'), 'facebook.png', $nodelink);
   }
   if (variable_get('service_links_show_myspace', 0)) {
-    $links['service_links_myspace'] = theme('service_links_build_link', t('MySpace'), "http://www.myspace.com/index.cfm?fuseaction=postto&t=$title&u=$url", t('Share on MySpace.'), 'myspace.png', $nodelink);
+    $links['service_links_myspace'] = theme('service_links_build_link', t('MySpace'), "http://www.myspace.com/index.cfm", "fuseaction=postto&t=$title&u=$url", t('Share on MySpace.'), 'myspace.png', $nodelink);
   }
   if (variable_get('service_links_show_twitter', 0)) {
-    $turl = drupal_http_request('http://tinyurl.com/api-create.php?url='. $url);
-    $url = isset($turl->data) ? $turl->data : urldecode($url);
-
-    $links['service_links_twitter'] = theme('service_links_build_link', t('Twitter'), "http://www.twitter.com/home/?status=$url". "+". $title, t('Share on Twitter.'), 'twitter.png', $nodelink);
+    $twitter_url = $url;
+    if (!variable_get('service_links_tinyurl_all', 0) && variable_get('service_links_tinyurl_twitter', 0)) {
+      $turl = drupal_http_request('http://tinyurl.com/api-create.php?url='. $url);
+      if ($turl->code == 200 && $turl->data) {
+        $twitter_url = $turl->data;
+      }
+    }
+    $links['service_links_twitter'] = theme('service_links_build_link', t('Twitter'), "http://twitter.com/home/", "status=$title+--+$twitter_url" , t('Share on Twitter.'), 'twitter.png', $nodelink);
   }
   if (variable_get('service_links_show_google', 0)) {
-    $links['service_links_google'] = theme('service_links_build_link', t('Google'), "http://www.google.com/bookmarks/mark?op=add&bkmk=$url&title=$title", t('Bookmark this post on Google.'), 'google.png', $nodelink);
+    $links['service_links_google'] = theme('service_links_build_link', t('Google'), "http://www.google.com/bookmarks/mark", "op=add&bkmk=$url&title=$title", t('Bookmark this post on Google.'), 'google.png', $nodelink);
   }
   if (variable_get('service_links_show_yahoo', 0)) {
-    $links['service_links_yahoo'] = theme('service_links_build_link', t('Yahoo'), "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=$url&t=$title", t('Bookmark this post on Yahoo.'), 'yahoo.png', $nodelink);
+    $links['service_links_yahoo'] = theme('service_links_build_link', t('Yahoo'), "http://bookmarks.yahoo.com/myresults/bookmarklet", "u=$url&t=$title", t('Bookmark this post on Yahoo.'), 'yahoo.png', $nodelink);
   }
   if (variable_get('service_links_show_buzz', 0)) {
-    $links['service_links_buzz'] = theme('service_links_build_link', t('Buzz Up!'), "http://buzz.yahoo.com/submit/?submitUrl=$url&submitHeadline=$title&submitSummary=$summary", t('Buzz up this post on Yahoo! Buzz.'), 'buzz.png', $nodelink);
+    $links['service_links_buzz'] = theme('service_links_build_link', t('Buzz Up!'), "http://buzz.yahoo.com/submit/", "submitUrl=$url&submitHeadline=$title&submitSummary=$summary", t('Buzz up this post on Yahoo! Buzz.'), 'buzz.png', $nodelink);
   }
   if (variable_get('service_links_show_linkedin', 0)) {
     $source = urlencode(variable_get('site_name', 'Drupal'));
-    $links['service_links_linkedin'] = theme('service_links_build_link', t('LinkedIn'), "http://www.linkedin.com/shareArticle?mini=true&url=$url&title=$title&summary=$summary&source=$source", t('Publish this to LinkedIn'), 'linkedin.png', $nodelink);
+    $links['service_links_linkedin'] = theme('service_links_build_link', t('LinkedIn'), "http://www.linkedin.com/shareArticle", "mini=true&url=$url&title=$title&summary=$summary&source=$source", t('Publish this to LinkedIn'), 'linkedin.png', $nodelink);
   }
   
   if (variable_get('service_links_show_technorati', 0)) {
-    $links['service_links_technorati'] = theme('service_links_build_link', t('Technorati'), "http://technorati.com/search/$url", t('Search Technorati for links to this post.'), 'technorati.png', $nodelink);
+    $links['service_links_technorati'] = theme('service_links_build_link', t('Technorati'), "http://technorati.com/search/$url", FALSE, t('Search Technorati for links to this post.'), 'technorati.png', $nodelink);
   }
   if (variable_get('service_links_show_icerocket', 0)) {
-    $links['service_links_icerocket'] = theme('service_links_build_link', t('Icerocket'), "http://blogs.icerocket.com/search?q=$url", t('Search IceRocket for links to this post.'), 'icerocket.png', $nodelink);
+    $links['service_links_icerocket'] = theme('service_links_build_link', t('Icerocket'), "http://blogs.icerocket.com/search", "q=$url", t('Search IceRocket for links to this post.'), 'icerocket.png', $nodelink);
   }
 
   // Add your own link by modifing the link below and uncomment it.
-  //$links['service_links_delicious'] = theme('service_links_build_link', t('Delicious'), "http://del.icio.us/post?url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png', $nodelink);
+  //$links['service_links_delicious'] = theme('service_links_build_link', t('Delicious'), "http://del.icio.us/post", "url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png', $nodelink);
 
   return $links;
 }
 
-function theme_service_links_build_link($text, $url, $title, $image, $nodelink) {
+function theme_service_links_build_link($text, $url, $query_string, $title, $image, $nodelink) {
   global $base_path;
 
   if ($nodelink) {
-    switch (variable_get('service_links_style', 1)) {
+    switch (variable_get('service_links_style', 1)) { 
       case 1:
         $link = array(
           'title' => $text,
           'href' => $url,
+          'query' => $query_string,
           'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank')
         );
         break;
@@ -444,6 +475,7 @@
         $link = array(
           'title' => '<img src="'. $base_path . drupal_get_path('module', 'service_links') .'/images/'. $image .'" alt="'. $text .'" />',
           'href' => $url,
+          'query' => $query_string,
           'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank'),
           'html' => TRUE
         );
@@ -452,6 +484,7 @@
         $link = array(
           'title' => '<img src="'. $base_path . drupal_get_path('module', 'service_links') .'/images/'. $image .'" alt="'. $text .'" /> '. $text,
           'href' => $url,
+          'query' => $query_string,
           'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank'),
           'html' => TRUE
         );
@@ -459,6 +492,9 @@
     }
   }
   else {
+    if ($query_string) {
+      $url = $url .'&'. $query_string;
+    }
     switch (variable_get('service_links_style', 1)) {
       case 1:
         $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow" target="_blank">'. $text .'</a>';
