]> git.mxchange.org Git - friendica.git/blob - mod/share.php
Merge pull request #558 from fermionic/20121222-use-smarty-template-engine
[friendica.git] / mod / share.php
1 <?php
2
3 require_once('bbcode.php');
4
5 function share_init(&$a) {
6
7         $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
8         if((! $post_id) || (! local_user()))
9                 killme();
10
11         $r = q("SELECT item.*, contact.network FROM `item` 
12                 left join contact on `item`.`contact-id` = `contact`.`id` 
13                 WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1",
14
15                 intval($post_id),
16                 intval(local_user())
17         );
18         if(! count($r) || ($r[0]['private'] == 1))
19                 killme();
20
21         if (intval(get_config('system','new_share'))) {
22                 if (strpos($r[0]['body'], "[/share]") !== false) {
23                         $pos = strpos($r[0]['body'], "[share");
24                         $o = substr($r[0]['body'], $pos);
25                 } else {
26                         $o = "[share author='".str_replace("'", "&#039;",$r[0]['author-name']).
27                                 "' profile='".$r[0]['author-link'].
28                                 "' avatar='".$r[0]['author-avatar'].
29                                 "' link='".$r[0]['plink']."']\n";
30                         if($r[0]['title'])
31                                 $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
32                         $o .= $r[0]['body'];
33                         $o.= "[/share]";
34                 }
35         } else {
36                 $o = '';
37
38                 $o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
39                 if($r[0]['title'])
40                         $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
41                 $o .= $r[0]['body'] . "\n" ;
42
43                 $o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
44         }
45         echo $o;
46         killme();
47 }