From 117d7a7ce83dbcf749c88201cd46a3e10efc899b Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 23 Feb 2017 18:24:01 -0500 Subject: When an ad receives a response, create a hook which emails the poster --- dash/apply.php | 2 ++ dash/dash_functions.php | 22 ++++++++++++++++++++++ inc/app_eml.tpl | 22 ++++++++++++++++++++++ inc/eml.tpl | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 inc/app_eml.tpl diff --git a/dash/apply.php b/dash/apply.php index ab2652c..d60700e 100644 --- a/dash/apply.php +++ b/dash/apply.php @@ -12,7 +12,9 @@ if (!empty($_POST['apply'])) { $result->free(); dash_fatal('You have already applied to this ad!', $b_config['base_url'].'dash/'); } + $result->free(); $db->query('INSERT INTO responses (adid, uid, comment) VALUES ('.$adid.', '.$b_user['id'].', \''.$db->escape_string($_POST['comments']).'\')') or dash_fatal($db->error); + app_trigger($db->insert_id); dash_fatal('Your application has been submitted.', $b_config['base_url'].'dash/'); } diff --git a/dash/dash_functions.php b/dash/dash_functions.php index c5644ca..334d253 100644 --- a/dash/dash_functions.php +++ b/dash/dash_functions.php @@ -54,4 +54,26 @@ function draw_ad ($row) { query('SELECT responses.id, responses.uid AS seeker, responses.adid, responses.comment, ads.title, users.name, users.email FROM responses INNER JOIN ads ON responses.adid = ads.id INNER JOIN users ON ads.uid = users.id WHERE responses.id = '.$responseid.' LIMIT 1') or dash_fatal($db->error); + if ($result->num_rows < 1) dash_fatal('The ad you\'ve tried to apply to no longer exists.'); + $appinfo = $result->fetch_assoc(); + $result->free(); + $result = $db->query('SELECT users.name, users.email, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM users LEFT JOIN ratings ON ratings.rated = users.id') or dash_fatal($db->error); + $uinfo = $result->fetch_assoc(); + $result->free(); + $options = array( + 'rid' => $appinfo['id'], + 'adname' => $appinfo['title'], + 'seekername' => $appinfo['name'], + 'seekerrating' => is_null($uinfo['rating']) ? 'has yet to be rated' : 'is rated '.number_format($uinfo['rating'], 1).' stars', + 'seekereml' => $uinfo['email'], + 'seekerid' => $appinfo['seeker'], + ); + mail($appinfo['email'], '"'.$appinfo['title'].'" Has Received a Response', tpl($options, 'app_eml.tpl'), "From: ".$b_config['mail_from']."\r\nContent-type: text/html"); +} ?> diff --git a/inc/app_eml.tpl b/inc/app_eml.tpl new file mode 100644 index 0000000..b788f93 --- /dev/null +++ b/inc/app_eml.tpl @@ -0,0 +1,22 @@ + + + + + Active Your Bulletin Account + + + +
+
+

Your Ad, [tpl:adname], has just received a response. The applicant is named [tpl:seekername] and [tpl:seekerrating]. To get in touch, you can check out more of their profile, you can email them at [tpl:seekereml], or check out more of their profile here.

+
+
+
+[config:eml_footer] +

Copyright © 2016 Bulletin Team

+ + diff --git a/inc/eml.tpl b/inc/eml.tpl index e09831d..49cd743 100644 --- a/inc/eml.tpl +++ b/inc/eml.tpl @@ -17,7 +17,7 @@
-

Welcome to Bulletin!

+[config:eml_footer]

Copyright © 2016 Bulletin Team

-- cgit v1.2.3