Changeset 2390
- Timestamp:
- 01/13/2010 09:47:16 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
bb-admin/options-discussion.php (modified) (4 diffs)
-
bb-includes/functions.bb-meta.php (modified) (1 diff)
-
bb-includes/functions.bb-posts.php (modified) (3 diffs)
-
bb-includes/functions.bb-template.php (modified) (4 diffs)
-
bb-post.php (modified) (3 diffs)
-
bb-templates/kakumei/post-form.php (modified) (1 diff)
-
bb-templates/kakumei/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-admin/options-discussion.php
r2264 r2390 10 10 if (!isset($_POST['enable_pingback'])) { 11 11 $_POST['enable_pingback'] = false; 12 } 13 14 if (!isset($_POST['enable_loginless'])) { 15 $_POST['enable_loginless'] = false; 12 16 } 13 17 … … 39 43 } 40 44 41 $ remote_options = array(45 $general_options = array( 42 46 'enable_pingback' => array( 43 47 'title' => __( 'Enable Pingbacks' ), … … 46 50 1 => __( 'Allow link notifications from other sites.' ) 47 51 ) 52 ), 53 54 'enable_loginless' => array( 55 'title' => __( 'Enable Login-less Posting' ), 56 'type' => 'checkbox', 57 'options' => array( 58 1 => __( 'Allow users to create topics and posts without logging in.' ) 59 ), 48 60 ), 49 61 ); … … 102 114 <fieldset> 103 115 <?php 104 foreach ( $ remote_options as $option => $args ) {116 foreach ( $general_options as $option => $args ) { 105 117 bb_option_form_element( $option, $args ); 106 118 } -
trunk/bb-includes/functions.bb-meta.php
r2387 r2390 466 466 'wp_plugins_cookie_path', 467 467 'wordpress_mu_primary_blog_id', 468 'enable_loginless', 468 469 'enable_xmlrpc', 469 470 'enable_pingback', -
trunk/bb-includes/functions.bb-posts.php
r2388 r2390 2 2 3 3 /* Posts */ 4 5 /** 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 * 10 * @param string $ip Comment IP. 11 * @param string $email Comment author email address. 12 * @param string $date MySQL time string. 13 */ 14 function bb_check_comment_flood( $ip = '', $email = '', $date = '' ) { 15 global $bbdb; 16 $user_id = (int) $user_id; 17 $throttle_time = bb_get_option( 'throttle_time' ); 18 19 if ( bb_current_user_can('manage_options') || empty( $throttle_time ) ) { 20 return; 21 } 22 23 $hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 ); 24 25 if ( bb_is_user_logged_in() ) { 26 $bb_current_user = bb_get_current_user(); 27 28 if ( isset($bb_current_user->data->last_posted) && time() < $bb_current_user->data->last_posted + $throttle_time && ! bb_current_user_can('throttle') ) { 29 if ( defined('DOING_AJAX') && DOING_AJAX ) { 30 die(__('Slow down; you move too fast.')); 31 } else { 32 bb_die(__('Slow down; you move too fast.')); 33 } 34 } 35 } else { 36 // todo: add logic for non-logged-in users 37 } 38 } 39 40 /** 41 * Get the current, non-logged-in commenter data. 42 * @return array The associative array of author, email, and url data. 43 */ 44 function bb_get_current_commenter() { 45 // 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'); 59 } 4 60 5 61 function bb_get_post( $post_id ) { … … 301 357 extract( wp_parse_args( $args, $defaults ) ); 302 358 359 if ( isset( $post_author ) ) { 360 $post_author = sanitize_user($post_author); 361 } 362 363 if ( isset( $post_email ) ) { 364 $post_email = sanitize_email($post_email); 365 } 366 367 if ( isset( $post_url ) ) { 368 $post_url = esc_url($post_url); 369 } 370 303 371 if ( !$topic = get_topic( $topic_id ) ) 304 372 return false; 305 373 306 if ( !$user = bb_get_user( $poster_id ) )374 if ( bb_is_login_required() && ! $user = bb_get_user( $poster_id ) ) 307 375 return false; 308 376 … … 331 399 $post_id = $topic_last_post_id = (int) $bbdb->insert_id; 332 400 401 // if user not logged in, save user data as meta data 402 if ( ! bb_is_user_logged_in() && ! bb_is_login_required() ) { 403 bb_update_meta($post_id, 'post_author', $post_author, 'post'); 404 bb_update_meta($post_id, 'post_email', $post_email, 'post'); 405 bb_update_meta($post_id, 'post_url', $post_url, 'post'); 406 } 407 333 408 if ( 0 == $post_status ) { 334 409 $topic_time = $post_time; 335 $topic_last_poster = $poster_id;336 $topic_last_poster_name = $user->user_login;410 $topic_last_poster = ( ! bb_is_user_logged_in() && ! bb_is_login_required() ) ? -1 : $poster_id; 411 $topic_last_poster_name = ( ! bb_is_user_logged_in() && ! bb_is_login_required() ) ? $post_author : $user->user_login; 337 412 338 413 $bbdb->query( $bbdb->prepare( "UPDATE $bbdb->forums SET posts = posts + 1 WHERE forum_id = %d;", $topic->forum_id ) ); -
trunk/bb-includes/functions.bb-template.php
r2387 r2390 292 292 293 293 if ( 294 ( false === bb_is_login_required() ) || 294 295 ( bb_is_topic() && bb_current_user_can( 'write_post', $topic->topic_id ) && ( $page == $last_page || !$last_page_only ) ) || 295 296 ( !bb_is_topic() && bb_current_user_can( 'write_topic', isset( $forum->forum_id ) ? $forum->forum_id : 0 ) ) … … 426 427 function bb_is_forum() { 427 428 return 'forum-page' == bb_get_location(); 429 } 430 431 /** 432 * Whether a user is required to log in in order to create posts and forums. 433 * @return bool Whether a user must be logged in. 434 */ 435 function bb_is_login_required() { 436 return ! (bool) bb_get_option('enable_loginless'); 428 437 } 429 438 … … 1736 1745 elseif ( $title = bb_get_post_meta( 'pingback_title' ) ) 1737 1746 return apply_filters( 'bb_get_pingback_title', $title, $post_id ); 1747 elseif ( $title = bb_get_post_meta( 'post_author' ) ) 1748 return apply_filters( 'get_post_author', $title, 0, $post_id ); 1738 1749 else 1739 1750 return apply_filters( 'get_post_author', __('Anonymous'), 0, $post_id ); … … 1744 1755 echo '<a href="' . esc_attr( $link ) . '">' . get_post_author( $post_id ) . '</a>'; 1745 1756 } elseif ( $link = bb_get_post_meta( 'pingback_uri' )) { 1757 echo '<a href="' . esc_attr( $link ) . '">' . get_post_author( $post_id ) . '</a>'; 1758 } elseif ( $link = bb_get_post_meta( 'post_url' ) ) { 1746 1759 echo '<a href="' . esc_attr( $link ) . '">' . get_post_author( $post_id ) . '</a>'; 1747 1760 } else { -
trunk/bb-post.php
r2075 r2390 2 2 require('./bb-load.php'); 3 3 4 bb_auth('logged_in'); 4 if ( bb_is_login_required() ) { 5 bb_auth('logged_in'); 6 } 5 7 6 if ( $throttle_time = bb_get_option( 'throttle_time' ) ) 7 if ( isset($bb_current_user->data->last_posted) && time() < $bb_current_user->data->last_posted + $throttle_time && !bb_current_user_can('throttle') ) 8 bb_die(__('Slow down; you move too fast.')); 8 bb_check_comment_flood(); 9 9 10 10 if ( !$post_content = trim($_POST['post_content']) ) 11 11 bb_die(__('You need to actually submit some content!')); 12 12 13 $post_author = $post_email = $post_url = ''; 14 15 if ( ! bb_is_user_logged_in() ) { 16 if ( bb_is_login_required() ) { 17 bb_die(__('You are not allowed to post. Are you logged in?')); 18 } else { 19 if ( ! $post_author = trim($_POST['author']) ) { 20 bb_die(__('You need to submit your name!')); 21 } elseif ( ! $post_email = trim($_POST['email']) ) { 22 bb_die(__('You need to submit your email!')); 23 } 24 25 if ( ! empty( $_POST['url'] ) ) { 26 $post_url = trim($_POST['url']); 27 } 28 } 29 } 30 31 32 33 13 34 if ( isset($_POST['topic']) && $forum_id = (int) $_POST['forum_id'] ) { 14 if ( !bb_current_user_can('write_posts') )35 if ( bb_is_login_required() && ! bb_current_user_can('write_posts') ) 15 36 bb_die(__('You are not allowed to post. Are you logged in?')); 16 37 17 if ( !bb_current_user_can( 'write_topic', $forum_id ) )38 if ( bb_is_login_required() && ! bb_current_user_can( 'write_topic', $forum_id ) ) 18 39 bb_die(__('You are not allowed to write new topics.')); 19 40 … … 33 54 } 34 55 35 if ( !bb_current_user_can( 'write_post', $topic_id ) )56 if ( bb_is_login_required() && ! bb_current_user_can( 'write_post', $topic_id ) ) 36 57 bb_die(__('You are not allowed to post. Are you logged in?')); 37 58 … … 39 60 bb_die(__('This topic has been closed')); 40 61 41 $post_id = bb_new_post( $topic_id, $_POST['post_content'] ); 62 $post_data = array( 63 'post_text' => stripslashes($_POST['post_content']), 64 'topic_id' => $topic_id, 65 ); 66 67 foreach( array('post_author', 'post_email', 'post_url') as $field ) { 68 if ( ! empty( $$field ) ) { 69 $post_data[$field] = $$field; 70 } 71 } 72 73 $post_id = bb_insert_post($post_data); 42 74 43 75 $tags = trim( $_POST['tags'] ); -
trunk/bb-templates/kakumei/post-form.php
r2351 r2390 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 <p id="post-form-post-container"> 9 32 <label for="post_content"><?php _e('Post'); ?> -
trunk/bb-templates/kakumei/style.css
r2349 r2390 593 593 .postform label { display: block; } 594 594 595 .postform #author, 596 .postform #email, 595 597 .postform #topic, 596 .postform #tags-input { 598 .postform #tags-input, 599 .postform #url { 597 600 margin: 5px 0; 598 601 padding: 5px;
Note: See TracChangeset
for help on using the changeset viewer.