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 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'dash') 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"); +} ?> -- cgit v1.2.3