You are here

function webform_civicrm_set_message in Webform CiviCRM Integration 6

Same name and namespace in other branches
  1. 6.2 webform_civicrm_forms.inc \webform_civicrm_set_message()
  2. 7 webform_civicrm_utils.inc \webform_civicrm_set_message()
  3. 7.2 webform_civicrm_forms.inc \webform_civicrm_set_message()

Displays the admin-defined message with "not you?" link to known contacts

1 call to webform_civicrm_set_message()
_webform_civicrm_webform_frontend_form_alter in ./webform_civicrm_forms.inc
Alter front-end of webforms: Called by hook_form_alter() when rendering a civicrm-enabled webform Add custom prefix. Display message. Block unknown users. Set webform default values.

File

./webform_civicrm_utils.inc, line 625
Webform CiviCRM module's utility functions.

Code

function webform_civicrm_set_message($message, $contact) {
  $message = webform_civicrm_replace_tokens($message, $contact);
  preg_match_all('#\\{([^}]+)\\}#', $message, $matches);
  if (!empty($matches[0])) {
    foreach ($matches[0] as $pos => $match) {
      if (user_is_logged_in()) {
        $link = l($matches[1][$pos], 'logout', array(
          'query' => 'destination=' . $_GET['q'],
        ));
      }
      else {
        $link = l($matches[1][$pos], $_GET['q']);
      }
      $message = str_replace($match, $link, $message);
    }
  }
  drupal_set_message($message);
}