summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--design/database.sql14
-rw-r--r--htdocs/css/main.css10
-rw-r--r--htdocs/moderate/admin.css5
-rw-r--r--htdocs/moderate/schedule/index.php25
-rw-r--r--htdocs/moderate/src/header.inc.php1
-rw-r--r--htdocs/src/ModerationExceptions.inc.php23
-rw-r--r--htdocs/src/ModerationSchedule.inc.php5
-rw-r--r--htdocs/src/Post.inc.php11
8 files changed, 70 insertions, 24 deletions
diff --git a/design/database.sql b/design/database.sql
index 60b7006..b13fa39 100644
--- a/design/database.sql
+++ b/design/database.sql
@@ -94,12 +94,16 @@ CREATE TABLE page (
UNIQUE KEY(url)
);
-CREATE TABLE moderator_schedule (
- position TINYINT UNSIGNED NOT NULL,
- user_id INTEGER UNSIGNED NOT NULL,
+-- CREATE TABLE moderator_schedule (
+-- position TINYINT UNSIGNED NOT NULL,
+-- user_id INTEGER UNSIGNED NOT NULL,
+--
+-- PRIMARY KEY(position, user_id)
+-- );
- PRIMARY KEY(position, user_id)
-);
+CREATE VIEW moderator_schedule AS
+ SELECT id AS position, id AS user_id FROM user
+ WHERE notify=1;
CREATE TABLE moderator_exceptions (
year INTEGER UNSIGNED NOT NULL,
diff --git a/htdocs/css/main.css b/htdocs/css/main.css
index 756d312..831ee18 100644
--- a/htdocs/css/main.css
+++ b/htdocs/css/main.css
@@ -6,6 +6,11 @@ body {
font-family: Helvetica;
}
+h3 {
+ margin-bottom: 0em;
+ margin-top: 1.75em;
+}
+
#nav, #content, #footer, #buttonblock {
margin: 0 auto 0 auto;
width: 660px;
@@ -44,7 +49,6 @@ body {
background: url('../images/headerbg.jpg') repeat-x center top;
text-align: center;
height: 191px;
- padding-top: 10px;
}
#about {
@@ -143,3 +147,7 @@ a, a:visited {
.errorbox p {
margin: 0;
}
+
+.nomargin {
+ margin: .5em 0 .5em 0;
+}
diff --git a/htdocs/moderate/admin.css b/htdocs/moderate/admin.css
index 65a5a7f..fbc82a6 100644
--- a/htdocs/moderate/admin.css
+++ b/htdocs/moderate/admin.css
@@ -50,6 +50,11 @@ h1 {
width: 5em;
}
+.userrow .remove {
+ width: 5em;
+ margin-left: 2em;
+}
+
input[type=text] {
width: 20em;
}
diff --git a/htdocs/moderate/schedule/index.php b/htdocs/moderate/schedule/index.php
index 9015350..f179c23 100644
--- a/htdocs/moderate/schedule/index.php
+++ b/htdocs/moderate/schedule/index.php
@@ -40,7 +40,7 @@ for ($i = 0; $i < $ui->getNumberOfModerators(); $i++, $ui->next()) {
}
echo "<h3>Exceptions</h3>";
-echo "<p><a href=\"exception.php\">New Exception</a></p>";
+echo "<p class=\"nomargin\"><a href=\"editor.php\">New Exception</a></p>";
// List out exceptions in order.
$exceptions = new ModerationExceptions();
@@ -48,20 +48,29 @@ $exceptions->query();
echo "<div class=\"userrow header\">"
. "<span class=\"name\">Name</span>"
- . " <span class=\"email\">Email</span>"
- . " <span class=\"admin\">Exception Week</span>"
+ . "<span class=\"name\">Substitute</span>"
+ . " <span class=\"admin\">Week</span>"
. " </div>";
while ($exceptions->valid()) {
- $user = $exceptions->current();
+ $user = $exceptions->getUser();
+ $substitute = $exceptions->getSubstitute();
+
+ $remove = "";
+
+ if ($_SESSION['currentUser']->getId() == $user->getId()) {
+ $remove = "<a href=\"remove.php?uid=" . $user->getId() ."&time=". $exceptions->key() ."\">remove</a>";
+ }
printf("<div class=\"userrow\">"
. "<span class=\"name\">%s</span>"
- . " <span class=\"email\"><a href=\"mailto:%s\">%s</a></span>"
- . " <span class=\"admin\">%s</span></div>",
+ . "<span class=\"name\">%s</span>"
+ . " <span class=\"admin\">%s</span>"
+ . " <span class=\"remove\">%s</span></div>",
$user->getName(),
- $user->getEmail(), $user->getEmail(),
- date('F j', $exceptions->key())
+ $substitute->getName(),
+ date('F j', $exceptions->key()),
+ $remove
);
diff --git a/htdocs/moderate/src/header.inc.php b/htdocs/moderate/src/header.inc.php
index f0abbe1..6b7f135 100644
--- a/htdocs/moderate/src/header.inc.php
+++ b/htdocs/moderate/src/header.inc.php
@@ -53,6 +53,7 @@ if (isset($_GET['logout'])) {
<div id="modnav">
<ul>
<li><a href="<?= buildUrl('moderate/') ?>">Moderate Posts</a></li>
+ <li><a href="<?= buildUrl('moderate/schedule/') ?>">Schedule</a></li>
<?php
// Admin Navigation
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();
}
}
}