You are here

function support_page_form_submit in Support Ticketing System 7

Same name and namespace in other branches
  1. 6 support.module \support_page_form_submit()

Update selected tickets.

File

./support.module, line 3453
support.module

Code

function support_page_form_submit($form, &$form_state) {
  global $user;
  foreach ($form_state['values']['tickets'] as $nid) {
    $message = array();
    $message['uid'] = $user->uid;
    $message['nid'] = $nid;

    // TODO: Allow the optional addition of a subject
    $message['subject'] = '';
    $message['body'] = $form_state['values']['update'];
    $message['attachments'] = array();
    $message['suppress'] = isset($form_state['values']['suppress']) ? $form_state['values']['suppress'] : FALSE;
    $message['state'] = $form_state['values']["state-{$nid}"];
    $message['priority'] = $form_state['values']["priority-{$nid}"];
    $message['assigned'] = $form_state['values']["assigned-{$nid}"];

    // TODO: Pass the client in rather than make unnecessary queries
    $clid = db_query('SELECT client FROM {support_ticket} WHERE nid = :nid', array(
      ':nid' => $nid,
    ))
      ->fetchField();
    $client = support_client_load($clid);

    // re-use email handling to save ticket updates
    support_save_message($message, $client);
  }
}