diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-07-17 19:26:00 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-07-17 19:26:00 -0700 |
commit | aff4f63ff8e005bb3ce1d726405fd6d5d2dcfa60 (patch) | |
tree | 37637e69e138ed247d2cbf194481324b39317d2c /mod | |
parent | 2a17c20fb8e910aeb814ab999cf9131478dd2b03 (diff) | |
download | volse-hubzilla-aff4f63ff8e005bb3ce1d726405fd6d5d2dcfa60.tar.gz volse-hubzilla-aff4f63ff8e005bb3ce1d726405fd6d5d2dcfa60.tar.bz2 volse-hubzilla-aff4f63ff8e005bb3ce1d726405fd6d5d2dcfa60.zip |
remote comments working now
Diffstat (limited to 'mod')
-rw-r--r-- | mod/dfrn_notify.php | 65 | ||||
-rw-r--r-- | mod/item.php | 11 | ||||
-rw-r--r-- | mod/network.php | 1 | ||||
-rw-r--r-- | mod/profile.php | 1 |
4 files changed, 52 insertions, 26 deletions
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 0f5f5eb6c..f81eb9cfb 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -8,12 +8,12 @@ function get_atom_elements($item) { $res = array(); $author = $item->get_author(); - $res['remote-name'] = $author->get_name(); - $res['remote-link'] = $author->get_link(); - $res['remote-avatar'] = $author->get_avatar(); - $res['remote-id'] = $item->get_id(); - $res['title'] = $item->get_title(); - $res['body'] = $item->get_content(); + $res['remote-name'] = unxmlify($author->get_name()); + $res['remote-link'] = unxmlify($author->get_link()); + $res['remote-avatar'] = unxmlify($author->get_avatar()); + $res['remote-id'] = unxmlify($item->get_id()); + $res['title'] = unxmlify($item->get_title()); + $res['body'] = unxmlify($item->get_content()); if(strlen($res['body']) > 100000) $res['body'] = substr($res['body'],0,10000) . "\r\n[Extremely large post truncated.]\r\n" ; @@ -26,19 +26,19 @@ function get_atom_elements($item) { $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published'); if($rawcreated) - $res['created'] = $rawcreated[0]['data']; + $res['created'] = unxmlify($rawcreated[0]['data']); $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated'); if($rawedited) - $res['edited'] = $rawcreated[0]['data']; + $res['edited'] = unxmlify($rawcreated[0]['data']); $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0', 'owner'); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) - $res['owner-name'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']; + $res['owner-name'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) - $res['owner-link'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']; + $res['owner-link'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) - $res['owner-avatar'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']; + $res['owner-avatar'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']); return $res; @@ -48,7 +48,8 @@ function get_atom_elements($item) { function post_remote($a,$arr) { $arr['hash'] = random_string(); - $arr['type'] = 'remote'; + if(! x($arr,'type')) + $arr['type'] = 'remote'; $arr['remote-name'] = notags(trim($arr['remote-name'])); $arr['remote-link'] = notags(trim($arr['remote-link'])); $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); @@ -82,7 +83,7 @@ function post_remote($a,$arr) { $parent_id = 0; dbesc_array($arr); - +dbg(3); $r = q("INSERT INTO `item` (`" . implode("`, `", array_keys($arr)) . "`) VALUES ('" @@ -121,7 +122,7 @@ function post_remote($a,$arr) { } function dfrn_notify_post(&$a) { - +dbg(3); $dfrn_id = notags(trim($_POST['dfrn_id'])); $challenge = notags(trim($_POST['challenge'])); $data = $_POST['data']; @@ -179,15 +180,32 @@ function dfrn_notify_post(&$a) { // remote reply to our post. Import and then notify everybody else. $datarray = get_atom_elements($item); $urn = explode(':',$parent_urn); - $datarray['parent_hash'] = $urn[4]; + $datarray['type'] = 'remote-comment'; + $datarray['parent_hash'] = $urn[5]; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; - $r = post_remote($a,$datarray); + $posted_id = post_remote($a,$datarray); + + $r = q("SELECT `parent` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($posted_id), + intval($importer['uid']) + ); + if(count($r)) { + $r1 = q("UPDATE `item` SET `last-child` = 0 WHERE `uid` = %d AND `parent` = %d", + intval($importer['uid']), + intval($r[0]['parent']) + ); + } + $r2 = q("UPDATE `item` SET `last-child` = 1 WHERE `uid` = %d AND `id` = %d LIMIT 1", + intval($importer['uid']), + intval($posted_id) + ); $url = bin2hex($a->get_baseurl()); - proc_close(proc_open("php include/notifier.php $url $notify_type $r > notify.log &", array(),$foo)); + proc_close(proc_open("php include/notifier.php $url comment-import $posted_id > remote-notify.log &", array(),$foo)); + xml_status(0); return; } @@ -196,16 +214,18 @@ function dfrn_notify_post(&$a) { $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); + // FIXME update content if 'updated' changes if(count($r)) { $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), - dbesc($item_id) + dbesc($item_id), + intval($importer['uid']) ); } continue; @@ -222,7 +242,7 @@ function dfrn_notify_post(&$a) { // Head post of a conversation. Have we seen it? If not, import it. $item_id = $item->get_id(); - $r = q("SELECT `uid` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); @@ -231,7 +251,8 @@ function dfrn_notify_post(&$a) { if($allow && $allow[0]['data'] != $r[0]['last-child']) { $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), - dbesc($item_id) + dbesc($item_id), + intval($importer['uid']) ); } continue; @@ -249,7 +270,7 @@ function dfrn_notify_post(&$a) { } - + xml_status(0); killme(); } diff --git a/mod/item.php b/mod/item.php index 437e6ac59..1584c7ddb 100644 --- a/mod/item.php +++ b/mod/item.php @@ -72,8 +72,10 @@ function item_post(&$a) { } // get contact info for poster - if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) + + if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) { $contact_id = $_SESSION['visitor_id']; + } else { $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); @@ -104,15 +106,16 @@ function item_post(&$a) { } while($dups == true); - $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,`edited`,`hash`,`body`, + $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `remote-id`, `created`,`edited`,`hash`,`body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) - VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($profile_uid), dbesc($_POST['type']), intval($contact_id), dbesc($contact_record['name']), dbesc($contact_record['url']), dbesc($contact_record['thumb']), + dbesc("urn:X-dfrn:" . $a->get_baseurl() . ':' . intval($profile_uid) . ':' . $hash), datetime_convert(), datetime_convert(), dbesc($hash), @@ -159,7 +162,7 @@ function item_post(&$a) { $url = bin2hex($a->get_baseurl()); - proc_close(proc_open("php include/notifier.php $url $notify_type $post_id > notify.log &", + proc_close(proc_open("php include/notifier.php \"$url\" \"$notify_type\" \"$post_id\" > notify.log &", array(),$foo)); } diff --git a/mod/network.php b/mod/network.php index 2685959a3..94ea065e9 100644 --- a/mod/network.php +++ b/mod/network.php @@ -108,6 +108,7 @@ function network_content(&$a) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( + '$return_path' => $a->cmd, '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $_SESSION['uid'], diff --git a/mod/profile.php b/mod/profile.php index 7b54340a9..f14cdbd11 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -196,6 +196,7 @@ function profile_content(&$a) { if(can_write_wall($a,$a->profile['profile_uid'])) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( + '$return_path' => $a->cmd, '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $a->profile['profile_uid'], |