LLMS_Table_NotificationSettings

LLMS_Table_NotificationSettings class


Description Description

Student Management table on Courses and Memberships.


Top ↑

Source Source

File: includes/admin/settings/tables/class.llms.table.notification.settings.php

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
class LLMS_Table_NotificationSettings extends LLMS_Admin_Table {
 
    /**
     * Unique ID for the Table
     *
     * @var  string
     */
    protected $id = 'notifications';
 
    /**
     * If true will be a table with a larger font size
     *
     * @var  bool
     */
    protected $is_large = true;
 
    /**
     * Retrieve data for the columns
     *
     * @since 3.8.0
     *
     * @param string $key  The column id / key.
     * @param array  $data Table data array.
     * @return mixed
     */
    public function get_data( $key, $data ) {
 
        switch ( $key ) {
 
            case 'configure':
                $links = array();
                foreach ( $data['configure'] as $type => $name ) {
                    $url     = esc_url(
                        add_query_arg(
                            array(
                                'notification' => $data['id'],
                                'type'         => $type,
                            )
                        )
                    );
                    $links[] = '<a href="' . $url . '">' . $name . '</a>';
                }
                $value = implode( ', ', $links );
                break;
 
            default:
                $value = $data[ $key ];
 
        }
 
        return $this->filter_get_data( $value, $key, $data );
 
    }
 
    /**
     * Execute a query to retrieve results from the table
     *
     * @param    array $args  array of query args
     * @return   void
     * @since    3.8.0
     * @version  3.10.0
     */
    public function get_results( $args = array() ) {
 
        $rows = array();
 
        foreach ( llms()->notifications()->get_controllers() as $controller ) {
 
            $rows[] = array(
                'id'           => $controller->id,
                'notification' => $controller->get_title(),
                'configure'    => $controller->get_supported_types(),
            );
 
        }
 
        usort( $rows, array( $this, 'sort_rows' ) );
 
        $this->tbody_data = $rows;
    }
 
    /**
     * Define the structure of arguments used to pass to the get_results method
     *
     * @return   array
     * @since    3.8.0
     * @version  3.8.0
     */
    public function set_args() {
        return array();
    }
 
    /**
     * Define the structure of the table
     *
     * @return   array
     * @since    3.8.0
     * @version  3.8.0
     */
    public function set_columns() {
        $cols = array(
            'notification' => __( 'Notification', 'lifterlms' ),
            'configure'    => __( 'Configure', 'lifterlms' ),
        );
 
        return $cols;
    }
 
    /**
     * Sorting function to display all loaded notifications in alphabetical order
     *
     * @param    array $row_a  first row to compare
     * @param    array $row_b  second row to compare
     * @return   int
     * @since    3.10.0
     * @version  3.10.0
     */
    public function sort_rows( $row_a, $row_b ) {
        return strcmp( $row_a['notification'], $row_b['notification'] );
    }
 
}


Top ↑

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
  • sort_rows — Sorting function to display all loaded notifications in alphabetical order

Top ↑

Changelog Changelog

Changelog
Version Description
3.8.0
3.10.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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