You are here

function mobile_tools_roles_configuration_form in Mobile Tools 6.3

Same name and namespace in other branches
  1. 5 mobile_tools.module \mobile_tools_roles_configuration_form()
  2. 6 mobile_tools_roles.inc \mobile_tools_roles_configuration_form()
  3. 6.2 modules/mobile_tools_roles/mobile_tools_roles.admin.inc \mobile_tools_roles_configuration_form()
  4. 7.2 mobile_tools_roles/mobile_tools_roles.module \mobile_tools_roles_configuration_form()
  5. 7.2 mobile_tools_roles/mobile_tools_roles.inc \mobile_tools_roles_configuration_form()

Configuration form for creating mobile user roles

1 string reference to 'mobile_tools_roles_configuration_form'
mobile_tools_roles_menu in ./mobile_tools_roles.module
Implementation of hook_menu

File

./mobile_tools_roles.admin.inc, line 10
Mobile Tools Admin pages

Code

function mobile_tools_roles_configuration_form() {
  $form['mobile_tools_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mobile Tools settings'),
    '#collapsible' => TRUE,
    '#description' => t('The Mobile Tools module allows the creation of a mobile version of each role . these mobile versions of each role will be assigned to the mobile user. In the !url configuration panel, you can assign permissions to the mobile user.', array(
      '!url' => l('permissions', 'admin/user/permissions'),
    )),
  );
  $form['mobile_tools_settings']['mobile_tools_enable_roles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Activate mobile user roles'),
    '#description' => t('When activated, mobile users will get the mobile versions of their normal roles when the site is being mobilized.'),
    '#default_value' => variable_get('mobile_tools_enable_roles', 0),
  );
  if (variable_get('mobile_tools_enable_roles', 0)) {
    $form['mobile_tools_roles'] = array(
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#title' => t('Mobile roles'),
      '#collapsible' => TRUE,
      '#description' => t('Enable or disable the mobile version of each user role. When no mobile role is created, the user will
      keep its normal role. The settings can also be configured in the !roles configuration section.', array(
        '!roles' => l('roles', 'admin/user/roles'),
      )),
      '#suffix' => mobile_tools_roles_overview(),
    );
    $result = db_query("SELECT r.rid, r.name FROM {role} r");
    $roles = variable_get('mobile_tools_roles', array());
    while ($role = db_fetch_object($result)) {
      $query = "SELECT COUNT(*) as count FROM {mobile_tools_roles_relations} WHERE mrid = %d";
      $count = db_result(db_query($query, $role->rid));
      if ($count == 0) {
        $form['mobile_tools_roles'][$role->rid] = array(
          '#type' => 'checkbox',
          '#truee' => TRUE,
          '#title' => $role->name,
          '#default_value' => isset($roles[$role->rid]) ? $roles[$role->rid] : 0,
          '#description' => t('Enabling will create the %role role . the name can be changed afterwards in the !roles settings page', array(
            '%role' => $role->name . ' (Mobile)',
            '!roles' => l('roles', 'admin/user/roles'),
          )),
        );
      }
    }
  }
  $form['#submit'][] = 'mobile_tools_roles_configuration_form_submit';
  return system_settings_form($form);
}