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