bp_document_user_can_manage_folder (intfolder_id美元,intuser_id美元)
检查用户是否有权限管理该文件夹。
描述
参数
- folder_id美元
-
(int)(必需)
- user_id美元
-
(int)(必需)
返回
(混合|空白)
源
文件:bp-document / bp-document-functions.php
函数bp_document_user_can_manage_folder($folder_id = 0, $user_id = 0) {$can_manage = false;美元can_view = false;美元can_download = false;美元can_add = false;$folder = new BP_Document_Folder($folder_id);$ data =数组();case 'public': if ($folder->user_id === $user_id) {$can_manage = true;美元can_view = true;美元can_download = true;美元can_add = true; } elseif ( bp_current_user_can( 'bp_moderate' ) ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = false; } else { $can_manage = false; $can_view = true; $can_download = true; } break; case 'grouponly': if ( bp_is_active( 'groups' ) ) { $manage = groups_can_user_manage_document( $user_id, $folder->group_id ); $status = bp_group_get_media_status( $folder->group_id ); $is_admin = groups_is_user_admin( $user_id, $folder->group_id ); $is_mod = groups_is_user_mod( $user_id, $folder->group_id ); if ( $manage ) { if ( $folder->user_id === $user_id ) { $can_manage = true; $can_add = true; } elseif ( bp_current_user_can( 'bp_moderate' ) ) { $can_manage = true; $can_add = false; } elseif ( 'members' == $status && ( $is_mod || $is_admin ) ) { $can_manage = true; $can_add = false; } elseif ( 'mods' == $status && ( $is_mod || $is_admin ) ) { $can_manage = true; $can_add = false; } elseif ( 'admins' == $status && $is_admin ) { $can_manage = true; $can_add = false; } $can_view = true; $can_download = true; } else { $the_group = groups_get_group( absint( $folder->group_id ) ); if ( $the_group->id > 0 && $the_group->user_has_access ) { $can_view = true; $can_download = true; } } } break; case 'loggedin': if ( $folder->user_id === $user_id ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = true; } elseif ( bp_current_user_can( 'bp_moderate' ) ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = false; } elseif ( bp_loggedin_user_id() === $user_id ) { $can_manage = false; $can_view = true; $can_download = true; } break; case 'friends': $is_friend = ( bp_is_active( 'friends' ) ) ? friends_check_friendship( $folder->user_id, $user_id ) : false; if ( $folder->user_id === $user_id ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = true; } elseif ( bp_current_user_can( 'bp_moderate' ) ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = false; } elseif ( $is_friend ) { $can_manage = false; $can_view = true; $can_download = true; } break; case 'onlyme': if ( $folder->user_id === $user_id ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = true; } elseif ( bp_current_user_can( 'bp_moderate' ) ) { $can_manage = true; $can_view = true; $can_download = true; $can_add = false; } break; } $data['can_manage'] = $can_manage; $data['can_view'] = $can_view; $data['can_download'] = $can_download; $data['can_add'] = $can_add; return apply_filters( 'bp_document_user_can_manage_folder', $data, $folder_id, $user_id ); }
更新日志
版本 | 描述 |
---|---|
BuddyBoss 1.4.0 | 介绍了。 |