+function tgroup_deliver($uid,$item_id) {
+
+
+ // setup a second delivery chain for forum/community posts if appropriate
+
+ $a = get_app();
+
+ $deliver_to_tgroup = false;
+
+ $u = q("select * from user where uid = %d and `page-flags` = %d limit 1",
+ intval($uid),
+ intval(PAGE_COMMUNITY)
+ );
+ if(! count($u))
+ return;
+
+ $i = q("select * from item where id = %d and uid = %d limit 1",
+ intval($item_id),
+ intval($uid)
+ );
+ if(! count($i))
+ return;
+
+ $item = $i[0];
+
+ // prevent delivery looping - only proceed
+ // if the message originated elsewhere and is a top-level post
+
+ if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
+ return;
+
+
+ $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+
+ $cnt = preg_match_all('/\@\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ if(link_compare($link,$mtch[1])) {
+ $deliver_to_tgroup = true;
+ logger('tgroup_deliver: local group mention found: ' . $mtch[2]);
+ }
+ }
+ }
+
+ if(! $deliver_to_tgroup)
+ return;
+
+ // now change this copy of the post to a forum head message and deliver to all the tgroup members
+
+
+ q("update item set wall = 1, origin = 1, forum_mode = 1 where id = %d limit 1",
+ intval($item_id)
+ );
+
+ proc_run('php','include/notifier.php','tgroup',$item_id);
+
+}
+
+
+
+
+
+