Skip to:
Content

bbPress.org

Changeset 2367


Ignore:
Timestamp:
08/17/2009 01:54:27 AM (16 years ago)
Author:
sambauers
Message:

branches 1.0: merge changes from trunk from [2344] to [2366]

Location:
branches/1.0
Files:
21 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/1.0/bb-admin/admin-base.php

    r1299 r2367  
    1111<?php if ( is_callable($bb_admin_page) ) : call_user_func( $bb_admin_page ); else : ?>
    1212
    13 <p><?php _e('Nothing to see here.'); ?><p>
     13<h2><?php _e( 'Page not found' ); ?></h2>
     14<?php
     15bb_admin_notice( __( 'There is no administration page at the requested address. Please check the address you entered and try again.' ), 'error' );
     16do_action( 'bb_admin_notices' );
     17?>
    1418
    1519<?php endif; ?>
  • branches/1.0/bb-admin/admin.php

    r2101 r2367  
    1717$bb_admin_page = bb_find_filename( $_SERVER['PHP_SELF'] );
    1818
     19$_check_callback = false;
    1920if ( $bb_admin_page == 'admin-base.php' ) {
    20     $bb_admin_page = $_GET['plugin'];
     21    $bb_admin_page = (string) @$_GET['plugin'];
     22    $_check_callback = true;
    2123}
    2224
     
    3537bb_admin_menu_generator();
    3638bb_get_current_admin_menu();
     39
     40if ( $_check_callback ) {
     41    if ( empty( $bb_registered_plugin_callbacks ) || empty( $bb_admin_page ) || !in_array( $bb_admin_page, $bb_registered_plugin_callbacks ) ) {
     42        unset( $bb_admin_page );
     43    }
     44}
    3745?>
  • branches/1.0/bb-admin/includes/functions.bb-admin.php

    r2290 r2367  
    118118{
    119119    global $bb_menu;
     120    global $bb_registered_plugin_callbacks;
     121    if ( empty( $bb_registered_plugin_callbacks ) ) {
     122        $bb_registered_plugin_callbacks = array();
     123    }
    120124
    121125    if ( $display_name && $capability && $file_name ) {
     
    165169        }
    166170
     171        if ( strpos( $file_name, '.php' ) === false ) {
     172            $bb_registered_plugin_callbacks[] = $file_name;
     173        }
     174
    167175        // Add the menu item at the given key
    168176        $bb_menu[$plugin_menu_next] = array( $display_name, $capability, $file_name, $class, $id );
     
    179187{
    180188    global $bb_submenu;
     189    global $bb_registered_plugin_callbacks;
     190    if ( empty( $bb_registered_plugin_callbacks ) ) {
     191        $bb_registered_plugin_callbacks = array();
     192    }
     193
    181194    if ( $display_name && $capability && $file_name ) {
     195        if ( strpos( $file_name, '.php' ) === false ) {
     196            $bb_registered_plugin_callbacks[] = $file_name;
     197        }
    182198        $bb_submenu[$parent][] = array( $display_name, $capability, $file_name );
    183199        ksort( $bb_submenu );
     
    398414function bb_user_row( $user, $role = '', $email = false ) {
    399415    $actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>";
    400     if ( bb_current_user_can( 'edit_user', $user_id ) )
     416    $title = '';
     417    if ( bb_current_user_can( 'edit_user', $user_id ) ) {
    401418        $actions .= " | <a href='" . esc_attr( get_profile_tab_link( $user->ID, 'edit' ) ) . "'>" . __('Edit') . "</a>";
     419        $title = " title='" . esc_attr( sprintf( __( 'User ID: %d' ), $user->ID ) ) . "'";
     420    }
    402421    $r  = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n";
    403     $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span>&nbsp;</div></td>\n";
     422    $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'" . $title . ">" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span>&nbsp;</div></td>\n";
    404423    $r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n";
    405424    if ( $email ) {
  • branches/1.0/bb-admin/index.php

    r2217 r2367  
    3030$rn_topic_tags_average = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
    3131
     32$rn = apply_filters( 'bb_admin_right_now', array(
     33    'forums'     => array( $rn_forums, '-' ),
     34    'topics'     => array( $rn_topics, $rn_topics_average ),
     35    'posts'      => array( $rn_posts, $rn_posts_average ),
     36    'topic_tags' => array( $rn_topic_tags, $rn_topic_tags_average ),
     37    'users'      => array( $rn_users, $rn_users_average )
     38) );
     39
    3240$bb_admin_body_class = ' bb-admin-dashboard';
    3341
     
    4957                    </tr>
    5058                </thead>
     59<?php
     60if ( !empty( $rn ) && is_array( $rn ) ) {
     61?>
    5162                <tbody>
     63<?php
     64    foreach ( $rn as $rn_row ) {
     65?>
    5266                    <tr>
    53                         <td><?php echo $rn_forums; ?></td>
    54                         <td>-</td>
     67                        <td><?php echo $rn_row[0]; ?></td>
     68                        <td><?php echo $rn_row[1]; ?></td>
    5569                    </tr>
    56                     <tr>
    57                         <td><?php echo $rn_topics; ?></td>
    58                         <td><?php echo $rn_topics_average; ?></td>
    59                     </tr>
    60                     <tr>
    61                         <td><?php echo $rn_posts; ?></td>
    62                         <td><?php echo $rn_posts_average; ?></td>
    63                     </tr>
    64                     <tr>
    65                         <td><?php echo $rn_topic_tags; ?></td>
    66                         <td><?php echo $rn_topic_tags_average; ?></td>
    67                     </tr>
    68                     <tr>
    69                         <td><?php echo $rn_users; ?></td>
    70                         <td><?php echo $rn_users_average; ?></td>
    71                     </tr>
     70<?php
     71    }
     72?>
    7273                </tbody>
     74<?php
     75}
     76?>
    7377            </table>
    7478        </div>
  • branches/1.0/bb-admin/tools-recount.php

    r2236 r2367  
    11<?php
    2 require_once('admin.php');
     2require_once( 'admin.php' );
     3require_once( 'includes/functions.bb-recount.php' );
    34
    45if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
    56    bb_check_admin_referer( 'do-counts' );
    67
     8    // Stores messages
    79    $messages = array();
    8     if ( isset($_POST['topic-posts']) && 1 == $_POST['topic-posts'] ) {
    9         if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status = '0' GROUP BY topic_id") ) {
    10             $messages[] = __('Counted posts');
    11             foreach ($topics as $topic) {
    12                 $topic_id = (int) $topic->topic_id;
    13                 $bbdb->query( $bbdb->prepare( "UPDATE $bbdb->topics SET topic_posts = %s WHERE topic_id = %s" ), $topic->count, $topic_id );
    14             }
    15             unset($topics, $topic, $topic_id);
    16         }
     10
     11    if ( !empty( $_POST['topic-posts'] ) ) {
     12        $messages[] = bb_recount_topic_posts();
    1713    }
    1814
    19     if ( isset($_POST['topic-voices']) && 1 == $_POST['topic-voices'] ) {
    20         if ( $topics = (array) $bbdb->get_results("SELECT topic_id FROM $bbdb->topics ORDER BY topic_id") ) {
    21             $messages[] = __('Counted voices');
    22             foreach ($topics as $topic) {
    23                 $topic_id = (int) $topic->topic_id;
    24                 if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
    25                     $voices = count( $voices );
    26                     bb_update_topicmeta( $topic_id, 'voices_count', $voices );
    27                 }
    28             }
    29             unset($topics, $topic, $topic_id);
    30         }
     15    if ( !empty( $_POST['topic-voices'] ) ) {
     16        $messages[] = bb_recount_topic_voices();
    3117    }
    3218
    33     if ( isset($_POST['topic-deleted-posts']) && 1 == $_POST['topic-deleted-posts'] ) {
    34         $old = (array) $bbdb->get_col("SELECT object_id FROM $bbdb->meta WHERE object_type = 'bb_topics' AND meta_key = 'deleted_posts'");
    35         $old = array_flip($old);
    36         if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status != '0' GROUP BY topic_id") ) {
    37             $messages[] = __('Counting deleted posts&#8230;');
    38             foreach ( $topics as $topic ) {
    39                 bb_update_topicmeta( $topic->topic_id, 'deleted_posts', $topic->count );
    40                 unset($old[$topic->topic_id]);
    41             }
    42             unset($topics, $topic);
    43         }
    44         if ( $old ) {
    45             $old = join(',', array_flip($old));
    46             $bbdb->query("DELETE FROM $bbdb->meta WHERE object_type = 'bb_topic' AND object_id IN ($old) AND meta_key = 'deleted_posts'");
    47             $messages[] = __('&#8230;counted deleted posts');
    48         } else {
    49             $messages[] = __('&#8230;no deleted posts to count');
    50         }
     19    if ( !empty( $_POST['topic-deleted-posts'] ) ) {
     20        $messages[] = bb_recount_topic_deleted_posts();
    5121    }
    5222
    53     if ( isset($_POST['forums']) && 1 == $_POST['forums'] ) {
    54         if ( $all_forums = (array) $bbdb->get_col("SELECT forum_id FROM $bbdb->forums") ) {
    55             $messages[] = __('Counted forum topics and posts');
    56             $all_forums = array_flip( $all_forums );
    57             $forums = $bbdb->get_results("SELECT forum_id, COUNT(topic_id) AS topic_count, SUM(topic_posts) AS post_count FROM $bbdb->topics WHERE topic_status = 0 GROUP BY forum_id");
    58             foreach ( (array) $forums as $forum ) {
    59                 $bbdb->query("UPDATE $bbdb->forums SET topics = '$forum->topic_count', posts = '$forum->post_count' WHERE forum_id = '$forum->forum_id'");
    60                 unset($all_forums[$forum->forum_id]);
    61             }
    62             if ( $all_forums ) {
    63                 $all_forums = implode(',', array_flip( $all_forums ) );
    64                 $bbdb->query("UPDATE $bbdb->forums SET topics = 0, posts = 0 WHERE forum_id IN ($all_forums)");
    65             }
    66             unset($all_forums, $forums, $forum);
    67         }
     23    if ( !empty( $_POST['forums'] ) ) {
     24        $messages[] = bb_recount_forum_topics();
     25        $messages[] = bb_recount_forum_posts();
    6826    }
    6927
    70     if ( isset($_POST['topics-replied']) && 1 == $_POST['topics-replied'] ) {
    71         if ( $users = (array) $bbdb->get_col("SELECT ID FROM $bbdb->users") ) {
    72             $messages[] = __('Counted topics to which each user has replied');
    73             foreach ( $users as $user )
    74                 bb_update_topics_replied( $user );
    75             unset($users, $user);
    76         }
     28    if ( !empty( $_POST['topics-replied'] ) ) {
     29        $messages[] = bb_recount_user_topics_replied();
    7730    }
    7831
    79     if ( isset($_POST['topic-tag-count']) && 1 == $_POST['topic-tag-count'] ) {
    80         // Reset tag count to zero
    81         $bbdb->query( "UPDATE $bbdb->topics SET tag_count = 0" );
    82 
    83         // Get all tags
    84         $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag' );
    85 
    86         if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
    87             $messages[] = __('Counted topic tags');
    88             foreach ( $terms as $term ) {
    89                 $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
    90                 if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
    91                     $bbdb->query(
    92                         "UPDATE $bbdb->topics SET tag_count = tag_count + 1 WHERE topic_id IN (" . join( ',', $topic_ids ) . ")"
    93                     );
    94                 }
    95                 unset( $topic_ids );
    96             }
    97         }
    98         unset( $terms, $term );
     32    if ( !empty( $_POST['topic-tag-count'] ) ) {
     33        $messages[] = bb_recount_topic_tags();
    9934    }
    10035
    101     if ( isset($_POST['tags-tag-count']) && 1 == $_POST['tags-tag-count'] ) {
    102         // Get all tags
    103         $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
    104 
    105         if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
    106             $messages[] = __('Counted tagged topics');
    107             $_terms = array();
    108             foreach ( $terms as $term ) {
    109                 $_terms[] = $term->term_id;
    110             }
    111             if ( count( $_terms ) ) {
    112                 $wp_taxonomy_object->update_term_count( $_terms, 'bb_topic_tag' );
    113             }
    114         }
    115         unset( $term, $_terms );
     36    if ( !empty( $_POST['tags-tag-count'] ) ) {
     37        $messages[] = bb_recount_tag_topics();
    11638    }
    11739
    118     if ( isset($_POST['tags-delete-empty']) && 1 == $_POST['tags-delete-empty'] ) {
    119         // Get all tags
    120         if ( !isset( $terms ) ) {
    121             $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
    122         }
    123 
    124         if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
    125             $messages[] = __('Deleted tags with no topics');
    126             foreach ( $terms as $term ) {
    127                 $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
    128                 if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
    129                     if ( false === $topic_ids || ( is_array( $topic_ids ) && !count( $topic_ids ) ) ) {
    130                         bb_destroy_tag( $term->term_taxonomy_id );
    131                     }
    132                 }
    133                 unset( $topic_ids );
    134             }
    135         }
    136         unset( $terms, $term );
     40    if ( !empty( $_POST['tags-delete-empty'] ) ) {
     41        $messages[] = bb_recount_tag_delete_empty();
    13742    }
    13843
    139     if ( isset($_POST['clean-favorites']) && 1 == $_POST['clean-favorites'] ) {
    140         $favorites_key = $bbdb->prefix . 'favorites';
    141         if ( $users = $bbdb->get_results("SELECT user_id AS id, meta_value AS favorites FROM $bbdb->usermeta WHERE meta_key = '" . $favorites_key . "'") ) {
    142             $messages[] = __('Removed deleted topics from users\' favorites');
    143             $topics = $bbdb->get_col("SELECT topic_id FROM $bbdb->topics WHERE topic_status = '0'");
    144             foreach ( $users as $user ) {
    145                 foreach ( explode(',', $user->favorites) as $favorite ) {
    146                     if ( !in_array($favorite, $topics) ) {
    147                         bb_remove_user_favorite( $user->id, $favorite );
    148                     }
    149                 }
    150             }
    151             unset($topics, $users, $user, $favorite);
    152         }
     44    if ( !empty( $_POST['clean-favorites'] ) ) {
     45        $messages[] = bb_recount_clean_favorites();
    15346    }
    15447
     
    15649    foreach ( (array) $recount_list as $item ) {
    15750        if ( isset($item[2]) && isset($_POST[$item[0]]) && 1 == $_POST[$item[0]] && is_callable($item[2]) ) {
    158             call_user_func( $item[2] );
     51            $messages[] = call_user_func( $item[2] );
    15952        }
    16053    }
    161    
     54
     55    wp_cache_flush();
     56
    16257    if ( count( $messages ) ) {
    16358        $messages = join( '</p>' . "\n" . '<p>', $messages );
  • branches/1.0/bb-cron.php

    r2011 r2367  
    1212ignore_user_abort( true );
    1313
     14if ( !empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {
     15    die();
     16}
     17
    1418/**
    1519 * Tell bbPress we are doing the CRON task.
     
    2226require_once( './bb-load.php' );
    2327
    24 if ( $_GET['check'] != backpress_get_option( 'cron_check' ) ) {
    25     exit;
     28if ( false === $crons = _get_cron_array() ) {
     29    die();
    2630}
    2731
    28 if ( bb_get_option( 'doing_cron' ) > time() ) {
    29     exit;
    30 }
     32$keys = array_keys( $crons );
     33$local_time = time();
    3134
    32 bb_update_option( 'doing_cron', time() + 30 );
    33 
    34 $crons = _get_cron_array();
    35 $keys = array_keys( $crons );
    36 if ( !is_array( $crons ) || $keys[0] > time() ) {
    37     return;
     35if ( !is_array( $crons ) || ( isset($keys[0]) && $keys[0] > $local_time ) ) {
     36    die();
    3837}
    3938
    4039foreach ( $crons as $timestamp => $cronhooks ) {
    41     if ( $timestamp > time() ) {
     40    if ( $timestamp > $local_time ) {
    4241        break;
    4342    }
     
    5453    }
    5554}
    56 
    57 bb_update_option( 'doing_cron', 0 );
  • branches/1.0/bb-includes/class.bp-options.php

    r2274 r2367  
    2525            case 'cron_uri':
    2626                return bb_get_uri( 'bb-cron.php', array( 'check' => BP_Options::get( 'cron_check' ) ), BB_URI_CONTEXT_WP_HTTP_REQUEST );
    27                 break;
    28             case 'cron_check':
    29                 return bb_hash( '187425' );
    3027                break;
    3128            case 'wp_http_version':
  • branches/1.0/bb-includes/functions.bb-core.php

    r2342 r2367  
    733733            } else {
    734734                if ( bb_get_option( 'mod_rewrite' ) === 'slugs') {
    735                     $user = bb_get_user_by_nicename( $id ); // Get by the user_nicename
     735                    if ( !$user = bb_get_user_by_nicename( $id ) ) {
     736                        $user = bb_get_user( $id );
     737                    }
    736738                } else {
    737                     $user = bb_get_user( $id ); // Get by the ID
     739                    if ( !$user = bb_get_user( $id ) ) {
     740                        $user = bb_get_user_by_nicename( $id );
     741                    }
    738742                }
    739743            }
  • branches/1.0/bb-includes/functions.bb-deprecated.php

    r2313 r2367  
    641641// $length parameter is deprecated
    642642function bb_random_pass( $length ) {
    643     bb_log_deprecated('function', __FUNCTION__, 'wp_generate_password');
    644     return wp_generate_password();
     643    bb_log_deprecated('function', __FUNCTION__, 'bb_generate_password');
     644    if ( 12 < (int) $length ) {
     645        $length = 12;
     646    }
     647    return bb_generate_password( $length );
    645648}
    646649
  • branches/1.0/bb-includes/functions.bb-pluggable.php

    r2319 r2367  
    369369endif;
    370370
    371 function _bb_get_key( $key, $default_key = false ) {
    372     if ( !$default_key ) {
    373         global $bb_default_secret_key;
    374         $default_key = $bb_default_secret_key;
    375     }
    376 
    377     if ( defined( $key ) && '' != constant( $key ) && $default_key != constant( $key ) ) {
     371function _bb_get_key( $key, $default_key = false )
     372{
     373    global $bb_default_secret_key;
     374
     375    if ( defined( $key ) && '' != constant( $key ) && $bb_default_secret_key != constant( $key ) ) {
    378376        return constant( $key );
    379377    }
    380378
    381     return $default_key;
    382 }
    383 
    384 function _bb_get_salt( $constants, $option = false ) {
     379    return '';
     380}
     381
     382function _bb_get_salt( $constants, $option = false )
     383{
    385384    if ( !is_array( $constants ) ) {
    386385        $constants = array( $constants );
     
    399398        $salt = bb_get_option( $option );
    400399        if ( empty( $salt ) ) {
    401             $salt = bb_generate_password();
     400            $salt = bb_generate_password( 64 );
    402401            bb_update_option( $option, $salt );
    403402        }
     
    420419 * @return string Salt value for the given scheme
    421420 */
    422 function bb_salt($scheme = 'auth') {
     421function bb_salt( $scheme = 'auth' )
     422{
     423    // Deprecated
    423424    $secret_key = _bb_get_key( 'BB_SECRET_KEY' );
    424425
    425426    switch ($scheme) {
    426427        case 'auth':
    427             $secret_key = _bb_get_key( 'BB_AUTH_KEY', $secret_key );
     428            $secret_key = _bb_get_key( 'BB_AUTH_KEY' );
    428429            $salt = _bb_get_salt( array( 'BB_AUTH_SALT', 'BB_SECRET_SALT' ) );
    429430            break;
    430431
    431432        case 'secure_auth':
    432             $secret_key = _bb_get_key( 'BB_SECURE_AUTH_KEY', $secret_key );
     433            $secret_key = _bb_get_key( 'BB_SECURE_AUTH_KEY' );
    433434            $salt = _bb_get_salt( 'BB_SECURE_AUTH_SALT' );
    434435            break;
    435436
    436437        case 'logged_in':
    437             $secret_key = _bb_get_key( 'BB_LOGGED_IN_KEY', $secret_key );
     438            $secret_key = _bb_get_key( 'BB_LOGGED_IN_KEY' );
    438439            $salt = _bb_get_salt( 'BB_LOGGED_IN_SALT' );
    439440            break;
    440441
    441442        case 'nonce':
    442             $secret_key = _bb_get_key( 'BB_NONCE_KEY', $secret_key );
     443            $secret_key = _bb_get_key( 'BB_NONCE_KEY' );
    443444            $salt = _bb_get_salt( 'BB_NONCE_SALT' );
    444445            break;
  • branches/1.0/bb-includes/functions.bb-template.php

    r2333 r2367  
    255255    global $page, $topic, $forum;
    256256
    257     if ( is_string( $args ) ) {
    258         $args['h2'] = $args;
    259     }
    260257    $defaults = array(
    261258        'h2' => '',
    262259        'last_page_only' => true
    263260    );
     261    if ( is_string( $args ) ) {
     262        $defaults['h2'] = $args;
     263    }
    264264    $args = wp_parse_args( $args, $defaults );
    265265    extract( $args, EXTR_SKIP );
     
    15241524        return;
    15251525
    1526     $r = $before . '<form id="topic-move" method="post" action="' . bb_get_uri( 'bb-admin/topic-move.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . '">' . "\n";
    1527     $r .= '<fieldset>' . "\n";
    1528     $r .= '<div>' . "\n";
     1526    $r = $before . '<form id="topic-move" method="post" action="' . bb_get_uri( 'bb-admin/topic-move.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . '"><fieldset><div>' . "\n";
    15291527    $r .= '<input type="hidden" name="topic_id" value="' . $topic->topic_id . '" />' . "\n";
    15301528    $r .= '<label for="forum-id">'. __( 'Move to' ) . '</label>' . "\n";
     
    15321530    $r .= bb_nonce_field( 'move-topic_' . $topic->topic_id, '_wpnonce', true , false );
    15331531    $r .= '<input type="submit" name="Submit" value="' . __( 'Move' ) . '" />' . "\n";
    1534     $r .= '</div>' . "\n";
    1535     $r .= '</fieldset>' . "\n";
    1536     $r .= '</form>' . $after;
     1532    $r .= '</div></fieldset></form>' . $after;
    15371533
    15381534    return $r;
     
    35073503        $format = 'Y-m-d H:i:s';
    35083504        break;
     3505    case 'datetime' :
     3506        $format = bb_get_option( 'datetime_format' );
     3507        break;
    35093508    endswitch;
    35103509
  • branches/1.0/bb-includes/functions.bb-users.php

    r2313 r2367  
    253253 * @return bool
    254254 */
    255 function bb_reset_email( $user_login ) {
     255function bb_reset_email( $user_login )
     256{
    256257    global $bbdb;
    257258
    258259    $user_login = sanitize_user( $user_login, true );
    259260
    260     if ( !$user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $user_login ) ) )
    261         return new WP_Error('user_does_not_exist', __('The specified user does not exist.'));
    262 
    263     $resetkey = substr(md5(bb_generate_password()), 0, 15);
     261    if ( !$user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $user_login ) ) ) {
     262        return new WP_Error( 'user_does_not_exist', __( 'The specified user does not exist.' ) );
     263    }
     264
     265    $resetkey = substr( md5( bb_generate_password() ), 0, 15 );
    264266    bb_update_usermeta( $user->ID, 'newpwdkey', $resetkey );
    265267
     268    $reseturi = bb_get_uri(
     269        'bb-reset-password.php',
     270        array( 'key' => $resetkey ),
     271        BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_BB_USER_FORMS
     272    );
     273
    266274    $message = sprintf(
    267         __("If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!"),
    268         bb_get_uri(
    269             'bb-reset-password.php',
    270             array('key' => $resetkey),
    271             BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_BB_USER_FORMS
    272         )
    273     );
     275        __( "If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!" ),
     276        $reseturi
     277    );
     278    $message = apply_filters( 'bb_reset_email_message', $message, $user, $reseturi, $resetkey );
     279
     280    $subject = sprintf(
     281        __( '%s: Password Reset' ),
     282        bb_get_option( 'name' )
     283    );
     284    $subject = apply_filters( 'bb_reset_email_subject', $subject, $user );
    274285
    275286    $mail_result = bb_mail(
    276287        bb_get_user_email( $user->ID ),
    277         bb_get_option('name') . ': ' . __('Password Reset'),
     288        $subject,
    278289        $message
    279290    );
    280291
    281     if (!$mail_result) {
    282         return new WP_Error('sending_mail_failed', __('The email containing the password reset link could not be sent.'));
    283     } else {
    284         return true;
    285     }
     292    if ( !$mail_result ) {
     293        return new WP_Error( 'sending_mail_failed', __( 'The email containing the password reset link could not be sent.' ) );
     294    }
     295
     296    return true;
    286297}
    287298
     
    298309 * @return unknown
    299310 */
    300 function bb_reset_password( $key ) {
    301     global $bbdb;
     311function bb_reset_password( $key )
     312{
     313    global $bbdb;
     314
    302315    $key = sanitize_user( $key, true );
    303     if ( empty( $key ) )
    304         return new WP_Error('key_not_found', __('Key not found.'));
    305     if ( !$user_id = $bbdb->get_var( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = 'newpwdkey' AND meta_value = %s", $key ) ) )
    306         return new WP_Error('key_not_found', __('Key not found.'));
    307     if ( $user = new BP_User( $user_id ) ) {
    308         if ( bb_has_broken_pass( $user->ID ) )
    309             bb_block_current_user();
    310         if ( !$user->has_cap( 'change_user_password', $user->ID ) )
    311             return new WP_Error('permission_denied', __('You are not allowed to change your password.'));
    312         $newpass = bb_generate_password();
    313         bb_update_user_password( $user->ID, $newpass );
    314         if (!bb_send_pass( $user->ID, $newpass )) {
    315             return new WP_Error('sending_mail_failed', __('The email containing the new password could not be sent.'));
    316         } else {
    317             bb_update_usermeta( $user->ID, 'newpwdkey', '' );
    318             return true;
    319         }
    320     } else {
    321         return new WP_Error('key_not_found', __('Key not found.'));
    322     }
     316
     317    if ( empty( $key ) || !is_string( $key ) ) {
     318        return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     319    }
     320
     321    if ( !$user_id = $bbdb->get_var( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = 'newpwdkey' AND meta_value = %s", $key ) ) ) {
     322        return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     323    }
     324
     325    $user = new BP_User( $user_id );
     326
     327    if ( !$user || is_wp_error( $user ) ) {
     328        return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     329    }
     330
     331    if ( bb_has_broken_pass( $user->ID ) ) {
     332        bb_block_current_user();
     333    }
     334
     335    if ( !$user->has_cap( 'change_user_password', $user->ID ) ) {
     336        return new WP_Error( 'permission_denied', __( 'You are not allowed to change your password.' ) );
     337    }
     338
     339    $newpass = bb_generate_password();
     340    bb_update_user_password( $user->ID, $newpass );
     341    if ( !bb_send_pass( $user->ID, $newpass ) ) {
     342        return new WP_Error( 'sending_mail_failed', __( 'The email containing the new password could not be sent.' ) );
     343    }
     344
     345    bb_update_usermeta( $user->ID, 'newpwdkey', '' );
     346    return true;
    323347}
    324348
     
    358382 * @return bool
    359383 */
    360 function bb_send_pass( $user, $pass ) {
    361     if ( !$user = bb_get_user( $user ) )
    362         return false;
    363 
    364     $message = __("Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!");
     384function bb_send_pass( $user, $pass )
     385{
     386    if ( !$user = bb_get_user( $user ) ) {
     387        return false;
     388    }
     389
     390    $message = sprintf(
     391        __( "Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!" ),
     392        $user->user_login,
     393        $pass,
     394        bb_get_uri( null, null, BB_URI_CONTEXT_TEXT )
     395    );
     396    $message = apply_filters( 'bb_send_pass_message', $message, $user, $pass );
     397
     398    $subject = sprintf(
     399        __( '%s: Password' ),
     400        bb_get_option( 'name' )
     401    );
     402    $subject = apply_filters( 'bb_send_pass_subject', $subject, $user );
    365403
    366404    return bb_mail(
    367405        bb_get_user_email( $user->ID ),
    368         bb_get_option('name') . ': ' . __('Password'),
    369         sprintf($message, $user->user_login, $pass, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))
     406        $subject,
     407        $message
    370408    );
    371409}
  • branches/1.0/bb-templates/kakumei-blue/style.css

    r2177 r2367  
    2323#thread li.pingback { background-color: #d8dcf2; border-color: #d8dcf2; }
    2424#thread li.pingback .threadpost { background-color: #d8dcf2; }
     25#topic-move input { color: #32689b; }
     26#topic-move input:hover { color: #001364; }
    2527#latest tr:hover, #forumlist tr:hover, #favorites tr:hover { background: #d8dcf2; }
    2628#profile-menu li a:hover { background: #d8dcf2; }
  • branches/1.0/bb-templates/kakumei/favorites.php

    r2202 r2367  
    3030    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    3131    <td class="num"><?php topic_last_poster(); ?></td>
    32     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     32    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    3333<?php if ( bb_current_user_can( 'edit_favorites_of', $user_id ) ) : ?>
    3434    <td class="num">[<?php user_favorites_link('', array('mid'=>'&times;'), $user_id); ?>]</td>
  • branches/1.0/bb-templates/kakumei/forum.php

    r2177 r2367  
    2020    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2121    <td class="num"><?php topic_last_poster(); ?></td>
    22     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     22    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    2323</tr>
    2424<?php endforeach; endif; ?>
     
    3030    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    3131    <td class="num"><?php topic_last_poster(); ?></td>
    32     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     32    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    3333</tr>
    3434<?php endforeach; endif; ?>
  • branches/1.0/bb-templates/kakumei/front-page.php

    r2300 r2367  
    2828    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2929    <td class="num"><?php topic_last_poster(); ?></td>
    30     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     30    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    3131</tr>
    3232<?php endforeach; endif; // $super_stickies ?>
     
    3838    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    3939    <td class="num"><?php topic_last_poster(); ?></td>
    40     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     40    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    4141</tr>
    4242<?php endforeach; endif; // $topics ?>
  • branches/1.0/bb-templates/kakumei/post-form.php

    r2286 r2367  
    22<p id="post-form-title-container">
    33    <label for="topic"><?php _e('Title'); ?>
    4         <input name="topic" type="text" id="topic" size="50" maxlength="80" tabindex="1" />
     4        <input name="topic" type="text" id="topic" size="50" maxlength="100" tabindex="1" />
    55    </label>
    66</p>
     
    1212</p>
    1313<p id="post-form-tags-container">
    14     <label for="tags-input"><?php printf(__('Tags (comma seperated)'), bb_get_tag_page_link()) ?>
     14    <label for="tags-input"><?php printf(__('Tags (comma separated)'), bb_get_tag_page_link()) ?>
    1515        <input id="tags-input" name="tags" type="text" size="50" maxlength="100" value="<?php bb_tag_name(); ?>" tabindex="4" />
    1616    </label>
  • branches/1.0/bb-templates/kakumei/style.css

    r2287 r2367  
    645645}
    646646
    647 #topic-move { margin-top: 1em; }
     647#topic-move,
     648#topic-move fieldset,
     649#topic-move fieldset div {
     650    display: inline;
     651}
     652
     653#topic-move input {
     654    font-family: inherit;
     655    background: none;
     656    border: none;
     657    cursor: pointer;
     658    color: #2e6e15;
     659    font-size: 1em;
     660}
     661
     662#topic-move input:hover { color: #006400; }
    648663
    649664/* Other
  • branches/1.0/bb-templates/kakumei/tag-single.php

    r2150 r2367  
    2222    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2323    <td class="num"><?php topic_last_poster(); ?></td>
    24     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     24    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    2525</tr>
    2626<?php endforeach; ?>
  • branches/1.0/bb-templates/kakumei/view.php

    r2150 r2367  
    2020    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2121    <td class="num"><?php topic_last_poster(); ?></td>
    22     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     22    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    2323</tr>
    2424<?php endforeach; endif; ?>
     
    3030    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    3131    <td class="num"><?php topic_last_poster(); ?></td>
    32     <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     32    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    3333</tr>
    3434<?php endforeach; endif; ?>
  • branches/1.0/rss.php

    r2333 r2367  
    109109                die();
    110110            }
    111             $title = esc_html( sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_login ) );
     111            $title = esc_html( sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename ) );
    112112            $link = bb_get_profile_link($feed_id);
    113113            $link_self = get_favorites_rss_link($feed_id);
Note: See TracChangeset for help on using the changeset viewer.