]> git.mxchange.org Git - friendica.git/commitdiff
working on delete
authorMike Macgirvin <mike@macgirvin.com>
Mon, 26 Jul 2010 10:33:56 +0000 (03:33 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Mon, 26 Jul 2010 10:33:56 +0000 (03:33 -0700)
include/items.php
include/poller.php
mod/dfrn_notify.php

index 2cb894f5add75995d706e9132856c70bef227d61..a0804bcbeeea0d303b2fa254b6a090d4cd23eff4 100644 (file)
@@ -62,8 +62,8 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
                `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, 
                `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`
                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-               WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
-               AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+               WHERE `item`.`uid` = %d AND `item`.`visible` = 1 
+               AND NOT `item`.`type` IN ( 'remote', 'net-comment' ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                AND `item`.`edited` > '%s'
                $sql_extra
                ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300",
index ab030a7091e02a0fd188d5340a24a08d69eeabd8..c7108d13c0bc5059a801a4bc6902ef945eeb8bc0 100644 (file)
@@ -74,16 +74,45 @@ echo "Length:" . strlen($xml) . "\r\n";
 
                foreach($feed->get_items() as $item) {
 
+                       $deleted = false;
+
                        $rawdelete = $item->get_item_tags("http://purl.org/atompub/tombstones/1.0", 'deleted-entry');
-                       print_r($rawdelete);
+                       if(isset($rawdelete[0]['attribs']['']['ref'])) {
+                               $uri = $rawthread[0]['attribs']['']['ref'];
+                               $deleted = true;
+                               if(isset($rawdelete[0]['attribs']['']['when'])) {
+                                       $when = $rawthread[0]['attribs']['']['when'];
+                                       $when = datetime_convert('UTC','UTC', $when, 'Y-m-d H:i:s');
+                               }
+                               else
+                                       $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
+                       }
                        if($deleted) {
-                               // pick out ref and when from attribs
-                               // check hasn't happened already, verify ownership and then process it
-
-
+                               $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                                       dbesc($uri),
+                                       intval($importer['uid'])
+                               );
+                               if(count($r)) {
+                                       if($r[0]['uri'] == $r[0]['parent-uri']) {
+                                               $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s'
+                                                       WHERE `parent-uri` = '%s'"
+                                                       dbesc($when),
+                                                       dbesc($r[0]['uri'])
+                                               );
+                                       }
+                                       else {
+                                               $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s' 
+                                                       WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($when),
+                                                       dbesc($uri),
+                                                       intval($importer['uid'])
+                                               );
+                                       }
+                               }       
                                continue;
                        }
 
+
                        $is_reply = false;              
                        $item_id = $item->get_id();
                        $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to');
index 169ae7bb7ca56da8716dd1f4be04020b62998f3e..ecab9ea72a9515a46863feb21f9e0f2869982e7b 100644 (file)
@@ -39,13 +39,41 @@ function dfrn_notify_post(&$a) {
 
        foreach($feed->get_items() as $item) {
 
+               $deleted = false;
+
                $rawdelete = $item->get_item_tags("http://purl.org/atompub/tombstones/1.0", 'deleted-entry');
-               print_r($rawdelete);
+               if(isset($rawdelete[0]['attribs']['']['ref'])) {
+                       $uri = $rawthread[0]['attribs']['']['ref'];
+                       $deleted = true;
+                       if(isset($rawdelete[0]['attribs']['']['when'])) {
+                               $when = $rawthread[0]['attribs']['']['when'];
+                               $when = datetime_convert('UTC','UTC', $when, 'Y-m-d H:i:s');
+                       }
+                       else
+                               $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
+               }
                if($deleted) {
-                       // pick out ref and when from attribs
-                       // check hasn't happened already, verify ownership and then process it
-
-
+                       $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                               dbesc($uri),
+                               intval($importer['uid'])
+                       );
+                       if(count($r)) {
+                               if($r[0]['uri'] == $r[0]['parent-uri']) {
+                                       $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s'
+                                               WHERE `parent-uri` = '%s'"
+                                               dbesc($when),
+                                               dbesc($r[0]['uri'])
+                                       );
+                               }
+                               else {
+                                       $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s' 
+                                               WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                                               dbesc($when),
+                                               dbesc($uri),
+                                               intval($importer['uid'])
+                                       );
+                               }
+                       }       
                        continue;
                }