Changeset 9301 for trunk/src/bp-messages/bp-messages-template.php
- Timestamp:
- 01/06/2015 03:51:19 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-template.php
r9260 r9301 115 115 * Constructor method. 116 116 * 117 * @param int $user_id ID of the user whose Messages box is being 118 * viewed. 119 * @param string $box Type of box being viewed ('notices', 'sentbox', 120 * 'inbox'). 121 * @param int $per_page Number of thread to return per page of results. 122 * @param int $max Max number of results to return. 123 * @param string $type Type of results to return. 'unread', 'read', 124 * or 'all'. 125 * @param string $search_terms Search terms for limiting results. 126 * @param string $page_arg Optional. URL argument for pagination 127 * parameter. Default: 'mpage'. 128 */ 129 public function __construct( $user_id, $box, $per_page, $max, $type, $search_terms, $page_arg = 'mpage' ) { 130 $this->pag_page = isset( $_GET[$page_arg] ) ? intval( $_GET[$page_arg] ) : 1; 131 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page; 132 133 $this->user_id = $user_id; 134 $this->box = $box; 135 $this->type = $type; 136 $this->search_terms = $search_terms; 117 * @param array $args { 118 * Array of arguments. See bp_has_message_threads() for full description. 119 * } 120 */ 121 public function __construct( $args = array() ) { 122 global $wpdb, $bp; 123 124 // Backward compatibility with old method of passing arguments 125 if ( ! is_array( $args ) || func_num_args() > 1 ) { 126 _deprecated_argument( __METHOD__, '2.2.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 127 128 $old_args_keys = array( 129 0 => 'user_id', 130 1 => 'box', 131 2 => 'per_page', 132 3 => 'max', 133 4 => 'type', 134 5 => 'search_terms', 135 6 => 'page_arg' 136 ); 137 138 $func_args = func_get_args(); 139 $args = bp_core_parse_args_array( $old_args_keys, $func_args ); 140 } 141 142 $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', 148 'search_terms' => '', 149 'page_arg' => 'mpage', 150 'meta_query' => array(), 151 ) ); 152 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']; 155 156 $this->user_id = $r['user_id']; 157 $this->box = $r['box']; 158 $this->type = $r['type']; 159 $this->search_terms = $r['search_terms']; 137 160 138 161 if ( 'notices' == $this->box ) { … … 142 165 ) ); 143 166 } else { 144 $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page, $this->search_terms ); 167 $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, 173 'search_terms' => $this->search_terms, 174 'meta_query' => $r['meta_query'], 175 ) ); 145 176 146 177 $this->threads = $threads['threads']; … … 154 185 $total_notice_count = BP_Messages_Notice::get_total_notice_count(); 155 186 156 if ( ! $max || $max>= (int) $total_notice_count ) {187 if ( ! $r['max'] || $r['max'] >= (int) $total_notice_count ) { 157 188 if ( 'notices' == $this->box ) { 158 189 $this->total_thread_count = (int) $total_notice_count; 159 190 } 160 191 } else { 161 $this->total_thread_count = (int) $ max;192 $this->total_thread_count = (int) $r['max']; 162 193 } 163 194 164 if ( $ max) {195 if ( $r['max'] ) { 165 196 if ( $max >= count( $this->threads ) ) { 166 197 $this->thread_count = count( $this->threads ); 167 198 } else { 168 $this->thread_count = (int) $ max;199 $this->thread_count = (int) $r['max']; 169 200 } 170 201 } else { … … 175 206 if ( (int) $this->total_thread_count && (int) $this->pag_num ) { 176 207 $pag_args = array( 177 $ page_arg=> '%#%',208 $r['page_arg'] => '%#%', 178 209 ); 179 210 … … 383 414 384 415 // Load the messages loop global up with messages 385 $messages_template = new BP_Messages_Box_Template( 386 $r['user_id'], 387 $r['box'], 388 $r['per_page'], 389 $r['max'], 390 $r['type'], 391 $r['search_terms'], 392 $r['page_arg'] 393 ); 416 $messages_template = new BP_Messages_Box_Template( $r ); 394 417 395 418 /**
Note: See TracChangeset
for help on using the changeset viewer.