bp_document_user_can_manage_document (intdocument_id美元,intuser_id美元)
检查用户是否有管理文档的权限。
描述
参数
- document_id美元
-
(int)(必需)
- user_id美元
-
(int)(必需)
返回
(混合|空白)
源
文件:bp-document / bp-document-functions.php
函数bp_document_user_can_manage_document($document_id = 0, $user_id = 0) {$can_manage = false;美元can_view = false;美元can_download = false;美元can_add = false;$document = new BP_Document($document_id);$ data =数组();Switch ($document->privacy) {case 'public': if ($document->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, $document->group_id ); $status = bp_group_get_document_status( $document->group_id ); $is_admin = groups_is_user_admin( $user_id, $document->group_id ); $is_mod = groups_is_user_mod( $user_id, $document->group_id ); if ( $manage ) { if ( $document->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( (int) $document->group_id ); if ( $the_group->id > 0 && $the_group->user_has_access ) { $can_view = true; $can_download = true; } } } break; case 'loggedin': if ( $document->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( $document->user_id, $user_id ) : false; if ( $document->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 'forums': $args = array( 'user_id' => $user_id, 'forum_id' => bp_document_get_meta( $document_id, 'forum_id', true ), 'check_ancestors' => false, ); $has_access = bbp_user_can_view_forum( $args ); if ( $document->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 ( $has_access ) { if ( bp_current_user_can( 'bp_moderate' ) ) { $can_manage = true; } $can_view = true; $can_download = true; } break; case 'message': $thread_id = bp_document_get_meta( $document_id, 'thread_id', true ); $has_access = messages_check_thread_access( $thread_id, $user_id ); if ( ! is_user_logged_in() ) { $can_manage = false; $can_view = false; $can_download = false; } elseif ( ! $thread_id ) { $can_manage = false; $can_view = false; $can_download = false; } elseif ( $document->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 ( $has_access > 0 ) { $can_manage = false; $can_view = true; $can_download = true; } break; case 'onlyme': if ( $document->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, $document_id, $user_id ); }
更新日志
版本 | 描述 |
---|---|
BuddyBoss 1.4.0 | 介绍了。 |