]> git.mxchange.org Git - friendica.git/blob - mod/editpost.php
Merge pull request #6048 from zeroadam/FileTag
[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 Friendcia\Model\FileTag;
12 use Friendica\Model\Item;
13 use Friendica\Database\DBA;
14
15 function editpost_content(App $a)
16 {
17         $o = '';
18
19         if (!local_user()) {
20                 notice(L10n::t('Permission denied.') . EOL);
21                 return;
22         }
23
24         $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
25
26         if (!$post_id) {
27                 notice(L10n::t('Item not found') . EOL);
28                 return;
29         }
30
31         $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
32                 'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
33
34         $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
35
36         if (!DBA::isResult($item)) {
37                 notice(L10n::t('Item not found') . EOL);
38                 return;
39         }
40
41         $geotag = '';
42
43         $o .= replace_macros(get_markup_template("section_title.tpl"), [
44                 '$title' => L10n::t('Edit post')
45         ]);
46
47         $tpl = get_markup_template('jot-header.tpl');
48         $a->page['htmlhead'] .= replace_macros($tpl, [
49                 '$baseurl' => System::baseUrl(),
50                 '$ispublic' => '&nbsp;', // L10n::t('Visible to <strong>everybody</strong>'),
51                 '$geotag' => $geotag,
52                 '$nickname' => $a->user['nickname']
53         ]);
54
55         $tpl = get_markup_template("jot.tpl");
56
57         if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
58                 $lockstate = 'lock';
59         } else {
60                 $lockstate = 'unlock';
61         }
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
76                 if (DBA::isResult($r)) {
77                         $mail_enabled = true;
78
79                         if (intval($r[0]['pubmail'])) {
80                                 $pubmail_enabled = true;
81                         }
82                 }
83         }
84
85         Addon::callHooks('jot_tool', $jotplugins);
86         //Addon::callHooks('jot_networks', $jotnets);
87
88         $o .= replace_macros($tpl, [
89                 '$is_edit' => true,
90                 '$return_path' => '/display/' . $item['guid'],
91                 '$action' => 'item',
92                 '$share' => L10n::t('Save'),
93                 '$upload' => L10n::t('Upload photo'),
94                 '$shortupload' => L10n::t('upload photo'),
95                 '$attach' => L10n::t('Attach file'),
96                 '$shortattach' => L10n::t('attach file'),
97                 '$weblink' => L10n::t('Insert web link'),
98                 '$shortweblink' => L10n::t('web link'),
99                 '$video' => L10n::t('Insert video link'),
100                 '$shortvideo' => L10n::t('video link'),
101                 '$audio' => L10n::t('Insert audio link'),
102                 '$shortaudio' => L10n::t('audio link'),
103                 '$setloc' => L10n::t('Set your location'),
104                 '$shortsetloc' => L10n::t('set location'),
105                 '$noloc' => L10n::t('Clear browser location'),
106                 '$shortnoloc' => L10n::t('clear location'),
107                 '$wait' => L10n::t('Please wait'),
108                 '$permset' => L10n::t('Permission settings'),
109                 '$wall' => $item['wall'],
110                 '$posttype' => $item['post-type'],
111                 '$content' => undo_post_tagging($item['body']),
112                 '$post_id' => $post_id,
113                 '$baseurl' => System::baseUrl(),
114                 '$defloc' => $a->user['default-location'],
115                 '$visitor' => 'none',
116                 '$pvisit' => 'none',
117                 '$emailcc' => L10n::t('CC: email addresses'),
118                 '$public' => L10n::t('Public post'),
119                 '$jotnets' => $jotnets,
120                 '$title' => htmlspecialchars($item['title']),
121                 '$placeholdertitle' => L10n::t('Set title'),
122                 '$category' => FileTag::fileToList($item['file'], 'category'),
123                 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
124                 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
125                 '$lockstate' => $lockstate,
126                 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
127                 '$bang' => ($lockstate === 'lock' ? '!' : ''),
128                 '$profile_uid' => $_SESSION['uid'],
129                 '$preview' => L10n::t('Preview'),
130                 '$jotplugins' => $jotplugins,
131                 '$sourceapp' => L10n::t($a->sourcename),
132                 '$cancel' => L10n::t('Cancel'),
133                 '$rand_num' => random_digits(12),
134
135                 //jot nav tab (used in some themes)
136                 '$message' => L10n::t('Message'),
137                 '$browser' => L10n::t('Browser'),
138                 '$shortpermset' => L10n::t('permissions'),
139         ]);
140
141         return $o;
142 }