Changeset 11806 for trunk/src/bp-activity/bp-activity-functions.php
- Timestamp:
- 01/10/2018 06:59:00 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r11793 r11806 3082 3082 3083 3083 /** 3084 * Can a user see a particular activity item? 3085 * 3086 * @since 3.0.0 3087 * 3088 * @param BP_Activity_Activity $activity Activity object. 3089 * @param integer $user_id User ID. 3090 * @return boolean True on success, false on failure. 3091 */ 3092 function bp_activity_user_can_read( $activity, $user_id = 0 ) { 3093 $retval = false; 3094 3095 // Fallback. 3096 if ( empty( $user_id ) ) { 3097 $user_id = bp_loggedin_user_id(); 3098 } 3099 3100 // Admins and moderators can see everything. 3101 if ( bp_current_user_can( 'bp_moderate' ) ) { 3102 $retval = true; 3103 } 3104 3105 // If activity author match user, allow access as well. 3106 if ( $user_id === $activity->user_id ) { 3107 $retval = true; 3108 } 3109 3110 // If activity is from a group, do an extra cap check. 3111 if ( ! $retval && bp_is_active( 'groups' ) && $activity->component === buddypress()->groups->id ) { 3112 3113 // Check to see if the user has access to the activity's parent group. 3114 $group = groups_get_group( $activity->item_id ); 3115 if ( $group ) { 3116 $retval = $group->user_has_access; 3117 } 3118 } 3119 3120 /** 3121 * Filters whether the current user has access to an activity item. 3122 * 3123 * @since 3.0.0 3124 * 3125 * @param bool $retval Return value. 3126 * @param int $user_id Current user ID. 3127 * @param BP_Activity_Activity $activity Activity object. 3128 */ 3129 return apply_filters( 'bp_activity_user_can_read', $retval, $user_id, $activity ); 3130 } 3131 3132 /** 3084 3133 * Hide a user's activity. 3085 3134 *
Note: See TracChangeset
for help on using the changeset viewer.