I have been trying to code a notification system for a profile wall script I made a long time ago for a forum.
The trouble I have is, that I am trying to only send one PM to the people who fit the criteria for the PM, but I also have 2 select statements in MYSQL to find the people who should be PM’d.
I have 2 tables to select from… log_statuses and log_status_replies
I am trying to achieve this.
I want it to notify everyone who has commented only ONCE! Also the persons wall it belongs to and the person who written the status on the persons wall, but not yourself if you written it.
Kinda complex that’s why I am struggling to get this right…
Here is my code for it to search through who commented and send them a PM.
How would I also do the checks for who written the status and who’s wall it is, without it sending a duplicate PM if they have commented aswell.
Otherwise they would receive a PM because they have commented and because its their status/wall.
I hope you understand that, kinda hard to explain.
Here is my source code.. I would love anyone who could help..
$query = $smcFunc['db_query']('', '
SELECT id_member, id_poster
FROM {db_prefix}log_statuses
WHERE id_status = {int:id_status}',
array(
'id_status' => $status,
)
);
list($id_member,$id_poster) = $smcFunc['db_fetch_row']($query);
if ($id_poster != $ucomment || $id_member != $ucomment)
{
$query2 = $smcFunc['db_query']('', '
SELECT DISTINCT id_member
FROM {db_prefix}log_status_replies
WHERE id_status = {int:id_status}',
array(
'id_status' => $status,
)
);
while ($row = $smcFunc['db_fetch_assoc']($query2)) {
if ($row['id_member'] != $ucomment)
{
$pm_recipients = array(
'to' => array($row['id_member']),
'bcc' => array(),
);
require_once($sourcedir . '/Subs-Post.php');
$notify_body = $txt['status_body'] . '[iurl]' .$scripturl . '?action=profile;area=showstatus;s=' . $status . '[/iurl]';
$notify_body = str_replace("%poster",$context['user']['name'],$notify_body);
$pm_from = array(
'id' => $ucomment,
'username' => '',
'name' => '',
);
sendpm($pm_recipients,$txt['status_subject'] , $notify_body,false,$pm_from);
}
}
}
$id_member is the persons wall, $id_poster is the person who posted on the wall.
$ucomment is the person who is posting..
Solved.. I built an array from the while, then checked if the value exists from the comments table when checking the other table to see who to PM also..