diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-10-13 12:24:43 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2017-09-04 11:16:53 -0700 |
commit | 326a23aded279dedc8a4e6de64618f0fbee17bac (patch) | |
tree | a3444296e388ac65709dfac25490828fc8f433f1 /htdocs/src | |
parent | 94f12b0a85feb8d8e6effb89021bf79a82174fce (diff) |
Changed the moderator schedule table to a view. Finished the exception iterator. Modified Post to only notify the next moderator. Need to add exception adding/removal.
Diffstat (limited to 'htdocs/src')
-rw-r--r-- | htdocs/src/ModerationExceptions.inc.php | 23 | ||||
-rw-r--r-- | htdocs/src/ModerationSchedule.inc.php | 5 | ||||
-rw-r--r-- | htdocs/src/Post.inc.php | 11 |
3 files changed, 29 insertions, 10 deletions
diff --git a/htdocs/src/ModerationExceptions.inc.php b/htdocs/src/ModerationExceptions.inc.php index 06d98f8..2cf4c9d 100644 --- a/htdocs/src/ModerationExceptions.inc.php +++ b/htdocs/src/ModerationExceptions.inc.php @@ -25,10 +25,30 @@ class ModerationExceptions implements Iterator { $this->expos = 0; } + /** + * Return the current exception row. + */ public function current() { - return User::getById($this->exceptions[$this->expos]['user_id']); + return $this->exceptions[$this->expos]; + } + + /** + * Return the User object for the substitute. + */ + public function getSubstitute() { + return User::getById($this->exceptions[$this->expos]['substitute']); } + /** + * Return the user object for the person who the exception is fore. + */ + public function getUser() { + return User::getById($this->exceptions[$this->expos]['user_id']); + } + + /** + * Return the unix timestamp of the first day of the exception week. + */ public function key() { $year = $this->exceptions[$this->expos]['year']; $week = $this->exceptions[$this->expos]['week'] + 0; @@ -62,4 +82,3 @@ class ModerationExceptions implements Iterator { } ?> - diff --git a/htdocs/src/ModerationSchedule.inc.php b/htdocs/src/ModerationSchedule.inc.php index 4c094e4..6cb1785 100644 --- a/htdocs/src/ModerationSchedule.inc.php +++ b/htdocs/src/ModerationSchedule.inc.php @@ -82,6 +82,7 @@ class ModerationSchedule implements Iterator { $this->moderator = User::getById($this->moderators[$modpos]['user_id']); // Check for exceptions + // TODO: Refactor this exception code to use the ModerationException iterator. if (count($this->exceptions) > 0) { // Skip exceptions prior to the current() date. while ( @@ -101,10 +102,10 @@ class ModerationSchedule implements Iterator { while($this->exceptions[$this->expos]['year'] == $this->year and $this->exceptions[$this->expos]['week'] == $this->week) { - if ($this->exceptions[$i]['user_id'] == $this->moderator->getId()) { + if ($this->exceptions[$this->expos]['user_id'] == $this->moderator->getId()) { // Yes, return the replacement $this->exceptionfor = $this->moderator; - $this->moderator = User::getById($this->exceptions[$this->expos]['user_id']); + $this->moderator = User::getById($this->exceptions[$this->expos]['substitute']); break; } diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php index eaad6b3..c99f938 100644 --- a/htdocs/src/Post.inc.php +++ b/htdocs/src/Post.inc.php @@ -414,8 +414,7 @@ class Post { } public function notifyModerators() { - $ui = new UserIterator(); - $ui->filterNotify(true); + $ui = new ModerationSchedule(); $ui->query(); $url = buildUrl('postings/' . $this->getId() .'.html?moderate'); @@ -425,10 +424,10 @@ class Post { $email->appendMessage("A new posting is awaiting moderation.\nYou can view the post at $url"); if ($ui->valid()) { - foreach($ui as $user) { - $email->setTo($user->getEmail()); - $email->send(); - } + $user = $ui->current(); + + $email->setTo($user->getEmail()); + $email->send(); } } } |