Changeset 5009 for trunk/includes/replies/functions.php
- Timestamp:
- 07/04/2013 12:11:09 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/includes/replies/functions.php (modified) (1 diff)
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
Note: See TracChangeset
for help on using the changeset viewer.