You are here

function hosting_queued_remove_semaphore_form in Hosting 7.3

Same name and namespace in other branches
  1. 7.4 queued/hosting_queued.admin.inc \hosting_queued_remove_semaphore_form()

Form for removing the hosting queue lock.

Return value

mixed

1 string reference to 'hosting_queued_remove_semaphore_form'
hosting_queued_menu in queued/hosting_queued.module
Implements hook_menu().

File

queued/hosting_queued.admin.inc, line 103
Configuration forms for the queue daemon.

Code

function hosting_queued_remove_semaphore_form() {
  drupal_set_title(t('Unlock Hosting Queue'));
  $processing_tasks = db_select('hosting_task', 't')
    ->fields('t', array(
    'nid',
  ))
    ->condition('task_status', HOSTING_TASK_PROCESSING)
    ->execute()
    ->fetchField();
  $semaphore_status = db_select('semaphore', 's')
    ->fields('s', array(
    'name',
  ))
    ->condition('s.name', 'hosting_queue_tasks_running')
    ->execute()
    ->fetchField();
  $form['hosting_queue_tasks_running'] = array(
    '#type' => 'item',
    '#title' => t('Tasks Running'),
    '#markup' => $processing_tasks ? t('Yes') : t('No'),
  );
  $form['hosting_queue_tasks_locked'] = array(
    '#type' => 'item',
    '#title' => t('Task Queue Locked'),
    '#markup' => $semaphore_status ? t('Yes') : t('No'),
  );
  $disabled = TRUE;
  if ($semaphore_status && !$processing_tasks) {
    $form['hosting_queue_tasks_locked']['#description'] = t('The task queue is locked but there are no tasks running. You should unlock the queue.');
    $button_class = 'btn-success';
    $disabled = FALSE;
  }
  else {
    $form['hosting_queue_tasks_locked']['#description'] = t('The task queue is not locked.');
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Unlock Hosting Queue'),
    '#disabled' => $disabled,
    '#attributes' => array(
      'class' => array(
        $button_class,
      ),
    ),
  );
  return $form;
}