You are here

function webform_conditional_confirmation_message_load in Webform Conditional Confirmation Messages 7

Same name and namespace in other branches
  1. 7.2 webform_conditional_confirmation.module \webform_conditional_confirmation_message_load()

Load confirmation message for a particular msgid and node.

4 calls to webform_conditional_confirmation_message_load()
webform_conditional_confirmation_delete_confirmation_form in ./webform_conditional_confirmation.pages.inc
Delete conditional confirmation message.
webform_conditional_confirmation_edit_confirmation_form in ./webform_conditional_confirmation.pages.inc
Add/edit conditional confirmation message.
webform_conditional_confirmation_get_message in ./webform_conditional_confirmation.module
Get first matching conditional confirmation message.
webform_conditional_confirmation_list_form in ./webform_conditional_confirmation.pages.inc
The table-based listing of all confirmation messages for this webform.

File

./webform_conditional_confirmation.module, line 75

Code

function webform_conditional_confirmation_message_load($node, $msgid = NULL) {

  // New message, so load defaults.
  if ($msgid == 'add') {
    $defaults = new stdClass();
    $defaults->name = '';
    $defaults->conditional_component = NULL;
    $defaults->conditional_operator = NULL;
    $defaults->conditional_values = '';
    $defaults->conditional_weight = 0;
    $defaults->confirmation = $node->webform['confirmation'];
    $defaults->confirmation_format = $node->webform['confirmation_format'];
    $defaults->redirect_url = $node->webform['redirect_url'];
    return $defaults;
  }
  else {
    $query = db_select('webform_conditional_confirmation', 'wcc')
      ->fields('wcc')
      ->condition('nid', $node->nid);

    // If msgid is set, just return settings for the specified message.
    if ($msgid) {
      $defaults = $query
        ->condition('msgid', $msgid)
        ->execute()
        ->fetchObject();
      return $defaults;
    }
    else {
      $records = array();
      $result = $query
        ->orderBy('conditional_weight', 'ASC')
        ->orderBy('msgid', 'ASC')
        ->execute();
      while ($record = $result
        ->fetchObject()) {
        $records[$record->msgid] = $record;
      }
      return $records;
    }
  }
  return;
}