diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-10-06 15:02:08 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2017-09-04 11:16:53 -0700 |
commit | 94f12b0a85feb8d8e6effb89021bf79a82174fce (patch) | |
tree | 2c327e87d5273a7042b0b76714caabb8dd0fc52c | |
parent | fa9a4f7eb160fc435dc34c493e6822d2fbb7e484 (diff) |
Forgot to add class in last commit.
-rw-r--r-- | htdocs/src/ModerationExceptions.inc.php | 65 |
1 files changed, 65 insertions, 0 deletions
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 @@ +<?php + +/* Foursquare Community Site + * + * Copyright (C) 2011 Foursquare Church. + * + * Developers: Jesse Morgan <jmorgan@foursquarestaff.com> + * + */ + +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(); + } +} + +?> + |