You are here

function anonymous_publishing_cl_admin_settings in Anonymous Publishing 7

Menu callback: Provide module settings page.

Return value

array Form.

1 string reference to 'anonymous_publishing_cl_admin_settings'
anonymous_publishing_cl_menu in modules/cl/anonymous_publishing_cl.admin.inc
Implements hook_menu().

File

modules/cl/anonymous_publishing_cl.admin.inc, line 16
Menu callbacks for the CL tabs on the module admin page.

Code

function anonymous_publishing_cl_admin_settings() {
  $anony = drupal_anonymous_user();
  $ctypes = variable_get('anonymous_publishing_cl_types', array());
  foreach ($ctypes as $ctype => $act) {
    if ('comment' == $ctype && $act) {
      $ua = user_access('post comments', $anony);
      if ($act && !$ua) {
        drupal_set_message(t('The module is set to to manage comments, but anonymous users are not allowed to post comments.'), 'warning');
      }
    }
    else {
      $ua = user_access('create ' . $ctype . ' content', $anony);
      if ($act && !$ua) {
        drupal_set_message(t('The module is set to to manage !ctypes, but anonymous users are not allowed to create !ctypes.', array(
          '!ctype' => $ctype,
        )), 'warning');
      }
    }
  }
  $admin = user_load(1);
  $ctypes = node_type_get_names();
  if (module_exists('comment')) {
    $ctypes['comment'] = 'Comment';
    $ctext = '(+ Comment)';
  }
  else {
    $ctext = '';
  }
  $form['anonymous_publishing_cl_types'] = array(
    '#type' => 'checkboxes',
    '#multiple' => TRUE,
    '#title' => t('Content types !comments where anonymous publishing is managed by this submodule:', array(
      '!comments' => $ctext,
    )),
    '#default_value' => variable_get('anonymous_publishing_cl_types', array()),
    '#options' => $ctypes,
    '#description' => t('Note: You also need to use node permissions to enable anonymous publishing for the anonymous user role if you want this role to be able to create content.'),
  );
  $form['anonymous_publishing_cl_options'] = array(
    '#type' => 'checkboxes',
    '#multiple' => TRUE,
    '#title' => t('Options:'),
    '#default_value' => variable_get('anonymous_publishing_cl_options', array(
      'sactivate' => 'sactivate',
      'modmail' => 0,
      'blockip' => 0,
      'aregist' => 0,
    )),
    '#options' => array(
      'sactivate' => t('Allow self-activation.'),
      'sactcomm' => t('“Skip comment approval” (set on <a title="Set permissions for anonymous." href="@url">Administration » People » Permissions</a>).', array(
        '@url' => url('admin/people/permissions', array(
          'fragment' => 'module-node',
        )),
      )),
      'modmail' => t('Send e-mail to administrator when anonymous content is created.'),
      'blockip' => t('Use IP-address for blocking.'),
      'aregist' => t('Allow registered e-mails to be used for anonymous posts.'),
    ),
    '#description' => t('Check the options you want to enable.'),
  );
  $form['anonymous_publishing_cl_options']['sactcomm'] = array(
    '#disabled' => TRUE,
    '#default_value' => user_access('skip comment approval', $anony),
  );
  $form['anonymous_publishing_cl_vrfypers'] = array(
    '#type' => 'radios',
    '#title' => t('Verification persistency:'),
    '#options' => array(
      0 => t('Make verification persistent.'),
      1 => t('Verification persists as long as the same IP is used.'),
      2 => t('Require verification for each posting.'),
    ),
    '#description' => t('This determines whether users need to re-verify.'),
    /* '#disabled' => array(1), */
    '#default_value' => variable_get('anonymous_publishing_cl_vrfypers', 0),
  );
  $usealias = variable_get('anonymous_publishing_cl_alias', 0);
  if ($usealias > 0) {
    $form['anonymous_publishing_cl_vrfypers'][1] = array(
      '#disabled' => TRUE,
    );
    $form['anonymous_publishing_cl_vrfypers'][2] = array(
      '#disabled' => TRUE,
    );
  }

  // Period is set on privacy tab, -1 = Indefinitely.
  $period = variable_get('anonymous_publishing_cl_period', -1);
  if (-1 == $period) {
    $form['anonymous_publishing_cl_alias'] = array(
      '#type' => 'radios',
      '#title' => t('To whom should anonymous postings be attributed:'),
      '#options' => array(
        0 => t('Use “@anon” (the default alias for anonymous users).', array(
          '@anon' => variable_get('anonymous', 'Anonymous'),
        )),
        1 => t('Use an autogenerated persistent alias (format “user<em>N</em>”).'),
        2 => t('Allows the anonymous publisher to set the byline.'),
        3 => t('Requires the anonymous publisher to set the byline.'),
      ),
      '#description' => t('This settings determines what string to use as byline for anonymous posts.'),
      '#default_value' => $usealias,
    );
    $form['anonymous_publishing_cl_requiredchar'] = array(
      '#type' => 'textfield',
      '#title' => t('Minimum number of characters required for byline:'),
      '#size' => 3,
      '#maxlength' => 3,
      '#default_value' => variable_get('anonymous_publishing_cl_requiredchar', 6),
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
      '#description' => t('Set the minimum number of characters for the byline (only used if a byline is allowed or required).'),
    );
    $form['anonymous_publishing_cl_bylineguide'] = array(
      '#type' => 'textfield',
      '#title' => t('Guidelines for the byline:'),
      '#size' => 60,
      '#maxlength' => EMAIL_MAX_LENGTH,
      '#default_value' => variable_get('anonymous_publishing_cl_bylineguide', _anonymous_publishing_cl_substitute_text('anonymous_publishing_cl_bylineguide')),
      '#description' => t('Guidance for users who set their own byline.  You can use <code>!reqchar</code> as placeholder for minimum number of characters.'),
    );
  }
  else {
    $form['anonymous_publishing_cl_alias'] = array(
      '#markup' => t('<p>To access the settings for the byline, you must set the retention period to “Indefinitely” (on the <em>Privacy</em> tab).</p>'),
    );
  }
  $form['anonymous_publishing_cl_moderator'] = array(
    '#type' => 'textfield',
    '#title' => t('Administrator&#39;s e-mail address:'),
    '#size' => 60,
    '#maxlength' => EMAIL_MAX_LENGTH,
    '#default_value' => variable_get('anonymous_publishing_cl_moderator', $admin->mail),
    '#description' => t('Address to use when the “Send e-mail to administrator…” option is checked.'),
  );
  $form['anonymous_publishing_cl_emailweight'] = array(
    '#type' => 'textfield',
    '#title' => t('Verification e-mail address field weight:'),
    '#size' => 3,
    '#maxlength' => 3,
    '#default_value' => variable_get('anonymous_publishing_cl_emailweight', 0),
    '#element_validate' => array(
      'element_validate_integer',
    ),
    '#description' => t('Weight of verification e-mail address field on create content form.'),
  );
  $form['anonymous_publishing_cl_autodelhours'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of hours to retain unverified anonymous posts before auto-deletions removes them:'),
    '#size' => 3,
    '#maxlength' => 3,
    '#default_value' => variable_get('anonymous_publishing_cl_autodelhours', -1),
    '#element_validate' => array(
      'element_validate_integer',
    ),
    '#description' => t('Non-verified content will be automatically deleted after this time. Type “-1” for no limit.'),
  );
  $form['anonymous_publishing_cl_flood'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of anonymous posts allowed from a single user e-mail/ip allowed within an hour:'),
    '#size' => 3,
    '#maxlength' => 2,
    '#default_value' => variable_get('anonymous_publishing_cl_flood', 5),
    '#element_validate' => array(
      'element_validate_integer',
    ),
    '#description' => t('Type “-1” for no limit.'),
  );
  return system_settings_form($form);
}