You are here

commentaccess.admin.inc in Comment Access 7

Administration settings for commentaccess.module

File

commentaccess.admin.inc
View source
<?php

/**
 * @file
 *
 * Administration settings for commentaccess.module
 */

/**
 * Generate the commentaccess admin settings form
 */
function commentaccess_admin_settings() {
  $form = array();
  $form['commentaccess_defaults'] = array(
    '#type' => 'fieldset',
    '#title' => t('Default settings'),
  );
  $form['commentaccess_defaults']['commentaccess_approval_default'] = array(
    '#type' => 'radios',
    '#title' => t('Require comment approval by default'),
    '#options' => array(
      1 => t('Disabled'),
      0 => t('Enabled'),
    ),
    '#description' => t('This sets the default on the user account form. When disabled your node authors will skip comment approvals by default. Enabling this may lead to legitimate comments not getting published, if your node authors are not aware of this feature.'),
    '#default_value' => variable_get('commentaccess_approval_default', 1),
  );
  $form['commentaccess_defaults']['commentaccess_mail_default'] = array(
    '#type' => 'radios',
    '#title' => t('Send e-mail approval notices by default'),
    '#options' => array(
      0 => t('Disabled'),
      1 => t('Enabled'),
    ),
    '#description' => t('This sets the default on the user account form. When disabled node authors must opt-in to receive an e-mail when comments need approval. <em>Warning: Enabling this may upset users who are not aware of this setting.</em>'),
    '#default_value' => variable_get('commentaccess_mail_default', 0),
  );
  $form['commentaccess_text'] = array(
    '#type' => 'fieldset',
    '#title' => t('Text options'),
  );
  $form['commentaccess_text']['commentaccess_approval_msg'] = array(
    '#type' => 'textfield',
    '#size' => 80,
    '#title' => t("Approval queue message"),
    '#description' => t("This message is displayed to a user after submitting a comment that requires author approval. The following variables are available for use: @poster, @node_owner, @subject."),
    '#default_value' => variable_get('commentaccess_approval_msg', t("Your comment will be posted once it's been approved.")),
  );
  $form['mail'] = array(
    '#type' => 'fieldset',
    '#title' => t('Approval email'),
    '#description' => t('Configure the approval notification e-mail generated by Comment Access module. The following variables are available for use: @approver, @commenter, @title, @comment, @commentlink, @nodelink, @site, @siteurl'),
  );
  $form['mail']['commentaccess_mail_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => variable_get('commentaccess_mail_subject', t('@commenter posted a new comment!')),
  );
  $form['mail']['commentaccess_mail_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#rows' => 10,
    '#default_value' => variable_get('commentaccess_mail_message', commentaccess_mail_message_default()),
  );

  // Only display php options if the filter is turned on and user has access
  if (module_exists('php') && user_access('use PHP for settings')) {
    $msg_php = variable_get('commentaccess_approval_php');
    $form['commentaccess_text']['commentaccess_approval_php_fieldset'] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => empty($msg_php) ? TRUE : FALSE,
      '#title' => t('PHP code'),
    );
    $form['commentaccess_text']['commentaccess_approval_php_fieldset']['commentaccess_approval_php'] = array(
      '#type' => 'textarea',
      '#title' => t('Approval queue message code'),
      '#default_value' => $msg_php,
      '#cols' => 60,
      '#rows' => 6,
      '#description' => '<p>' . t('Advanced Usage Only: PHP code that returns the text of the status message. The PHP code must be entered between %php. Note that executing incorrect PHP-code can break your Drupal site.', array(
        '%php' => '<?php ?>',
      )) . '</p><p>' . t('Note: if set, this will override any Approval queue message text set above.') . '</p>',
    );
  }
  return system_settings_form($form);
}

Functions

Namesort descending Description
commentaccess_admin_settings Generate the commentaccess admin settings form