From 724dc48fe8784b52e214c8ee65e2b9e2f19b7519 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 15 Sep 2018 21:41:13 +0200 Subject: Add new file --- include/msglib.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 include/msglib.php (limited to 'include/msglib.php') diff --git a/include/msglib.php b/include/msglib.php new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3 From f83c2d5cd102291c9ef3372fda904fb67bcf61da Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 15 Sep 2018 22:27:39 +0200 Subject: Create msglib.php --- include/msglib.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'include/msglib.php') diff --git a/include/msglib.php b/include/msglib.php index e69de29bb..c55839f6c 100644 --- a/include/msglib.php +++ b/include/msglib.php @@ -0,0 +1,35 @@ + Date: Sat, 15 Sep 2018 22:31:08 +0200 Subject: formatting --- include/msglib.php | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'include/msglib.php') diff --git a/include/msglib.php b/include/msglib.php index c55839f6c..2c9a9a696 100644 --- a/include/msglib.php +++ b/include/msglib.php @@ -6,30 +6,27 @@ function msg_drop($message_id, $channel_id, $conv_guid) { // Delete message $r = q("DELETE FROM mail WHERE id = %d AND channel_id = %d", - $message_id, - $channel_id - ); + $message_id, + $channel_id + ); - // If it was a first message in thread - $z = q("SELECT * FROM mail WHERE mid = '%s' AND channel_id = %d", - $message_id, - $channel_id - ); - if (! $z) { - // Get new first message... - $r = q("SELECT mid FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1", - $conv_guid, - $channel_id - ); - // ...and refer whole thread to it - 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']), - $conv_guid, - $channel_id - ); - return true; - } else { - return false; - } + // If it was a first message in thread + $z = q("SELECT * FROM mail WHERE mid = '%s' AND channel_id = %d", + $message_id, + $channel_id + ); + if (! $z) { + // Get new first message... + $r = q("SELECT mid FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1", + $conv_guid, + $channel_id + ); + // ...and refer whole thread to it + 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']), + $conv_guid, + $channel_id + ); + } } -- cgit v1.2.3 From 585bdf562a31e6fb822fc0b06bdfbbe5b8ba324e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 16 Sep 2018 00:43:45 +0200 Subject: Update msglib.php --- include/msglib.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'include/msglib.php') diff --git a/include/msglib.php b/include/msglib.php index 2c9a9a696..f196e7bee 100644 --- a/include/msglib.php +++ b/include/msglib.php @@ -10,18 +10,14 @@ function msg_drop($message_id, $channel_id, $conv_guid) { $channel_id ); - // If it was a first message in thread - $z = q("SELECT * FROM mail WHERE mid = '%s' AND channel_id = %d", - $message_id, + // 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", + $conv_guid, $channel_id ); - if (! $z) { - // Get new first message... - $r = q("SELECT mid FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1", - $conv_guid, - $channel_id - ); - // ...and refer whole thread to it + // ...and if wasn't first before... + if ($r[0]['mid'] != $r[0]['parent_mid']) { + // ...refer whole thread to it 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']), $conv_guid, -- cgit v1.2.3 From 774729b2215b9d417a6736b1dbaa5bf593df760d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 17 Sep 2018 13:15:24 +0200 Subject: Update msglib.php --- include/msglib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/msglib.php') diff --git a/include/msglib.php b/include/msglib.php index f196e7bee..f0bf523de 100644 --- a/include/msglib.php +++ b/include/msglib.php @@ -6,22 +6,22 @@ function msg_drop($message_id, $channel_id, $conv_guid) { // Delete message $r = q("DELETE FROM mail WHERE id = %d AND channel_id = %d", - $message_id, - $channel_id + intval($message_id), + intval($channel_id) ); // 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", - $conv_guid, - $channel_id + dbesc($conv_guid), + intval($channel_id) ); // ...and if wasn't first before... if ($r[0]['mid'] != $r[0]['parent_mid']) { // ...refer whole thread to it 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']), - $conv_guid, - $channel_id + dbesc($conv_guid), + intval($channel_id) ); } -- cgit v1.2.3