? .DS_Store
? .buildpath
? .project
? .settings
Index: uc_cart/uc_cart.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_cart/uc_cart.module,v
retrieving revision 1.15.2.25
diff -u -p -r1.15.2.25 uc_cart.module
--- uc_cart/uc_cart.module	21 Jul 2009 14:51:20 -0000	1.15.2.25
+++ uc_cart/uc_cart.module	11 Aug 2009 23:18:15 -0000
@@ -1265,22 +1265,23 @@ function uc_cart_complete_sale($order, $
                       FALSE) .'</p>';
 
   $output_message = token_replace_multiple($output, array('global' => NULL, 'order' => $order));
-  $themed_output = theme('uc_cart_complete_sale', $output_message);
-
+  
   // Move an order's status from "In Checkout" to "Pending"
   $status = db_result(db_query("SELECT order_status FROM {uc_orders} WHERE order_id = %d", $order->order_id));
   if (uc_order_status_data($status, 'state') == 'in_checkout') {
     uc_order_update_status($order->order_id, uc_order_state_default('post_checkout'));
   }
 
+  ca_pull_trigger('uc_checkout_complete', $order, $user->uid == 0 ? $account : $user);
+
+  $themed_output = theme('uc_cart_complete_sale', $output_message);
+
   // Empty that cart...
   uc_cart_empty(uc_cart_get_id());
 
   // Clear our the session variables used to force the cart workflow.
   unset($_SESSION['cart_order'], $_SESSION['do_complete'], $_SESSION['new_user']);
-
-  ca_pull_trigger('uc_checkout_complete', $order, $user->uid == 0 ? $account : $user);
-
+  
   return $themed_output;
 }
 
Index: uc_file/uc_file.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_file/uc_file.module,v
retrieving revision 1.2.2.18
diff -u -p -r1.2.2.18 uc_file.module
--- uc_file/uc_file.module	21 Jul 2009 14:37:18 -0000	1.2.2.18
+++ uc_file/uc_file.module	11 Aug 2009 23:18:15 -0000
@@ -57,6 +57,7 @@ function uc_file_menu() {
     'access arguments' => array('administer product features'),
     'type' => MENU_CALLBACK,
   );
+
   $items['admin/store/products/files'] = array(
     'title' => 'View file downloads',
     'description' => 'View all file download features on products.',
@@ -116,17 +117,17 @@ function uc_file_theme() {
   return array(
     'uc_file_downloads_token' => array(
       'arguments' => array('file_downloads' => NULL),
-    ),
+  ),
     'uc_file_admin_files_form_show' => array(
       'arguments' => array('form' => NULL),
       'file' => 'uc_file.admin.inc',
-    ),
+  ),
     'uc_file_hook_user_file' => array(
       'arguments' => array('form' => NULL),
-    ),
+  ),
     'uc_file_hook_user_file_downloads' => array(
       'arguments' => array('form' => NULL),
-    ),
+  ),
   );
 }
 
@@ -166,8 +167,8 @@ function uc_file_user_form(&$account, $c
     $form['file']['file_message'] = array(
       '#value' => t(
         'You must add files at the !url in order to attach them to a user.',
-        array('!url' => l(t('Ubercart file download administration page'), 'admin/store/products/files', array('query' => 'destination=user/'. $account->uid .'/edit')))
-      ),
+    array('!url' => l(t('Ubercart file download administration page'), 'admin/store/products/files', array('query' => 'destination=user/'. $account->uid .'/edit')))
+    ),
     );
 
     return $form;
