summaryrefslogtreecommitdiff
path: root/htdocs/src/ModerationExceptions.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'htdocs/src/ModerationExceptions.inc.php')
-rw-r--r--htdocs/src/ModerationExceptions.inc.php65
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();
+ }
+}
+
+?>
+