Changeset 8761 for trunk/src/bp-notifications/bp-notifications-template.php
- Timestamp:
- 08/05/2014 10:40:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-template.php
r8706 r8761 221 221 * Constructor method. 222 222 * 223 * @see bp_has_notifications() For information on the array format. 224 * 223 225 * @since BuddyPress (1.9.0) 224 226 * 225 227 * @param array $args { 226 * @type int $user_id ID of the user to whom the displayed 227 * notifications belong. 228 * @type bool $is_new Whether to limit the query to unread 229 * notifications. Default: true. 230 * @type int $page Number of the page of results to return. 231 * Will be overridden by URL parameter. Default: 1. 232 * @type int $per_page Number of results to return per page. 233 * Will be overridden by URL parameter. Default: 25. 234 * @type int $max Optional. Max results to display. 235 * @type string $search_terms Optional. Term to match against 236 * component_name and component_action. 237 * @type string $page_arg URL argument to use for pagination. 238 * Default: 'npage'. 228 * An array of arguments. See {@link bp_has_notifications()} 229 * for more details. 239 230 * } 240 231 */ … … 243 234 // Parse arguments 244 235 $r = wp_parse_args( $args, array( 245 'user_id' => 0, 246 'is_new' => true, 247 'page' => 1, 248 'per_page' => 25, 249 'order_by' => 'date_notified', 250 'sort_order' => 'DESC', 251 'max' => null, 252 'search_terms' => '', 253 'page_arg' => 'npage', 236 'id' => false, 237 'user_id' => 0, 238 'secondary_item_id' => false, 239 'component_name' => bp_notifications_get_registered_components(), 240 'component_action' => false, 241 'is_new' => true, 242 'search_terms' => '', 243 'order_by' => 'date_notified', 244 'sort_order' => 'DESC', 245 'page' => 1, 246 'per_page' => 25, 247 'max' => null, 248 'page_arg' => 'npage', 254 249 ) ); 255 250 … … 258 253 // Set which pagination page 259 254 if ( isset( $_GET[ $r['page_arg'] ] ) ) { 260 $pag_page = intval( $_GET[ $r['page_arg'] ] ); 261 } else { 262 $pag_page = $r['page']; 255 $r['page'] = intval( $_GET[ $r['page_arg'] ] ); 263 256 } 264 257 265 258 // Set the number to show per page 266 259 if ( isset( $_GET['num'] ) ) { 267 $ pag_num= intval( $_GET['num'] );260 $r['per_page'] = intval( $_GET['num'] ); 268 261 } else { 269 $ pag_num= intval( $r['per_page'] );262 $r['per_page'] = intval( $r['per_page'] ); 270 263 } 271 264 … … 273 266 $orders = array( 'ASC', 'DESC' ); 274 267 if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders ) ) { 275 $ sort_order= $_GET['sort_order'];268 $r['sort_order'] = $_GET['sort_order']; 276 269 } else { 277 $ sort_order= in_array( $r['sort_order'], $orders ) ? $r['sort_order'] : 'DESC';270 $r['sort_order'] = in_array( $r['sort_order'], $orders ) ? $r['sort_order'] : 'DESC'; 278 271 } 279 272 280 273 // Setup variables 281 $this->pag_page = $ pag_page;282 $this->pag_num = $ pag_num;274 $this->pag_page = $r['page']; 275 $this->pag_num = $r['per_page']; 283 276 $this->user_id = $r['user_id']; 284 277 $this->is_new = $r['is_new']; … … 286 279 $this->page_arg = $r['page_arg']; 287 280 $this->order_by = $r['order_by']; 288 $this->sort_order = $sort_order; 289 290 // Get the notifications 291 $notifications = BP_Notifications_Notification::get_current_notifications_for_user( array( 292 'user_id' => $this->user_id, 293 'is_new' => $this->is_new, 294 'page' => $this->pag_page, 295 'per_page' => $this->pag_num, 296 'search_terms' => $this->search_terms, 297 'order_by' => $this->order_by, 298 'sort_order' => $this->sort_order, 299 ) ); 281 $this->sort_order = $r['sort_order']; 300 282 301 283 // Setup the notifications to loop through 302 $this->notifications = $notifications['notifications'];303 $this->total_notification_count = $notifications['total'];284 $this->notifications = BP_Notifications_Notification::get( $r ); 285 $this->total_notification_count = BP_Notifications_Notification::get_total_count( $r ); 304 286 305 287 if ( empty( $this->notifications ) ) { … … 448 430 * Arguments for limiting the contents of the notifications loop. Can be 449 431 * passed as an associative array, or as a URL query string. 450 * @type int $user_id ID of the user to whom notifications belong. Default: 451 * ID of the logged-in user. 452 * @type bool $is_new Whether to limit query to unread notifications. 453 * Default: when viewing the 'unread' tab, defaults to true; when 454 * viewing the 'read' tab, defaults to false. 455 * @type int $page The page of notifications being fetched. Default: 1. 456 * @type int $per_page Number of items to display on a page. Default: 25. 432 * 433 * See {@link BP_Notifications_Notification::get()} for detailed 434 * information on the arguments. In addition, also supports: 435 * 457 436 * @type int $max Optional. Max items to display. Default: false. 458 * @type string $search_terms Optional. Term to match against459 * component_name and component_action.460 437 * @type string $page_arg URL argument to use for pagination. 461 438 * Default: 'npage'. … … 469 446 } elseif ( bp_is_current_action( 'read' ) ) { 470 447 $is_new = 0; 448 449 // not on a notifications page? default to fetch new notifications 450 } else { 451 $is_new = 1; 471 452 } 472 453 … … 480 461 // Parse the args 481 462 $r = bp_parse_args( $args, array( 482 'user_id' => $user_id, 483 'is_new' => $is_new, 484 'page' => 1, 485 'per_page' => 25, 486 'max' => false, 487 'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '', 488 'page_arg' => 'npage', 463 'id' => false, 464 'user_id' => $user_id, 465 'secondary_item_id' => false, 466 'component_name' => bp_notifications_get_registered_components(), 467 'component_action' => false, 468 'is_new' => $is_new, 469 'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '', 470 'order_by' => 'date_notified', 471 'sort_order' => 'DESC', 472 'page' => 1, 473 'per_page' => 25, 474 475 // these are additional arguments that are not available in 476 // BP_Notifications_Notification::get() 477 'max' => false, 478 'page_arg' => 'npage', 489 479 ), 'has_notifications' ); 490 480
Note: See TracChangeset
for help on using the changeset viewer.