@@ -211,13 +212,13 @@ function uc_file_user_form(&$account, $c
         '#options' => array(
           '+' => '+',
           '-' => '-',
-        ),
-      ),
+    ),
+    ),
       'time_quantity' => array(
         '#type' => 'textfield',
         '#size' => 2,
         '#maxlength' => 2,
-      ),
+    ),
       'time_granularity' => array(
         '#type' => 'select',
         '#default_value' => 'day',
@@ -227,8 +228,8 @@ function uc_file_user_form(&$account, $c
           'week' => t('week(s)'),
           'month' => t('month(s)'),
           'year' => t('year(s)'),
-        ),
-      ),
+    ),
+    ),
 
       'downloads_in' => array('#value' => $file_download->accessed),
       'download_limit' => array(
@@ -236,7 +237,7 @@ function uc_file_user_form(&$account, $c
         '#maxlength' => 3,
         '#size' => 3,
         '#default_value' => $file_download->download_limit ? $file_download->download_limit : NULL
-      ),
+    ),
 
       'addresses_in' => array('#value' => count(unserialize($file_download->addresses))),
       'address_limit' => array(
@@ -244,7 +245,7 @@ function uc_file_user_form(&$account, $c
         '#maxlength' => 2,
         '#size' => 2,
         '#default_value' => $file_download->address_limit ? $file_download->address_limit : NULL
-      ),
+    ),
     );
 
     // Incrementally add behaviors.
@@ -328,6 +329,8 @@ function uc_file_user_validate(&$edit) {
  */
 function uc_file_user_submit(&$edit, &$account) {
 
+  dpm("uc_file_user_submit triggered");
+  
   // Check out if any downloads were modified.
   foreach ((array)$edit['file_download'] as $fid => $download_modification) {
 
@@ -344,8 +347,8 @@ function uc_file_user_submit(&$edit, &$a
 
       // Don't touch anything if everything's the same.
       if ($download_modification['download_limit'] == $download_modification['download_limit_old'] &&
-          $download_modification['address_limit' ] == $download_modification['address_limit_old' ] &&
-          $download_modification['expiration'    ] == $download_modification['expiration_old'    ]) {
+      $download_modification['address_limit' ] == $download_modification['address_limit_old' ] &&
+      $download_modification['expiration'    ] == $download_modification['expiration_old'    ]) {
         continue;
       }
 
@@ -395,7 +398,7 @@ function uc_file_user_view(&$account) {
       'user_items' => array(
         '#type' => 'user_profile_item',
         '#value' => l(t('Click here to view your file downloads.'), 'user/'. $account->uid .'/purchased-files'),
-      ),
+  ),
   );
 
   $account->content['uc_file_download'] = $item;
@@ -454,11 +457,11 @@ Drupal.behaviors.ucUserAccountFileDownlo
 function theme_uc_file_hook_user_file_downloads($form) {
 
   $header = array(
-    array('data' => t('Remove'    )),
-    array('data' => t('Filename'  )),
-    array('data' => t('Expiration')),
-    array('data' => t('Downloads' )),
-    array('data' => t('Addresses' )),
+  array('data' => t('Remove'    )),
+  array('data' => t('Filename'  )),
+  array('data' => t('Expiration')),
+  array('data' => t('Downloads' )),
+  array('data' => t('Addresses' )),
   );
 
   foreach ($form['file_download'] as $key => $data) {
@@ -471,35 +474,35 @@ function theme_uc_file_hook_user_file_do
 
     $rows[] = array(
       'data' => array(
-        array('data' => drupal_render($file_download['remove'])),
+    array('data' => drupal_render($file_download['remove'])),
 
-        array('data' => drupal_render($file_download['filename'])),
+    array('data' => drupal_render($file_download['filename'])),
 
-        array(
+    array(
           'data' =>
-            drupal_render($file_download['expires']) .' <br />'.
+    drupal_render($file_download['expires']) .' <br />'.
 
             '<div class="duration">'.
-              drupal_render($file_download['time_polarity']) .
-              drupal_render($file_download['time_quantity']) .
-              drupal_render($file_download['time_granularity']) .
+    drupal_render($file_download['time_polarity']) .
+    drupal_render($file_download['time_quantity']) .
+    drupal_render($file_download['time_granularity']) .
             '</div>',
-        ),
+    ),
 
-        array(
+    array(
           'data' =>
             '<div class="download-table-index">'.
-              drupal_render($file_download['downloads_in']) .'/'. drupal_render($file_download['download_limit']) .
+    drupal_render($file_download['downloads_in']) .'/'. drupal_render($file_download['download_limit']) .
             '</div>',
-        ),
+    ),
 
-        array(
+    array(
           'data' =>
             '<div class="download-table-index">'.
-              drupal_render($file_download['addresses_in']) .'/'. drupal_render($file_download['address_limit']) .
+    drupal_render($file_download['addresses_in']) .'/'. drupal_render($file_download['address_limit']) .
             '</div>',
-        ),
-      ),
+    ),
+    ),
       'class' => 'download-table-row',
     );
   }
@@ -580,12 +583,12 @@ function uc_file_add_to_cart($nid, $qty,
       _uc_file_accumulate_limits($file_user, $file_modification, FALSE);
 
       drupal_set_message(t('You already have privileges to download %file. If you complete the purchase of this item, your new download limit will be %download_limit, your access location limit will be %address_limit, and your new expiration time will be %expiration.',
-        array(
+      array(
           '%file' => $product_feature->filename,
           '%download_limit' => $file_user['download_limit'] ? $file_user['download_limit'] : t('unlimited'),
           '%address_limit'  => $file_user['address_limit' ] ? $file_user['address_limit' ] : t('unlimited'),
           '%expiration'     => $file_user['expiration'    ] ? format_date($file_user['expiration'], 'small') : t('never'),
-        )
+      )
       ));
     }
   }
@@ -735,8 +738,8 @@ function uc_file_feature_form($form_stat
     $form['file']['file_message'] = array(
       '#value' => t(
         'You must add files at the !url in order to attach them to a model.',
-        array('!url' => l(t('Ubercart file download administration page'), 'admin/store/products/files', array('query' => 'destination=node/'. $node->nid .'/edit/features/file/add')))
-      ),
+    array('!url' => l(t('Ubercart file download administration page'), 'admin/store/products/files', array('query' => 'destination=node/'. $node->nid .'/edit/features/file/add')))
+    ),
     );
     return $form;
   }
@@ -874,7 +877,7 @@ function uc_file_feature_form($form_stat
       'week' => t('week(s)'),
       'month' => t('month(s)'),
       'year' => t('year(s)')
-    ),
+  ),
     '#description' => t('How long after this product has been purchased until this file download expires.'),
     '#prefix' => '<div class="duration">',
     '#suffix' => '</div>',
