You are here

protected function BotchaForm::createAdminLinksFieldset in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.2 controller/botcha_form.controller.inc \BotchaForm::createAdminLinksFieldset()
  2. 6.3 controller/form/botcha.form.controller.inc \BotchaForm::createAdminLinksFieldset()
  3. 7.2 controller/botcha_form.controller.inc \BotchaForm::createAdminLinksFieldset()
1 call to BotchaForm::createAdminLinksFieldset()
BotchaForm::addAdminLinks in controller/form/botcha.form.controller.inc

File

controller/form/botcha.form.controller.inc, line 159
Controller layer of the BotchaForm objects.

Class

BotchaForm

Code

protected function createAdminLinksFieldset($form_id) {

  // For administrators: show BOTCHA info and offer link to configure it.
  $botcha_element = array(
    '#type' => 'fieldset',
    '#title' => t('BOTCHA'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    // @todo Abstract it.

    //'#attributes' => array('class' => 'botcha-admin-links'),
    '#attributes' => array(
      'class' => array(
        'botcha-admin-links',
      ),
    ),
  );
  $rbid = $this
    ->getRecipebook();

  // @todo Remove hardcode.
  if ($rbid === 'none') {
    $botcha_element['#title'] = t('BOTCHA: no protection enabled');
    $botcha_element['add_botcha'] = array(
      // @todo Abstract it.

      //'#value' => l(t('Add BOTCHA protection on form'), Botcha::ADMIN_PATH . "/form/add", array('query' => drupal_get_destination() . "&botcha_form_id=$form_id", 'html' => TRUE)),
      '#markup' => l(t('Add BOTCHA protection on form'), Botcha::ADMIN_PATH . "/form/add", array(
        'query' => array_merge(drupal_get_destination(), array(
          'botcha_form_id' => $form_id,
        )),
        'html' => TRUE,
      )),
    );
  }
  else {
    $botcha_element['#title'] = t('BOTCHA: protection enabled (@recipebook recipe book)', array(
      '@recipebook' => $rbid,
    ));
    $botcha_element['#description'] = t('Untrusted users will have form %form_id protected by BOTCHA (!recipebook_settings, !general_settings).', array(
      '%form_id' => $form_id,
      '!recipebook_settings' => l(t('Recipe book settings'), Botcha::ADMIN_PATH . "/recipebook/{$rbid}"),
      '!general_settings' => l(t('General BOTCHA settings'), Botcha::ADMIN_PATH),
    ));
    $botcha_element['protection'] = array(
      '#type' => 'item',
      '#title' => t('Enabled protection'),
      // @todo Abstract it.

      //'#value' => t('Form is protected by "@recipebook" recipe book (!edit, !disable)', array(
      '#markup' => t('Form is protected by "@recipebook" recipe book (!edit, !disable)', array(
        '@recipebook' => $rbid,
        '!edit' => l(t('edit'), Botcha::ADMIN_PATH . "/form/{$form_id}", array(
          'query' => drupal_get_destination(),
          'html' => TRUE,
        )),
        '!disable' => l(t('disable'), Botcha::ADMIN_PATH . "/form/{$form_id}/disable", array(
          'query' => drupal_get_destination(),
          'html' => TRUE,
        )),
      )),
    );
  }
  return $botcha_element;
}