Changeset 12163 for trunk/src/bp-groups/bp-groups-functions.php
- Timestamp:
- 06/04/2018 08:52:12 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-functions.php
r12126 r12163 2639 2639 } 2640 2640 add_action( 'groups_delete_group', 'bp_remove_group_type_on_group_delete' ); 2641 2642 /** 2643 * Finds and exports group membership data associated with an email address. 2644 * 2645 * @since 4.0.0 2646 * 2647 * @param string $email_address The user's email address. 2648 * @param int $page Batch number. 2649 * @return array An array of personal data. 2650 */ 2651 function bp_groups_memberships_personal_data_exporter( $email_address, $page ) { 2652 $number = 20; 2653 2654 $email_address = trim( $email_address ); 2655 2656 $data_to_export = array(); 2657 2658 $user = get_user_by( 'email', $email_address ); 2659 2660 if ( ! $user ) { 2661 return array( 2662 'data' => array(), 2663 'done' => true, 2664 ); 2665 } 2666 2667 $memberships = BP_Groups_Member::get_user_memberships( $user->ID, array( 2668 'type' => 'membership', 2669 'page' => $page, 2670 'per_page' => $number, 2671 ) ); 2672 2673 foreach ( $memberships as $membership ) { 2674 $group = groups_get_group( $membership->group_id ); 2675 2676 $item_data = array( 2677 array( 2678 'name' => __( 'Group Name', 'buddypress' ), 2679 'value' => bp_get_group_name( $group ), 2680 ), 2681 array( 2682 'name' => __( 'Group URL', 'buddypress' ), 2683 'value' => bp_get_group_permalink( $group ), 2684 ), 2685 ); 2686 2687 if ( $membership->inviter_id ) { 2688 $item_data[] = array( 2689 'name' => __( 'Invited By', 'buddypress' ), 2690 'value' => bp_core_get_userlink( $membership->inviter_id ), 2691 ); 2692 } 2693 2694 if ( $group->creator_id === $user->ID ) { 2695 $group_role = __( 'Creator', 'buddypress' ); 2696 } elseif ( $membership->is_admin ) { 2697 $group_role = __( 'Admin', 'buddypress' ); 2698 } elseif ( $membership->is_mod ) { 2699 $group_role = __( 'Moderator', 'buddypress' ); 2700 } else { 2701 $group_role = __( 'Member', 'buddypress' ); 2702 } 2703 2704 $item_data[] = array( 2705 'name' => __( 'Group Role', 'buddypress' ), 2706 'value' => $group_role, 2707 ); 2708 2709 $item_data[] = array( 2710 'name' => __( 'Date Joined', 'buddypress' ), 2711 'value' => $membership->date_modified, 2712 ); 2713 2714 $data_to_export[] = array( 2715 'group_id' => 'bp_groups_memberships', 2716 'group_label' => __( 'Group Memberships', 'buddypress' ), 2717 'item_id' => "bp-group-membership-{$group->id}", 2718 'data' => $item_data, 2719 ); 2720 } 2721 2722 // Tell core if we have more items to process. 2723 $done = count( $memberships ) < $number; 2724 2725 return array( 2726 'data' => $data_to_export, 2727 'done' => $done, 2728 ); 2729 } 2730 2731 /** 2732 * Finds and exports data on pending group membership requests associated with an email address. 2733 * 2734 * @since 4.0.0 2735 * 2736 * @param string $email_address The user's email address. 2737 * @param int $page Batch number. 2738 * @return array An array of personal data. 2739 */ 2740 function bp_groups_pending_requests_personal_data_exporter( $email_address, $page ) { 2741 $number = 20; 2742 2743 $email_address = trim( $email_address ); 2744 2745 $data_to_export = array(); 2746 2747 $user = get_user_by( 'email', $email_address ); 2748 2749 if ( ! $user ) { 2750 return array( 2751 'data' => array(), 2752 'done' => true, 2753 ); 2754 } 2755 2756 $requests = BP_Groups_Member::get_user_memberships( $user->ID, array( 2757 'type' => 'pending_request', 2758 'page' => $page, 2759 'per_page' => $number, 2760 ) ); 2761 2762 foreach ( $requests as $request ) { 2763 $group = groups_get_group( $request->group_id ); 2764 2765 $item_data = array( 2766 array( 2767 'name' => __( 'Group Name', 'buddypress' ), 2768 'value' => bp_get_group_name( $group ), 2769 ), 2770 array( 2771 'name' => __( 'Group URL', 'buddypress' ), 2772 'value' => bp_get_group_permalink( $group ), 2773 ), 2774 array( 2775 'name' => __( 'Date Sent', 'buddypress' ), 2776 'value' => $request->date_modified, 2777 ), 2778 ); 2779 2780 $data_to_export[] = array( 2781 'group_id' => 'bp_groups_pending_requests', 2782 'group_label' => __( 'Pending Group Membership Requests', 'buddypress' ), 2783 'item_id' => "bp-group-pending-request-{$group->id}", 2784 'data' => $item_data, 2785 ); 2786 } 2787 2788 // Tell core if we have more items to process. 2789 $done = count( $requests ) < $number; 2790 2791 return array( 2792 'data' => $data_to_export, 2793 'done' => $done, 2794 ); 2795 } 2796 2797 /** 2798 * Finds and exports data on pending group invitations sent by a user associated with an email address. 2799 * 2800 * @since 4.0.0 2801 * 2802 * @param string $email_address The user's email address. 2803 * @param int $page Batch number. 2804 * @return array An array of personal data. 2805 */ 2806 function bp_groups_pending_sent_invitations_personal_data_exporter( $email_address, $page ) { 2807 $number = 20; 2808 2809 $email_address = trim( $email_address ); 2810 2811 $data_to_export = array(); 2812 2813 $user = get_user_by( 'email', $email_address ); 2814 2815 if ( ! $user ) { 2816 return array( 2817 'data' => array(), 2818 'done' => true, 2819 ); 2820 } 2821 2822 $invitations = BP_Groups_Member::get_user_memberships( $user->ID, array( 2823 'type' => 'pending_sent_invitation', 2824 'page' => $page, 2825 'per_page' => $number, 2826 ) ); 2827 2828 foreach ( $invitations as $invitation ) { 2829 $group = groups_get_group( $invitation->group_id ); 2830 2831 $item_data = array( 2832 array( 2833 'name' => __( 'Group Name', 'buddypress' ), 2834 'value' => bp_get_group_name( $group ), 2835 ), 2836 array( 2837 'name' => __( 'Group URL', 'buddypress' ), 2838 'value' => bp_get_group_permalink( $group ), 2839 ), 2840 array( 2841 'name' => __( 'Sent To', 'buddypress' ), 2842 'value' => bp_core_get_userlink( $invitation->user_id ), 2843 ), 2844 array( 2845 'name' => __( 'Date Sent', 'buddypress' ), 2846 'value' => $invitation->date_modified, 2847 ), 2848 ); 2849 2850 $data_to_export[] = array( 2851 'group_id' => 'bp_groups_pending_sent_invitations', 2852 'group_label' => __( 'Pending Group Invitations (Sent)', 'buddypress' ), 2853 'item_id' => "bp-group-pending-sent-invitation-{$group->id}", 2854 'data' => $item_data, 2855 ); 2856 } 2857 2858 // Tell core if we have more items to process. 2859 $done = count( $invitations ) < $number; 2860 2861 return array( 2862 'data' => $data_to_export, 2863 'done' => $done, 2864 ); 2865 } 2866 2867 /** 2868 * Finds and exports data on pending group invitations received by a user associated with an email address. 2869 * 2870 * @since 4.0.0 2871 * 2872 * @param string $email_address The user's email address. 2873 * @param int $page Batch number. 2874 * @return array An array of personal data. 2875 */ 2876 function bp_groups_pending_received_invitations_personal_data_exporter( $email_address, $page ) { 2877 $number = 20; 2878 2879 $email_address = trim( $email_address ); 2880 2881 $data_to_export = array(); 2882 2883 $user = get_user_by( 'email', $email_address ); 2884 2885 if ( ! $user ) { 2886 return array( 2887 'data' => array(), 2888 'done' => true, 2889 ); 2890 } 2891 2892 $invitations = BP_Groups_Member::get_user_memberships( $user->ID, array( 2893 'type' => 'pending_received_invitation', 2894 'page' => $page, 2895 'per_page' => $number, 2896 ) ); 2897 2898 foreach ( $invitations as $invitation ) { 2899 $group = groups_get_group( $invitation->group_id ); 2900 2901 $item_data = array( 2902 array( 2903 'name' => __( 'Group Name', 'buddypress' ), 2904 'value' => bp_get_group_name( $group ), 2905 ), 2906 array( 2907 'name' => __( 'Group URL', 'buddypress' ), 2908 'value' => bp_get_group_permalink( $group ), 2909 ), 2910 array( 2911 'name' => __( 'Invited By', 'buddypress' ), 2912 'value' => bp_core_get_userlink( $invitation->inviter_id ), 2913 ), 2914 array( 2915 'name' => __( 'Date Sent', 'buddypress' ), 2916 'value' => $invitation->date_modified, 2917 ), 2918 ); 2919 2920 $data_to_export[] = array( 2921 'group_id' => 'bp_groups_pending_received_invitations', 2922 'group_label' => __( 'Pending Group Invitations (Received)', 'buddypress' ), 2923 'item_id' => "bp-group-pending-received-invitation-{$group->id}", 2924 'data' => $item_data, 2925 ); 2926 } 2927 2928 // Tell core if we have more items to process. 2929 $done = count( $invitations ) < $number; 2930 2931 return array( 2932 'data' => $data_to_export, 2933 'done' => $done, 2934 ); 2935 }
Note: See TracChangeset
for help on using the changeset viewer.