### Eclipse Workspace Patch 1.0
#P contributions
Index: modules/vote_up_down/vote_storylink.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vote_storylink.module,v
retrieving revision 1.25
diff -u -r1.25 vote_storylink.module
--- modules/vote_up_down/vote_storylink.module	3 Apr 2007 15:37:26 -0000	1.25
+++ modules/vote_up_down/vote_storylink.module	7 Apr 2007 18:10:51 -0000
@@ -89,6 +89,20 @@
       'access' => user_access('create storylinks'),
       'type' => MENU_DYNAMIC_ITEM
     );
+      $items[] = array(
+      'path' => 'storylinkexternal',
+      'title' => t('story link external'),
+      'callback' => 'vote_storylink_external',
+      'access' => user_access('access content'),
+      'type' => MENU_CALLBACK
+    );
+      $items[] = array(
+      'path' => 'storylinkexternalvote',
+      'title' => t('story link external vote'),
+      'callback' => 'vote_storylink_externalvote',
+      'access' => user_access('access content'),
+      'type' => MENU_CALLBACK
+    );
   }
 
   return $items;
@@ -576,3 +590,80 @@
   // Wrap $link as the [0] element of a trivial outer array.
   $node->vote_storylink = array($link);
 }
+
+function vote_storylink_external(){
+  global $base_url;
+  if(isset($_GET['source'])){
+    $story_url = check_url($_GET['source']);
+    $lid_arr = links_get_link($story_url);
+    $lid = $lid_arr['lid'];
+    if(isset($lid) && $lid > 0){
+      $nid = db_result(db_query("SELECT nid FROM {links_node} WHERE lid = %d", $lid));
+      $vote_result = votingapi_get_voting_result('node', $nid, 'points', variable_get('vote_up_down_tag', 'vote'), 'sum');
+      $path = $base_url.'/'.drupal_get_path_alias('node/' . $nid);
+      $attrib = array("target" => "_top");
+      $output = l(theme('vote_storylink_remote_box',$vote_result->value),$path,$attrib,NULL,NULL,TRUE,TRUE);
+      $output .= theme('vote_storylink_remote_box_plus',$story_url);
+    }else{
+      if(isset($_GET['title'])){
+        $title = check_plain($_GET['title']);
+      }
+      $attrib = array("target" => "_top");
+      $path = $base_url.'/node/add/storylink?edit[url]='.$story_url.'&edit[title]='.$_GET['title'];
+      $output = l(theme('vote_storylink_remote_box_add'),$path,$attrib,NULL,NULL,TRUE,TRUE);
+    }
+  }else{
+  	$attrib = array("target" => "_top");
+    $output = l(theme('vote_storylink_remote_box_add'),$base_url,$attrib,NULL,NULL,TRUE,TRUE);
+  }
+  print $output;
+}
+
+function vote_storylink_externalvote(){
+  global $base_url;
+  global $user;
+  if($user->uid > 0){
+  	if(isset($_GET['source'])){
+	  $story_url = check_url($_GET['source']);
+	  $lid_arr = links_get_link($story_url);
+	  $lid = $lid_arr['lid'];
+	  if(isset($lid) && $lid > 0){
+	    $nid = db_result(db_query("SELECT nid FROM {links_node} WHERE lid = %d", $lid));
+	    $vote = new stdClass();
+	    /* change the next line according to your settings -> value_type standard is 'percent'  */
+	    $vote->value = 1; $vote->value_type = 'points'; $vote->tag = 'vote';
+	    votingapi_set_vote('node', $nid, $vote);
+	    drupal_set_message(t('Thank you for voting'));
+	    drupal_goto('node/' . $nid);
+	  }else{
+		drupal_set_message(t('The requested page could not be found'),'error');
+	  }
+	}else{
+	  drupal_set_message(t('The requested page could not be found'),'error');
+    }
+  }else{
+  	drupal_goto('user/login');
+  }
+}
+
+function theme_vote_storylink_remote_box($value){
+  if($value == NULL){$value = 0;}
+  $output = '<div style="padding:0px; margin: 0px; height:65px; width: 60px; background-color: yellow; text-align:center;">';
+  $output .= '<div style="font-family: Georgia, Times New Roman, Times, serif; font-size: 22px; font-weight: bold; padding-top:10px;">';
+  $output .= $value.'</div><br />';
+  $output .= '</div>';
+  return $output;
+}
+function theme_vote_storylink_remote_box_plus($story_url){
+  global $base_url;
+  $output .= '<div style="font-family: Georgia, Times New Roman, Times, serif; font-size: 10px; font-weight: bold; margin-top:5px; background-color:grey;height:20px; width: 60px;text-align:center;">';
+  $output .= '<a href='.$base_url.'/storylinkexternalvote?source='.$story_url.'" target="_top">vote +</a></div>';
+  return $output;
+}
+
+
+function theme_vote_storylink_remote_box_add(){
+  $output = '<div style="padding:0px; margin: 0px; height:65px; width: 62px;background-color: yellow; text-align:center;">';
+  $output .= 'add this article</div>';
+  return $output;
+}
