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