summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htdocs/new-post.php39
-rw-r--r--htdocs/src/Post.inc.php65
-rw-r--r--htdocs/src/config.inc.php2
3 files changed, 81 insertions, 25 deletions
diff --git a/htdocs/new-post.php b/htdocs/new-post.php
index 4181b07..ea7c0b2 100644
--- a/htdocs/new-post.php
+++ b/htdocs/new-post.php
@@ -155,7 +155,12 @@ function finish_post() {
$post->setName($values['title']);
$post->setDescription($values['description']);
- return true;
+ if ($post->save()) {
+ return true;
+
+ } else {
+ $error .= 'An internal error has occured.';
+ }
}
handle_post($error);
@@ -165,17 +170,23 @@ function finish_post() {
function handle_images() {
$post = $_SESSION['newpost'];
- // Save Post
- if (!$post->save()) {
- $error .= "An internal error has occured.";
- }
-
// Display image form
+ echo "<p>You may upload up to four images with your post.</p>";
+ form_start('finish');
+
+ for ($i = 1; $i <= 4; $i++) {
+ echo "<p><label>Image $i: "
+ . "<input type=\"file\" name=\"images[]\" /></label></p>";
+ }
+
+ form_end();
}
function finish_images() {
+ $post = $_SESSION['newpost'];
+ return true;
}
function handle_finish() {
@@ -185,14 +196,13 @@ function handle_finish() {
$post->sendValidation();
// Display confirmation message
- // TODO: Revise wording of confirmation message.
- echo "<p>Your posting is awaiting email verification</p>";
+ echo "<p>Your posting is almost complete. You must verify your email address by visiting the link we have emailed you, then your posting will be reviewed by our moderation team.</p>";
}
function form_start($stage) {
echo "<form action=\"". $GLOBALS['CONFIG']['urlroot'] ."/new-post.php?stage=$stage\""
- ." method=\"post\">";
+ ." method=\"post\" enctype=\"multipart/form-data\">";
}
function form_end() {
@@ -211,16 +221,17 @@ function render_form($error="") {
echo "<div class=\"errorbox\">$error</div>";
}
- echo "<p><label>Title: <input type=\"text\" name=\"title\" value=\"${values[title]}\" /></label></p>";
+ echo "<p><label>Title: <input type=\"text\" name=\"title\" value=\"${_POST[title]}\" /></label></p>";
echo "<p><label for=\"desc\">Description:</label></p>";
echo "<p><textarea name=\"description\" id=\"desc\" rows=\"10\""
- . " cols=\"80\">${values[description]}</textarea></p>";
+ . " cols=\"80\">${_POST[description]}</textarea></p>";
- echo "<p><label>Email Address: <input type=\"text\" name=\"email\" value=\"${values[email]}\" />"
+ echo "<p><label>Email Address: <input type=\"text\" name=\"email\" value=\"${_POST[email]}\" />"
. "</label>";
- echo " <label>Confirm Email: <input type=\"text\" name=\"email2\" value=\"${values[email2]}\" />"
- . "</label></p>";
+ echo " <label>Confirm Email: <input type=\"text\" name=\"email2\" value=\"${_POST[email2]}\" />"
+ . "</label></p>"
+ . "<p>Your email address will only be visible to our moderators.</p>";
}
diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php
index 8c936d9..6dec593 100644
--- a/htdocs/src/Post.inc.php
+++ b/htdocs/src/Post.inc.php
@@ -68,7 +68,13 @@ class Post {
// Save or create?
if ($this->indatabase) {
- return $db->update('post', $info, "WHERE `id`='". $this->getId() ."'");
+ try {
+ $db->update('post', $info, "WHERE `id`='". $this->getId() ."'");
+ return true;
+
+ } catch (Cif_Database_Exception $e) {
+ return false;
+ }
} else {
// Creating... set special fields.
@@ -76,15 +82,20 @@ class Post {
$info['secretid'] = uniqid();
$info['created'] = date('Y-m-d H:i:s');
- $ret = $db->insert('post', $info);
-
- if ($ret) {
- $this->info['id'] = $ret;
- $this->info['stage'] = 'verification';
- $this->info['secretid'] = $info['secretid'];
- }
+ try {
+ $ret = $db->insert('post', $info);
- return $ret;
+ if ($ret) {
+ $this->info['id'] = $ret;
+ $this->info['stage'] = 'verification';
+ $this->info['secretid'] = $info['secretid'];
+ }
+
+ return true;
+
+ } catch (Cif_Database_Exception $e) {
+ return false;
+ }
}
}
@@ -119,6 +130,7 @@ class Post {
public function approve() {
if ($this->getStage() == 'moderation') {
$this->info['stage'] = 'approved';
+ $this->sendAcceptance();
}
}
@@ -128,8 +140,10 @@ class Post {
}
}
- public function reject() {
+ public function reject($message='') {
$this->info['stage'] = 'rejected';
+
+ $this->sendRejection($message);
}
public function getCreated() {
@@ -184,6 +198,37 @@ class Post {
$email->send();
}
+
+ public function sendAcceptance() {
+ $email = new Email($this->getEmail());
+
+ $email->setSubject($GLOBAL['CONFIG']['sitetitle'] . " Posting Approved");
+
+ $email->appendMessage("Your posting titled ". $this->getName()
+ ." has been approved by our moderation team.\n\n");
+
+ $url = $GLOBALS['CONFIG']['urlroot'] . '/postings/'
+ . $this->getId() .'.html';
+ $email->appendMessage("You can view your post at $url.");
+
+ $email->send();
+ }
+
+ public function sendRejection($message='') {
+ $email = new Email($this->getEmail());
+
+ $email->setSubject($GLOBAL['CONFIG']['sitetitle'] . " Posting Rejected");
+
+ $email->appendMessage("Your posting titled ". $this->getName()
+ ." has been rejected by our moderation team.\n\n");
+
+ if ($message != '') {
+ $email->appendMessage("The moderator left the following comment\n");
+ $email->appendMessage($message);
+ }
+
+ $email->send();
+ }
}
?>
diff --git a/htdocs/src/config.inc.php b/htdocs/src/config.inc.php
index f1308b6..211a798 100644
--- a/htdocs/src/config.inc.php
+++ b/htdocs/src/config.inc.php
@@ -20,7 +20,7 @@ $CONFIG = array(
'email_from' => 'community@myfoursquarechurch.com',
'urlroot' => 'http://localhost/~jesse/p4s/community/htdocs',
- 'root' => '/Users/jesse/Development/P4Square/community/htdocs',
+ 'root' => '/home/jesse/Development/p4square/community/htdocs',
'debug' => true,
'production' => false,