diff options
Diffstat (limited to 'htdocs/src')
-rw-r--r-- | htdocs/src/Post.inc.php | 34 | ||||
-rw-r--r-- | htdocs/src/PostIterator.inc.php | 10 | ||||
-rw-r--r-- | htdocs/src/base.inc.php | 5 | ||||
-rw-r--r-- | htdocs/src/config.inc.php.example | 1 |
4 files changed, 44 insertions, 6 deletions
diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php index c05cb7e..4a109d2 100644 --- a/htdocs/src/Post.inc.php +++ b/htdocs/src/Post.inc.php @@ -88,7 +88,7 @@ class Post { } else { // Creating... set special fields. $info['stage'] = 'verification'; - $info['secretid'] = uniqid(); + $info['secretid'] = uniqid('', true); $info['created'] = date('Y-m-d H:i:s'); try { @@ -108,6 +108,16 @@ class Post { } } + public function delete() { + $db = getDatabase(); + + // Delete Images + $db->delete('image', 'post_id=' . $this->getId()); + + // Delete Post + $db->delete('post', 'id=' . $this->getId()); + } + public function getId() { return $this->info['id']; } @@ -167,6 +177,10 @@ class Post { return $this->info['email']; } + public function getPublicEmail() { + return 'posting-' . $this->getId() .'@'. $GLOBALS['CONFIG']['emaildomain']; + } + public function setEmail($value) { $this->info['email'] = $value; } @@ -254,7 +268,7 @@ class Post { $email->setSubject($GLOBALS['CONFIG']['sitetitle'] . " Email Validation"); - $url = $GLOBALS['CONFIG']['urlroot'] . '/validate.php?id=' . $this->getSecretId(); + $url = buildUrl('validate.php?id=' . $this->getSecretId()); $email->appendMessage("Please click on the link below to verify your email address.\n\n"); $email->appendMessage($url); @@ -265,14 +279,22 @@ class Post { public function sendAcceptance() { $email = new Email($this->getEmail()); - $email->setSubject($GLOBALS['CONFIG']['sitetitle'] . " Posting Approved"); + $email->setSubject($GLOBALS['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."); + // View URL + $url = buildUrl('postings/' . $this->getId() . '.html'); + $email->appendMessage("You can view your post at $url.\n\n"); + + // Delete URL + $url = buildUrl('deletepost.php?id=' . $this->getId() + . '&secret=' . $this->getSecretId()); + $email->appendMessage("Your posting will expire in " . + $GLOBALS['CONFIG']['expiretime'] + . " days. If you would like to remove it sooner, go to $url.\n"); $email->send(); } diff --git a/htdocs/src/PostIterator.inc.php b/htdocs/src/PostIterator.inc.php index 43c1a05..a269853 100644 --- a/htdocs/src/PostIterator.inc.php +++ b/htdocs/src/PostIterator.inc.php @@ -37,6 +37,16 @@ class PostIterator implements Iterator { $this->where[] = "category_id='$category_id'"; } + public function filterCreated($after, $before = false) { + $sqlafter = date('Y-m-d H:i:s', $after); + $this->where[] = "created > '$sqlafter'"; + + if ($before !== false) { + $sqlbefore = date('Y-m-d H:i:s', $before); + $this->where[] = "created < '$sqlbefore'"; + } + } + public function orderBy($order) { $this->order = $order; } diff --git a/htdocs/src/base.inc.php b/htdocs/src/base.inc.php index d7a9354..7d48ca7 100644 --- a/htdocs/src/base.inc.php +++ b/htdocs/src/base.inc.php @@ -41,5 +41,10 @@ function __autoload($class) { require_once "$class.inc.php"; } +function buildUrl($tail='') { + return 'http://' . $GLOBALS['CONFIG']['domain'] + . $GLOBALS['CONFIG']['urlroot'] . "/$tail"; +} + ?> diff --git a/htdocs/src/config.inc.php.example b/htdocs/src/config.inc.php.example index d0d912c..0a4a8d4 100644 --- a/htdocs/src/config.inc.php.example +++ b/htdocs/src/config.inc.php.example @@ -20,6 +20,7 @@ $CONFIG = array( 'email_from' => 'community@myfoursquarechurch.com', 'emaildomain' => 'listandshare.com', + 'domain' => 'localhost', 'urlroot' => '/~jesse/p4s/community/htdocs', 'root' => '/Users/jesse/Development/P4Square/community/htdocs', 'uploads' => '/Users/jesse/Development/P4Square/community/uploads', |