Changeset 5009
- Timestamp:
- 07/04/2013 12:11:09 PM (11 years ago)
- Location:
- trunk/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/replies/functions.php
r5002 r5009 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']; 152 // Topic id was not passed 153 if ( empty( $_POST['bbp_topic_id'] ) ) { 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 155 161 } else { 156 bbp_add_error( 'bbp_reply_topic_id', __( '<strong>ERROR</strong>: Topic ID is missing.', 'bbpress' ) ); 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 ( 0 > $posted_topic_id ) { 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 empty 204 if ( 0 === $posted_forum_id ) { 205 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 206 207 // Forum id is a negative number 208 } elseif ( 0 > $posted_forum_id ) { 209 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID cannot be a negative number.', 'bbpress' ) ); 210 211 // Forum does not exist 212 } elseif ( ! get_post( $posted_forum_id ) ) { 213 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum does not exist.', 'bbpress' ) ); 214 215 // Use the POST'ed forum id 216 } else { 217 $forum_id = $posted_forum_id; 218 } 219 } 168 220 } 169 221 -
trunk/includes/topics/functions.php
r5002 r5009 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' ) ); 194 195 // Forum id was passed 196 } elseif ( is_numeric( $_POST['bbp_forum_id'] ) ) { 197 $forum_id = (int) $_POST['bbp_forum_id']; 191 // Error check the POST'ed topic id 192 if ( isset( $_POST['bbp_forum_id'] ) ) { 193 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 empty 209 if ( 0 === $posted_forum_id ) { 210 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 211 212 // Forum id is a negative number 213 } elseif ( 0 > $posted_forum_id ) { 214 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID cannot be a negative number.', 'bbpress' ) ); 215 216 // Forum does not exist 217 } elseif ( ! get_post( $posted_forum_id ) ) { 218 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum does not exist.', 'bbpress' ) ); 219 220 // Use the POST'ed forum id 221 } else { 222 $forum_id = $posted_forum_id; 223 } 224 } 198 225 } 199 226
Note: See TracChangeset
for help on using the changeset viewer.