]> git.mxchange.org Git - friendica.git/blob - mod/editpost.php
fix undeclared variables or wrong variable names (/mod)
[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\Database\DBM;
12
13 require_once 'include/acl_selectors.php';
14
15 function editpost_content(App $a) {
16
17         $o = '';
18
19         if (! local_user()) {
20                 notice(L10n::t('Permission denied.') . EOL);
21                 return;
22         }
23
24         $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
25
26         if (! $post_id) {
27                 notice(L10n::t('Item not found') . EOL);
28                 return;
29         }
30
31         $itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
32                 intval($post_id),
33                 intval(local_user())
34         );
35
36         if (! DBM::is_result($itm)) {
37                 notice(L10n::t('Item not found') . EOL);
38                 return;
39         }
40
41         $geotag = '';
42
43         $o .= replace_macros(get_markup_template("section_title.tpl"),[
44                 '$title' => L10n::t('Edit post')
45         ]);
46
47         $tpl = get_markup_template('jot-header.tpl');
48         $a->page['htmlhead'] .= replace_macros($tpl, [
49                 '$baseurl' => System::baseUrl(),
50                 '$ispublic' => '&nbsp;', // L10n::t('Visible to <strong>everybody</strong>'),
51                 '$geotag' => $geotag,
52                 '$nickname' => $a->user['nickname']
53         ]);
54
55         $tpl = get_markup_template('jot-end.tpl');
56         $a->page['end'] .= replace_macros($tpl, [
57                 '$baseurl' => System::baseUrl(),
58                 '$ispublic' => '&nbsp;', // L10n::t('Visible to <strong>everybody</strong>'),
59                 '$geotag' => $geotag,
60                 '$nickname' => $a->user['nickname']
61         ]);
62
63
64         $tpl = get_markup_template("jot.tpl");
65
66         if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))))
67                 $lockstate = 'lock';
68         else
69                 $lockstate = 'unlock';
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                 if (DBM::is_result($r)) {
84                         $mail_enabled = true;
85                         if(intval($r[0]['pubmail']))
86                                 $pubmail_enabled = true;
87                 }
88         }
89
90         // I don't think there's any need for the $jotnets when editing the post,
91         // and including them makes it difficult for the JS-free theme, so let's
92         // disable them
93 /*      if($mail_enabled) {
94        $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
95                 $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
96                 . L10n::t("Post to Email") . '</div>';
97         }*/
98
99
100
101         Addon::callHooks('jot_tool', $jotplugins);
102         //Addon::callHooks('jot_networks', $jotnets);
103
104
105         //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
106
107         $o .= replace_macros($tpl,[
108                 '$is_edit' => true,
109                 '$return_path' => $_SESSION['return_url'],
110                 '$action' => 'item',
111                 '$share' => L10n::t('Save'),
112                 '$upload' => L10n::t('Upload photo'),
113                 '$shortupload' => L10n::t('upload photo'),
114                 '$attach' => L10n::t('Attach file'),
115                 '$shortattach' => L10n::t('attach file'),
116                 '$weblink' => L10n::t('Insert web link'),
117                 '$shortweblink' => L10n::t('web link'),
118                 '$video' => L10n::t('Insert video link'),
119                 '$shortvideo' => L10n::t('video link'),
120                 '$audio' => L10n::t('Insert audio link'),
121                 '$shortaudio' => L10n::t('audio link'),
122                 '$setloc' => L10n::t('Set your location'),
123                 '$shortsetloc' => L10n::t('set location'),
124                 '$noloc' => L10n::t('Clear browser location'),
125                 '$shortnoloc' => L10n::t('clear location'),
126                 '$wait' => L10n::t('Please wait'),
127                 '$permset' => L10n::t('Permission settings'),
128                 '$ptyp' => $itm[0]['type'],
129                 '$content' => undo_post_tagging($itm[0]['body']),
130                 '$post_id' => $post_id,
131                 '$baseurl' => System::baseUrl(),
132                 '$defloc' => $a->user['default-location'],
133                 '$visitor' => 'none',
134                 '$pvisit' => 'none',
135                 '$emailcc' => L10n::t('CC: email addresses'),
136                 '$public' => L10n::t('Public post'),
137                 '$jotnets' => $jotnets,
138                 '$title' => htmlspecialchars($itm[0]['title']),
139                 '$placeholdertitle' => L10n::t('Set title'),
140                 '$category' => file_tag_file_to_list($itm[0]['file'], 'category'),
141                 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
142                 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
143                 '$lockstate' => $lockstate,
144                 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
145                 '$bang' => (($group) ? '!' : ''),
146                 '$profile_uid' => $_SESSION['uid'],
147                 '$preview' => L10n::t('Preview'),
148                 '$jotplugins' => $jotplugins,
149                 '$sourceapp' => L10n::t($a->sourcename),
150                 '$cancel' => L10n::t('Cancel'),
151                 '$rand_num' => random_digits(12),
152
153                 //jot nav tab (used in some themes)
154                 '$message' => L10n::t('Message'),
155                 '$browser' => L10n::t('Browser'),
156                 '$shortpermset' => L10n::t('permissions'),
157         ]);
158
159         return $o;
160 }