3 require_once('include/security.php');
4 require_once('include/bbcode.php');
5 require_once('include/items.php');
8 function subthread_content(&$a) {
10 if(! local_user() && ! remote_user()) {
14 $activity = ACTIVITY_FOLLOW;
16 $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
18 $r = q("SELECT * FROM `item` WHERE `parent` = '%s' OR `parent-uri` = '%s' and parent = id LIMIT 1",
23 if(! $item_id || (! count($r))) {
24 logger('subthread: no item ' . $item_id);
30 $owner_uid = $item['uid'];
32 if(! can_write_wall($a,$owner_uid)) {
39 // The top level post may have been written by somebody on another system
40 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
41 intval($item['contact-id']),
47 $remote_owner = $r[0];
50 // this represents the post owner on this system.
52 $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
53 WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
60 logger('like: no owner');
65 $remote_owner = $owner;
68 // This represents the person posting
70 if((local_user()) && (local_user() == $owner_uid)) {
74 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
75 intval($_SESSION['visitor_id']),
85 $uri = item_new_uri($a->get_hostname(),$owner_uid);
87 $post_type = (($item['resource-id']) ? t('photo') : t('status'));
88 $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
89 $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
90 $body = $item['body'];
97 <id>{$item['uri']}</id>
100 <content>$body</content>
103 $bodyverb = t('%1$s is following %2$s\'s %3$s');
105 if(! isset($bodyverb))
111 $arr['uid'] = $owner_uid;
112 $arr['contact-id'] = $contact['id'];
113 $arr['type'] = 'activity';
114 $arr['wall'] = $item['wall'];
116 $arr['gravity'] = GRAVITY_LIKE;
117 $arr['parent'] = $item['id'];
118 $arr['parent-uri'] = $item['uri'];
119 $arr['thr-parent'] = $item['uri'];
120 $arr['owner-name'] = $remote_owner['name'];
121 $arr['owner-link'] = $remote_owner['url'];
122 $arr['owner-avatar'] = $remote_owner['thumb'];
123 $arr['author-name'] = $contact['name'];
124 $arr['author-link'] = $contact['url'];
125 $arr['author-avatar'] = $contact['thumb'];
127 $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
128 $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
129 $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
130 $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
132 $arr['verb'] = $activity;
133 $arr['object-type'] = $objtype;
134 $arr['object'] = $obj;
135 $arr['allow_cid'] = $item['allow_cid'];
136 $arr['allow_gid'] = $item['allow_gid'];
137 $arr['deny_cid'] = $item['deny_cid'];
138 $arr['deny_gid'] = $item['deny_gid'];
141 $arr['last-child'] = 0;
143 $post_id = item_store($arr);
145 if(! $item['visible']) {
146 $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
152 $arr['id'] = $post_id;
154 call_hooks('post_local_end', $arr);