Changeset 9570
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-template.php
r9556 r9570 206 206 207 207 /** 208 * The $_GET argument used in URLs for determining pagination 209 * 210 * @since BuddyPress (1.9.0) 211 * @access public 212 * @var int 213 */ 214 public $pag_arg; 215 216 /** 208 217 * The number of items to display per page of results. 209 218 * … … 249 258 */ 250 259 public $sort_order; 260 261 /** 262 * Array of variables used in this notification query 263 * 264 * @since BuddyPress (2.2.2) 265 * @var array 266 */ 267 public $query_vars; 251 268 252 269 /** … … 268 285 'id' => false, 269 286 'user_id' => 0, 287 'item_id' => false, 270 288 'secondary_item_id' => false, 271 289 'component_name' => bp_notifications_get_registered_components(), … … 275 293 'order_by' => 'date_notified', 276 294 'sort_order' => 'DESC', 295 'page_arg' => 'npage', 277 296 'page' => 1, 278 297 'per_page' => 25, 279 298 'max' => null, 280 'page_arg' => 'npage',281 299 ) ); 282 300 … … 300 318 $this->order_by = $r['order_by']; 301 319 $this->sort_order = $r['sort_order']; 320 $this->query_vars = array( 321 'id' => $r['id'], 322 'user_id' => $this->user_id, 323 'item_id' => $r['item_id'], 324 'secondary_item_id' => $r['secondary_item_id'], 325 'component_name' => $r['component_name'], 326 'component_action' => $r['component_action'], 327 'is_new' => $this->is_new, 328 'search_terms' => $this->search_terms, 329 'order_by' => $this->order_by, 330 'sort_order' => $this->sort_order, 331 'page' => $this->pag_page, 332 'per_page' => $this->pag_num, 333 ); 302 334 303 335 // Setup the notifications to loop through 304 $this->notifications = BP_Notifications_Notification::get( $ r);305 $this->total_notification_count = BP_Notifications_Notification::get_total_count( $ r);336 $this->notifications = BP_Notifications_Notification::get( $this->query_vars ); 337 $this->total_notification_count = BP_Notifications_Notification::get_total_count( $this->query_vars ); 306 338 307 339 if ( empty( $this->notifications ) ) { -
trunk/tests/phpunit/testcases/notifications/class-bp-notifications-notification.php
r9139 r9570 280 280 $this->assertEquals( $expected, $actual ); 281 281 } 282 283 /** 284 * @group pagination 285 * @group BP6229 286 */ 287 public function test_get_paged_sql() { 288 $u = $this->factory->user->create(); 289 290 $notifications = array(); 291 for ( $i = 1; $i <= 6; $i++ ) { 292 $notifications[] = $this->factory->notification->create( array( 293 'component_name' => 'activity', 294 'secondary_item_id' => $i, 295 'user_id' => $u, 296 'is_new' => true, 297 ) ); 298 } 299 300 $found = BP_Notifications_Notification::get( array( 301 'user_id' => $u, 302 'is_new' => true, 303 'page' => 2, 304 'per_page' => 2, 305 'order_by' => 'id', 306 ) ); 307 308 // Check that the correct number of items are pulled up 309 $expected = array( $notifications[2], $notifications[3] ); 310 $this->assertEquals( $expected, wp_list_pluck( $found, 'id' ) ); 311 } 282 312 }
Note: See TracChangeset
for help on using the changeset viewer.