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