4 use Friendica\Database\DBA;
5 use Friendica\Model\Item;
7 function share_init(App $a) {
8 $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
10 if (!$post_id || !local_user()) {
14 $fields = ['private', 'body', 'author-name', 'author-link', 'author-avatar',
15 'guid', 'created', 'plink', 'title'];
16 $item = Item::selectFirst($fields, ['id' => $post_id]);
18 if (!DBA::isResult($item) || $item['private'] == 1) {
22 if (strpos($item['body'], "[/share]") !== false) {
23 $pos = strpos($item['body'], "[share");
24 $o = substr($item['body'], $pos);
26 $o = share_header($item['author-name'], $item['author-link'], $item['author-avatar'], $item['guid'], $item['created'], $item['plink']);
29 $o .= '[h3]'.$item['title'].'[/h3]'."\n";
40 /// @TODO Rewrite to handle over whole record array
41 function share_header($author, $profile, $avatar, $guid, $posted, $link) {
42 $header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author).
43 "' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile).
44 "' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
47 $header .= "' guid='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
51 $header .= "' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
54 $header .= "' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";