]> git.mxchange.org Git - friendica.git/blob - mod/bookmarklet.php
Merge pull request #4168 from annando/comment-dfrn
[friendica.git] / mod / bookmarklet.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\System;
5 use Friendica\Module\Login;
6
7 require_once('include/conversation.php');
8 require_once('include/items.php');
9
10 function bookmarklet_init(App $a)
11 {
12         $_GET["mode"] = "minimal";
13 }
14
15 function bookmarklet_content(App $a)
16 {
17         if (!local_user()) {
18                 $o = '<h2>' . t('Login') . '</h2>';
19                 $o .= Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? false : true);
20                 return $o;
21         }
22
23         $referer = normalise_link($_SERVER["HTTP_REFERER"]);
24         $page = normalise_link(System::baseUrl() . "/bookmarklet");
25
26         if (!strstr($referer, $page)) {
27                 $content = add_page_info($_REQUEST["url"]);
28
29                 $x = array(
30                         'is_owner' => true,
31                         'allow_location' => $a->user['allow_location'],
32                         'default_location' => $a->user['default-location'],
33                         'nickname' => $a->user['nickname'],
34                         'lockstate' => ((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) ? 'lock' : 'unlock'),
35                         'default_perms' => get_acl_permissions($a->user),
36                         'acl' => populate_acl($a->user, true),
37                         'bang' => '',
38                         'visitor' => 'block',
39                         'profile_uid' => local_user(),
40                         'title' => trim($_REQUEST["title"], "*"),
41                         'content' => $content
42                 );
43                 $o = status_editor($a, $x, 0, false);
44                 $o .= "<script>window.resizeTo(800,550);</script>";
45         } else {
46                 $o = '<h2>' . t('The post was created') . '</h2>';
47                 $o .= "<script>window.close()</script>";
48         }
49
50         return $o;
51 }