You are here

function og_ui_confirm_subscribe in Organic groups 7

Same name and namespace in other branches
  1. 7.2 og_ui/og_ui.pages.inc \og_ui_confirm_subscribe()

Confirm subscribe form.

1 string reference to 'og_ui_confirm_subscribe'
og_ui_subscribe in og_ui/og_ui.pages.inc
Manage user subscription to a group.

File

og_ui/og_ui.pages.inc, line 85
Page callbacks for Group module.

Code

function og_ui_confirm_subscribe($form, &$form_state, $group, $account) {
  $form['group'] = array(
    '#type' => 'value',
    '#value' => $group,
  );
  $form['account'] = array(
    '#type' => 'value',
    '#value' => $account,
  );

  // Add group membership form.
  // TODO: We need to associate a group membership with group?
  $type = OG_MEMBERSHIP_TYPE_DEFAULT;
  $form['membership_type'] = array(
    '#type' => 'value',
    '#value' => $type,
  );
  $dummy_entity = og_membership_create(0, 'user', 0, array(
    'type' => $type,
  ));
  $form['membership_fields'] = array(
    '#prefix' => '<div id="og-ui-membership-type">',
    '#suffix' => '</div>',
    '#tree' => TRUE,
    '#parents' => array(
      'membership_fields',
    ),
  );
  field_attach_form('og_membership', $dummy_entity, $form['membership_fields'], $form_state);
  if (og_user_access($group->gid, 'subscribe without approval')) {

    // Hide the user request field.
    if (!empty($form['membership_fields'][OG_MEMBERSHIP_REQUEST_FIELD])) {
      $form['membership_fields'][OG_MEMBERSHIP_REQUEST_FIELD]['#access'] = FALSE;
    }
  }
  $label = og_label($group->gid);
  return confirm_form($form, t('Are you sure you want to join the group %title?', array(
    '%title' => $label,
  )), "{$group->entity_type}/{$group->etid}", ' ', t('Join'), t('Cancel'));
}