You are here

function flexiaccess_admin_anon in Flexi Access 7

Form builder to display a listing of content types and their ACL status.

1 string reference to 'flexiaccess_admin_anon'
flexiaccess_menu in ./flexiaccess.module
Implements hook_menu().

File

./flexiaccess.admin.inc, line 96
Administrative page callbacks for the Flexi access module.

Code

function flexiaccess_admin_anon($form) {
  $anon = user_load(0);
  if ($anon != FALSE) {
    $uname = $anon->name;
  }
  else {
    $uname = '';
  }
  $form = array();
  $form['flexiacceess_anon']['intro'] = array(
    '#markup' => '<p>' . t('This admin-page lets you inspect the name of the Anonymous user as it is represented in the {users} table in the database, and change it if it is required.') . '</p>',
  );
  if (!empty($uname)) {
    $nname = $uname;
    $form['flexiacceess_anon']['anonprofile'] = array(
      '#markup' => '<p>' . t('The Anonymous user is currently known to Flexi access as &#8220;!anon&#8221;.', array(
        '!anon' => $uname,
      )) . '</p>',
    );
    $default = 0;
  }
  else {
    $uid = 1;
    $ii = 0;
    while ($uid) {
      $iii = sprintf('%d', $ii++);
      $nname = 'anon' . $iii;
      $uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(
        ':name' => $nname,
      ))
        ->fetchAssoc();

      // drupal_set_message("[$nname | $uid]");
    }

    // drupal_set_message("[$nname]");
    $form['flexiacceess_anon']['anonprofile'] = array(
      '#markup' => '<p>' . t('The current name of the Anonymous user in the {users} table is the empty string.  This the default for Drupal 7, but it rules out having the Anonymous user in an ACL.') . '</p>',
    );
    $default = 1;
  }
  $form['flexiacceess_anon']['nname'] = array(
    // '#title' => 'ID',
    '#value' => $nname,
    '#type' => 'hidden',
  );
  $form['flexiacceess_anon']['howshall'] = array(
    '#type' => 'radios',
    '#title' => t("How shall the Anonymous user's name be represented in the {users} table in the database?"),
    '#default_value' => $default,
    '#options' => array(
      t('Store &#8220;@name&#8221; as the name the Anonymous user (pick this option to use have the Anonymous user in ACLs).', array(
        '@name' => $nname,
      )),
      t('Make the name of the Anonymous user an empty string (pick this option to reset this to Drupal 7 default).'),
    ),
    '#description' => t('Choose how you want the name of the Anonymous user represented in the database and press <em>Execute</em> to execute.'),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Execute'),
  );
  return $form;
}