You are here

function secure_permissions_form in Secure Permissions 6

Same name and namespace in other branches
  1. 7.2 secure_permissions.module \secure_permissions_form()
  2. 7 secure_permissions.module \secure_permissions_form()

Configuration form for the module.

1 string reference to 'secure_permissions_form'
secure_permissions_menu in ./secure_permissions.module
Implement hook_menu().

File

./secure_permissions.module, line 411
Secure Permissions module file.

Code

function secure_permissions_form() {
  $form = array();

  // Check which modules run our hook,
  $modules = module_implements('secure_permissions');
  $files = module_rebuild_cache();
  $items = array();
  foreach ($modules as $module) {
    if ($module != 'secure_permissions') {
      $items[] = check_plain($files[$module]->info['name']);
    }
  }
  $module_list = theme('item_list', $items);
  $extra = '';
  if (count($modules) == 1) {
    $extra = t('Your permissions have not been <a href="!url">exported to code</a> yet. You may need to do so before activating this module.', array(
      '!url' => url('admin/user/secure_permissions/export'),
    ));
  }
  $form['help'] = array(
    '#type' => 'markup',
    '#value' => t('The following modules implement secure permissions: !list !extra', array(
      '!list' => $module_list,
      '!extra' => $extra,
    )),
  );
  $form['user_interface'] = array(
    '#type' => 'fieldset',
    '#title' => t('User interface settings'),
  );
  $form['user_interface']['secure_permissions_disable_forms'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_disable_forms'),
    '#title' => t('Disable permissions and roles forms'),
    '#description' => t('Disables the ability to edit or add permissions and roles through the user interface.'),
  );
  $form['user_interface']['secure_permissions_show_permissions_page'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_show_permissions_page'),
    '#title' => t('Show permissions page'),
    '#description' => t('Allows administrators to view the permissions overview page.'),
  );
  $form['user_interface']['secure_permissions_show_roles_page'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_show_roles_page'),
    '#title' => t('Show roles page'),
    '#description' => t('Allows administrators to view the roles overview page.'),
  );
  $form['user_interface']['secure_permissions_verbose'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_verbose'),
    '#title' => t('Display permissions updates'),
    '#description' => t('Prints a message to the screen whenever permissions are updated.'),
  );
  $form['code'] = array(
    '#type' => 'fieldset',
    '#title' => t('API settings'),
    '#description' => t('If the <em>Load permissions from code</em> setting is not enabled, none of the features below will be enabled.'),
  );
  $form['code']['secure_permissions_active'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_active'),
    '#title' => t('Load permissions from code'),
    '#description' => t('Allows permissions and roles to be defined in code, replacing values set through the user interface.'),
  );
  $form['code']['secure_permissions_use_default'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_use_default'),
    '#title' => t('Reload default permissions on rebuild'),
    '#description' => t('Sets the default Drupal permissions for anonymous and authenticated users.'),
  );
  $form['code']['secure_permissions_administrative_role'] = array(
    '#type' => 'checkbox',
    '#default_value' => secure_permissions_variable('secure_permissions_administrative_role'),
    '#title' => t('Use administrative role'),
    '#description' => t('Maintains an administrative role that is granted all permissions.'),
  );
  $form['code']['secure_permissions_role_name'] = array(
    '#type' => 'textfield',
    '#default_value' => secure_permissions_variable('secure_permissions_role_name'),
    '#title' => t('Administrative role name'),
    '#required' => TRUE,
    '#description' => t('The name of the administrative role. Normally this need not be changed.'),
  );

  // Make sure the menu is rebuilt correctly.
  $form['#submit'][] = 'secure_permissions_form_submit';
  if (isset($_SESSION['secure_permissions_rebuild'])) {
    unset($_SESSION['secure_permissions_rebuild']);
    menu_rebuild();
  }
  return system_settings_form($form);
}