2 function share_init(App $a) {
4 $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
5 if((! $post_id) || (! local_user()))
8 $r = q("SELECT item.*, contact.network FROM `item`
9 inner join contact on `item`.`contact-id` = `contact`.`id`
10 WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1",
15 if(! dbm::is_result($r) || ($r[0]['private'] == 1))
18 if (strpos($r[0]['body'], "[/share]") !== false) {
19 $pos = strpos($r[0]['body'], "[share");
20 $o = substr($r[0]['body'], $pos);
22 $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
25 $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
34 function share_header($author, $profile, $avatar, $guid, $posted, $link) {
35 $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author).
36 "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile).
37 "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar);
40 $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid);
43 $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted);
45 $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']";