You are here

function sf_notifications_queue_form in Salesforce Suite 7.2

Salesforce Notifications queue form.

Shows queue contents, and adds some controls to process and empty the queue.

1 string reference to 'sf_notifications_queue_form'
sf_notifications_menu in sf_notifications/sf_notifications.module
Implements hook_menu.

File

sf_notifications/sf_notifications.admin.inc, line 86

Code

function sf_notifications_queue_form($form, &$form_state) {
  $queue = DrupalQueue::get('sf_notifications_queue');
  $form = array();
  $form['queue_count'] = array(
    '#markup' => t('There are currently @count items in the queue', array(
      '@count' => $queue
        ->numberOfItems(),
    )),
  );

  // get a list of items from the queue.
  $queue_items = array();
  $results = db_query("SELECT item_id, data, created FROM {queue} WHERE name = 'sf_notifications_queue'");
  foreach ($results as $item) {
    $data = unserialize($item->data);
    $queue_items[] = array(
      $item->item_id,
      print_r($data, TRUE),
      format_date($item->created),
    );
  }
  $header = array(
    array(
      'data' => 'Queue ID',
      'field' => 'item_id',
    ),
    'Data',
    array(
      'data' => 'Created',
      'field' => 'created',
    ),
  );
  $form['queue_table'] = array(
    '#markup' => theme('table', array(
      'header' => $header,
      'rows' => $queue_items,
      'empty' => t('There are no items in the inbound notifications queue at the moment'),
    )),
  );
  $form['actions']['#type'] = 'actions';
  $form['actions']['help_text'] = array(
    '#markup' => '<p>' . t("The buttons below only act on items in the queue that are not currently claimed for processing. If items still remain in the queue after clicking 'Empty Notifications Queue', please wait a minute for the queue claim to expire, then try again.") . '</p>',
  );
  $form['actions']['process'] = array(
    '#type' => 'submit',
    '#value' => t('Process queue items'),
    //    '#disabled' => !$queue->numberOfItems() ? TRUE : FALSE,
    '#submit' => array(
      'sf_notifications_process_submit',
    ),
  );
  $form['actions']['empty'] = array(
    '#type' => 'submit',
    '#value' => t('Empty notifications queue'),
    //    '#disabled' => !$queue->numberOfItems() ? TRUE : FALSE,
    '#submit' => array(
      'sf_notifications_empty_submit',
    ),
  );
  return $form;
}