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