summaryrefslogtreecommitdiff
path: root/dash
diff options
context:
space:
mode:
Diffstat (limited to 'dash')
-rw-r--r--dash/apply.php2
-rw-r--r--dash/dash_functions.php22
2 files changed, 24 insertions, 0 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");
+}
?>