diff options
| author | Carson Fleming <cflems@cflems.net> | 2017-02-23 18:24:01 -0500 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2017-02-23 18:24:01 -0500 |
| commit | 117d7a7ce83dbcf749c88201cd46a3e10efc899b (patch) | |
| tree | 0937bf274a77984bae213d37be9b9ee531d06a73 | |
| parent | b13221d3d3c98912e130c33c725d7274cda5b27d (diff) | |
| download | bulletin-117d7a7ce83dbcf749c88201cd46a3e10efc899b.tar.gz | |
When an ad receives a response, create a hook which emails the poster
| -rw-r--r-- | dash/apply.php | 2 | ||||
| -rw-r--r-- | dash/dash_functions.php | 22 | ||||
| -rw-r--r-- | inc/app_eml.tpl | 22 | ||||
| -rw-r--r-- | inc/eml.tpl | 2 |
4 files changed, 47 insertions, 1 deletions
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) { </div> <?php } + +// triggers +function app_trigger ($responseid) { + global $db; + + $result = $db->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 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>Active Your Bulletin Account</title> + </head> + <body> + <div id="head" style="text-align: center; width: 100%; height: 110px; border-bottom: 1px solid #dddddd;"> + <a class="logolink" href="[config:base_url]"> + <img style="width: 334px; height: 80px; margin: 15px auto;" src="[config:base_url]img/5.png" alt="Bulletin" /> + </a> + </div> + <div style="width: 450px; display: table; margin: 1em auto;"> + <div style="font-family: sans-serif; font-size: 12pt; text-align: center; margin: 15px -15px; width: 100%; display: block;"> + <p style="width: 100%;">Your Ad, <a style="color: #fb4d00;" href="[config:base_url]dash/review.php?id=[tpl:rid]">[tpl:adname]</a>, 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 <a style="color: #fb4d00;" href="mailto:[tpl:seekereml]">[tpl:seekereml]</a>, or check out more of their profile <a style="color: #fb4d00;" href="[config:base_url]dash/profile.php?id=[tpl:seekerid]">here</a>.</p> + </div> + </div> + <div style="width: 450px; height: 1px; margin: auto; background: #dddddd;"></div> +[config:eml_footer] + <p style="color: #dddddd; margin: 4em auto auto auto; text-align: center; font-size: x-small; font-family: sans-serif;">Copyright © 2016 Bulletin Team</p> + </body> +</html> 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 @@ </div> </div> <div style="width: 450px; height: 1px; margin: auto; background: #dddddd;"></div> - <p style="margin-top: 2em; text-align: center; font-family: sans-serif; font-size: 12pt; color: #aaaaaa;">Welcome to Bulletin!</p> +[config:eml_footer] <p style="color: #dddddd; margin: 4em auto auto auto; text-align: center; font-size: x-small; font-family: sans-serif;">Copyright © 2016 Bulletin Team</p> </body> </html> |
