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