summaryrefslogtreecommitdiff
path: root/htdocs/src/PostIterator.inc.php
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-05-12 16:59:36 -0700
committerJesse Morgan <jesse@jesterpm.net ; true>2011-05-12 16:59:36 -0700
commitdd24e2c973a7979894971bdc38d904d2aecc7d5d (patch)
tree2f8474d22cbf29749219bd6dd543bb22b959465e /htdocs/src/PostIterator.inc.php
parente159ae5209a561043ceb89aa640b207df15181b7 (diff)
Well, you can see posts on the moderation panel now
Diffstat (limited to 'htdocs/src/PostIterator.inc.php')
-rw-r--r--htdocs/src/PostIterator.inc.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/htdocs/src/PostIterator.inc.php b/htdocs/src/PostIterator.inc.php
new file mode 100644
index 0000000..6106f23
--- /dev/null
+++ b/htdocs/src/PostIterator.inc.php
@@ -0,0 +1,67 @@
+<?php
+
+/* Foursquare Community Site
+ *
+ * Copyright (C) 2011 Foursquare Church.
+ *
+ * Developers: Jesse Morgan <jmorgan@foursquarestaff.com>
+ *
+ */
+
+require_once "base.inc.php";
+
+class PostIterator implements Iterator {
+ private $where;
+ private $rows;
+ private $position;
+
+ public function __construct() {
+ $this->where = array();
+ $this->rows = array();
+ $this->position = 0;
+ }
+
+ public function filterStage($stage) {
+ $this->where[] = "stage='$stage'";
+ }
+
+ public function filterSource($source) {
+ $this->where[] = "source_id='$source'";
+ }
+
+ public function rewind() {
+ $this->position = 0;
+ }
+
+ public function current() {
+ return new Post($this->rows[$this->position]);
+ }
+
+ public function key() {
+ return $this->rows[$this->position]['id'];
+ }
+
+ public function next() {
+ ++$this->position;
+ }
+
+ public function valid() {
+ return isset($this->rows[$this->position]);
+ }
+
+ public function query() {
+ $query = "SELECT * FROM post";
+
+ if (count($this->where) > 0) {
+ $where = join(' AND ', $this->where);
+ $query .= " WHERE $where";
+ }
+
+ $db = getDatabase();
+
+ $this->rows = $db->fetchAssocRows($query);
+ $this->position = 0;
+ }
+}
+
+?>