Skip to:
Content

BuddyPress.org

Changeset 9350


Ignore:
Timestamp:
01/12/2015 11:11:38 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Improvements to BP_Messages_Box_Template::__construct():

  • Update $max to $r['max'] fixing potential for total_count to be incorrect.
  • Strict comparisons where appropriate.
  • Cast $r['max'] to int where appropriate.
  • Bring surrounding code up to current coding standards.

Similar to r8578.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-template.php

    r9349 r9350  
    120120     */
    121121    public function __construct( $args = array() ) {
    122         global $wpdb, $bp;
    123122
    124123        // Backward compatibility with old method of passing arguments
     
    141140
    142141        $r = wp_parse_args( $args, array(
    143             'user_id'  => bp_loggedin_user_id(),
    144             'box'      => 'inbox',
    145             'per_page' => 10,
    146             'max'      => false,
    147             'type'     => 'all',
     142            'user_id'      => bp_loggedin_user_id(),
     143            'box'          => 'inbox',
     144            'per_page'     => 10,
     145            'max'          => false,
     146            'type'         => 'all',
    148147            'search_terms' => '',
    149148            'page_arg'     => 'mpage',
     
    151150        ) );
    152151
    153         $this->pag_page = isset( $_GET[ $r['page_arg'] ] ) ? intval( $_GET[ $r['page_arg'] ] ) : 1;
    154         $this->pag_num  = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $r['per_page'];
     152        $this->pag_page     = isset( $_GET[ $r['page_arg'] ] ) ? intval( $_GET[ $r['page_arg'] ] ) : 1;
     153        $this->pag_num      = isset( $_GET['num']            ) ? intval( $_GET['num']            ) : $r['per_page'];
    155154
    156155        $this->user_id      = $r['user_id'];
     
    159158        $this->search_terms = $r['search_terms'];
    160159
    161         if ( 'notices' == $this->box ) {
     160        if ( 'notices' === $this->box ) {
    162161            $this->threads = BP_Messages_Notice::get_notices( array(
    163162                'pag_num'  => $this->pag_num,
     
    166165        } else {
    167166            $threads = BP_Messages_Thread::get_current_threads_for_user( array(
    168                 'user_id' => $this->user_id,
    169                 'box'     => $this->box,
    170                 'type'    => $this->type,
    171                 'limit'   => $this->pag_num,
    172                 'page'    => $this->pag_page,
     167                'user_id'      => $this->user_id,
     168                'box'          => $this->box,
     169                'type'         => $this->type,
     170                'limit'        => $this->pag_num,
     171                'page'         => $this->pag_page,
    173172                'search_terms' => $this->search_terms,
    174173                'meta_query'   => $r['meta_query'],
     
    185184            $total_notice_count = BP_Messages_Notice::get_total_notice_count();
    186185
    187             if ( ! $r['max'] || $r['max'] >= (int) $total_notice_count ) {
    188                 if ( 'notices' == $this->box ) {
     186            if ( empty( $r['max'] ) || ( (int) $r['max'] >= (int) $total_notice_count ) ) {
     187                if ( 'notices' === $this->box ) {
    189188                    $this->total_thread_count = (int) $total_notice_count;
    190189                }
     
    193192            }
    194193
    195             if ( $r['max'] ) {
    196                 if ( $max >= count( $this->threads ) ) {
     194            if ( ! empty( $r['max'] ) ) {
     195                if ( (int) $r['max'] >= count( $this->threads ) ) {
    197196                    $this->thread_count = count( $this->threads );
    198197                } else {
Note: See TracChangeset for help on using the changeset viewer.