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