Skip to content
Newer
Older
100644 226 lines (180 sloc) 9.17 KB
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
1 <?php
619e67e Added phpDoc comments to the start of every PHP file, replacing the e…
Anatoly authored Oct 21, 2008
2 /**
3 * Post deletion page.
4 *
5 * Deletes the specified post (and, if necessary, the topic it is in).
6 *
b0b11dc @dimkalinux Change copyright date
dimkalinux authored Apr 5, 2011
7 * @copyright (C) 2008-2011 PunBB, partially based on code (C) 2008-2009 FluxBB.org
619e67e Added phpDoc comments to the start of every PHP file, replacing the e…
Anatoly authored Oct 21, 2008
8 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
9 * @package PunBB
10 */
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
11
12
13 if (!defined('FORUM_ROOT'))
14 define('FORUM_ROOT', './');
15 require FORUM_ROOT.'include/common.php';
16
17 ($hook = get_hook('dl_start')) ? eval($hook) : null;
18
19 if ($forum_user['g_read_board'] == '0')
20 message($lang_common['No view']);
21
22 // Load the delete.php language file
23 require FORUM_ROOT.'lang/'.$forum_user['language'].'/delete.php';
24
25 $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
26 if ($id < 1)
27 message($lang_common['Bad request']);
28
29
30 // Fetch some info about the post, the topic and the forum
31 $query = array(
7eb6d4f Fixed incorrect posted column being used to display post time in dele…
Anatoly authored Oct 16, 2008
32 'SELECT' => 'f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.first_post_id, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted',
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
33 'FROM' => 'posts AS p',
34 'JOINS' => array(
35 array(
36 'INNER JOIN' => 'topics AS t',
37 'ON' => 't.id=p.topic_id'
38 ),
39 array(
40 'INNER JOIN' => 'forums AS f',
41 'ON' => 'f.id=t.forum_id'
42 ),
43 array(
44 'LEFT JOIN' => 'forum_perms AS fp',
45 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
46 )
47 ),
48 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id
49 );
50
51 ($hook = get_hook('dl_qr_get_post_info')) ? eval($hook) : null;
52 $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
53 $cur_post = $forum_db->fetch_assoc($result);
54
ca4a8bb @dimkalinux Remove num_rows from delete.php
dimkalinux authored Mar 22, 2011
55 if (!$cur_post)
56 message($lang_common['Bad request']);
57
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
58 // Sort out who the moderators are and if we are currently a moderator (or an admin)
59 $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array();
60 $forum_page['is_admmod'] = ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && array_key_exists($forum_user['username'], $mods_array))) ? true : false;
61
62 $cur_post['is_topic'] = ($id == $cur_post['first_post_id']) ? true : false;
63
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
64 ($hook = get_hook('dl_pre_permission_check')) ? eval($hook) : null;
65
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
66 // Do we have permission to delete this post?
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
67 if ((($forum_user['g_delete_posts'] == '0' && !$cur_post['is_topic']) ||
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
68 ($forum_user['g_delete_topics'] == '0' && $cur_post['is_topic']) ||
69 $cur_post['poster_id'] != $forum_user['id'] ||
70 $cur_post['closed'] == '1') &&
71 !$forum_page['is_admmod'])
72 message($lang_common['No permission']);
73
74
75 ($hook = get_hook('dl_post_selected')) ? eval($hook) : null;
76
77 // User pressed the cancel button
78 if (isset($_POST['cancel']))
79 redirect(forum_link($forum_url['post'], $id), $lang_common['Cancel redirect']);
80
81 // User pressed the delete button
82 else if (isset($_POST['delete']))
83 {
84 ($hook = get_hook('dl_form_submitted')) ? eval($hook) : null;
85
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
86 if (!isset($_POST['req_confirm']))
87 redirect(forum_link($forum_url['post'], $id), $lang_common['No confirm redirect']);
88
89 if ($cur_post['is_topic'])
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
90 {
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
91 // Delete the topic and all of it's posts
92 delete_topic($cur_post['tid'], $cur_post['fid']);
93
b7eb32b @dimkalinux Delete.php: add flash messages
dimkalinux authored Jun 22, 2011
94 $forum_flash->add_info($lang_delete['Topic del redirect']);
95
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
96 ($hook = get_hook('dl_topic_deleted_pre_redirect')) ? eval($hook) : null;
97
98 redirect(forum_link($forum_url['forum'], array($cur_post['fid'], sef_friendly($cur_post['forum_name']))), $lang_delete['Topic del redirect']);
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
99 }
100 else
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
101 {
102 // Delete just this one post
103 delete_post($id, $cur_post['tid'], $cur_post['fid']);
104
b7eb32b @dimkalinux Delete.php: add flash messages
dimkalinux authored Jun 22, 2011
105 $forum_flash->add_info($lang_delete['Post del redirect']);
106
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
107 ($hook = get_hook('dl_post_deleted_pre_redirect')) ? eval($hook) : null;
108
109 redirect(forum_link($forum_url['topic'], array($cur_post['tid'], sef_friendly($cur_post['subject']))), $lang_delete['Post del redirect']);
110 }
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
111 }
112
113 // Run the post through the parser
114 if (!defined('FORUM_PARSER_LOADED'))
115 require FORUM_ROOT.'include/parser.php';
806afa0 Added constants to various included files.
Anatoly authored Oct 20, 2008
116
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
117 $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
118
119 // Setup form
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
120 $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
121 $forum_page['form_action'] = forum_link($forum_url['delete'], $id);
122
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
123 $forum_page['hidden_fields'] = array(
124 'form_sent' => '<input type="hidden" name="form_sent" value="1" />',
125 'csrf_token' => '<input type="hidden" name="csrf_token" value="'.generate_form_token($forum_page['form_action']).'" />'
126 );
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
127
128 // Setup form information
129 $forum_page['frm_info'] = array(
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
130 '<li><span>'.$lang_delete['Forum'].':<strong> '.forum_htmlencode($cur_post['forum_name']).'</strong></span></li>',
131 '<li><span>'.$lang_delete['Topic'].':<strong> '.forum_htmlencode($cur_post['subject']).'</strong></span></li>',
132 '<li><span>'.sprintf((($cur_post['is_topic']) ? $lang_delete['Delete topic info'] : $lang_delete['Delete post info']), forum_htmlencode($cur_post['poster']), format_time($cur_post['posted'])).'</span></li>'
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
133 );
134
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
135 // Generate the post heading
136 $forum_page['post_ident'] = array();
137 $forum_page['post_ident']['byline'] = '<span class="post-byline">'.sprintf((($cur_post['is_topic']) ? $lang_delete['Topic byline'] : $lang_delete['Reply byline']), '<strong>'.forum_htmlencode($cur_post['poster']).'</strong>').'</span>';
138 $forum_page['post_ident']['link'] = '<span class="post-link"><a class="permalink" href="'.forum_link($forum_url['post'], $cur_post['tid']).'">'.format_time($cur_post['posted']).'</a></span>';
139
140 ($hook = get_hook('dl_pre_item_ident_merge')) ? eval($hook) : null;
141
142 // Generate the post title
143 if ($cur_post['is_topic'])
144 $forum_page['item_subject'] = sprintf($lang_delete['Topic title'], $cur_post['subject']);
145 else
146 $forum_page['item_subject'] = sprintf($lang_delete['Reply title'], $cur_post['subject']);
147
148 $forum_page['item_subject'] = forum_htmlencode($forum_page['item_subject']);
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
149
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
150 // Setup breadcrumbs
151 $forum_page['crumbs'] = array(
152 array($forum_config['o_board_title'], forum_link($forum_url['index'])),
153 array($cur_post['forum_name'], forum_link($forum_url['forum'], array($cur_post['fid'], sef_friendly($cur_post['forum_name'])))),
154 array($cur_post['subject'], forum_link($forum_url['topic'], array($cur_post['tid'], sef_friendly($cur_post['subject'])))),
155 (($cur_post['is_topic']) ? $lang_delete['Delete topic'] : $lang_delete['Delete post'])
156 );
157
158 ($hook = get_hook('dl_pre_header_load')) ? eval($hook) : null;
159
160 define ('FORUM_PAGE', 'postdelete');
161 require FORUM_ROOT.'header.php';
162
163 // START SUBST - <!-- forum_main -->
164 ob_start();
165
166 ($hook = get_hook('dl_main_output_start')) ? eval($hook) : null;
167
168 ?>
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
169 <div class="main-content main-frm">
170 <div class="ct-box info-box">
171 <ul class="info-list">
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
172 <?php echo implode("\n\t\t\t\t", $forum_page['frm_info'])."\n" ?>
173 </ul>
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
174 </div>
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
175 <?php ($hook = get_hook('dl_pre_post_display')) ? eval($hook) : null; ?>
176 <div class="post singlepost">
177 <div class="posthead">
178 <h3 class="hn post-ident"><?php echo implode(' ', $forum_page['post_ident']) ?></h3>
179 <?php ($hook = get_hook('dl_new_post_head_option')) ? eval($hook) : null; ?>
180 </div>
181 <div class="postbody">
182 <div class="post-entry">
183 <h4 class="entry-title hn"><?php echo $forum_page['item_subject'] ?></h4>
184 <div class="entry-content">
185 <?php echo $cur_post['message']."\n" ?>
186 </div>
187 <?php ($hook = get_hook('dl_new_post_entry_data')) ? eval($hook) : null; ?>
188 </div>
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
189 </div>
190 </div>
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
191 <form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo $forum_page['form_action'] ?>">
192 <div class="hidden">
193 <?php echo implode("\n\t\t\t\t", $forum_page['hidden_fields'])."\n" ?>
194 </div>
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
195 <?php ($hook = get_hook('dl_pre_confirm_delete_fieldset')) ? eval($hook) : null; ?>
196 <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
197 <legend class="group-legend"><strong><?php echo ($cur_post['is_topic']) ? $lang_delete['Delete topic'] : $lang_delete['Delete post'] ?></strong></legend>
198 <?php ($hook = get_hook('dl_pre_confirm_delete_checkbox')) ? eval($hook) : null; ?>
199 <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
200 <div class="sf-box checkbox">
201 <span class="fld-input"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="req_confirm" value="1" checked="checked" /></span>
202 <label for="fld<?php echo $forum_page['fld_count'] ?>"><span><?php echo $lang_delete['Please confirm'] ?></span> <?php printf(((($cur_post['is_topic'])) ? $lang_delete['Delete topic label'] : $lang_delete['Delete post label']), forum_htmlencode($cur_post['poster']), format_time($cur_post['posted'])) ?></label>
203 </div>
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
204 </div>
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
205 <?php ($hook = get_hook('dl_pre_confirm_delete_fieldset_end')) ? eval($hook) : null; ?>
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
206 </fieldset>
0a8534c Merged new markup (based on markup by Paul Sullivan) into main PunBB …
Anatoly authored Oct 25, 2008
207 <?php ($hook = get_hook('dl_confirm_delete_fieldset_end')) ? eval($hook) : null; ?>
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
208 <div class="frm-buttons">
7c9a3d1 @dimkalinux Add .primary class to submit buttons in delete.php
dimkalinux authored May 6, 2011
209 <span class="submit primary"><input type="submit" name="delete" value="<?php echo ($cur_post['is_topic']) ? $lang_delete['Delete topic'] : $lang_delete['Delete post'] ?>" /></span>
e3c781f @dimkalinux Add novalidate attr for non-submit buttons for prevent validation on …
dimkalinux authored Apr 1, 2011
210 <span class="cancel"><input type="submit" name="cancel" value="<?php echo $lang_common['Cancel'] ?>" formnovalidate /></span>
b8f0ce4 Reverting to rev248
Anatoly authored Jun 17, 2008
211 </div>
212 </form>
213 </div>
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
214 <?php
215
216 $forum_id = $cur_post['fid'];
217
218 ($hook = get_hook('dl_end')) ? eval($hook) : null;
219
a096817 Globally replacing trim() with forum_trim().
Anatoly authored Oct 16, 2008
220 $tpl_temp = forum_trim(ob_get_contents());
07959a2 Development version of PunBB 1.3
Anatoly authored Jun 4, 2008
221 $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
222 ob_end_clean();
223 // END SUBST - <!-- forum_main -->
224
225 require FORUM_ROOT.'footer.php';
Something went wrong with that request. Please try again.