/** * @inheritdoc */ public function isValid($data, $field = '', array $extra = []) { $date = $this->repository->getLastDateFromIp($extra['ip']); $floodTime = !empty($date) ? $this->date->timestamp($date, true) + 30 : 0; $time = $this->date->timestamp('now', true); return $floodTime <= $time; }
/** * @return array */ public function fetchFeedItems() { $items = []; $results = $this->filesRepository->getAll($this->date->getCurrentDateTime(), 10); $cResults = count($results); for ($i = 0; $i < $cResults; ++$i) { $items[] = ['title' => $results[$i]['title'], 'date' => $this->date->timestamp($results[$i]['start']), 'description' => $this->formatter->shortenEntry($results[$i]['text'], 300, 0), 'link' => $this->router->route('files/index/details/id_' . $results[$i]['id'], true)]; } return $items; }
/** * @return array */ public function execute() { $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']); $polls = $this->pollRepository->getAll($this->date->getCurrentDateTime()); $cPolls = count($polls); for ($i = 0; $i < $cPolls; ++$i) { if ($this->hasAlreadyVoted($polls[$i]['id']) || $polls[$i]['start'] !== $polls[$i]['end'] && $this->date->timestamp($polls[$i]['end']) <= $this->date->timestamp()) { $polls[$i]['link'] = 'result'; } else { $polls[$i]['link'] = 'vote'; } } return ['polls' => $polls]; }