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 (!intval(get_config('system','old_share'))) {
19 if (strpos($r[0]['body'], "[/share]") !== false) {
20 $pos = strpos($r[0]['body'], "[share");
21 $o = substr($r[0]['body'], $pos);
23 $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
26 $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
33 $o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
35 $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
36 $o .= $r[0]['body'] . "\n" ;
38 $o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
44 function share_header($author, $profile, $avatar, $guid, $posted, $link) {
45 $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author).
46 "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile).
47 "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar);
50 $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid);
53 $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted);
55 $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']";