bp_nouveau_ajax_document_get_activity()

Get activity for the document.

Description

Source

File: bp-templates/bp-nouveau/includes/document/ajax.php

function bp_nouveau_ajax_document_get_activity() {
	$response = array(
		'feedback' => sprintf(
			'<div class="bp-feedback bp-messages error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
			esc_html__( 'There was a problem displaying the content. Please try again.', 'buddyboss' )
		),
	);

	// Nonce check!
	$nonce = filter_input( INPUT_POST, 'nonce', FILTER_SANITIZE_STRING );
	if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'bp_nouveau_media' ) ) {
		wp_send_json_error( $response );
	}

	$post_id 	= filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT );
	$group_id 	= filter_input( INPUT_POST, 'group_id', FILTER_VALIDATE_INT );
	$author_id 	= filter_input( INPUT_POST, 'author', FILTER_VALIDATE_INT );

	// check activity is document or not.
	$document_activity = bp_activity_get_meta( $post_id, 'bp_document_activity', true );

	remove_action( 'bp_activity_entry_content', 'bp_document_activity_entry' );
	add_action( 'bp_before_activity_activity_content', 'bp_nouveau_document_activity_description' );
	add_filter( 'bp_get_activity_content_body', 'bp_nouveau_clear_activity_content_body', 99, 2 );

	if ( ! empty( $document_activity ) ) {
		$args = array(
			'include'     => $post_id,
			'privacy'     => false,
			'show_hidden' => true,
			'scope'       => 'document',
		);
	} else {
		if ( $group_id > 0 ) {
			$args = array(
				'include'     => $post_id,
				'object'      => buddypress()->groups->id,
				'primary_id'  => $group_id,
				'privacy'     => false,
				'scope'       => false,
				'show_hidden' => (bool) ( groups_is_user_member( bp_loggedin_user_id(), $group_id ) || bp_current_user_can( 'bp_moderate' ) ),
			);
		} else {
			$args = array(
				'include' => $post_id,
				'privacy' => false,
				'scope'   => false,
			);
		}
	}

	ob_start();
	if ( bp_has_activities( $args ) ) {
		while ( bp_activities() ) {
			bp_the_activity();
			bp_get_template_part( 'activity/entry' );
		}
	}
	$activity = ob_get_contents();
	ob_end_clean();

	remove_filter( 'bp_get_activity_content_body', 'bp_nouveau_clear_activity_content_body', 99, 2 );
	remove_action( 'bp_before_activity_activity_content', 'bp_nouveau_document_activity_description' );
	add_action( 'bp_activity_entry_content', 'bp_document_activity_entry' );

	wp_send_json_success(
		array(
			'activity' => $activity,
		)
	);
}

Changelog

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.