From ca41e9154d147317ab315cdac8592fb1a1ffae66 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 4 Dec 2017 19:04:50 +0000 Subject: [PATCH 1/4] Archive and unarchive contacts --- include/items.php | 4 ++++ src/Object/Contact.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index 98149dea5..73a5ad9cc 100644 --- a/include/items.php +++ b/include/items.php @@ -1165,6 +1165,10 @@ function item_set_last_item($arr) { if ($update) { dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']), array('id' => $arr['contact-id'])); + $contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]); + if ($contact['term-date'] > NULL_DATE) { + Contact::unmarkForArchival($contact); + } } // Now do the same for the system wide contacts with uid=0 if (!$arr['private']) { diff --git a/src/Object/Contact.php b/src/Object/Contact.php index 34519401c..56204395c 100644 --- a/src/Object/Contact.php +++ b/src/Object/Contact.php @@ -99,7 +99,7 @@ class Contact extends BaseObject if ($contact['archive']) { return; } - +logger('Blubb-m: '.$contact['id'].' - '.System::callstack()); if ($contact['term-date'] <= NULL_DATE) { dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id'])); @@ -139,6 +139,7 @@ class Contact extends BaseObject */ public static function unmarkForArchival(array $contact) { +//logger('Blubb-m: '.$contact['id'].' - '.System::callstack()); $condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact[`id`], NULL_DATE); $exists = dba::exists('contact', $condition); From 360e39ca5b9d6a816106a23b52b477d7a058b003 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 4 Dec 2017 19:36:08 +0000 Subject: [PATCH 2/4] unmark for archival --- include/items.php | 8 ++++---- src/Object/Contact.php | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/items.php b/include/items.php index f0470feb7..e49eadd86 100644 --- a/include/items.php +++ b/include/items.php @@ -1151,6 +1151,10 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f * @param array $arr Contains the just posted item record */ function item_set_last_item($arr) { + $contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]); + if ($contact['term-date'] > NULL_DATE) { + Contact::unmarkForArchival($contact); + } $update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"]))); @@ -1166,10 +1170,6 @@ function item_set_last_item($arr) { if ($update) { dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']), array('id' => $arr['contact-id'])); - $contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]); - if ($contact['term-date'] > NULL_DATE) { - Contact::unmarkForArchival($contact); - } } // Now do the same for the system wide contacts with uid=0 if (!$arr['private']) { diff --git a/src/Object/Contact.php b/src/Object/Contact.php index af8489958..f0299603e 100644 --- a/src/Object/Contact.php +++ b/src/Object/Contact.php @@ -145,7 +145,6 @@ class Contact extends BaseObject if ($contact['archive']) { return; } -logger('Blubb-m: '.$contact['id'].' - '.System::callstack()); if ($contact['term-date'] <= NULL_DATE) { dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id'])); @@ -185,8 +184,7 @@ logger('Blubb-m: '.$contact['id'].' - '.System::callstack()); */ public static function unmarkForArchival(array $contact) { -//logger('Blubb-m: '.$contact['id'].' - '.System::callstack()); - $condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact[`id`], NULL_DATE); + $condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE); $exists = dba::exists('contact', $condition); // We don't need to update, we never marked this contact for archival From a206f6d832a24aa58ebc90115537005a084aacaa Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 4 Dec 2017 19:37:36 +0000 Subject: [PATCH 3/4] Only a newline --- src/Object/Contact.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Object/Contact.php b/src/Object/Contact.php index f0299603e..bd7cee7fb 100644 --- a/src/Object/Contact.php +++ b/src/Object/Contact.php @@ -145,6 +145,7 @@ class Contact extends BaseObject if ($contact['archive']) { return; } + if ($contact['term-date'] <= NULL_DATE) { dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id'])); From dc32553a1d94db877580b8bfbf08f825cc7262a1 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 4 Dec 2017 19:50:32 +0000 Subject: [PATCH 4/4] Better usew the author --- include/items.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index e49eadd86..f334990d7 100644 --- a/include/items.php +++ b/include/items.php @@ -1151,7 +1151,8 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f * @param array $arr Contains the just posted item record */ function item_set_last_item($arr) { - $contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]); + // Unarchive the author + $contact = dba::select('contact', [], ['id' => $arr["author-link"]], ['limit' => 1]); if ($contact['term-date'] > NULL_DATE) { Contact::unmarkForArchival($contact); }