LLMS_Table_Student_Memberships
Source Source
File: includes/admin/reporting/tables/llms.table.student.memberships.php
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | class LLMS_Table_Student_Memberships extends LLMS_Admin_Table { /** * Unique ID for the Table * * @var string */ protected $id = 'student-memberships' ; /** * Instance of LLMS_Student * * @var null */ protected $student = null; /** * Retrieve data for the columns * * @param string $key the column id / key * @param int $membership_id ID of the membership * @return mixed * @since 3.2.0 * @version 3.7.5 */ public function get_data( $key , $membership_id ) { switch ( $key ) { case 'id' : $value = $this ->get_post_link( $membership_id ); break ; case 'name' : $value = get_the_title( $membership_id ); break ; case 'status' : $value = llms_get_enrollment_status_name( $this ->student->get_enrollment_status( $membership_id ) ); break ; case 'enrolled' : $value = $this ->student->get_enrollment_date( $membership_id , 'enrolled' ); break ; default : $value = $key ; } return $this ->filter_get_data( $value , $key , $membership_id ); } /** * Execute a query to retrieve results from the table * * @param array $args array of query args * @return void * @since 3.2.0 * @version 3.2.0 */ public function get_results( $args = array () ) { $args = $this ->clean_args( $args ); if ( is_numeric ( $args [ 'student' ] ) ) { $args [ 'student' ] = new LLMS_Student( $args [ 'student' ] ); } $this ->student = $args [ 'student' ]; $this ->tbody_data = $this ->student->get_membership_levels(); } /** * Define the structure of arguments used to pass to the get_results method * * @since 2.3.0 * @since 3.35.0 Get student ID more reliably. * * @return array */ public function set_args() { $student = false; if ( ! empty ( $this ->student ) ) { $student = $this ->student->get_id(); } elseif ( ! empty ( $_GET [ 'student_id' ] ) ) { $student = llms_filter_input( INPUT_GET, 'student_id' , FILTER_SANITIZE_NUMBER_INT ); } return array ( 'student' => $student , ); } /** * Define the structure of the table * * @return array * @since 3.2.0 * @version 3.2.0 */ public function set_columns() { return array ( 'id' => array ( 'title' => __( 'ID' , 'lifterlms' ), ), 'name' => array ( 'title' => __( 'Name' , 'lifterlms' ), ), 'status' => array ( 'title' => __( 'Status' , 'lifterlms' ), ), 'enrolled' => array ( 'title' => __( 'Enrolled' , 'lifterlms' ), ), ); } /** * Empty message displayed when no results are found * * @return string * @since 3.2.0 * @version 3.2.0 */ protected function set_empty_message() { return __( 'This student is not enrolled in any memberships.' , 'lifterlms' ); } } |
Expand full source code Collapse full source code View on GitHub
Methods Methods
- get_data — Retrieve data for the columns
- get_results — Execute a query to retrieve results from the table
- set_args — Define the structure of arguments used to pass to the get_results method
- set_columns — Define the structure of the table
- set_empty_message — Empty message displayed when no results are found
Changelog Changelog
Version | Description |
---|---|
3.7.5 | Unknown. |
3.35.0 | Get student ID more reliably. |
3.2.0 | Introduced. |