### Eclipse Workspace Patch 1.0
#P drupal-contrib-5
Index: modules/google_analytics/googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v
retrieving revision 1.14.2.10
diff -u -r1.14.2.10 googleanalytics.module
--- modules/google_analytics/googleanalytics.module	20 Aug 2007 21:32:03 -0000	1.14.2.10
+++ modules/google_analytics/googleanalytics.module	21 Aug 2007 18:52:36 -0000
@@ -8,7 +8,6 @@
  * @author: Mike Carter <www.ixis.co.uk/contact>
  */
 
-
 function googleanalytics_help($section) {
   switch ($section) {
     case 'admin/settings/googleanalytics':
@@ -16,7 +15,6 @@
   }
 }
 
-
 function googleanalytics_menu($maycache) {
   $items = array();
   if ($maycache) {
@@ -33,7 +31,6 @@
   return $items;
 }
 
-
 /**
  * Implementation of hook_footer()  to insert Javascript at the end of the page
  */
@@ -44,130 +41,133 @@
 
   // Check if we should track the currently active user's role
   $track = TRUE;
-  foreach(array_keys($user->roles) as $role) {
-    if (variable_get("googleanalytics_track_". $role, FALSE)) {
+  foreach (array_keys($user->roles) as $role) {
+    if (variable_get('googleanalytics_track_'. $role, FALSE)) {
       $track = FALSE;
     }
   }
 
-  if ($user->uid == 1 and variable_get("googleanalytics_track__user1", FALSE)) {
+  if ($user->uid == 1 and variable_get('googleanalytics_track__user1', FALSE)) {
     $track = FALSE;
   }
 
   // Don't track page views in the admin sections
-  if($id && (arg(0) != 'admin') && $track == TRUE) {
+  if ($id && (arg(0) != 'admin') && $track == TRUE) {
 
     $prefix = '://www';
 
     // Are we on a secure page?
-    if(isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
+    if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
       $prefix = 's://ssl';
     }
 
     // Add User profile segmentation values
-    if(is_array($profile_fields = variable_get('googleanalytics_segmentation', '')) && ($user->uid > 0)) {
+    if (is_array($profile_fields = variable_get('googleanalytics_segmentation', '')) && ($user->uid > 0)) {
 
       $p = module_invoke('profile', 'load_profile', $user);
 
       $fields = array();
-      foreach($profile_fields as $field => $title) {
+      foreach ($profile_fields as $field => $title) {
         $value = $user->$field;
-
-        if(is_array($value)) {
+        if (is_array($value)) {
           $value = implode(',', $value);
         }
-
         $fields[$field] = utf8_encode($value);
       }
 
       // Only show segmentation variable if there are specified fields
-      if(count($fields) > 0) {
-        $segmentation = "__utmSetVar('".implode(':', $fields)."');";
+      if (count($fields) > 0) {
+        $segmentation = "__utmSetVar('". implode(':', $fields) ."');";
       }
-		}
+    }
 
-		// Add any custom code snippets if specified
-		$codesnippet = variable_get('googleanalytics_codesnippet', '');
+    // Add any custom code snippets if specified
+    $codesnippet = variable_get('googleanalytics_codesnippet', '');
 
-    $script = '<script type="text/javascript" src="http' . $prefix . ".google-analytics.com/urchin.js\"></script>\n";
-    $script .= '<script type="text/javascript">' . "\n_uacct = \"".$id."\";urchinTracker();{$segmentation}{$codesnippet}\n</script>\n";
+    $script = '<script type="text/javascript" src="http'. $prefix .".google-analytics.com/urchin.js\"></script>\n";
+    $script .= '<script type="text/javascript">' . "\n_uacct = \"". $id ."\";urchinTracker();{$segmentation}{$codesnippet}\n</script>\n";
     return $script;
   }
 }
 
-
 /**
  * Implementation of hook_admin_settings() for configuring the module
  */
 function googleanalytics_admin_settings() {
   $form['account'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Analytics Account Settings'),
-        '#collapsible' => FALSE,
-      );
+    '#type' => 'fieldset',
+    '#title' => t('Analytics Account Settings'),
+    '#collapsible' => FALSE
+  );
 
   $form['account']['googleanalytics_account'] = array(
-      '#type' => 'textfield',
-      '#title' => t('User ID'),
-      '#default_value' => variable_get('googleanalytics_account','UA-'),
-      '#size' => 15,
-      '#maxlength' => 20,
-      '#required' => TRUE,
-      '#description' => t('The user account is unique to the websites domain. You can obtain a user account from the <a href="@url">Google Analytics</a> website.', array('@url' => 'http://www.google.com/analytics/'))    );
+    '#type' => 'textfield',
+    '#title' => t('User ID'),
+    '#default_value' => variable_get('googleanalytics_account', 'UA-'),
+    '#size' => 15,
+    '#maxlength' => 20,
+    '#required' => TRUE,
+    '#description' => t('The user account is unique to the websites domain. You can obtain a user account from the <a href="@url">Google Analytics</a> website.', array('@url' => 'http://www.google.com/analytics/'))
+  );
 
-   // Render the role overview.
+  // Render the role overview.
   $result = db_query('SELECT * FROM {role} ORDER BY name');
 
   $form['roles'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('User Role Tracking'),
-        '#collapsible' => TRUE,
-        '#description' => t('Define what user roles should not be tracked by Google Analytics.')
+    '#type' => 'fieldset',
+    '#title' => t('User Role Tracking'),
+    '#collapsible' => TRUE,
+    '#description' => t('Define what user roles should not be tracked by Google Analytics.')
   );
 
-  $form['roles']["googleanalytics_track__user1"] = array(
+  $form['roles']['googleanalytics_track__user1'] = array(
     '#type' => 'checkbox',
-    '#title' => t("Admin (user 1)"),
-    '#default_value' => variable_get("googleanalytics_track__user1", TRUE),
-	);
+    '#title' => t('Admin (user 1)'),
+    '#default_value' => variable_get('googleanalytics_track__user1', TRUE)
+  );
 
   while ($role = db_fetch_object($result)) {
-     // can't use empty spaces in varname
+    // can't use empty spaces in varname
     $role_varname = $string = str_replace(' ', '_', $role->name);
-    $form['roles']["googleanalytics_track_". $role->rid] = array(
-       '#type' => 'checkbox',
-       '#title' => t($role->name),
-       '#default_value' => variable_get("googleanalytics_track_". $role->rid, FALSE),
+    $form['roles']['googleanalytics_track_'. $role->rid] = array(
+      '#type' => 'checkbox',
+      '#title' => t($role->name),
+      '#default_value' => variable_get('googleanalytics_track_'. $role->rid, FALSE)
     );
   }
 
   $form['segmentation'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('User Segmentation'),
-        '#collapsible' => TRUE,
-        '#description' => t('If your users have profile fields completed, you can track your logged in users based on a defined profile field.')
+    '#type' => 'fieldset',
+    '#title' => t('User Segmentation'),
+    '#collapsible' => TRUE,
+    '#description' => t('If your users have profile fields completed, you can track your logged in users based on a defined profile field.')
   );
 
-  if(!module_exists('profile')) {
+  if (!module_exists('profile')) {
     $form['segmentation']['profile'] = array(
       '#type' => 'markup',
-      '#value' => t('You need to activate the !profile to use this feature.', array('!profile' => l(t('Profile module'), 'admin/build/modules')) ),
+      '#value' => t('You need to activate the !profile to use this feature.', array('!profile' => l(t('Profile module'), 'admin/build/modules'))),
       '#prefix' => '<p>',
       '#suffix' => '</p>'
-      );
-  } else {
+    );
+  }
+  else {
     // Compile a list of fields to show.
-    $fields = array('uid' => t('User ID'), 'name' => t('Username'), 'roles' => t('User Roles'));
+    $fields = array(
+      'uid' => t('User ID'),
+      'name' => t('Username'),
+      'roles' => t('User Roles')
+    );
     $result = db_query('SELECT name, title, type, weight FROM {profile_fields} ORDER BY weight');
     while ($record = db_fetch_object($result)) {
       $fields[$record->name] = $record->title;
     }
 
-    $form['segmentation']["googleanalytics_segmentation"] = array(
+    $form['segmentation']['googleanalytics_segmentation'] = array(
       '#type' => 'select',
       '#title' => t('Track'),
       '#description' => t('Selecting one or more values allows you to track users by profile values rather than simply an IP address. To select multiple items, hold down CTRL whilst selecting fields.'),
-      '#default_value' => variable_get("googleanalytics_segmentation", ''),
+      '#default_value' => variable_get('googleanalytics_segmentation', ''),
       '#options' => $fields,
       '#size' => 10,
       '#multiple' => TRUE
@@ -175,18 +175,19 @@
   }
 
   $form['advanced'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Advanced'),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-        '#description' => t('You can add custom Google Analytic code here.')
+    '#type' => 'fieldset',
+    '#title' => t('Advanced'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('You can add custom Google Analytic code here.')
   );
   $form['advanced']['googleanalytics_codesnippet'] = array(
-      '#type' => 'textarea',
-      '#title' => t('JavaScript Code'),
-      '#default_value' => variable_get('googleanalytics_codesnippet',''),
-      '#rows' => 15,
-      '#description' => t('Paste <a href="@snippets">custom code snippets here</a>. These will be added to every page that Google Analytics appears on. For help with this feature see the <a href="@blog">cutroni.com blog</a>. <strong>Do not include the &lt;script&gt; tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/39282', '@blog' => 'http://cutroni.com/blog/') )   );
+    '#type' => 'textarea',
+    '#title' => t('JavaScript Code'),
+    '#default_value' => variable_get('googleanalytics_codesnippet', ''),
+    '#rows' => 15,
+    '#description' => t('Paste <a href="@snippets">custom code snippets here</a>. These will be added to every page that Google Analytics appears on. For help with this feature see the <a href="@blog">cutroni.com blog</a>. <strong>Do not include the &lt;script&gt; tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/39282', '@blog' => 'http://cutroni.com/blog/'))
+  );
 
   return system_settings_form($form);
 }
@@ -204,7 +205,7 @@
         'title' => t('Google Analytics module'),
         'description' => t('Google Analytics module has not been configured yet. Please configure its settings from the <a href="@url">Google Analytics settings page</a>.', array('@url' => url('admin/settings/googleanalytics'))),
         'severity' => REQUIREMENT_ERROR,
-        'value' => t('Not configured'),
+        'value' => t('Not configured')
       );
     }
   }
Index: modules/google_analytics/googleanalytics.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.install,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 googleanalytics.install
--- modules/google_analytics/googleanalytics.install	20 Aug 2007 21:11:37 -0000	1.2.2.2
+++ modules/google_analytics/googleanalytics.install	21 Aug 2007 18:52:36 -0000
@@ -5,10 +5,10 @@
   $result = db_query('SELECT * FROM {role} ORDER BY name');
 
   while ($role = db_fetch_object($result)) {
-    $ga_role = "googleanalytics_track_".  $role->rid;
+    $ga_role = 'googleanalytics_track_'. $role->rid;
 
-    //check if variable is not already set from a previous install
-    if(strpos(variable_get($ga_role, 'new'), 'new') !== FALSE) {
+    // check if variable is not already set from a previous install
+    if (strpos(variable_get($ga_role, 'new'), 'new') !== FALSE) {
       variable_set($ga_role, FALSE);
       drupal_set_message(t('Role %rolename is now being tracked by Google Analytics', array('%rolename' => $role->name)));
     }
@@ -21,6 +21,7 @@
   variable_del('googleanalytics_account');
   variable_del('googleanalytics_codesnippet');
   variable_del('googleanalytics_segmentation');
+  variable_del('googleanalytics_track__user1');
 }
 
 
@@ -30,11 +31,11 @@
   $result = db_query("SELECT * FROM {role}");
   while ($role = db_fetch_object($result)) {
     // can't use empty spaces in varname
-    $role_varname = str_replace(" ", "_", $role->name);
-    variable_set("googleanalytics_track_".  $role->rid,   !variable_get("googleanalytics_track_{$role_varname}", FALSE));
+    $role_varname = str_replace(' ', '_', $role->name);
+    variable_set('googleanalytics_track_'. $role->rid, !variable_get("googleanalytics_track_{$role_varname}", FALSE));
     variable_del("googleanalytics_track_{$role_varname}");
   }
-  variable_set("googleanalytics_track__user1", TRUE);
+  variable_set('googleanalytics_track__user1', TRUE);
 
   return $ret;
 }
\ No newline at end of file
