include the item's description in the insert/update/delete subscription messages
This commit is contained in:
parent
221b4c2df8
commit
6c5ce31dcd
2 changed files with 16 additions and 13 deletions
|
@ -92,7 +92,7 @@ function getExistingQuantity($itemid, $userid, $bought, $dbh, $opt) {
|
|||
}
|
||||
}
|
||||
|
||||
function processSubscriptions($publisher, $action, $dbh, $opt) {
|
||||
function processSubscriptions($publisher, $action, $itemdesc, $dbh, $opt) {
|
||||
// join the users table as a cheap way to get the guy's name without having to pass it in.
|
||||
$stmt = $dbh->prepare("SELECT subscriber, fullname FROM subscriptions sub INNER JOIN users u ON u.userid = sub.publisher WHERE publisher = ? AND (last_notified IS NULL OR DATE_ADD(last_notified, INTERVAL {$opt["notify_threshold_minutes"]} MINUTE) < NOW())");
|
||||
$stmt->bindParam(1, $publisher, PDO::PARAM_INT);
|
||||
|
@ -103,13 +103,13 @@ function processSubscriptions($publisher, $action, $dbh, $opt) {
|
|||
if ($msg == "") {
|
||||
// same message for each user but we need the fullname from the first row before we can assemble it.
|
||||
if ($action == "insert") {
|
||||
$msg = $row["fullname"] . " has added an item to their list.";
|
||||
$msg = $row["fullname"] . " has added the item \"$itemdesc\" to their list.";
|
||||
}
|
||||
else if ($action == "update") {
|
||||
$msg = $row["fullname"] . " has updated an item on their list.";
|
||||
$msg = $row["fullname"] . " has updated the item \"$itemdesc\" on their list.";
|
||||
}
|
||||
else if ($action == "delete") {
|
||||
$msg = $row["fullname"] . " has deleted an item from their list.";
|
||||
$msg = $row["fullname"] . " has deleted the item \"$itemdesc\" from their list.";
|
||||
}
|
||||
$msg .= "\r\n\r\nYou are receiving this message because you are subscribed to their updates. You will not receive another message for their updates for the next " . $opt["notify_threshold_minutes"] . " minutes.";
|
||||
}
|
||||
|
|
21
src/item.php
21
src/item.php
|
@ -115,18 +115,21 @@ if (!empty($_REQUEST["action"])) {
|
|||
if ($action == "delete") {
|
||||
try {
|
||||
/* find out if this item is bought or reserved. */
|
||||
$stmt = $smarty->dbh()->prepare("SELECT a.userid, a.quantity, a.bought, i.description FROM {$opt["table_prefix"]}allocs a INNER JOIN {$opt["table_prefix"]}items i ON i.itemid = a.itemid WHERE a.itemid = ?");
|
||||
$stmt = $smarty->dbh()->prepare("SELECT a.userid, a.quantity, a.bought, i.description FROM {$opt["table_prefix"]}allocs a LEFT OUTER JOIN {$opt["table_prefix"]}items i ON i.itemid = a.itemid WHERE a.itemid = ?");
|
||||
$stmt->bindValue(1, (int) $_REQUEST["itemid"], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
while ($row = $stmt->fetch()) {
|
||||
$buyerid = $row["userid"];
|
||||
$quantity = $row["quantity"];
|
||||
$bought = $row["bought"];
|
||||
sendMessage($userid,
|
||||
$buyerid,
|
||||
$row["description"] . " that you " . (($bought == 1) ? "bought" : "reserved") . " $quantity of for {$_SESSION["fullname"]} has been deleted. Check your reservation/purchase to ensure it's still needed.",
|
||||
$smarty->dbh(),
|
||||
$smarty->opt());
|
||||
$description = $row["description"]; // need this for descriptions.
|
||||
if ($buyerid != null) {
|
||||
sendMessage($userid,
|
||||
$buyerid,
|
||||
$row["description"] . " that you " . (($bought == 1) ? "bought" : "reserved") . " $quantity of for {$_SESSION["fullname"]} has been deleted. Check your reservation/purchase to ensure it's still needed.",
|
||||
$smarty->dbh(),
|
||||
$smarty->opt());
|
||||
}
|
||||
}
|
||||
|
||||
deleteImageForItem((int) $_REQUEST["itemid"], $smarty->dbh(), $smarty->opt());
|
||||
|
@ -138,7 +141,7 @@ if (!empty($_REQUEST["action"])) {
|
|||
// TODO: are we leaking allocs records here?
|
||||
|
||||
stampUser($userid, $smarty->dbh(), $smarty->opt());
|
||||
processSubscriptions($userid, $action, $smarty->dbh(), $smarty->opt());
|
||||
processSubscriptions($userid, $action, $description, $smarty->dbh(), $smarty->opt());
|
||||
|
||||
header("Location: " . getFullPath("index.php?message=Item+deleted."));
|
||||
exit;
|
||||
|
@ -194,7 +197,7 @@ if (!empty($_REQUEST["action"])) {
|
|||
$stmt->execute();
|
||||
|
||||
stampUser($userid, $smarty->dbh(), $smarty->opt());
|
||||
processSubscriptions($userid, $action, $smarty->dbh(), $smarty->opt());
|
||||
processSubscriptions($userid, $action, $description, $smarty->dbh(), $smarty->opt());
|
||||
|
||||
header("Location: " . getFullPath("index.php"));
|
||||
exit;
|
||||
|
@ -232,7 +235,7 @@ if (!empty($_REQUEST["action"])) {
|
|||
$stmt->execute();
|
||||
|
||||
stampUser($userid, $smarty->dbh(), $smarty->opt());
|
||||
processSubscriptions($userid, $action, $smarty->dbh(), $smarty->opt());
|
||||
processSubscriptions($userid, $action, $description, $smarty->dbh(), $smarty->opt());
|
||||
|
||||
header("Location: " . getFullPath("index.php"));
|
||||
exit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue