- Timestamp:
- 06/04/2018 07:58:30 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-functions.php
r11933 r12158 795 795 return $retval; 796 796 } 797 798 /** 799 * Finds and exports personal data associated with an email address from the Notifications tables. 800 * 801 * @since 4.0.0 802 * 803 * @param string $email_address The users email address. 804 * @param int $page Batch number. 805 * @return array An array of personal data. 806 */ 807 function bp_notifications_personal_data_exporter( $email_address, $page ) { 808 $number = 50; 809 810 $email_address = trim( $email_address ); 811 812 $data_to_export = array(); 813 814 $user = get_user_by( 'email', $email_address ); 815 816 if ( ! $user ) { 817 return array( 818 'data' => array(), 819 'done' => true, 820 ); 821 } 822 823 $notifications = BP_Notifications_Notification::get( array( 824 'is_new' => null, 825 'per_page' => $number, 826 'page' => $page, 827 'user_id' => $user->ID, 828 'order' => 'DESC', 829 ) ); 830 831 $user_data_to_export = array(); 832 833 foreach ( $notifications as $notification ) { 834 if ( 'xprofile' === $notification->component_name ) { 835 $component_name = 'profile'; 836 } else { 837 $component_name = $notification->component_name; 838 } 839 840 // Format notifications. 841 if ( isset( buddypress()->{$component_name}->notification_callback ) && is_callable( buddypress()->{$component_name}->notification_callback ) ) { 842 $content = call_user_func( buddypress()->{$component_name}->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1, 'string', $notification->id ); 843 } else { 844 // The array to reference with apply_filters_ref_array(). 845 $ref_array = array( 846 $notification->component_action, 847 $notification->item_id, 848 $notification->secondary_item_id, 849 $notification->total_count, 850 'string', 851 $notification->component_action, 852 $component_name, 853 $notification_item->id, 854 ); 855 856 /** This filter is documented in bp-notifications/bp-notifications-functions.php */ 857 $content = apply_filters_ref_array( 'bp_notifications_get_notifications_for_user', $ref_array ); 858 } 859 860 $item_data = array( 861 array( 862 'name' => __( 'Notification Content', 'buddypress' ), 863 'value' => $content, 864 ), 865 array( 866 'name' => __( 'Notification Date', 'buddypress' ), 867 'value' => $notification->date_notified, 868 ), 869 array( 870 'name' => __( 'Status', 'buddypress' ), 871 'value' => $notification->is_new ? __( 'Unread', 'buddypress' ) : __( 'Read', 'buddypress' ), 872 ), 873 ); 874 875 $data_to_export[] = array( 876 'group_id' => 'bp_notifications', 877 'group_label' => __( 'Notifications' ), 878 'item_id' => "bp-notifications-{$notification->id}", 879 'data' => $item_data, 880 ); 881 } 882 883 // Tell core if we have more items to process. 884 $done = count( $notifications ) < $number; 885 886 return array( 887 'data' => $data_to_export, 888 'done' => $done, 889 ); 890 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)