5 function share_init(App $a) {
7 $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
8 if((! $post_id) || (! local_user()))
11 $r = q("SELECT item.*, contact.network FROM `item`
12 inner join contact on `item`.`contact-id` = `contact`.`id`
13 WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1",
18 if(! dbm::is_result($r) || ($r[0]['private'] == 1))
21 if (strpos($r[0]['body'], "[/share]") !== false) {
22 $pos = strpos($r[0]['body'], "[share");
23 $o = substr($r[0]['body'], $pos);
25 $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
28 $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
37 function share_header($author, $profile, $avatar, $guid, $posted, $link) {
38 $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author).
39 "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile).
40 "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar);
43 $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid);
46 $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted);
48 $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']";