Changeset 2453
- Timestamp:
- 07/01/2010 09:12:10 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
bb-includes/defaults.bb-filters.php (modified) (1 diff)
-
bb-includes/functions.bb-capabilities.php (modified) (1 diff)
-
bb-includes/functions.bb-deprecated.php (modified) (1 diff)
-
bb-includes/functions.bb-meta.php (modified) (1 diff)
-
bb-includes/functions.bb-posts.php (modified) (5 diffs)
-
bb-includes/functions.bb-template.php (modified) (5 diffs)
-
bb-includes/functions.bb-topics.php (modified) (2 diffs)
-
bb-post.php (modified) (2 diffs)
-
bb-templates/kakumei/post-form.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-includes/defaults.bb-filters.php
r2430 r2453 163 163 add_action( 'bb_new_post', 'bb_notify_subscribers' ); 164 164 165 add_action( 'post_form_pre_post', 'bb_anonymous_post_form' ); 166 165 167 unset( $filters, $filter ); -
trunk/bb-includes/functions.bb-capabilities.php
r2147 r2453 26 26 if ( empty($bb_current_user) ) { 27 27 $retvalue = false; 28 if ( ( $capability == 'write_topic' || $capability == 'write_topics' ) && !bb_is_login_required() ) 29 $retvalue = true; 30 if ( ( $capability == 'write_topic' || $capability == 'write_topics' ) && !bb_is_login_required() ) 31 $retvalue = true; 28 32 } else { 29 33 $retvalue = call_user_func_array(array(&$bb_current_user, 'has_cap'), $args); -
trunk/bb-includes/functions.bb-deprecated.php
r2363 r2453 1181 1181 } 1182 1182 } 1183 1184 function bb_get_current_commenter() { 1185 bb_log_deprecated( 'function', __FUNCTION__, 'bb_get_current_poster' ); 1186 extract( bb_get_current_poster() ); 1187 return array( 'comment_author' => $post_author, 'comment_email' => $post_author_email, 'comment_author_url' => $post_author_url ); 1188 } -
trunk/bb-includes/functions.bb-meta.php
r2452 r2453 298 298 break; 299 299 case 'version': 300 return '1.1-alpha-245 2'; // Don't filter300 return '1.1-alpha-2453'; // Don't filter 301 301 break; 302 302 case 'bb_db_version' : -
trunk/bb-includes/functions.bb-posts.php
r2452 r2453 5 5 /** 6 6 * Check to make sure that a user is not making too many posts in a short amount of time. 7 *8 * @todo Add logic for users not logged in.9 7 * 10 8 * @param string $ip Comment IP. … … 20 18 return; 21 19 } 22 23 $hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 );24 20 25 21 if ( bb_is_user_logged_in() ) { … … 34 30 } 35 31 } else { 36 // todo: add logic for non-logged-in users 32 if ( ( $last_posted = bb_get_transient($_SERVER['REMOTE_ADDR'] . '_last_posted') ) && time() < $last_posted + $throttle_time ) { 33 if ( defined('DOING_AJAX') && DOING_AJAX ) { 34 die(__('Slow down; you move too fast.')); 35 } else { 36 bb_die(__('Slow down; you move too fast.')); 37 } 38 } 37 39 } 38 40 } 39 41 40 42 /** 41 * Get the current, non-logged-in commenter data.43 * Get the current, non-logged-in poster data. 42 44 * @return array The associative array of author, email, and url data. 43 45 */ 44 function bb_get_current_ commenter() {46 function bb_get_current_poster() { 45 47 // Cookies should already be sanitized. 46 $ comment_author = '';47 if ( isset( $_COOKIE['comment_author_'.COOKIEHASH]) )48 $ comment_author = $_COOKIE['comment_author_'.COOKIEHASH];49 50 $ comment_author_email = '';51 if ( isset( $_COOKIE['comment_author_email_'.COOKIEHASH]) )52 $ comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];53 54 $ comment_author_url = '';55 if ( isset( $_COOKIE['comment_author_url_'.COOKIEHASH]) )56 $ comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];57 58 return compact( 'comment_author', 'comment_author_email', 'comment_author_url');48 $post_author = ''; 49 if ( isset( $_COOKIE['post_author_'.COOKIEHASH] ) ) 50 $post_author = $_COOKIE['post_author_'.COOKIEHASH]; 51 52 $post_author_email = ''; 53 if ( isset( $_COOKIE['post_author_email_'.COOKIEHASH] ) ) 54 $post_author_email = $_COOKIE['post_author_email_'.COOKIEHASH]; 55 56 $post_author_url = ''; 57 if ( isset( $_COOKIE['post_author_url_'.COOKIEHASH] ) ) 58 $post_author_url = $_COOKIE['post_author_url_'.COOKIEHASH]; 59 60 return compact( 'post_author', 'post_author_email', 'post_author_url' ); 59 61 } 60 62 … … 412 414 413 415 // if user not logged in, save user data as meta data 414 if ( ! bb_is_user_logged_in() && ! bb_is_login_required()) {416 if ( !$user ) { 415 417 bb_update_meta($post_id, 'post_author', $post_author, 'post'); 416 418 bb_update_meta($post_id, 'post_email', $post_email, 'post'); … … 440 442 bb_update_topic_voices( $topic_id ); 441 443 442 if ( $throttle && !bb_current_user_can( 'throttle' ) ) 443 bb_update_usermeta( $poster_id, 'last_posted', time() ); 444 if ( $throttle && !bb_current_user_can( 'throttle' ) ) { 445 if ( $user ) 446 bb_update_usermeta( $poster_id, 'last_posted', time() ); 447 else 448 bb_set_transient( $_SERVER['REMOTE_ADDR'] . '_last_posted', time() ); 449 } 444 450 445 451 wp_cache_delete( $topic_id, 'bb_topic' ); -
trunk/bb-includes/functions.bb-template.php
r2440 r2453 331 331 echo "\n" . '</fieldset>' . "\n" . '</form>' . "\n"; 332 332 do_action('post_edit_form'); 333 } 334 335 function bb_anonymous_post_form() { 336 if ( !bb_is_user_logged_in() && !bb_is_login_required() ) 337 bb_load_template( 'post-form-anonymous.php' ); 333 338 } 334 339 … … 1203 1208 function get_topic_last_poster( $id = 0 ) { 1204 1209 $topic = get_topic( get_topic_id( $id ) ); 1205 $user_display_name = get_ user_display_name($topic->topic_last_poster);1210 $user_display_name = get_post_author( $topic->topic_last_post_id ); 1206 1211 return apply_filters( 'get_topic_last_poster', $user_display_name, $topic->topic_last_poster, $topic->topic_id ); // $topic->topic_last_poster = user ID 1207 1212 } … … 1214 1219 function get_topic_author( $id = 0 ) { 1215 1220 $topic = get_topic( get_topic_id( $id ) ); 1216 $user_display_name = get_user_display_name($topic->topic_poster); 1221 $first_post = bb_get_first_post( $topic ); 1222 $user_display_name = get_post_author( $first_post->post_id ); 1217 1223 return apply_filters( 'get_topic_author', $user_display_name, $topic->topic_poster, $topic->topic_id ); // $topic->topic_poster = user ID 1218 1224 } … … 1601 1607 $url = bb_get_uri(null, array('new' => 1)); 1602 1608 1603 if ( !bb_is_user_logged_in() )1609 if ( !bb_is_user_logged_in() && bb_is_login_required() ) 1604 1610 $url = bb_get_uri('bb-login.php', array('redirect_to' => $url), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS); 1605 1611 elseif ( bb_is_forum() || bb_is_topic() ) { … … 1762 1768 if ( $user = bb_get_user( get_post_author_id( $post_id ) ) ) 1763 1769 return apply_filters( 'get_post_author', $user->display_name, $user->ID, $post_id ); 1764 elseif ( $title = bb_get_post_meta( 'pingback_title' ) )1770 elseif ( $title = bb_get_post_meta( 'pingback_title', $post_id ) ) 1765 1771 return apply_filters( 'bb_get_pingback_title', $title, $post_id ); 1766 elseif ( $title = bb_get_post_meta( 'post_author' ) )1772 elseif ( $title = bb_get_post_meta( 'post_author', $post_id ) ) 1767 1773 return apply_filters( 'get_post_author', $title, 0, $post_id ); 1768 1774 else -
trunk/bb-includes/functions.bb-topics.php
r2425 r2453 176 176 $forum_id = (int) $forum->forum_id; 177 177 178 if ( !$user = bb_get_user( $topic_poster ) ) 179 if ( !$user = bb_get_user( $topic_poster_name, array( 'by' => 'login' ) ) ) 180 return false; 181 $topic_poster = $user->ID; 182 $topic_poster_name = $user->user_login; 183 184 if ( !$last_user = bb_get_user( $topic_last_poster ) ) 185 if ( !$last_user = bb_get_user( $topic_last_poster_name, array( 'by' => 'login' ) ) ) 186 return false; 187 $topic_last_poster = $last_user->ID; 188 $topic_last_poster_name = $last_user->user_login; 178 if ( bb_is_user_logged_in() || bb_is_login_required() ) { 179 if ( !$user = bb_get_user( $topic_poster ) ) 180 if ( !$user = bb_get_user( $topic_poster_name, array( 'by' => 'login' ) ) ) 181 return false; 182 $topic_poster = $user->ID; 183 $topic_poster_name = $user->user_login; 184 185 if ( !$last_user = bb_get_user( $topic_last_poster ) ) 186 if ( !$last_user = bb_get_user( $topic_last_poster_name, array( 'by' => 'login' ) ) ) 187 return false; 188 $topic_last_poster = $last_user->ID; 189 $topic_last_poster_name = $last_user->user_login; 190 } 189 191 190 192 if ( in_array( 'topic_title', $fields ) ) { … … 235 237 236 238 // Deprecated: expects $title to be pre-escaped 237 function bb_new_topic( $title, $forum, $tags = '' ) {239 function bb_new_topic( $title, $forum, $tags = '', $args = '' ) { 238 240 $title = stripslashes( $title ); 239 241 $tags = stripslashes( $tags ); 240 242 $forum = (int) $forum; 241 return bb_insert_topic( array( 'topic_title' => $title, 'forum_id' => $forum, 'tags' => $tags ) );243 return bb_insert_topic( wp_parse_args( $args ) + array( 'topic_title' => $title, 'forum_id' => $forum, 'tags' => $tags ) ); 242 244 } 243 245 -
trunk/bb-post.php
r2415 r2453 47 47 bb_die(__('Please enter a topic title')); 48 48 49 $topic_id = bb_new_topic( $topic, $forum_id, $tags ); 49 $args = array(); 50 51 if ( isset( $post_author ) ) 52 $args['topic_poster_name'] = $args['topic_last_poster_name'] = $post_author; 53 54 $topic_id = bb_new_topic( $topic, $forum_id, $tags, $args ); 50 55 51 56 } elseif ( isset($_POST['topic_id'] ) ) { … … 89 94 wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 90 95 exit; 91 92 ?> -
trunk/bb-templates/kakumei/post-form.php
r2390 r2453 6 6 </p> 7 7 <?php endif; do_action( 'post_form_pre_post' ); ?> 8 <?php if ( ! bb_is_user_logged_in() && ! bb_is_login_required() ) :9 $current_commenter = bb_get_current_commenter();10 ?>11 <p id="post-form-author-container">12 <label for="author"><?php _e('Author (required)'); ?>13 <input type="text" name="author" id="author" size="50" aria-required="true" value="<?php echo esc_attr($current_commenter['comment_author']); ?>" />14 </label>15 </p>16 17 <p id="post-form-email-container">18 <label for="email"><?php _e('Email (required)'); ?>19 <input type="text" name="email" id="email" size="50" aria-required="true" value="<?php echo esc_attr($current_commenter['comment_author_email']); ?>" />20 </label>21 </p>22 23 <p id="post-form-url-container">24 <label for="url"><?php _e('URL'); ?>25 <input type="text" name="url" id="url" size="50" aria-required="true" value="<?php echo esc_attr($current_commenter['comment_author_url']); ?>" />26 </label>27 28 </p>29 <?php endif; // end user not logged in but logins aren't required ?>30 8 31 9 <p id="post-form-post-container">
Note: See TracChangeset
for help on using the changeset viewer.