]> git.mxchange.org Git - friendica.git/blob - mod/editpost.php
Merge pull request #4440 from rabuzarus/20180211_-_fix_variables_part_two
[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 (strlen($itm['allow_cid']) || strlen($itm['allow_gid']) || strlen($itm['deny_cid']) || strlen($itm['deny_gid'])) {
67                 $lockstate = 'lock';
68         } else {
69                 $lockstate = 'unlock';
70         }
71
72         $jotplugins = '';
73         $jotnets = '';
74
75         $mail_disabled = ((function_exists('imap_open') && (! Config::get('system','imap_disabled'))) ? 0 : 1);
76
77         $mail_enabled = false;
78         $pubmail_enabled = false;
79
80         if(! $mail_disabled) {
81                 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
82                         intval(local_user())
83                 );
84                 if (DBM::is_result($r)) {
85                         $mail_enabled = true;
86                         if(intval($r[0]['pubmail']))
87                                 $pubmail_enabled = true;
88                 }
89         }
90
91         // I don't think there's any need for the $jotnets when editing the post,
92         // and including them makes it difficult for the JS-free theme, so let's
93         // disable them
94 /*      if($mail_enabled) {
95        $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
96                 $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
97                 . L10n::t("Post to Email") . '</div>';
98         }*/
99
100
101
102         Addon::callHooks('jot_tool', $jotplugins);
103         //Addon::callHooks('jot_networks', $jotnets);
104
105
106         //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
107
108         $o .= replace_macros($tpl,[
109                 '$is_edit' => true,
110                 '$return_path' => $_SESSION['return_url'],
111                 '$action' => 'item',
112                 '$share' => L10n::t('Save'),
113                 '$upload' => L10n::t('Upload photo'),
114                 '$shortupload' => L10n::t('upload photo'),
115                 '$attach' => L10n::t('Attach file'),
116                 '$shortattach' => L10n::t('attach file'),
117                 '$weblink' => L10n::t('Insert web link'),
118                 '$shortweblink' => L10n::t('web link'),
119                 '$video' => L10n::t('Insert video link'),
120                 '$shortvideo' => L10n::t('video link'),
121                 '$audio' => L10n::t('Insert audio link'),
122                 '$shortaudio' => L10n::t('audio link'),
123                 '$setloc' => L10n::t('Set your location'),
124                 '$shortsetloc' => L10n::t('set location'),
125                 '$noloc' => L10n::t('Clear browser location'),
126                 '$shortnoloc' => L10n::t('clear location'),
127                 '$wait' => L10n::t('Please wait'),
128                 '$permset' => L10n::t('Permission settings'),
129                 '$ptyp' => $itm[0]['type'],
130                 '$content' => undo_post_tagging($itm[0]['body']),
131                 '$post_id' => $post_id,
132                 '$baseurl' => System::baseUrl(),
133                 '$defloc' => $a->user['default-location'],
134                 '$visitor' => 'none',
135                 '$pvisit' => 'none',
136                 '$emailcc' => L10n::t('CC: email addresses'),
137                 '$public' => L10n::t('Public post'),
138                 '$jotnets' => $jotnets,
139                 '$title' => htmlspecialchars($itm[0]['title']),
140                 '$placeholdertitle' => L10n::t('Set title'),
141                 '$category' => file_tag_file_to_list($itm[0]['file'], 'category'),
142                 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
143                 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
144                 '$lockstate' => $lockstate,
145                 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
146                 '$bang' => ($lockstate === 'lock' ? '!' : ''),
147                 '$profile_uid' => $_SESSION['uid'],
148                 '$preview' => L10n::t('Preview'),
149                 '$jotplugins' => $jotplugins,
150                 '$sourceapp' => L10n::t($a->sourcename),
151                 '$cancel' => L10n::t('Cancel'),
152                 '$rand_num' => random_digits(12),
153
154                 //jot nav tab (used in some themes)
155                 '$message' => L10n::t('Message'),
156                 '$browser' => L10n::t('Browser'),
157                 '$shortpermset' => L10n::t('permissions'),
158         ]);
159
160         return $o;
161 }