ReportsGenerator::setupParams()

Setup ld activity query params

Description

Source

File: bp-integrations/learndash/library/ReportsGenerator.php

	protected function setupParams()
	{
		// includes/ld-reports.php:882 learndash_reports_get_activity only allowd leader if group_id is passed
		// $this->params['group_ids'] = $this->args['group'];
		$ldGroupId = bp_ld_sync('buddypress')->sync->generator($this->args['group'])->getLdGroupId();

		if ($this->hasArg('date_format')) {
			$this->params['date_format'] = $this->args['date_format'] ?: 'Y-m-d';
		}

		$this->params['course_ids'] = learndash_group_enrolled_courses($ldGroupId);

		if ($this->hasArg('step')) {
			$this->params['post_types'] = $this->args['step'] == 'all'? $this->allSteps() : $this->args['step'];
		}

		// if ($this->hasArg('user')) {
			$this->params['user_ids'] = $this->args['user'] ?: learndash_get_groups_user_ids($ldGroupId);
		// }

		if ($this->hasArg('completed')) {
			$this->params['activity_status'] = $this->args['completed']? 'COMPLETED' : 'IN_PROGRESS';
		}

		if ($this->hasArg('order')) {
			$columns = $this->columns();
			$columnIndex = $this->args['order'][0]['column'];
			$column = $columns[$this->args['columns'][$columnIndex]['name']];

			$oldOrder = isset($this->params['orderby_order'])? ", {$this->params['orderby_order']}" : '';
			$this->params['orderby_order'] = "{$column['order_key']} {$this->args['order'][0]['dir']} {$oldOrder}";
		}

		if ($this->hasArg('start')) {
			$this->params['paged'] = $this->args['start'] / $this->args['length'] + 1;
		}

		if ($this->hasArg('length')) {
			$this->params['per_page'] = $this->args['length'];
		}
// print_r($this->params);die();
		$this->params = apply_filters('bp_ld_sync/reports_generator_params', $this->params, $this->args);
	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.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.