You are here

function autoassignrole_page_form in Auto Assign Role 7

Same name and namespace in other branches
  1. 7.2 autoassignrole.admin.inc \autoassignrole_page_form()

Implements hook_form().

Form to edit or add role-specific pages.

1 string reference to 'autoassignrole_page_form'
autoassignrole_menu in ./autoassignrole.module
Implements hook_menu().

File

./autoassignrole.admin.inc, line 249
Administrative functionality for auto assign role.

Code

function autoassignrole_page_form($form, &$form_state, $op = 'add', $id = 0) {
  $roles = user_roles(TRUE);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);
  $form = array();
  switch ($op) {
    case 'add':
      $title = t('Add a new role page');
      $submit_value = t('Add');
      break;
    case 'edit':
      $title = t('Edit role page');
      $submit_value = t('Save');
      break;
  }
  $form['rid_page'] = array(
    '#type' => 'fieldset',
    '#title' => $title,
  );
  $form['rid_page']['op_term'] = array(
    '#type' => 'hidden',
    '#value' => $op,
  );
  if ($op == 'edit') {
    $form['rid_page']['id'] = array(
      '#type' => 'hidden',
      '#value' => $id,
    );
    if ($id > 0) {
      $page = autoassignrole_get_page($id);
    }
  }
  $form['rid_page']['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Role'),
    '#description' => t('Select the roles this page will assign'),
    '#options' => $roles,
    '#required' => TRUE,
    '#default_value' => isset($page->rids) ? unserialize($page->rids) : array(),
  );
  $form['rid_page']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Page Title'),
    '#description' => t('Enter the title of the page'),
    '#size' => 60,
    '#required' => TRUE,
    '#default_value' => isset($page->title) ? $page->title : "",
  );
  $form['rid_page']['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Page Path'),
    '#description' => t('Enter the Drupal path for the registration page for this role. This is a relative path based on your Drupal installation.'),
    '#size' => 60,
    '#required' => TRUE,
    '#default_value' => isset($page->path) ? $page->path : "",
  );
  $form['rid_page']['menu'] = array(
    '#type' => 'select',
    '#title' => t('Menu'),
    '#description' => t('Which parent menu item should these pages appear under? This will only apply if you choose the "Standard" display option below.'),
    '#options' => menu_get_menus(),
    '#default_value' => isset($page->menu) ? $page->menu : "",
  );
  $form['rid_page']['display'] = array(
    '#type' => 'select',
    '#title' => t('Display type'),
    '#description' => t('Choose the way you would like these pages to be displayed.<br /><em>Standard</em> is equivalent to the core Drupal log in/ registration form, with tabs along the top.<br /><em>Individual</em> is a separate page without tabs.'),
    '#options' => array(
      AUTOASSIGNROLE_PAGE_DISPLAY_STANDARD => t('Standard'),
      AUTOASSIGNROLE_PAGE_DISPLAY_INDIVIDUAL => t('Individual'),
    ),
    '#default_value' => isset($page->display) ? $page->display : "",
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $submit_value,
  );
  return $form;
}