Ticket #2363: 2363.patch
File 2363.patch, 4.8 KB (added by , 11 years ago) |
---|
-
includes/replies/functions.php
149 149 150 150 /** Topic ID **************************************************************/ 151 151 152 // Handle Topic ID to append reply to 153 if ( isset( $_POST['bbp_topic_id'] ) ) { 154 $topic_id = (int) $_POST['bbp_topic_id']; 155 } else { 152 // Topic id was not passed 153 if ( empty( $_POST['bbp_topic_id'] ) ) { 156 154 bbp_add_error( 'bbp_reply_topic_id', __( '<strong>ERROR</strong>: Topic ID is missing.', 'bbpress' ) ); 155 156 // Topic id is not a number 157 } elseif ( ! is_numeric( $_POST['bbp_topic_id'] ) ) { 158 bbp_add_error( 'bbp_reply_topic_id', __( '<strong>ERROR</strong>: Topic ID must be a number.', 'bbpress' ) ); 159 160 // Topic id might be valid 161 } else { 162 163 // Get the topic id 164 $posted_topic_id = intval( $_POST['bbp_topic_id'] ); 165 166 // Topic id is a negative number 167 if ( $posted_topic_id <= 0 ) { 168 bbp_add_error( 'bbp_reply_topic_id', __( '<strong>ERROR</strong>: Topic ID cannot be a negative number.', 'bbpress' ) ); 169 170 // Topic does not exist 171 } elseif ( ! get_post( $posted_topic_id ) ) { 172 bbp_add_error( 'bbp_reply_topic_id', __( '<strong>ERROR</strong>: Topic does not exist.', 'bbpress' ) ); 173 174 // Use the POST'ed topic id 175 } else { 176 $topic_id = $posted_topic_id; 177 } 157 178 } 158 179 159 180 /** Forum ID **************************************************************/ 160 181 161 // Handle Forum ID to adjust counts of 162 if ( isset( $_POST['bbp_forum_id'] ) ) { 163 $forum_id = (int) $_POST['bbp_forum_id']; 164 } elseif ( !empty( $topic_id ) ) { 182 // Try to use the forum id of the topic 183 if ( !isset( $_POST['bbp_forum_id'] ) && !empty( $topic_id ) ) { 165 184 $forum_id = bbp_get_topic_forum_id( $topic_id ); 166 } else { 167 bbp_add_error( 'bbp_reply_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 185 186 // Error check the POST'ed forum id 187 } elseif ( isset( $_POST['bbp_forum_id'] ) ) { 188 189 // Empty Forum id was passed 190 if ( empty( $_POST['bbp_forum_id'] ) ) { 191 bbp_add_error( 'bbp_reply_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 192 193 // Forum id is not a number 194 } elseif ( ! is_numeric( $_POST['bbp_forum_id'] ) ) { 195 bbp_add_error( 'bbp_reply_forum_id', __( '<strong>ERROR</strong>: Forum ID must be a number.', 'bbpress' ) ); 196 197 // Forum id might be valid 198 } else { 199 200 // Get the forum id 201 $posted_forum_id = intval( $_POST['bbp_forum_id'] ); 202 203 // Forum id is a negative number 204 if ( 0 === $posted_forum_id ) { 205 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 206 207 } elseif ( 0 > $posted_forum_id ) { 208 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID cannot be a negative number.', 'bbpress' ) ); 209 210 // Forum does not exist 211 } elseif ( ! get_post( $posted_forum_id ) ) { 212 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum does not exist.', 'bbpress' ) ); 213 214 // Use the POST'ed forum id 215 } else { 216 $forum_id = $posted_forum_id; 217 } 218 } 168 219 } 169 220 170 221 // Forum exists -
includes/topics/functions.php
188 188 189 189 /** Topic Forum ***********************************************************/ 190 190 191 // Forum id was not passed 192 if ( empty( $_POST['bbp_forum_id'] ) ) { 193 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 191 // Error check the POST'ed topic id 192 if ( isset( $_POST['bbp_forum_id'] ) ) { 194 193 195 // Forum id was passed 196 } elseif ( is_numeric( $_POST['bbp_forum_id'] ) ) { 197 $forum_id = (int) $_POST['bbp_forum_id']; 194 // Empty Forum id was passed 195 if ( empty( $_POST['bbp_forum_id'] ) ) { 196 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 197 198 // Forum id is not a number 199 } elseif ( ! is_numeric( $_POST['bbp_forum_id'] ) ) { 200 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID must be a number.', 'bbpress' ) ); 201 202 // Forum id might be valid 203 } else { 204 205 // Get the forum id 206 $posted_forum_id = intval( $_POST['bbp_forum_id'] ); 207 208 // Forum id is a negative number 209 if ( 0 === $posted_forum_id ) { 210 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 211 212 } elseif ( 0 > $posted_forum_id ) { 213 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID cannot be a negative number.', 'bbpress' ) ); 214 215 // Forum does not exist 216 } elseif ( ! get_post( $posted_forum_id ) ) { 217 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum does not exist.', 'bbpress' ) ); 218 219 // Use the POST'ed forum id 220 } else { 221 $forum_id = $posted_forum_id; 222 } 223 } 198 224 } 199 225 200 226 // Forum exists