You are here

function hosting_form_submit_messages in Hosting 7.4

Same name and namespace in other branches
  1. 7.3 hosting.module \hosting_form_submit_messages()

Submit handler for hosting node forms: Display helpful messages.

1 string reference to 'hosting_form_submit_messages'
hosting_form_alter in ./hosting.module
Implements hook_form_alter().

File

./hosting.module, line 1145
Hosting module.

Code

function hosting_form_submit_messages($form, $form_state) {

  // Only act on sites, platforms, & servers.
  if (in_array($form_state['node']->type, array(
    'site',
    'platform',
    'server',
  ))) {

    // Translation array.
    $t = array(
      '@type' => $form_state['node']->type,
      '%title' => $form_state['values']['title'],
      '%task' => t('Verify'),
    );

    // If this is an add form...
    if (!isset($form_state['node']->nid)) {
      $t['!message'] = t('It will be available once the task is completed.');

      // If node is a site, task is "install".
      if ($form_state['node']->type == 'site') {
        $t['%task'] = t('Install');
      }
    }
    else {
      $t['!message'] = t('Changes will be applied once the task is completed.');
    }

    // Display the message.
    drupal_set_message(t('%task task has been queued for @type %title. !message', $t));

    // If using the hosting queue, mention the scheduled time.
    $queues = hosting_get_queues();
    if ($queues['tasks']['enabled']) {
      $until = _hosting_queue_next_run('tasks') - REQUEST_TIME;
      drupal_set_message(t('Task is scheduled to start in approximately %until.', array(
        '%until' => format_interval($until),
      )));
    }
  }
}