]> git.mxchange.org Git - friendica.git/blob - mod/editpost.php
Catch HTTPExceptions in App::runFrontend()
[friendica.git] / mod / editpost.php
1 <?php
2 /**
3  * @file mod/editpost.php
4  */
5 use Friendica\App;
6 use Friendica\Content\Feature;
7 use Friendica\Core\Addon;
8 use Friendica\Core\Config;
9 use Friendica\Core\Hook;
10 use Friendica\Core\L10n;
11 use Friendica\Core\Renderer;
12 use Friendica\Core\System;
13 use Friendica\Model\FileTag;
14 use Friendica\Model\Item;
15 use Friendica\Database\DBA;
16 use Friendica\Util\Crypto;
17
18 function editpost_content(App $a)
19 {
20         $o = '';
21
22         if (!local_user()) {
23                 notice(L10n::t('Permission denied.') . EOL);
24                 return;
25         }
26
27         $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
28
29         if (!$post_id) {
30                 notice(L10n::t('Item not found') . EOL);
31                 return;
32         }
33
34         $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
35                 'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
36
37         $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
38
39         if (!DBA::isResult($item)) {
40                 notice(L10n::t('Item not found') . EOL);
41                 return;
42         }
43
44         $geotag = '';
45
46         $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate("section_title.tpl"), [
47                 '$title' => L10n::t('Edit post')
48         ]);
49
50         $tpl = Renderer::getMarkupTemplate('jot-header.tpl');
51         $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
52                 '$baseurl' => System::baseUrl(),
53                 '$ispublic' => '&nbsp;', // L10n::t('Visible to <strong>everybody</strong>'),
54                 '$geotag' => $geotag,
55                 '$nickname' => $a->user['nickname']
56         ]);
57
58         if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
59                 $lockstate = 'lock';
60         } else {
61                 $lockstate = 'unlock';
62         }
63
64         $jotplugins = '';
65         $jotnets = '';
66
67         $mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1);
68
69         $mail_enabled = false;
70         $pubmail_enabled = false;
71
72         if (!$mail_disabled) {
73                 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
74                         intval(local_user())
75                 );
76
77                 if (DBA::isResult($r)) {
78                         $mail_enabled = true;
79
80                         if (intval($r[0]['pubmail'])) {
81                                 $pubmail_enabled = true;
82                         }
83                 }
84         }
85
86         Hook::callAll('jot_tool', $jotplugins);
87
88         $tpl = Renderer::getMarkupTemplate("jot.tpl");
89         $o .= Renderer::replaceMacros($tpl, [
90                 '$is_edit' => true,
91                 '$return_path' => '/display/' . $item['guid'],
92                 '$action' => 'item',
93                 '$share' => L10n::t('Save'),
94                 '$upload' => L10n::t('Upload photo'),
95                 '$shortupload' => L10n::t('upload photo'),
96                 '$attach' => L10n::t('Attach file'),
97                 '$shortattach' => L10n::t('attach file'),
98                 '$weblink' => L10n::t('Insert web link'),
99                 '$shortweblink' => L10n::t('web link'),
100                 '$video' => L10n::t('Insert video link'),
101                 '$shortvideo' => L10n::t('video link'),
102                 '$audio' => L10n::t('Insert audio link'),
103                 '$shortaudio' => L10n::t('audio link'),
104                 '$setloc' => L10n::t('Set your location'),
105                 '$shortsetloc' => L10n::t('set location'),
106                 '$noloc' => L10n::t('Clear browser location'),
107                 '$shortnoloc' => L10n::t('clear location'),
108                 '$wait' => L10n::t('Please wait'),
109                 '$permset' => L10n::t('Permission settings'),
110                 '$wall' => $item['wall'],
111                 '$posttype' => $item['post-type'],
112                 '$content' => undo_post_tagging($item['body']),
113                 '$post_id' => $post_id,
114                 '$baseurl' => System::baseUrl(),
115                 '$defloc' => $a->user['default-location'],
116                 '$visitor' => 'none',
117                 '$pvisit' => 'none',
118                 '$emailcc' => L10n::t('CC: email addresses'),
119                 '$public' => L10n::t('Public post'),
120                 '$jotnets' => $jotnets,
121                 '$title' => $item['title'],
122                 '$placeholdertitle' => L10n::t('Set title'),
123                 '$category' => FileTag::fileToList($item['file'], 'category'),
124                 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
125                 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
126                 '$lockstate' => $lockstate,
127                 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
128                 '$bang' => ($lockstate === 'lock' ? '!' : ''),
129                 '$profile_uid' => $_SESSION['uid'],
130                 '$preview' => L10n::t('Preview'),
131                 '$jotplugins' => $jotplugins,
132                 '$sourceapp' => L10n::t($a->sourcename),
133                 '$cancel' => L10n::t('Cancel'),
134                 '$rand_num' => Crypto::randomDigits(12),
135
136                 //jot nav tab (used in some themes)
137                 '$message' => L10n::t('Message'),
138                 '$browser' => L10n::t('Browser'),
139                 '$shortpermset' => L10n::t('permissions'),
140         ]);
141
142         return $o;
143 }