@@ -897,16 +900,16 @@ function uc_file_feature_form_validate($
 
   // If any of our overrides are set, then we make sure they make sense.
   if ($form_state['values']['download_override'] &&
-      $form_state['values']['download_limit_number'] < 0) {
+  $form_state['values']['download_limit_number'] < 0) {
     form_set_error('download_limit_number', t('A negative download limit does not make sense. Please enter a positive integer, or leave empty for no limit.'));
   }
   if ($form_state['values']['location_override'] &&
-      $form_state['values']['download_limit_addresses'] < 0) {
+  $form_state['values']['download_limit_addresses'] < 0) {
     form_set_error('download_limit_addresses', t('A negative IP address limit does not make sense. Please enter a positive integer, or leave empty for no limit.'));
   }
   if ($form_state['values']['time_override'] &&
-      $form_state['values']['download_limit_duration_granularity'] != 'never' &&
-      $form_state['values']['download_limit_duration_qty'] < 1) {
+  $form_state['values']['download_limit_duration_granularity'] != 'never' &&
+  $form_state['values']['download_limit_duration_qty'] < 1) {
     form_set_error('download_limit_duration_qty', t('You set the granularity (%gran), but you did not set how many. Please enter a positive non-zero integer.', array('%gran' => $form_state['values']['download_limit_duration_granularity'] .'(s)')));
   }
 }
