bpln_get_notification_messages

Get a list of processed messages.

Description

bpln_get_notification_messages( $notification_ids ); 

Parameters (1)

0. $notification_ids
The notification ids.

Usage

  1. if ( !function_exists( 'bpln_get_notification_messages' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-live-notification/bp-live-notification.php'; 
  3.  
  4. // The notification ids. 
  5. $notification_ids = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bpln_get_notification_messages($notification_ids); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-live-notification.php  
  1. function bpln_get_notification_messages($notification_ids) { 
  2. if(!is_user_logged_in()) 
  3. return; 
  4. global $bp, $wpdb; 
  5. $list_ids="(".join(", ", $notification_ids).")"; 
  6. $notifications =$wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id in {$list_ids} AND is_new = %d", 1) ); 
  7. $renderable=array(); 
  8.  
  9. /** Group notifications by component and component_action and provide totals */ 
  10. for ( $i = 0; $i < count($notifications); $i++ ) { 
  11. $notification = $notifications[$i]; 
  12.  
  13. $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification; 
  14.  
  15. if ( !$grouped_notifications ) 
  16. return false; 
  17.  
  18. /** Calculated a renderable outcome for each notification type */ 
  19. foreach ( (array)$grouped_notifications as $component_name => $action_arrays ) { 
  20. if ( !$action_arrays ) 
  21. continue; 
  22.  
  23. foreach ( (array)$action_arrays as $component_action_name => $component_action_items ) { 
  24. $action_item_count = count($component_action_items); 
  25.  
  26. if ( $action_item_count < 1 ) 
  27. continue; 
  28.  
  29. if ( isset($bp->{$component_name}->format_notification_function )&&function_exists( $bp->{$component_name}->format_notification_function ) ) { 
  30. $renderable[] = call_user_func( $bp->{$component_name}->format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count ); 
  31.  
  32. } elseif ( isset( $bp->{$component_name}->notification_callback ) && function_exists( $bp->{$component_name}->notification_callback ) ) { 
  33.  
  34. $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, 'array' ); 
  35. if ( is_string( $content ) ) { 
  36. $renderable[] = $content; 
  37.  
  38. } else { 
  39. $renderable[] = $content['text']; 
  40.  
  41.  
  42.  
  43.  
  44.  
  45. }  
  46.  
  47. return $renderable;//array of messages