Index: ad.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ad/ad.module,v
retrieving revision 1.2.2.29.2.83.2.1
diff -u -p -r1.2.2.29.2.83.2.1 ad.module
--- ad.module	11 Aug 2008 21:15:26 -0000	1.2.2.29.2.83.2.1
+++ ad.module	30 Oct 2008 03:09:57 -0000
@@ -2,7 +2,7 @@
 // $Id: ad.module,v 1.2.2.29.2.83.2.1 2008/08/11 21:15:26 jeremy Exp $
 
 /* TODO Implement the hook_theme registry. Combine all theme registry entries
-   into one hook_theme function in each corresponding module file.
+   into one hook_theme function in each corresponding module file.*/
 function ad_theme() {
   return array(
     'ad_display' => array(
@@ -57,8 +57,8 @@ function ad_theme() {
       ),
     ),
   );
-}; */
-
+};
+  /**/
 
 /* TODO You may want to take advantage of new form-specific alter hooks.
    The hook_form_alter(&$form, &$form_state, $form_id) is complemented by hook_form_$form-id_alter().
@@ -97,7 +97,7 @@ function ad($group = FALSE, $quantity = 
     _ad_check_install();
     $adserve = variable_get('adserve', '');
     $adserveinc = variable_get('adserveinc', '');
-  }
+  } 
   if (!file_exists($adserve) || !file_exists($adserveinc)) {
     drupal_set_message(t('Ads cannot be displayed.  The ad module is <a href="@misconfigured">misconfigured</a>, failed to locate the required <em>serve.php</em> ond/or <em>adserve.inc</em> file.', array('@misconfigured' => url('admin/content/ad/configure'))), 'error');
     _ad_check_install();
@@ -121,26 +121,21 @@ function ad($group = FALSE, $quantity = 
       break;
     case 'iframe':
     case 'jquery':
-      $display_variables = 'm=' . $options['ad_display'];
+      $query['m'] = $options['ad_display'];
       // Fall through...
     case 'javascript':
     default:
-      if ($display_variables) {
-        $display_variables .= "&amp;q=$quantity";
-      }
-      else {
-        $display_variables = "q=$quantity";
-      }
+      $query['q'] = $quantity;
       if ($hostid = $options['hostid']) {
-        $display_variables .= "&amp;k=$hostid";
+        $query['k'] = $hostid;
       }
       // Allow external cache files to define additional display variables.
       if ($options['cache'] != 'none') {
-        $display_variables .= '&amp;c='. $options['cache'];
+        $query['c'] =  $options['cache'];
         $cache_variables = module_invoke('ad_cache_'. $options['cache'], 'adcacheapi', 'display_variables', array());
         if (is_array($cache_variables)) {
           foreach ($cache_variables as $key => $value) {
-            $display_variables .= "&amp;$key=$value";
+            $query[$key] = $value;
           }
         }
       }
@@ -148,25 +143,25 @@ function ad($group = FALSE, $quantity = 
       $type_variables = module_invoke_all('adapi', 'display_variables', array());
       if (is_array($type_variables)) {
         foreach ($type_variables as $key => $value) {
-          $display_variables .= "&amp;$key=$value";
+          $query[$key] = $value;
         }
       }
       if ($nids = $options['nids']) {
         // Choose ads from the provided list of node Id's.
-        $display_variables .= "&amp;n=$nids";
+        $query['n'] = $nids;
         $group = "nids-$nids";
       }
       else if ($tids = $options['tids']) {
         // Choose ads from the provided list of taxonomy terms.
-        $display_variables .= "&amp;t=$tids";
+        $query['t'] = $tids;
         $group = "tids-$tids";
       }
       else {
         // Choose ads from the specified group.
-        $display_variables .= "&amp;t=$group";
+        $query['t'] = $group;
         $options['tids'] = $group;
       }
-      $src = url("$base_url/$adserve?$display_variables");
+      $src = url("$base_url/$adserve", array('query' => $query));
       if ($options['ad_display'] == 'iframe') {
         // TODO: We need to know the IFrame size before it is displayed.  This
         // limits the flexibility of what can be displayed in these frames.
@@ -223,7 +218,10 @@ function theme_ad_display($group, $displ
 /**
  * Update click counter then redirect host to ad's target URL.
  */
-function ad_redirect($aid, $group = NULL, $hostid = NULL) {
+function ad_redirect() {
+  $aid = arg(2);
+  $group = arg(3);
+  $hostid = arg(4);
   global $user;
   if (function_exists('click_filter_status')) {
     $status = click_filter_status($aid, $hostid);
@@ -1168,7 +1166,9 @@ function ad_adapi($op, $node = NULL) {
       break;
   }
 }
-
+function ad_id_load($arg) {
+  return is_numeric($arg);
+}
 /**
  * Implementation of hook_menu().
  */
@@ -1252,7 +1252,7 @@ function ad_menu() {
       $settings = 'ad_no_global_settings';
     }
     $items['admin/content/ad/configure/'. $adtype] = array(
-      'title' => '!adtype ads', array('!adtype' => drupal_ucfirst($adtype)),
+      'title' => t('!adtype ads', array('!adtype' => drupal_ucfirst($adtype))),
       'page callback' => 'drupal_get_form',
       'page arguments' => array($settings),
       'access arguments' => array('administer advertisements'),
@@ -1265,7 +1265,13 @@ function ad_menu() {
      'access arguments' => array('create advertisements'),
     );
   }
-
+  
+  
+  $items["ad/redirect"] = array(
+    'access arguments' => array('show advertisements'),
+    'type' => MENU_CALLBACK, 
+    'page callback' => 'ad_redirect',
+  );/**
   // callbacks
   if (arg(0) == 'ad' && arg(1) == 'redirect' && is_numeric(arg(2))) {
     $aid = preg_replace('/[^0-9]/', '', arg(2));
@@ -1275,7 +1281,8 @@ function ad_menu() {
       'access arguments' => array('show advertisements'),
       'type' => MENU_CALLBACK, 
       'page callback' => 'ad_redirect',
-      'page arguments' => array($aid, $group, $hostid));
+      'page arguments' => array($aid, $group, $hostid)
+    );
   }
   elseif (arg(2) == 'ad' && arg(3) == 'groups' && is_numeric(arg(4))) {
     if ($term = taxonomy_get_term(arg(4))) {
@@ -1349,7 +1356,7 @@ function ad_menu() {
       'type' => MENU_CALLBACK
     );
   }
-
+/**/
   return $items;
 }
 
