public function StatisticsPopularBlock::access

Overrides \Drupal\block\BlockBase::access().

Overrides BlockBase::access

File

drupal/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php, line 60
Contains \Drupal\statistics\Plugin\Block\StatisticsPopularBlock.

Class

StatisticsPopularBlock
Provides a 'Popular content' block.

Namespace

Drupal\statistics\Plugin\Block

Code

public function access() {
  if (user_access('access content')) {
    $daytop = $this->configuration['top_day_num'];
    if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, t("Today's:")))) {
      return FALSE;
    }
    $alltimetop = $this->configuration['top_all_num'];
    if (!$alltimetop || !($result = statistics_title_list('totalcount', $alltimetop)) || !($this->all_time_list = node_title_list($result, t('All time:')))) {
      return FALSE;
    }
    $lasttop = $this->configuration['top_last_num'];
    if (!$lasttop || !($result = statistics_title_list('timestamp', $lasttop)) || !($this->last_list = node_title_list($result, t('Last viewed:')))) {
      return FALSE;
    }
    return TRUE;
  }
  return FALSE;
}