You are here

function webform_invitation_codes_page in Webform Invitation 7

Same name and namespace in other branches
  1. 7.2 webform_invitation.module \webform_invitation_codes_page()
1 string reference to 'webform_invitation_codes_page'
webform_invitation_menu in ./webform_invitation.module
Implements hook_menu().

File

./webform_invitation.module, line 162

Code

function webform_invitation_codes_page($nid = null) {
  $codes = db_select('webform_invitation_codes', 'c')
    ->fields('c')
    ->condition('nid', $nid, '=')
    ->execute()
    ->fetchAll();
  $node = node_load($nid);
  $out = "<h2>" . t('Invitation codes for webform %node_title', array(
    "%node_title" => $node->title,
  )) . "</h2>";
  if (count($codes) > 0) {
    $out .= "<table><tr><th>" . t('Code') . "</th><th>" . t('used?') . "</th></tr>";
    foreach ($codes as $code) {
      $out .= '<tr><td>' . $code->code . '</td><td>' . ($code->used != null ? t('yes') : t('no')) . '</td></tr>';
    }
    $out .= '</table>';
  }
  else {
    $out .= '<p><em>' . t('No codes present, yet. Click on "Generate" above to create codes.') . '</em></p>';
  }
  return $out;
}