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