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