3 if(! function_exists('share_init')) {
4 function share_init(&$a) {
6 $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
7 if((! $post_id) || (! local_user()))
10 $r = q("SELECT item.*, contact.network FROM `item`
11 inner join contact on `item`.`contact-id` = `contact`.`id`
12 WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1",
17 if(! count($r) || ($r[0]['private'] == 1))
20 if (!intval(get_config('system','old_share'))) {
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";
35 $o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
37 $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
38 $o .= $r[0]['body'] . "\n" ;
40 $o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
47 if(! function_exists('share_header')) {
48 function share_header($author, $profile, $avatar, $guid, $posted, $link) {
49 $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author).
50 "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile).
51 "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar);
54 $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid);
57 $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted);
59 $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']";