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