@@ -927,7 +930,7 @@ function uc_file_feature_form_submit($fo
     'description' => $form_state['values']['uc_file_description'],
     'shippable'   => $form_state['values']['uc_file_shippable'],
 
-    // Local limitations... set them if there's an override.
+  // Local limitations... set them if there's an override.
     'download_limit'   => $form_state['values']['download_override'] ? $form_state['values']['download_limit_number'              ] : UC_FILE_LIMIT_SENTINEL,
     'address_limit'    => $form_state['values']['location_override'] ? $form_state['values']['download_limit_addresses'           ] : UC_FILE_LIMIT_SENTINEL,
     'time_granularity' => $form_state['values']['time_override'    ] ? $form_state['values']['download_limit_duration_granularity'] : UC_FILE_LIMIT_SENTINEL,
@@ -1041,12 +1044,33 @@ function uc_file_feature_settings() {
       'week' => t('week(s)'),
       'month' => t('month(s)'),
       'year' => t('year(s)')
-    ),
+  ),
     '#default_value' => variable_get('uc_file_download_limit_duration_granularity', 'never'),
     '#description' => t('How long after a product has been purchased until its file download expires.'),
     '#prefix' => '<div class="duration">',
     '#suffix' => '</div>',
   );
+
+  $form['access_denied'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Access Denied Settings'),
+    '#collapsible' => true,
+    '#collapsed' => false,
+  );
+
+  $form['access_denied']['uc_file_access_denied_message'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Access Denied Message'),
+    '#description' => t('Users will see this message when they attempt to download a file that do not have access to.'),
+    '#default_value' => variable_get('uc_file_access_denied_message', ''),
+  );
+  $form['access_denied']['uc_file_access_denied_redirect'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Access Denied Redirect URL'),
+    '#description' => t('Optional URL to redirect to when a user doesn\'t have access to download a file.'),
+    '#default_value' => variable_get('uc_file_access_denied_redirect', ''),
+  );
+
   return $form;
 }
 
@@ -1063,7 +1087,7 @@ function uc_file_feature_settings_valida
 
   // If the user selected a granularity, let's make sure they also selected a duration.
   if ($form_state['values']['uc_file_download_limit_duration_granularity'] != 'never' &&
-      $form_state['values']['uc_file_download_limit_duration_qty'] < 1) {
+  $form_state['values']['uc_file_download_limit_duration_qty'] < 1) {
     form_set_error('uc_file_download_limit_duration_qty', t('You set the granularity (%gran), but you did not set how many. Please enter a positive non-zero integer.', array('%gran' => $form_state['values']['uc_file_download_limit_duration_granularity'] .'(s)')));
   }
 
