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