summaryrefslogtreecommitdiff
path: root/htdocs/src
diff options
context:
space:
mode:
authorjesse <jesse@jesterpm.net>2011-05-26 14:38:46 -0700
committerJesse Morgan <jesse@jesterpm.net ; true>2011-05-26 14:38:46 -0700
commite61cd160107544d2437827e7fda59450c4dca2c6 (patch)
treea389e105e6b233bfe0c5881204643241d2c25657 /htdocs/src
parent7f4dfecdbf2505b3fa91fb00f07d345ae3b3b456 (diff)
Added accept/reject emails. Still working on new post flow
Diffstat (limited to 'htdocs/src')
-rw-r--r--htdocs/src/Post.inc.php65
-rw-r--r--htdocs/src/config.inc.php2
2 files changed, 56 insertions, 11 deletions
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,