@@ -1083,6 +1107,9 @@ function uc_file_feature_settings_valida
  * @see uc_file_feature_settings()
  */
 function uc_file_feature_settings_submit($form, &$form_state) {
+  variable_set('uc_file_access_denied_message', $form_state['values']['uc_file_access_denied_message']);
+  variable_set('uc_file_access_denied_redirect', $form_state['values']['uc_file_access_denied_redirect']);
+
   // No directory now; truncate the file list.
   if (empty($form_state['values']['uc_file_base_dir'])) {
     uc_file_empty();
@@ -1425,14 +1452,14 @@ function _uc_file_get_dir_file_ids($fids
       continue;
     }
 
-   $base_name = $base->filename . (is_dir(uc_file_qualify_file($base->filename)) ? '%' : '');
-   $files = db_query("SELECT * FROM {uc_files} WHERE filename LIKE '%s'", $base_name);
+    $base_name = $base->filename . (is_dir(uc_file_qualify_file($base->filename)) ? '%' : '');
+    $files = db_query("SELECT * FROM {uc_files} WHERE filename LIKE '%s'", $base_name);
 
     // PHP str_replace() can't replace only n matches, so we use regex. First
     // we escape our file slashes, though.
     // ...using str_replace()
-   $base_name = str_replace("\\", "\\\\", $base_name);
-   $base_name = str_replace("/", "\/", $base_name);
+    $base_name = str_replace("\\", "\\\\", $base_name);
+    $base_name = str_replace("/", "\/", $base_name);
 
     while ($file = db_fetch_object($files)) {
 
@@ -1695,7 +1722,7 @@ function uc_file_user_renew($fid, $user,
 
     // Doesn't exist yet?
     $key = NULL;
-    if ($file_user === FALSE) {
+    if (!$file_user) {
       $file_user = array(
         'granted' => time(),
         'accessed' => 0,
@@ -1744,7 +1771,10 @@ function uc_file_user_renew($fid, $user,
  */
 function _uc_file_user_get($user, $fid) {
   $file_user = db_fetch_object(db_query("SELECT * FROM {uc_file_users} WHERE uid = %d AND fid = %d", $user->uid, $fid));
-  $file_user->addresses = unserialize($file_user->addresses);
+
+  if ($file_user) {
+    $file_user->addresses = unserialize($file_user->addresses);
+  }
 
   return $file_user;
 }
Index: uc_file/uc_file.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_file/Attic/uc_file.pages.inc,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 uc_file.pages.inc
--- uc_file/uc_file.pages.inc	21 Jul 2009 14:37:18 -0000	1.1.2.10
+++ uc_file/uc_file.pages.inc	11 Aug 2009 23:18:15 -0000
@@ -37,22 +37,22 @@ function uc_file_user_downloads($account
 
   // Create a header and the pager it belongs to.
   $header = array(
-    array('data' => t('Purchased'  ), 'field' => 'u.granted', 'sort' => 'asc'),
-    array('data' => t('Filename'   ), 'field' => 'f.filename'),
-    array('data' => t('Description'), 'field' => 'p.description'),
-    array('data' => t('Downloads'  ), 'field' => 'u.accessed'),
-    array('data' => t('Addresses'  )),
+  array('data' => t('Purchased'  ), 'field' => 'u.granted', 'sort' => 'asc'),
+  array('data' => t('Filename'   ), 'field' => 'f.filename'),
+  array('data' => t('Description'), 'field' => 'p.description'),
+  array('data' => t('Downloads'  ), 'field' => 'u.accessed'),
+  array('data' => t('Addresses'  )),
   );
 
   $files = pager_query(
     "SELECT u.granted, f.filename, u.accessed, u.addresses, p.description, u.file_key, f.fid, u.download_limit, u.address_limit, u.expiration FROM {uc_file_users} as u ".
     "LEFT JOIN {uc_files} as f ON u.fid = f.fid ".
     "LEFT JOIN {uc_file_products} as p ON p.pfid = u.pfid WHERE uid = %d".
-    tablesort_sql($header),
-    UC_FILE_PAGER_SIZE,
-    0,
+  tablesort_sql($header),
+  UC_FILE_PAGER_SIZE,
+  0,
     "SELECT COUNT(*) FROM {uc_file_users} WHERE uid = %d",
-    $account->uid
+  $account->uid
   );
 
   $rows = array();
@@ -65,7 +65,7 @@ function uc_file_user_downloads($account
     $onclick = array(
       'attributes' => array(
         'onclick' => 'uc_file_update_download('. $row .', '. $file->accessed .', '. ((empty($download_limit)) ? -1 : $download_limit) .');', 'id' => 'link-'. $row
-      ),
+    ),
     );
 
     // Expiration set to 'never'
@@ -84,11 +84,11 @@ function uc_file_user_downloads($account
     }
 
     $rows[] = array(
-      array('data' => format_date($file->granted, 'custom', variable_get('uc_date_format_default', 'm/d/Y')), 'class' => 'date-row', 'id' => 'date-'. $row),
-      array('data' => $file_link, 'class' => 'filename-row', 'id' => 'filename-'. $row),
-      array('data' => $file->description, 'class' => 'description-row', 'id' => 'description-'. $row),
-      array('data' => $file->accessed .'/'. ($file->download_limit ? $file->download_limit : t('Unlimited')), 'class' => 'download-row', 'id' => 'download-'. $row),
-      array('data' => count(unserialize($file->addresses)) .'/'. ($file->address_limit ? $file->address_limit : t('Unlimited')), 'class' => 'addresses-row', 'id' => 'addresses-'. $row),
+    array('data' => format_date($file->granted, 'custom', variable_get('uc_date_format_default', 'm/d/Y')), 'class' => 'date-row', 'id' => 'date-'. $row),
+    array('data' => $file_link, 'class' => 'filename-row', 'id' => 'filename-'. $row),
+    array('data' => $file->description, 'class' => 'description-row', 'id' => 'description-'. $row),
+    array('data' => $file->accessed .'/'. ($file->download_limit ? $file->download_limit : t('Unlimited')), 'class' => 'download-row', 'id' => 'download-'. $row),
+    array('data' => count(unserialize($file->addresses)) .'/'. ($file->address_limit ? $file->address_limit : t('Unlimited')), 'class' => 'addresses-row', 'id' => 'addresses-'. $row),
     );
   }
   if (empty($rows)) {
@@ -122,15 +122,17 @@ function _uc_file_download($fid, $key) {
   // Error messages for various failed download states.
   $admin_message = t('Please contact the site administrator if this message has been received in error.');
   $error_messages = array(
-    UC_FILE_ERROR_NOT_A_FILE              => t('The file you requested does not exist. '),
-    UC_FILE_ERROR_TOO_MANY_BOGUS_REQUESTS => t('You have attempted to download an incorrect file URL too many times. '),
-    UC_FILE_ERROR_INVALID_DOWNLOAD        => t("The following URL is not a valid download link. "),
-    UC_FILE_ERROR_TOO_MANY_LOCATIONS      => t('You have downloaded this file from too many different locations. '),
-    UC_FILE_ERROR_TOO_MANY_DOWNLOADS      => t('You have reached the download limit for this file. '),
-    UC_FILE_ERROR_EXPIRED                 => t("This file download has expired. "),
-    UC_FILE_ERROR_HOOK_ERROR              => t("A hook denied your access to this file. "),
+  UC_FILE_ERROR_NOT_A_FILE              => t('The file you requested does not exist. '),
+  UC_FILE_ERROR_TOO_MANY_BOGUS_REQUESTS => t('You have attempted to download an incorrect file URL too many times. '),
+  UC_FILE_ERROR_INVALID_DOWNLOAD        => t("The following URL is not a valid download link. "),
+  UC_FILE_ERROR_TOO_MANY_LOCATIONS      => t('You have downloaded this file from too many different locations. '),
+  UC_FILE_ERROR_TOO_MANY_DOWNLOADS      => t('You have reached the download limit for this file. '),
+  UC_FILE_ERROR_EXPIRED                 => t("This file download has expired. "),
+  UC_FILE_ERROR_HOOK_ERROR              => t("A hook denied your access to this file. "),
   );
 
+  $custom_message = variable_get('uc_file_access_denied_message', '');
+
   $ip = ip_address();
   $file_download = uc_file_get_by_key($key);
 
@@ -142,9 +144,14 @@ function _uc_file_download($fid, $key) {
     _uc_file_download_transfer($file_download, $ip);
   }
 
-  // Some error state came back, so report it.
   else {
-    drupal_set_message($error_messages[$status] . $admin_message, 'error');
+    // Some error state came back, so report it.
+    if (!empty($custom_message)) {
+      drupal_set_message($custom_message, 'error');
+    }
+    else {
+      drupal_set_message($error_messages[$status] . $admin_message, 'error');
+    }
   }
 
   // Kick 'em to the curb. >:)
@@ -334,7 +341,8 @@ function _uc_file_log_download($file_use
   if (!in_array($ip, $addresses)) {
     $addresses[] = $ip;
   }
-  $file_user->addresses = serialize($addresses);
+  //$file_user->addresses = serialize($addresses);
+  $file_user->addresses = $addresses;
 
   // Accessed again.
   $file_user->accessed++;
@@ -350,11 +358,18 @@ function _uc_file_log_download($file_use
  */
 function _uc_file_download_redirect($uid = NULL) {
 
-  // Shoo away anonymous users.
-  if ($uid == 0) {
+  $custom_redirect = variable_get('uc_file_access_denied_redirect', '');
+
+  // First, if a custom redirect has been set, use that.
+  if ($custom_redirect)
+  {
+    drupal_goto($custom_redirect);
+  }
+  // Secondly, if no custom redirect is set, just deny access to anonymous users.  They don't have a "purchased files" page.
+  else if ($uid == 0) {
     drupal_access_denied();
   }
-  // Redirect users back to their file page.
+  // Lastly, if no redirect and the user is logged in, redirec them to to their file page.
   else {
     drupal_goto('user/'. $uid .'/purchased-files');
   }
