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