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