bp_nouveau_ajax_document_folder_move()
Move folder to another folder.
Description
Source
File: bp-templates/bp-nouveau/includes/document/ajax.php
function bp_nouveau_ajax_document_folder_move() { $response = array( 'feedback' => sprintf( '<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', esc_html__( 'There was a problem performing this action. Please try again.', 'buddyboss' ) ), ); // Bail if not a POST action. if ( ! bp_is_post_request() ) { wp_send_json_error( $response ); } $destination_folder_id = ! empty( $_POST['folderMoveToId'] ) ? (int) filter_input( INPUT_POST, 'folderMoveToId', FILTER_VALIDATE_INT ) : 0; $folder_id = ! empty( $_POST['currentFolderId'] ) ? (int) filter_input( INPUT_POST, 'currentFolderId', FILTER_VALIDATE_INT ) : 0; $group_id = ! empty( $_POST['group'] ) ? (int) filter_input( INPUT_POST, 'group', FILTER_VALIDATE_INT ) : 0; if ( (int) $folder_id > 0 ) { $has_access = bp_folder_user_can_edit( $folder_id ); if ( ! $has_access ) { $response['feedback'] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', esc_html__( 'You don\'t have permission to move this folder.', 'buddyboss' ) ); wp_send_json_error( $response ); } } if ( (int) $destination_folder_id > 0 ) { $has_access_destination = bp_folder_user_can_edit( $destination_folder_id ); if ( ! $has_access_destination ) { $response['feedback'] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', esc_html__( 'You don\'t have permission to move this folder.', 'buddyboss' ) ); wp_send_json_error( $response ); } } if ( '' === $destination_folder_id ) { wp_send_json_error( $response ); } if ( $destination_folder_id === $folder_id ) { $response = array( 'feedback' => sprintf( '<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', esc_html__( 'Couldn’t move item. ', 'buddyboss' ) ), ); wp_send_json_error( $response ); } $fetch_children = bp_document_get_folder_children( $folder_id ); if ( ! empty( $fetch_children ) ) { if ( in_array( $destination_folder_id, $fetch_children, true ) ) { $response = array( 'feedback' => sprintf( '<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', esc_html__( 'Couldn’t move item because it\'s parent folder. ', 'buddyboss' ) ), ); wp_send_json_error( $response ); } } bp_document_move_folder_to_folder( $folder_id, $destination_folder_id, $group_id ); $content = ''; ob_start(); if ( bp_has_document( bp_ajax_querystring( 'document' ) ) ) : if ( empty( $_POST['page'] ) || 1 === (int) filter_input( INPUT_POST, 'page', FILTER_SANITIZE_STRING ) ) : ?> <div class="document-data-table-head"> <span class="data-head-sort-label">:<?php esc_html_e( 'Sort By:', 'buddyboss' ); ?></span> <div class="data-head data-head-name"> <span> <?php esc_html_e( 'Name', 'buddyboss' ); ?> <i class="bb-icon-triangle-fill"></i> </span> </div> <div class="data-head data-head-modified"> <span> <?php esc_html_e( 'Modified', 'buddyboss' ); ?> <i class="bb-icon-triangle-fill"></i> </span> </div> <div class="data-head data-head-visibility"> <span> <?php esc_html_e( 'Visibility', 'buddyboss' ); ?> <i class="bb-icon-triangle-fill"></i> </span> </div> </div><!-- .document-data-table-head --> <div id="media-folder-document-data-table"> <?php bp_get_template_part( 'document/activity-document-move' ); bp_get_template_part( 'document/activity-document-folder-move' ); endif; while ( bp_document() ) : bp_the_document(); bp_get_template_part( 'document/document-entry' ); endwhile; if ( bp_document_has_more_items() ) : ?> <div class="pager"> <div class="dt-more-container load-more"> <a class="button outline full" href="<?php bp_document_load_more_link(); ?>"><?php esc_html_e( 'Load More', 'buddyboss' ); ?></a> </div> </div> <?php endif; if ( empty( $_POST['page'] ) || 1 === (int) filter_input( INPUT_POST, 'page', FILTER_SANITIZE_STRING ) ) : ?> </div> <!-- #media-folder-document-data-table --> <?php endif; else : bp_nouveau_user_feedback( 'media-loop-document-none' ); endif; $content .= ob_get_clean(); wp_send_json_success( array( 'message' => 'success', 'html' => $content, ) ); }
Changelog
Version | Description |
---|---|
BuddyBoss 1.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.