3 * @file mod/editpost.php
6 use Friendica\Content\Feature;
7 use Friendica\Core\Addon;
8 use Friendica\Core\Config;
9 use Friendica\Core\Hook;
10 use Friendica\Core\L10n;
11 use Friendica\Core\Renderer;
12 use Friendica\Core\System;
13 use Friendica\Model\FileTag;
14 use Friendica\Model\Item;
15 use Friendica\Database\DBA;
16 use Friendica\Util\Crypto;
18 function editpost_content(App $a)
23 notice(L10n::t('Permission denied.') . EOL);
27 $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
30 notice(L10n::t('Item not found') . EOL);
34 $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
35 'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
37 $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
39 if (!DBA::isResult($item)) {
40 notice(L10n::t('Item not found') . EOL);
46 $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate("section_title.tpl"), [
47 '$title' => L10n::t('Edit post')
50 $tpl = Renderer::getMarkupTemplate('jot-header.tpl');
51 $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
52 '$baseurl' => System::baseUrl(),
53 '$ispublic' => ' ', // L10n::t('Visible to <strong>everybody</strong>'),
55 '$nickname' => $a->user['nickname']
58 if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
61 $lockstate = 'unlock';
67 $mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1);
69 $mail_enabled = false;
70 $pubmail_enabled = false;
72 if (!$mail_disabled) {
73 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
77 if (DBA::isResult($r)) {
80 if (intval($r[0]['pubmail'])) {
81 $pubmail_enabled = true;
86 Hook::callAll('jot_tool', $jotplugins);
88 $tpl = Renderer::getMarkupTemplate("jot.tpl");
89 $o .= Renderer::replaceMacros($tpl, [
91 '$return_path' => '/display/' . $item['guid'],
93 '$share' => L10n::t('Save'),
94 '$upload' => L10n::t('Upload photo'),
95 '$shortupload' => L10n::t('upload photo'),
96 '$attach' => L10n::t('Attach file'),
97 '$shortattach' => L10n::t('attach file'),
98 '$weblink' => L10n::t('Insert web link'),
99 '$shortweblink' => L10n::t('web link'),
100 '$video' => L10n::t('Insert video link'),
101 '$shortvideo' => L10n::t('video link'),
102 '$audio' => L10n::t('Insert audio link'),
103 '$shortaudio' => L10n::t('audio link'),
104 '$setloc' => L10n::t('Set your location'),
105 '$shortsetloc' => L10n::t('set location'),
106 '$noloc' => L10n::t('Clear browser location'),
107 '$shortnoloc' => L10n::t('clear location'),
108 '$wait' => L10n::t('Please wait'),
109 '$permset' => L10n::t('Permission settings'),
110 '$wall' => $item['wall'],
111 '$posttype' => $item['post-type'],
112 '$content' => undo_post_tagging($item['body']),
113 '$post_id' => $post_id,
114 '$baseurl' => System::baseUrl(),
115 '$defloc' => $a->user['default-location'],
116 '$visitor' => 'none',
118 '$emailcc' => L10n::t('CC: email addresses'),
119 '$public' => L10n::t('Public post'),
120 '$jotnets' => $jotnets,
121 '$title' => $item['title'],
122 '$placeholdertitle' => L10n::t('Set title'),
123 '$category' => FileTag::fileToList($item['file'], 'category'),
124 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
125 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
126 '$lockstate' => $lockstate,
127 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
128 '$bang' => ($lockstate === 'lock' ? '!' : ''),
129 '$profile_uid' => $_SESSION['uid'],
130 '$preview' => L10n::t('Preview'),
131 '$jotplugins' => $jotplugins,
132 '$sourceapp' => L10n::t($a->sourcename),
133 '$cancel' => L10n::t('Cancel'),
134 '$rand_num' => Crypto::randomDigits(12),
136 //jot nav tab (used in some themes)
137 '$message' => L10n::t('Message'),
138 '$browser' => L10n::t('Browser'),
139 '$shortpermset' => L10n::t('permissions'),