streams/include/msglib.php

29 lines
847 B
PHP
Raw Normal View History

2018-09-15 20:27:39 +00:00
<?php
/* Common private message processing functions */
function msg_drop($message_id, $channel_id, $conv_guid) {
// Delete message
$r = q("DELETE FROM mail WHERE id = %d AND channel_id = %d",
2018-09-17 11:15:24 +00:00
intval($message_id),
intval($channel_id)
2018-09-15 20:31:08 +00:00
);
2018-09-15 20:27:39 +00:00
2018-09-15 22:43:45 +00:00
// Get new first message...
$r = q("SELECT mid, parent_mid FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1",
2018-09-17 11:15:24 +00:00
dbesc($conv_guid),
intval($channel_id)
2018-09-15 20:31:08 +00:00
);
2018-09-15 22:43:45 +00:00
// ...and if wasn't first before...
if ($r[0]['mid'] != $r[0]['parent_mid']) {
// ...refer whole thread to it
2018-09-15 20:31:08 +00:00
q("UPDATE mail SET parent_mid = '%s', mail_isreply = abs(mail_isreply - 1) WHERE conv_guid = '%s' AND channel_id = %d",
dbesc($r[0]['mid']),
2018-09-17 11:15:24 +00:00
dbesc($conv_guid),
intval($channel_id)
2018-09-15 20:31:08 +00:00
);
}
2018-09-15 20:27:39 +00:00
}