You are here

function certificate_alter_node_form in Certificate 6

Same name and namespace in other branches
  1. 8.3 certificate.admin.inc \certificate_alter_node_form()
  2. 6.2 certificate.admin.inc \certificate_alter_node_form()
  3. 7.3 certificate.admin.inc \certificate_alter_node_form()
  4. 7.2 certificate.admin.inc \certificate_alter_node_form()
  5. 3.x certificate.admin.inc \certificate_alter_node_form()

Alters the node form to inject the appropriate per-node template settings.

1 call to certificate_alter_node_form()
certificate_form_alter in ./certificate.module
Implements hook_form_alter for course nodes.

File

./certificate.admin.inc, line 309
Administrative pages for the module.

Code

function certificate_alter_node_form(&$form, &$form_state) {
  global $user;

  // Node is not saved but previewed (nid is empty).
  if (isset($form['#node']->build_mode) && $form['#node']->build_mode == NODE_BUILD_PREVIEW) {
    $node = $form['#node'];
  }
  elseif (!empty($form['#node'])) {
    $node = $form['#node'];
  }
  if (module_exists('og')) {
    $group = og_get_group_context();
    $group_admin = og_is_group_admin($group);
  }

  // Add template-mapping form.
  // Note, make sure to set #tree to TRUE.
  if (user_access('administer certificates') || $group_admin) {
    $form['certificate'] = array(
      '#type' => 'fieldset',
      '#title' => t('Certificate template settings'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#weight' => 100,
      '#tree' => TRUE,
      '#group' => TRUE,
    );

    // Do we get the form state on submit?

    #drupal_set_message('<pre>'. print_r($node_template_settings, TRUE) .' </pre>');

    #module_load_include('inc', 'certificate', 'certificate.admin');
    $form['certificate']['node_settings'] = certificate_type_mapping_form($form_state, $node);
  }
}