]> git.mxchange.org Git - friendica.git/blob - mod/editpost.php
Merge pull request #423 from fermionic/frost-updates
[friendica.git] / mod / editpost.php
1 <?php
2
3 require_once('acl_selectors.php');
4
5 function editpost_content(&$a) {
6
7         $o = '';
8
9         if(! local_user()) {
10                 notice( t('Permission denied.') . EOL);
11                 return;
12         }
13
14         $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
15
16         if(! $post_id) {
17                 notice( t('Item not found') . EOL);
18                 return;
19         }
20
21         $itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
22                 intval($post_id),
23                 intval(local_user())
24         );
25
26         if(! count($itm)) {
27                 notice( t('Item not found') . EOL);
28                 return;
29         }
30
31         $plaintext = false;
32         if(local_user() && intval(get_pconfig(local_user(),'system','plaintext')))
33                 $plaintext = true;
34
35
36         $o .= '<h2>' . t('Edit post') . '</h2>';
37
38         $tpl = get_markup_template('jot-header.tpl');
39         $a->page['htmlhead'] .= replace_macros($tpl, array(
40                 '$baseurl' => $a->get_baseurl(),
41                 '$editselect' =>  (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
42                 '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
43                 '$geotag' => $geotag,
44                 '$nickname' => $a->user['nickname']
45         ));
46
47         $tpl = get_markup_template('jot-end.tpl');
48         $a->page['end'] .= replace_macros($tpl, array(
49                 '$baseurl' => $a->get_baseurl(),
50                 '$editselect' =>  (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
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         $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
65
66         $jotplugins = '';
67         $jotnets = '';
68
69         $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
70
71         $mail_enabled = false;
72         $pubmail_enabled = false;
73
74         if(! $mail_disabled) {
75                 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
76                         intval(local_user())
77                 );
78                 if(count($r)) {
79                         $mail_enabled = true;
80                         if(intval($r[0]['pubmail']))
81                                 $pubmail_enabled = true;
82                 }
83         }
84
85         if($mail_enabled) {
86        $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
87                 $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
88                 . t("Post to Email") . '</div>';
89         }
90                                         
91
92
93         call_hooks('jot_tool', $jotplugins);
94         call_hooks('jot_networks', $jotnets);
95
96         
97         //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));      
98         
99
100         $o .= replace_macros($tpl,array(
101                 '$return_path' => $_SESSION['return_url'],
102                 '$action' => 'item',
103                 '$share' => t('Edit'),
104                 '$upload' => t('Upload photo'),
105                 '$attach' => t('Attach file'),
106                 '$weblink' => t('Insert web link'),
107                 '$youtube' => t('Insert YouTube video'),
108                 '$video' => t('Insert Vorbis [.ogg] video'),
109                 '$audio' => t('Insert Vorbis [.ogg] audio'),
110                 '$setloc' => t('Set your location'),
111                 '$noloc' => t('Clear browser location'),
112                 '$wait' => t('Please wait'),
113                 '$permset' => t('Permission settings'),
114                 '$ptyp' => $itm[0]['type'],
115                 '$content' => undo_post_tagging($itm[0]['body']),
116                 '$post_id' => $post_id,
117                 '$baseurl' => $a->get_baseurl(),
118                 '$defloc' => $a->user['default-location'],
119                 '$visitor' => 'none',
120                 '$pvisit' => 'none',
121                 '$emailcc' => t('CC: email addresses'),
122                 '$public' => t('Public post'),
123                 '$jotnets' => $jotnets,
124                 '$title' => $itm[0]['title'],
125                 '$placeholdertitle' => t('Set title'),
126                 '$category' => file_tag_file_to_list($itm[0]['file'], 'category'),
127                 '$placeholdercategory' => t('Categories (comma-separated list)'),
128                 '$emtitle' => t('Example: bob@example.com, mary@example.com'),
129                 '$lockstate' => $lockstate,
130                 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user), $celeb),
131                 '$bang' => (($group) ? '!' : ''),
132                 '$profile_uid' => $_SESSION['uid'],
133                 '$preview' => t('Preview'),
134                 '$jotplugins' => $jotplugins,
135                 '$sourceapp' => t($a->sourcename),
136         ));
137
138         return $o;
139
140 }
141
142