]> git.mxchange.org Git - friendica.git/commitdiff
child conversations inherit ACL's from parent
authorMike Macgirvin <mike@macgirvin.com>
Tue, 13 Jul 2010 23:09:53 +0000 (16:09 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Tue, 13 Jul 2010 23:09:53 +0000 (16:09 -0700)
include/notifier.php
mod/item.php

index 89b0964b497efda013cf9ebe098632a5156e2b62..f1231839b83854df3116cb49634299472fa0d0ea 100644 (file)
@@ -36,7 +36,7 @@ if($argc < 3)
 
        $recipients = array();
 
-       // fetch requested item
+       // fetch requested item(s)
 
        $r = q("SELECT `item`.*,  `contact`.*,`item`.`id` AS `item_id` FROM `item` LEFT JOIN `contact` ON `item`.`contact-id` = `contact`.`id` 
                WHERE `item`.`id` = %d LIMIT 1",
index ff3f4113881ed06d4ef7f85b080f7499c0e68d26..e4551ac5702c1fd334683bfe0897429ac71c6c79 100644 (file)
@@ -13,6 +13,20 @@ function item_post(&$a) {
 
        $uid = $_SESSION['uid'];
        $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
+
+       $parent_item = null;
+
+       if($parent) {
+               $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
+                       intval($parent)
+               );
+               if(! count($r)) {
+                       notice("Unable to locate original post." . EOL);
+                       goaway($a->get_baseurl() . "/profile/$profile_uid");
+               }
+               $parent_item = $r[0];
+       }
+
        $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0);
 
        if(! can_write_wall($a,$profile_uid)) {
@@ -99,10 +113,25 @@ function item_post(&$a) {
                        dbesc($hash));
                if(count($r)) {
                        $post_id = $r[0]['id'];
+
                        if($parent) {
+
+                               // This item is the last leaf and gets the comment box, clear any ancestors
                                $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent` = %d ",
                                        intval($parent)
                                );
+
+                               // Inherit ACL's from the parent item.
+                               // TODO merge with subsequent UPDATE operation and save a db write 
+
+                               $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
+                                       WHERE `id` = %d LIMIT 1",
+                                       intval($parent_item['allow_cid']),
+                                       intval($parent_item['allow_gid']),
+                                       intval($parent_item['deny_cid']),
+                                       intval($parent_item['deny_gid']),
+                                       intval($post_id)
+                               );
                        }
                        else {
                                $parent = $post_id;