/** * Populate this object * @since Version 3.9.1 * @return \Railpage\Images\Competition */ private function load() { $query = "SELECT * FROM image_competition WHERE id = ?"; $row = $this->db->fetchRow($query, $this->id); $lookup = ["title", "description", "status", "slug", "theme"]; foreach ($lookup as $var) { $this->{$var} = $row[$var]; } $this->meta = json_decode($row['meta'], true); $lookup = array("voting_date_open" => "VotingDateOpen", "voting_date_close" => "VotingDateClose", "submissions_date_open" => "SubmissionsDateOpen", "submissions_date_close" => "SubmissionsDateClose"); foreach ($lookup as $db => $var) { if ($row[$db] != "0000-00-00 00:00:00") { $this->{$var} = new DateTime($row[$db]); } } if ($this->VotingDateClose->format("H:i:s") === "00:00:00") { $this->VotingDateClose = new DateTime($this->VotingDateClose->format("Y-m-d 23:59:59")); } if ($this->SubmissionsDateClose->format("H:i:s") === "00:00:00") { $this->SubmissionsDateClose = new DateTime($this->SubmissionsDateClose->format("Y-m-d 23:59:59")); } $this->setAuthor(UserFactory::CreateUser($row['author'])); $this->url = Utility\Url::makeCompetitionUrls($this); $this->notifySubmissionsOpen(); $this->notifyVotingOpen(); Utility\CompNotify::notifyWinner($this); Utility\CompetitionUtility::createNewsArticle_SubmissionsOpen($this); Utility\CompetitionUtility::createNewsArticle_VotingOpen($this); return $this; }