CVS edit link for gregor7777

Hello,

My name is Greg Eisenman and I work for a company called Peter Glenn. We have developed two of our ecommerce sites (http://www.peterglenn.com) and (http://www.98main.com) using Drupal. We would like to contribute several of the modules we've developed for these sites back to the community.

The primary module we will contribute and maintain is an Ubercart customer service/ticketing module. This module tightly integrates with the Ubercart ordering system and Drupal contact form so that users can submit issues and have them tied to specific orders, which can then be viewed and modified in the admin order view and also the issue view forms.

We associate and display useful customer information with each ticket, such as number of orders, total volume of sales for that customer, last order date, etc.

We also have several contributions to existing ubercart related modules.

I am requesting a CVS account so that we may create a Drupal.org project for our ubercart issue module, and any other projects we create and would like to share.

Regards,

Greg Eisenman
Developer

CommentFileSizeAuthor
#3 uc_ticket.tar_.gz15.17 KBAnonymous (not verified)
#1 uc_ticket.tar_.gz15.76 KBAnonymous (not verified)

Comments

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new15.76 KB

code attached

thanks

avpaderno’s picture

Status: Needs review » Needs work
  1. 		'#default_value' => (arg(5) != '0') ? check_plain(arg(5)) : '',
    

    check_plain() is not used with values passed to the form API.

  2. Verify the line ending, which seems to be the one used by Windows, in some places.
  3. 	if (arg(4) == 'results') {
    		$email = strtolower(str_replace(' ', '%', check_plain(arg(5))));
        $title = strtolower(str_replace(' ', '%', check_plain(arg(6))));
    		$SQL = "SELECT * FROM {uc_ticket_tickets} WHERE (LOWER(title) LIKE '%%%s%' OR LOWER(email) LIKE '%s')";
    		$limit = 20;
    

    The code should use the Drupal Unicode functions, when possible. check_plain() is not used on values saved in the database; it should be used when the value is output on a page, if the value is not passed to the form API.

  4.     $links = l('VIEW', 'admin/store/ticket/' . $data->ticket_id);
        $links .= (user_access('delete tickets')) ? ' | ' . l('DELETE', 'admin/store/ticket/' . $data->ticket_id . '/delete') : '';
        $row[] = array('data' => $links, 'class' => 'username-cell');
    

    The first argument of l(), which is shown in the user interface, needs to be translatable.

  5. 	//results table
    	if (arg(4) == 'results') {
    		$email = strtolower(str_replace(' ', '%', check_plain(arg(5))));
        $title = strtolower(str_replace(' ', '%', check_plain(arg(6))));
    		$SQL = "SELECT * FROM {uc_ticket_tickets} WHERE (LOWER(title) LIKE '%%%s%' OR LOWER(email) LIKE '%s')";
    		$limit = 20;
    		$header = array(
    		array('data' => t('ID'), 'field' => 'ticket_id'),
    		array('data' => t('Subject')),
    		array('data' => t('Status'), 'field' => 'status'),
        array('data' => t('Category'), 'field' => 'category'),
        array('data' => t('Created'), 'field' => 'created'),
        array('data' => t('Updated'), 'field' => 'updated', 'sort' => 'asc'),
        array('data' => t('Functions')),
    	);
    	$tablesort = tablesort_sql($header);
    	$result = pager_query($SQL . $tablesort, $limit, 0, NULL, $title, $email);
    

    The indentation is not correct; it should be two spaces, not tab characters.

  6. function uc_ticket_search_form_submit($form, &$form_state) {
    
      $email = ($form_state['values']['email']) ? check_plain($form_state['values']['email']) : 0;
      $title = ($form_state['values']['title']) ? check_plain($form_state['values']['title']) : 0;
    
    	drupal_goto('admin/store/ticket/search/results/'. $email . '/' . $title);
    
    }
    

    Submission functions don't call drupal_goto().

  7.   $templates = uc_ticket_get_templates();
      $templates[0] = 'Please Select...';
      ksort($templates);
    
      $form['new_ticket']['template'] = array(
        '#type' => 'select',
        '#title' => t('Template'),
        '#default_value' => $templates[0],
        '#options' => $templates, 
      );
    

    The value contained in $templates[0] is not translatable.

  8.   $SQL = "SELECT uid FROM {uc_orders} WHERE order_id = %d LIMIT 1";
      $uid = db_result(db_query($SQL, $order_id));
    

    If you want to limit the result returned from the query, you should use db_query_range(), which allows the code to be compatible with all the database engines.

  9.   $form['description'] = array(
        '#value' => '<span>Are you sure you want to delete this ticket?</span>',
      );
    

    The string is not translatable.

  10.     drupal_set_message('Ticket ' . $ticket_id . ' deleted.');
    

    The string is not translatable.

  11.   $output .= '<div id="info_box"><fieldset><legend>Ticket Information</legend>';
      $output .= '<strong>Ticket ID:</strong> ' . $ticket_trail->ticket_id . '<br />';
      $output .= '<strong>Created On:</strong> ' . date('m/d/Y g:i A', $ticket_trail->created) . '<br />';
      $output .= '<strong>Last Update:</strong> ' . date('m/d/Y g:i A', $ticket_trail->updated) . '<br />';
      $output .= '<strong>Category:</strong> ' . uc_ticket_get_category_name($ticket_trail->category) . '<br />';
      $output .= '<strong>Status:</strong> ' . uc_ticket_get_status_name($ticket_trail->status) . '<br />';
      $output .= '<strong>Assigned To:</strong> ' . $assigned_to = ($ticket_trail->assigned_to) ? $ticket_trail->assigned_to : 'none' . '<br />';
      $output .= '<strong>Order:</strong> ' . $order_id = ($ticket_trail->order_id) ? l($ticket_trail->order_id, 'admin/store/orders/' . $ticket_trail->order_id) : 'none' . '<br />';
      $output .= '</fieldset>';
    

    The string contained in $output is not translatable; why doesn't the code use theme functions?

  12.   $output = '<div id="form_functions">';
      if (user_access('delete tickets')) {
        $output .= '<a href="' . base_path() . 'admin/store/ticket/' . $ticket->ticket_id . '/delete" title="Delete Ticket"><img src="/' . drupal_get_path('module', 'uc_ticket') . '/images/delete.png' . '" alt="Delete Ticket" /></a>';
      }
    

    Why isn't the code using url()?

  13.   drupal_set_message('Changes saved.');
    
    	if (!$rows) {
      	$rows[] = array(array('data' => 'There are no email accounts set up. ' . l('You can create them here', 'admin/store/settings/ticket/edit/email/add') . '.', 'colspan' => 5));
    	}
    

    Same error as reported before.

  14.   $form['protocol'] = array(
        '#type' => 'select',
        '#title' => t('Email Server Protocol'),
        '#default_value' => $form_state['storage']['protocol'],
        '#options' => array(
          'pop3' => t('POP3'),
          'imap' => t('IMAP'),
        ),
        '#description' => t('The protocol in use for this email account. Typically this is POP3.'),
      );
    

    The code is accessing a value that is probably not defined ($form_state).

  15.     '#title' => t('Template Body'),
    

    In Drupal the strings shown in the user interface have the first word in capital case, while the others are in lower case (if they are not acronyms, or proper nouns).

  16.     '#description' => t('The text you enter here will appear anywhere this staus is shown.'),
    

    Staus?

  17. function uc_ticket_uninstall() {
      // Delete the variables we created.
      variable_del('uc_ticket_default_filter');
      variable_del('uc_ticket_default_sort');
    
      drupal_uninstall_schema('uc_ticket');
    
      // Clear the cache tables.
      cache_clear_all('*', 'cache', TRUE);
      cache_clear_all('*', 'cache_filter', TRUE);
      cache_clear_all('*', 'cache_menu', TRUE);
      cache_clear_all('*', 'cache_page', TRUE);
    }
    

    I think the cache is automatically cleared from Drupal, when uninstalling a module.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new15.17 KB

Thanks for the review, here are the changes/notes made by number:

  1. Removed in instances where the text is being filtered through Form API
  2. This one I'm unsure about. I'm on a linux box and it looks fine in gedit.
  3. Now using drupal_strtolower() where applicable
  4. Changes made where necessary
  5. Changes made where necessary
  6. Now using $form_state['redirect']
  7. Now using t() in _get function
  8. Changes made where necessary
  9. Changes made where necessary
  10. Changes made where necessary
  11. Now using t() where applicable
  12. Using l() in this case
  13. Changes made where necessary
  14. Storage is populated in the submit handler. When a user tests the connection, we store the values in storage and populate the fields with that data. This way the user doesn't lose the values they entered after testing the connection.
  15. Changes made where necessary
  16. Now 'Status' :)
  17. I believe you're right. Code removed.

New code is attached.

Thanks!

avpaderno’s picture

Status: Needs review » Fixed
  1.   t("")
    

    An empty string is always an empty string, in every language; there is no need to pass it to t().

  2.   $templates[0] = 'Please select...';
    

    The string is still not translatable. Drupal modules don't normally use such option.

  3.     $output .= l('<img src="/' . drupal_get_path('module', 'uc_ticket') . '/images/delete.png' . '" alt="' . t('Delete Ticket') . '" />', 'admin/store/ticket/' . $ticket->ticket_id . '/delete', array('html' => TRUE));
      }
      $output .= l('<img src="/' . drupal_get_path('module', 'uc_ticket') . '/images/add.png' . '" alt="' . t('Add Followup To Ticket') . '" />', 'admin/store/ticket/followup/' . $ticket->ticket_id, array('html' => TRUE));
    

    Rather than calling l(), it would be better to use theme('image').

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.