lifterlms_template_student_dashboard_my_notifications()


Description Description


Source Source

File: includes/functions/llms.functions.templates.dashboard.php

	function lifterlms_template_student_dashboard_my_notifications() {

		$url = llms_get_endpoint_url( 'notifications', '', llms_get_page_url( 'myaccount' ) );

		$sections = array(
			array(
				'url' => $url,
				'name' => __( 'View Notifications', 'lifterlms' ),
			),
			array(
				'url' => add_query_arg( 'sdview', 'prefs', $url ),
				'name' => __( 'Manage Preferences', 'lifterlms' ),
			),
		);

		$view = isset( $_GET['sdview'] ) ? $_GET['sdview'] : 'view';

		if ( 'view' === $view ) {

			$page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

			$notifications = new LLMS_Notifications_Query( array(
				'page' => $page,
				'per_page' => apply_filters( 'llms_sd_my_notifications_per_page', 25 ),
				'subscriber' => get_current_user_id(),
				'sort' => array(
					'created' => 'DESC',
					'id' => 'DESC',
				),
				'types' => 'basic',
			) );

			$pagination = array(
				'max' => $notifications->max_pages,
				'current' => $page,
			);

			$args = array(
				'notifications' => $notifications->get_notifications(),
				'pagination' => $pagination,
				'sections' => $sections,
			);

		} else {

			$types = apply_filters( 'llms_notification_subscriber_manageable_types', array( 'email' ) );

			$settings = array();
			$student = new LLMS_Student( get_current_user_id() );

			foreach ( LLMS()->notifications()->get_controllers() as $controller ) {

				foreach ( $types as $type ) {

					$configs = $controller->get_subscribers_settings( $type );
					if ( in_array( 'student', array_keys( $configs ) ) && 'yes' === $configs['student'] ) {

						if ( ! isset( $settings[ $type ] ) ) {
							$settings[ $type ] = array();
						}

						$settings[ $type ][ $controller->id ] = array(
							'name' => $controller->get_title(),
							'value' => $student->get_notification_subscription( $type, $controller->id, 'yes' ),
						);
					}
				}
			}

			$args = array(
				'sections' => $sections,
				'settings' => $settings,
			);

		}// End if().

		add_filter( 'paginate_links', 'llms_modify_dashboard_pagination_links' );

		llms_get_template( 'myaccount/my-notifications.php', $args );

		remove_filter( 'paginate_links', 'llms_modify_dashboard_pagination_links' );

	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: