You are here

function front_page_admin_arrange_form in Front Page 7.2

Same name and namespace in other branches
  1. 6.2 front_page.admin.inc \front_page_admin_arrange_form()

Form for arranging the roles according to what order the roles should be processed.

1 string reference to 'front_page_admin_arrange_form'
front_page_menu in ./front_page.module
Implements hook_menu().

File

./front_page.admin.inc, line 212
Admin page callbacks for the front page module.

Code

function front_page_admin_arrange_form($form, &$form_state) {
  $roles = user_roles();
  $front_page_data = front_page_get_all();
  foreach ($roles as $rid => $role) {
    $front_page_data[$rid]['name'] = $role;
  }
  $form['roles'] = array(
    '#tree' => TRUE,
  );
  foreach ($front_page_data as $role_id => $role) {
    $form['roles'][$role_id]['title']['#markup'] = $role['name'];
    $form['roles'][$role_id]['mode']['#markup'] = !empty($role['mode']) ? $role['mode'] : 'skip';
    $form['roles'][$role_id]['preview']['#markup'] = !empty($role['mode']) ? l(t('preview'), 'front_page/preview/' . $role_id, array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )) : '';
    if (!empty($role['mode'])) {
      $form['roles'][$role_id]['enabled'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable'),
        '#title_display' => 'invisible',
        '#default_value' => TRUE,
      );
    }
    else {
      $form['roles'][$role_id]['enabled']['#markup'] = 'disabled';
    }
    $form['roles'][$role_id]['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight'),
      '#title_display' => 'invisible',
      '#delta' => 10,
      '#default_value' => isset($role['weight']) ? $role['weight'] : 0,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Order'),
  );
  return $form;
}