### Eclipse Workspace Patch 1.0 #P ubercart Index: uc_order/uc_order.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_order/uc_order.admin.inc,v retrieving revision 1.10 diff -u -r1.10 uc_order.admin.inc --- uc_order/uc_order.admin.inc 12 Mar 2010 13:53:46 -0000 1.10 +++ uc_order/uc_order.admin.inc 15 Mar 2010 04:36:19 -0000 @@ -96,13 +96,14 @@ ), '#default_value' => variable_get('uc_cust_view_order_invoices', TRUE), ); + $default = drupal_get_path('module', 'uc_order') .'/templates/customer.itpl.php'; $form['customer']['uc_cust_order_invoice_template'] = array( '#type' => 'select', '#title' => t('On-site invoice template'), '#description' => t('Select the invoice template to use when invoices are viewed on the site.
This is separate from the template used to e-mail invoices to customers which is configured through Conditional actions.', array('!url' => url(CA_UI_PATH))), '#options' => uc_order_template_options(), - '#summary' => t('You are using the %template order invoice template.', array('%template' => variable_get('uc_cust_order_invoice_template', 'customer'))), - '#default_value' => variable_get('uc_cust_order_invoice_template', 'customer'), + '#summary' => t('You are using the %template order invoice template.', array('%template' => variable_get('uc_cust_order_invoice_template', $default))), + '#default_value' => variable_get('uc_cust_order_invoice_template', $default), ); return system_settings_form($form); @@ -1182,7 +1183,8 @@ } if ($view == 'invoice') { - $output = uc_order_load_invoice($order, 'print', variable_get('uc_cust_order_invoice_template', 'customer')); + $default = drupal_get_path('module', 'uc_order') .'/templates/customer.itpl.php'; + $output = uc_order_load_invoice($order, 'print', variable_get('uc_cust_order_invoice_template', $default)); $output .= '
' .'
'; print $output; @@ -1821,7 +1823,8 @@ * Display an invoice in the browser, convert it to PDF, or e-mail it as HTML. */ function uc_order_invoice($order, $op = 'view') { - $output = uc_order_load_invoice($order, $op, variable_get('uc_cust_order_invoice_template', 'customer')); + $default = drupal_get_path('module', 'uc_order') .'/templates/customer.itpl.php'; + $output = uc_order_load_invoice($order, $op, variable_get('uc_cust_order_invoice_template', $default)); if ($op == 'print') { print $output; Index: uc_order/uc_order.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_order/uc_order.module,v retrieving revision 1.23 diff -u -r1.23 uc_order.module --- uc_order/uc_order.module 10 Mar 2010 14:02:21 -0000 1.23 +++ uc_order/uc_order.module 15 Mar 2010 04:36:20 -0000 @@ -541,7 +541,8 @@ $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed'; $message['subject'] = t('Your Order Invoice', array(), $langcode); $message['from'] = uc_store_email_from(); - $message['body'][] = uc_order_load_invoice($params['order'], 'admin-mail', variable_get('uc_cust_order_invoice_template', 'customer')); + $default = drupal_get_path('module', 'uc_order') .'/templates/customer.itpl.php'; + $message['body'][] = uc_order_load_invoice($params['order'], 'admin-mail', variable_get('uc_cust_order_invoice_template', $default)); break; // Setup a custom e-mail defined by an action on a predicate. @@ -1634,16 +1635,21 @@ /** * Load a formatted invoice with an order's data. */ -function uc_order_load_invoice($order, $op = 'view', $template = 'customer') { +function uc_order_load_invoice($order, $op = 'view', $template = NULL) { static $invoice; + if ($template == NULL) { + $template = drupal_get_path('module', 'uc_order') .'/templates/customer.itl.php'; + } + if (isset($invoice[$order->order_id][$template])) { return $invoice[$order->order_id][$template]; } $thank_you_message = FALSE; - $file = drupal_get_path('module', 'uc_order') .'/templates/'. $template .'.itpl.php'; + $file = $template; + if (file_exists($file)) { switch ($op) { case 'checkout-mail': @@ -1708,13 +1714,18 @@ // If the template list hasn't already been loaded... if (empty($templates)) { - // Get the path to the templates directory. - $dir = drupal_get_path('module', 'uc_order') .'/templates'; + $dirs = array( + path_to_theme(), + drupal_get_path('module', 'uc_order') .'/templates', + ); + + foreach ($dirs as $dir) { // Loop through all the files found in the directory. - foreach (file_scan_directory($dir, '/.*\.itpl\.php/', array('recurse' => FALSE)) as $file) { - // Add them by name to the templates array, trimming off the extension. - $templates[] = substr($file->name, 0, strlen($file->name) - 5); + foreach (file_scan_directory($dir, '.*\.itpl\.php', array('.', '..', 'CVS'), 0, FALSE) as $file) { + // Add them by name to the templates array + $templates[] = $file->filename; + } } // Sort the template names alphabetically.