1 | <?php namespace EmailLog\Core\DB; |
||
15 | class TableManager implements Loadie { |
||
16 | |||
17 | /* Database table name */ |
||
18 | const LOG_TABLE_NAME = 'email_log'; |
||
19 | |||
20 | /* Database option name */ |
||
21 | const DB_OPTION_NAME = 'email-log-db'; |
||
22 | |||
23 | /* Database version */ |
||
24 | const DB_VERSION = '0.1'; |
||
25 | |||
26 | /** |
||
27 | * Setup hooks. |
||
28 | */ |
||
29 | public function load() { |
||
34 | |||
35 | /** |
||
36 | * On plugin activation, create table if needed. |
||
37 | * |
||
38 | * @param bool $network_wide True if the plugin was network activated. |
||
39 | */ |
||
40 | public function on_activate( $network_wide ) { |
||
56 | |||
57 | /** |
||
58 | * Create email log table when a new blog is created. |
||
59 | * |
||
60 | * @param int $blog_id Blog Id. |
||
61 | */ |
||
62 | public function create_table_for_new_blog( $blog_id ) { |
||
69 | |||
70 | /** |
||
71 | * Add email log table to the list of tables deleted when a blog is deleted. |
||
72 | * |
||
73 | * @param array $tables List of tables to be deleted. |
||
74 | * |
||
75 | * @return string[] $tables Modified list of tables to be deleted. |
||
76 | */ |
||
77 | 1 | public function delete_table_from_deleted_blog( $tables ) { |
|
82 | |||
83 | /** |
||
84 | * Get email log table name. |
||
85 | * |
||
86 | * @return string Email Log Table name. |
||
87 | */ |
||
88 | 2 | public function get_log_table_name() { |
|
93 | |||
94 | /** |
||
95 | * Insert log data into DB. |
||
96 | * |
||
97 | * @param array $data Data to be inserted. |
||
98 | */ |
||
99 | public function insert_log( $data ) { |
||
105 | |||
106 | /** |
||
107 | * Delete log entries by ids. |
||
108 | * |
||
109 | * @param string $ids Comma separated list of log ids. |
||
110 | * |
||
111 | * @return false|int Number of log entries that got deleted. False on failure. |
||
112 | */ |
||
113 | public function delete_logs( $ids ) { |
||
123 | |||
124 | /** |
||
125 | * Delete all log entries. |
||
126 | * |
||
127 | * @return false|int Number of log entries that got deleted. False on failure. |
||
128 | */ |
||
129 | public function delete_all_logs() { |
||
136 | |||
137 | /** |
||
138 | * Deletes Email Logs older than the specified interval. |
||
139 | * |
||
140 | * @param int $interval_in_days No. of days beyond which logs are to be deleted. |
||
141 | * |
||
142 | * @return int $deleted_rows_count Count of rows deleted. |
||
143 | */ |
||
144 | public function delete_logs_older_than( $interval_in_days ) { |
||
153 | |||
154 | /** |
||
155 | * Fetch log item by ID. |
||
156 | * |
||
157 | * @param array $ids Optional. Array of IDs of the log items to be retrieved. |
||
158 | * |
||
159 | * @return array Log item(s). |
||
160 | */ |
||
161 | public function fetch_log_items_by_id( $ids = array() ) { |
||
178 | |||
179 | /** |
||
180 | * Fetch log items. |
||
181 | * |
||
182 | * @param array $request Request object. |
||
183 | * @param int $per_page Entries per page. |
||
184 | * @param int $current_page_no Current page no. |
||
185 | * |
||
186 | * @return array Log entries and total items count. |
||
187 | */ |
||
188 | public function fetch_log_items( $request, $per_page, $current_page_no ) { |
||
234 | |||
235 | /** |
||
236 | * Create email log table. |
||
237 | * |
||
238 | * @access private |
||
239 | * |
||
240 | * @global object $wpdb |
||
241 | */ |
||
242 | private function create_table() { |
||
267 | |||
268 | /** |
||
269 | * Get the total number of email logs. |
||
270 | * |
||
271 | * @return int Total email log count |
||
272 | */ |
||
273 | public function get_logs_count() { |
||
280 | } |
||
281 |