Commit 9cbdff91 authored by Bhupesh Upadhyay's avatar Bhupesh Upadhyay Committed by Gisle Hannemyr
Browse files

Issue #2868594 by Bhupesh_upadhyay: Use short array syntax

parent 2e4aaac6
Loading
Loading
Loading
Loading
+95 −94
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
 * @file
 * Install and uninstall hooks.
 */

use Drupal\Core\Render\Element\Email;

/**
@@ -11,226 +12,226 @@ use Drupal\Core\Render\Element\Email;
 */
function anonymous_publishing_schema() {

  $schema['anonymous_publishing'] = array(
  $schema['anonymous_publishing'] = [
    'description' => 'Record of anonymous nodes (only needed for activation).',
    'fields' => array(
      'apid' => array(
    'fields' => [
      'apid' => [
        'description' => 'primary key',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
      ],
      'nid' => [
        'description' => '{node}.nid reference',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'cid' => array(
      ],
      'cid' => [
        'description' => '{comment}.cid reference',
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'akey' => array(
      ],
      'akey' => [
        'description' => 'activation key',
        'type' => 'char',
        'length' => 60,
        'not null' => FALSE,
        'default' => '',
      ),
      'verified' => array(
      ],
      'verified' => [
        'description' => '0 = not verified',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'alias' => array(
      ],
      'alias' => [
        'description' => 'byline/alias set by user',
        'type' => 'varchar',
        'length' => Email::EMAIL_MAX_LENGTH,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'email' => array(
      ],
      'email' => [
        'description' => 'activation email',
        'type' => 'varchar',
        'length' => Email::EMAIL_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ),
      'ip' => array(
      ],
      'ip' => [
        'description' => 'IP-address used to post contents.',
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'unique keys' => array(
      'akey' => array('akey'),
    ),
    'primary key' => array('apid'),
    'foreign keys' => array(
      'fk_node' => array(
      ],
    ],
    'unique keys' => [
      'akey' => ['akey'],
    ],
    'primary key' => ['apid'],
    'foreign keys' => [
      'fk_node' => [
        'table' => 'node',
        'columns' => array('nid' => 'nid'),
      ),
      'fk_comment' => array(
        'columns' => ['nid' => 'nid'],
      ],
      'fk_comment' => [
        'table' => 'comment',
        'columns' => array('cid' => 'cid'),
      ),
    ),
  );
        'columns' => ['cid' => 'cid'],
      ],
    ],
  ];

  $schema['anonymous_publishing_realname'] = array(
  $schema['anonymous_publishing_realname'] = [
    'description' => 'Record of real user name for nodes published asanon.',
    'fields' => array(
      'rnid' => array(
    'fields' => [
      'rnid' => [
        'description' => 'primary key',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
      ],
      'nid' => [
        'description' => '{node}.nid reference',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'cid' => array(
      ],
      'cid' => [
        'description' => '{comment}.cid reference',
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'uid' => array(
      ],
      'uid' => [
        'description' => '{users}.uid reference',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('rnid'),
    'foreign keys' => array(
      'fk_node2' => array(
      ],
    ],
    'primary key' => ['rnid'],
    'foreign keys' => [
      'fk_node2' => [
        'table' => 'node',
        'columns' => array('nid' => 'nid'),
      ),
      'fk_comment2' => array(
        'columns' => ['nid' => 'nid'],
      ],
      'fk_comment2' => [
        'table' => 'comment',
        'columns' => array('cid' => 'cid'),
      ),
      'fk_user2' => array(
        'columns' => ['cid' => 'cid'],
      ],
      'fk_user2' => [
        'table' => 'users',
        'columns' => array('uid' => 'uid'),
      ),
    ),
  );
        'columns' => ['uid' => 'uid'],
      ],
    ],
  ];

  $schema['anonymous_publishing_emails'] = array(
  $schema['anonymous_publishing_emails'] = [
    'description' => 'For keeping track of emails used by anonymous publishers.',
    'fields' => array(
      'auid' => array(
    'fields' => [
      'auid' => [
        'description' => 'anonymous user id',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'email' => array(
      ],
      'email' => [
        'description' => 'email used to activate',
        'type' => 'varchar',
        'length' => Email::EMAIL_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ),
      'alias' => array(
      ],
      'alias' => [
        'description' => 'Alias to be associated with this email (may be used as byline).',
        'type' => 'varchar',
        'length' => Email::EMAIL_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ),
      'ipaddress' => array(
      ],
      'ipaddress' => [
        'description' => 'IP-address used to activate',
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'default' => '',
      ),
      'firstseen' => array(
      ],
      'firstseen' => [
        'description' => 'First seen as an ISO formatted date',
        'type' => 'varchar',
        'mysql_type' => 'DATE',
        'pgsql_type' => 'DATE',
        'not null' => TRUE,
        'default' => '1970-01-01',
      ),
      'lastseen' => array(
      ],
      'lastseen' => [
        'description' => 'Last seen as an ISO formatted date',
        'type' => 'varchar',
        'mysql_type' => 'DATE',
        'pgsql_type' => 'DATE',
        'not null' => TRUE,
        'default' => '1970-01-01',
      ),
      'blocked' => array(
      ],
      'blocked' => [
        'description' => '0 = in good standing; 1 = blocked',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('auid'),
  );
      ],
    ],
    'primary key' => ['auid'],
  ];

  $schema['anonymous_publishing_bots'] = array(
  $schema['anonymous_publishing_bots'] = [
    'description' => 'Counts visits by bots based upon IP-address.',
    'fields' => array(
      'id' => array(
    'fields' => [
      'id' => [
        'description' => 'primary index',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'ip' => array(
      ],
      'ip' => [
        'description' => 'IP-address of bot',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'visits' => array(
      ],
      'visits' => [
        'description' => 'Number of visits',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'first' => array(
      ],
      'first' => [
        'description' => 'First seen as a Unix timestamp',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'last' => array(
      ],
      'last' => [
        'description' => 'Last seen as a Unix timestamp',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'ip' => array('ip'),
    ),
    'primary key' => array('id'),
  );
      ],
    ],
    'unique keys' => [
      'ip' => ['ip'],
    ],
    'primary key' => ['id'],
  ];

  return $schema;
}
+86 −88
Original line number Diff line number Diff line
@@ -7,9 +7,7 @@
 * Common functions shared by more that one submodule in the project.
 */

use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;

/**
 * Implements hook_help().
+83 −90
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ use Drupal\comment\CommentInterface;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\Email;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Site\Settings;
@@ -22,14 +21,14 @@ use Drupal\node\NodeInterface;
function anonymous_publishing_cl_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.anonymous_publishing_cl':
      $output = t('<p>This submodule of <strong>Anonymous Publishing</strong> lets users publish content without first registering an account at the site, but in a manner that affords some protection against spam.</p><p>Just enabling the module does nothing. You also need to enable anonymous publishing for at least one node type.  If you want visitors to be able to create content without registering, you also need to grant the the anonymous user role the permission to “Create new content” for at least one node type .  To do this, go to <a title="Set permissions for anonymous." <a href="@url">Administration » People » Permissions</a> for the node module.</p>', array('@url' => Url::fromRoute('user.admin_permissions')->toString()));
      $output = t('<p>This submodule of <strong>Anonymous Publishing</strong> lets users publish content without first registering an account at the site, but in a manner that affords some protection against spam.</p><p>Just enabling the module does nothing. You also need to enable anonymous publishing for at least one node type.  If you want visitors to be able to create content without registering, you also need to grant the the anonymous user role the permission to “Create new content” for at least one node type .  To do this, go to <a title="Set permissions for anonymous." <a href="@url">Administration » People » Permissions</a> for the node module.</p>', ['@url' => Url::fromRoute('user.admin_permissions')->toString()]);
      $output .= _anonymous_publishing_ah_hint();
      return $output;
  }
}


/** --------------------------------------------------------------------------
/**
 * --------------------------------------------------------------------------
 * Hook definitions
 * -------------------------------------------------------------------------- */

@@ -59,7 +58,7 @@ function anonymous_publishing_cl_preprocess_node(&$variables) {

        $alias = \Drupal::database()
          ->select('anonymous_publishing_emails')
          ->fields('anonymous_publishing_emails', array('alias'))
          ->fields('anonymous_publishing_emails', ['alias'])
          ->condition('email', $result['email'])
          ->execute()
          ->fetchField();
@@ -99,7 +98,7 @@ function anonymous_publishing_cl_preprocess_comment(&$variables) {

        $alias = \Drupal::database()
          ->select('anonymous_publishing_emails')
          ->fields('anonymous_publishing_emails', array('alias'))
          ->fields('anonymous_publishing_emails', ['alias'])
          ->condition('email', $result['email'])
          ->execute()
          ->fetchField();
@@ -107,17 +106,16 @@ function anonymous_publishing_cl_preprocess_comment(&$variables) {
        if (!empty($alias)) {
          $variables['author'] = $alias;
          $variables['author'] .= $result['verified'] ? '' : ' (' . t('not verified') . ')';
          $variables['submitted'] = t('Submitted by @username on @datetime', array(
          $variables['submitted'] = t('Submitted by @username on @datetime', [
            '@username' => $variables['author'],
            '@datetime' => $variables['created']
          ));
            '@datetime' => $variables['created'],
          ]);
        }
      }
    }
  }
}


/**
 * Entity form builder to add the anonymous publishing informations to the entity.
 */
@@ -190,36 +188,36 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn

    // Create the anonymous publishing options.
    // Node author information for administrators.
    $form['anonymous_publishing'] = array(
    $form['anonymous_publishing'] = [
      '#type' => 'details',
      '#title' => t('Anonymous Publishing'),
      '#group' => 'advanced',
      '#open' => TRUE,
      '#attributes' => array(
        'class' => array('form-anonymous-publishing'),
      ),
      '#attached' => array(
        'library' => array('node/drupal.node'),
      ),
      '#attributes' => [
        'class' => ['form-anonymous-publishing'],
      ],
      '#attached' => [
        'library' => ['node/drupal.node'],
      ],
      '#optional' => FALSE,
    );
    ];

    $options = $settings->get('general_options');
    $aliasopt = $settings->get('user_alias');

    $selfactmsg = $options['sactivate'] ? '' : ' ' . t('and the content is approved by by an administrator');
    $verifymsg = t('Your content will not appear on this site until your email is verified@selfactmsg.', array('@selfactmsg' => $selfactmsg));
    $verifymsg = t('Your content will not appear on this site until your email is verified@selfactmsg.', ['@selfactmsg' => $selfactmsg]);
    $verifymsg .= ' <b>' . t('Your email address will not be shown publicly.') . '</b>';

    $form['anonymous_publishing']['email'] = array(
    $form['anonymous_publishing']['email'] = [
      '#type' => 'email',
      '#title' => t('Verification email address:'),
      '#description' => $verifymsg,
      '#size' => 60,
      '#maxlength' => Email::EMAIL_MAX_LENGTH,
      '#required' => TRUE,
      '#parents' => array('anonymous_publishing_email'),
    );
      '#parents' => ['anonymous_publishing_email'],
    ];

    // If user can choose an alias, give him UI for this config.
    if ($aliasopt == 'byline') {
@@ -227,14 +225,14 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
      if (!empty($bylineguide)) {
        $bylineguide .= ' ';
      }
      $form['anonymous_publishing']['alias'] = array(
      $form['anonymous_publishing']['alias'] = [
        '#type' => 'textfield',
        '#title' => t('Byline:'),
        '#description' => t('@bylineguide<em>All</em> posts associated with this email address will carry this byline.  Leave blank if you want to keep the byline already associated with this email address.', array('@bylineguide' => $bylineguide)),
        '#description' => t('@bylineguide<em>All</em> posts associated with this email address will carry this byline.  Leave blank if you want to keep the byline already associated with this email address.', ['@bylineguide' => $bylineguide]),
        '#size' => 30,
        '#maxlength' => Email::EMAIL_MAX_LENGTH,
        '#parents' => array('anonymous_publishing_alias'),
      );
        '#parents' => ['anonymous_publishing_alias'],
      ];
    }

    // Set default_value non-empty to simulate 'bot.
@@ -242,15 +240,15 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
    // It shall never be seen by humans. 'Bots look for English words like
    // "email", so it is better to leave this untranslated to make sure the
    // 'bot bites the bait.
    $form['email_confirm_field'] = array(
    $form['email_confirm_field'] = [
      '#type' => 'email',
      '#title' => 'Enter your email address (not!):',
      '#default_value' => '',
      '#size' => 20,
      '#description' => t('This field should not even be visible to humans.'),
      '#post_render' => array('_anonymous_publishing_honeyfield_cl_post_render'),
      '#parents' => array('anonymous_publishing_email_confirm_field'),
    );
      '#post_render' => ['_anonymous_publishing_honeyfield_cl_post_render'],
      '#parents' => ['anonymous_publishing_email_confirm_field'],
    ];

    // Add some CSS to actually hide the honeypot.
    $form['#attached']['library'][] = 'anonymous_publishing/anonymous_publishing.library';
@@ -276,8 +274,8 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
    $cid = $form['cid']['#value'];
    $amail = \Drupal::database()
      ->select('anonymous_publishing', 'a')
      ->fields('a', array('email'))
      ->where('cid = :cid', array(':cid' => $cid))
      ->fields('a', ['email'])
      ->where('cid = :cid', [':cid' => $cid])
      ->execute()
      ->fetchField();
  }
@@ -285,19 +283,19 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
    $nid = $form['nid']['#value'];
    $amail = \Drupal::database()
      ->select('anonymous_publishing', 'a')
      ->fields('a', array('email'))
      ->where('nid = :nid', array(':nid' => $nid))
      ->fields('a', ['email'])
      ->where('nid = :nid', [':nid' => $nid])
      ->execute()
      ->fetchField();
  }

  // Show it if it exists and the user is allowed to see this form.
  if (!empty($amail)) {
    $form['email_confirm_field'] = array(
    $form['email_confirm_field'] = [
      '#type' => 'markup',
      '#markup' => t('<div class="anon-cl-email"><strong>Posted using the email-address</strong> “@email”.</div>', array('@email' => $amail)),
      '#markup' => t('<div class="anon-cl-email"><strong>Posted using the email-address</strong> “@email”.</div>', ['@email' => $amail]),
      '#weight' => -5,
    );
    ];
  }

  // Add our custom data in the node.
@@ -318,18 +316,15 @@ function anonymous_publishing_cl_node_form_submit($form, FormStateInterface &$fo
  $node = $form_state->getFormObject()->getEntity();
  // $node->anonymous_publishing_email = $activation_email;
  // $node->anonymous_publishing_alias = $activation_alias;

  // No need to manage insertion of this content.
  if (\Drupal::currentUser()->isAuthenticated() || !isset($activation_email)) {
    return;
  }

  // Get the anonymous user alias strategy.


  // If the node is published already, then we can bypass email validation.
  if ($node->isPublished()) {
    \Drupal::database()->insert('anonymous_publishing')->fields(array(
    \Drupal::database()->insert('anonymous_publishing')->fields([
      'nid' => $node->id(),
      'cid' => 0,
      'akey' => NULL,
@@ -337,13 +332,13 @@ function anonymous_publishing_cl_node_form_submit($form, FormStateInterface &$fo
      'alias' => $activation_alias,
      'email' => $activation_email,
      'ip' => \Drupal::request()->getClientIp(),
      ))->execute();
    ])->execute();

    $aliasopt = $settings->get('user_alias');
    if (!empty($activation_alias) && $aliasopt == 'byline') {
      \Drupal::database()
        ->update('anonymous_publishing_emails')
        ->fields(array('alias' => $activation_alias))
        ->fields(['alias' => $activation_alias])
        ->condition('email', $activation_email, '=')
        ->execute();
    }
@@ -361,7 +356,7 @@ function anonymous_publishing_cl_node_form_submit($form, FormStateInterface &$fo
  // Build a unique key for this insertion request.
  $at = $options['sactivate'] ? 'A' : 'V';
  $akey = $at . Crypt::hmacBase64(mt_rand(), Settings::getHashSalt());
  \Drupal::database()->insert('anonymous_publishing')->fields(array(
  \Drupal::database()->insert('anonymous_publishing')->fields([
    'nid' => $node->id(),
    'cid' => 0,
    'akey' => $akey,
@@ -369,7 +364,7 @@ function anonymous_publishing_cl_node_form_submit($form, FormStateInterface &$fo
    'alias' => $activation_alias,
    'email' => $activation_email,
    'ip' => \Drupal::request()->getClientIp(),
    ))->execute();
  ])->execute();

  // Build and send the confirmation mail for this particular insertion.
  \Drupal::service('anonymous_publishing_cl.service')
@@ -406,7 +401,6 @@ function anonymous_publishing_cl_comment_form_submit($form, &$form_state) {
  $comment = $form_state->getFormObject()->getEntity();
  // $comment->anonymous_publishing_email = $activation_email;
  // $comment->anonymous_publishing_alias = $activation_alias;

  // No need to manage insertion of this content.
  if (\Drupal::currentUser()->isAuthenticated() || !isset($activation_email)) {
    return;
@@ -417,9 +411,9 @@ function anonymous_publishing_cl_comment_form_submit($form, &$form_state) {
  if (!empty($activation_alias) && $aliasopt == 'byline') {
    $comment->setAuthorName($activation_alias);
    \Drupal::database()->update('anonymous_publishing_emails')
      ->fields(array(
      ->fields([
        'alias' => $activation_alias,
      ))
      ])
      ->condition('email', $activation_email)
      ->execute();
  }
@@ -434,7 +428,7 @@ function anonymous_publishing_cl_comment_form_submit($form, &$form_state) {
    }

    \Drupal::database()->insert('anonymous_publishing')
      ->fields('anonymous_publishing', array(
      ->fields('anonymous_publishing', [
        'nid' => $comment->getCommentedEntityId(),
        'cid' => $comment->id(),
        'akey' => NULL,
@@ -442,7 +436,7 @@ function anonymous_publishing_cl_comment_form_submit($form, &$form_state) {
        'alias' => 'BOGUS COMMENT',
        'email' => $activation_email,
        'ip' => \Drupal::request()->getClientIp(),
      ))
      ])
      ->execute();
    return;
  }
@@ -458,7 +452,7 @@ function anonymous_publishing_cl_comment_form_submit($form, &$form_state) {
  // Build a unique key for this insertion request.
  $at = $options['sactivate'] ? 'A' : 'V';
  $akey = $at . Crypt::hmacBase64(mt_rand(), Settings::getHashSalt());
  \Drupal::database()->insert('anonymous_publishing')->fields(array(
  \Drupal::database()->insert('anonymous_publishing')->fields([
    'nid' => $comment->getCommentedEntityId(),
    'cid' => $comment->id(),
    'akey' => $akey,
@@ -466,7 +460,7 @@ function anonymous_publishing_cl_comment_form_submit($form, &$form_state) {
    'alias' => $activation_alias,
    'email' => $activation_email,
    'ip' => \Drupal::request()->getClientIp(),
  ))->execute();
  ])->execute();

  // Build and send the confirmation mail for this particular insertion.
  \Drupal::service('anonymous_publishing_cl.service')
@@ -527,11 +521,11 @@ function anonymous_publishing_cl_comment_presave(CommentInterface $comment) {

      $result = \Drupal::database()
        ->select('anonymous_publishing_emails')
        ->fields('anonymous_publishing_emails', array(
        ->fields('anonymous_publishing_emails', [
          'email',
          'ipaddress',
          'blocked'
        ))
          'blocked',
        ])
        ->condition('email', $comment->anonymous_publishing_email)
        ->execute()
        ->fetchAssoc();
@@ -549,7 +543,7 @@ function anonymous_publishing_cl_comment_presave(CommentInterface $comment) {

    if ($needs_confirmation) {
      $comment->set('status', CommentInterface::NOT_PUBLISHED);
      \Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.', array('@email' => $comment->anonymous_publishing_email)));
      \Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.', ['@email' => $comment->anonymous_publishing_email]));
    }
  }
}
@@ -571,11 +565,11 @@ function anonymous_publishing_cl_node_presave(NodeInterface $node) {
    if ($verification_persistency != 'each_post') {
      $result = \Drupal::database()
        ->select('anonymous_publishing_emails')
        ->fields('anonymous_publishing_emails', array(
        ->fields('anonymous_publishing_emails', [
          'email',
          'ipaddress',
          'blocked'
        ))
          'blocked',
        ])
        ->condition('email', $node->anonymous_publishing_email)
        ->execute()
        ->fetchAssoc();
@@ -593,7 +587,7 @@ function anonymous_publishing_cl_node_presave(NodeInterface $node) {

    if ($needs_confirmation) {
      $node->set('status', NODE_NOT_PUBLISHED);
      \Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.', array('@email' => $node->anonymous_publishing_email)));
      \Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.', ['@email' => $node->anonymous_publishing_email]));
    }
  }
}
@@ -605,7 +599,7 @@ function anonymous_publishing_cl_entity_delete(EntityInterface $entity) {
  $apid = NULL;

  $apid = \Drupal::database()->select('anonymous_publishing')
    ->fields('anonymous_publishing', array('apid'))
    ->fields('anonymous_publishing', ['apid'])
    ->condition('nid', $entity->id())
    ->execute()
    ->fetchField();
@@ -617,7 +611,6 @@ function anonymous_publishing_cl_entity_delete(EntityInterface $entity) {
  }
}


/**
 * --------------------------------
 * HELPER METHODS/
+11 −7
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ class AnonymousPublishingController extends ControllerBase {
    );
  }

  /**
   *
   */
  public function verifyAnonymousPost() {

    $akey = \Drupal::request()->query->get('akey', NULL);
@@ -65,7 +68,6 @@ class AnonymousPublishingController extends ControllerBase {
    $email = $result['email'];
    $at = $akey[0];


    if ($akey != $rkey) {
      $this->messenger->addError(t('Invalid activation key.'));
      return $this->redirect('<front>');
@@ -87,17 +89,18 @@ class AnonymousPublishingController extends ControllerBase {
        // Hand-moderate if already blocked.
        $at = 'V';
      }
    } else {
    }
    else {
      $ip = \Drupal::request()->getClientIp();
      $now = date('Y-m-d');
      $auid = \Drupal::database()
        ->insert('anonymous_publishing_emails')
        ->fields(array(
        ->fields([
          'email' => $email,
          'ipaddress' => $ip,
          'firstseen' => $now,
          'lastseen' => $now,
        ))
        ])
        ->execute();
      $aliasopt = \Drupal::config('anonymous_publishing_cl.settings')->get('user_alias');

@@ -151,9 +154,10 @@ class AnonymousPublishingController extends ControllerBase {
        $node->save();
        $this->messenger->addMessage($vfymsg . ' ' . t('your content has been published and will appear on the site soon.'));
        if ($node->access('view')) {
          return $this->redirect($node->toUrl()->getRouteName(), array('node' => $nid));
          return $this->redirect($node->toUrl()->getRouteName(), ['node' => $nid]);
        }
      }
    }
  }

}
+46 −40

File changed.

Preview size limit exceeded, changes collapsed.

Loading