From 94f12b0a85feb8d8e6effb89021bf79a82174fce Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 6 Oct 2011 15:02:08 -0700 Subject: Forgot to add class in last commit. --- htdocs/src/ModerationExceptions.inc.php | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 htdocs/src/ModerationExceptions.inc.php (limited to 'htdocs') diff --git a/htdocs/src/ModerationExceptions.inc.php b/htdocs/src/ModerationExceptions.inc.php new file mode 100644 index 0000000..06d98f8 --- /dev/null +++ b/htdocs/src/ModerationExceptions.inc.php @@ -0,0 +1,65 @@ + + * + */ + +require_once "base.inc.php"; + +class ModerationExceptions implements Iterator { + private $exceptions; + + private $expos; + + public function __construct() { + $this->exceptions = array(); + } + + // Iterator methods + + public function rewind() { + $this->expos = 0; + } + + public function current() { + return User::getById($this->exceptions[$this->expos]['user_id']); + } + + public function key() { + $year = $this->exceptions[$this->expos]['year']; + $week = $this->exceptions[$this->expos]['week'] + 0; + + return strtotime($year . 'W' . + ($week < 10 ? '0' : '') . $week); + } + + public function next() { + $this->expos++; + } + + public function valid() { + return $this->expos < count($this->exceptions); + } + + public function query() { + $db = getDatabase(); + + // Get the exceptions + $year = date('o'); + $week = date('W'); + + $query = "SELECT * FROM moderator_exceptions" + . " WHERE year >= $year AND week >= $week" + . " ORDER BY year, week"; + $this->exceptions = $db->fetchAssocRows($query); + + $this->rewind(); + } +} + +?> + -- cgit v1.2.3