Skip to content

Commit 18120f6

Browse files
author
JasWSInc
committed
Queue event log enhancements. #59
1 parent 22a1741 commit 18120f6

3 files changed

Lines changed: 111 additions & 19 deletions

File tree

comment-mail/includes/classes/menu-page-queue-event-log-table.php

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@ public static function get_columns_()
5858
{
5959
$plugin = plugin(); // Plugin class instance.
6060

61-
return array(
61+
$columns = array(
6262
'cb' => '1', // Include checkboxes.
6363
'ID' => __('Entry', $plugin->text_domain),
6464

6565
'time' => __('Time', $plugin->text_domain),
66-
6766
'event' => __('Event', $plugin->text_domain),
68-
'note_code' => __('Note', $plugin->text_domain),
6967

7068
'queue_id' => __('Queue ID', $plugin->text_domain),
7169
'dby_queue_id' => __('Digested by Queue ID', $plugin->text_domain),
@@ -87,6 +85,12 @@ public static function get_columns_()
8785

8886
'status' => __('Subscr. Status', $plugin->text_domain),
8987
);
88+
if(!$plugin->options['geo_location_tracking_enable']) foreach($columns as $_key => $_column)
89+
if(in_array($_key, array('region', 'country'), TRUE))
90+
unset($columns[$_key]); // Ditch this column by key.
91+
unset($_key, $_column); // Housekeeping.
92+
93+
return $columns; // Associative array.
9094
}
9195

9296
/**
@@ -98,9 +102,9 @@ public static function get_columns_()
98102
*/
99103
public static function get_hidden_columns_()
100104
{
101-
return array(
102-
'note_code',
105+
$plugin = plugin(); // Plugin class instance.
103106

107+
$columns = array(
104108
'queue_id',
105109
'dby_queue_id',
106110

@@ -119,6 +123,12 @@ public static function get_hidden_columns_()
119123

120124
'status',
121125
);
126+
if(!$plugin->options['geo_location_tracking_enable']) foreach($columns as $_key => $_column)
127+
if(in_array($_column, array('region', 'country'), TRUE))
128+
unset($columns[$_key]); // Ditch this column by key.
129+
unset($_key, $_column); // Housekeeping.
130+
131+
return array_values($columns);
122132
}
123133

124134
/**
@@ -217,6 +227,38 @@ protected function column_ID(\stdClass $item)
217227
return $id_info.$this->row_actions($row_actions);
218228
}
219229

230+
/**
231+
* Table column handler.
232+
*
233+
* @since 141111 First documented version.
234+
*
235+
* @param \stdClass $item Item object; i.e. a row from the DB.
236+
*
237+
* @return string HTML markup for this table column.
238+
*/
239+
protected function column_event(\stdClass $item)
240+
{
241+
$event_label = $this->plugin->utils_i18n->event_label($item->event);
242+
243+
switch($item->event) // Based on the type of event that took place.
244+
{
245+
case 'notified': // Queue entry was notified in this case.
246+
247+
$name_email_args = array(
248+
'anchor_to' => 'search',
249+
'email_style' => 'font-weight:normal;',
250+
);
251+
return esc_html($event_label).' '.$this->plugin->utils_event->queue_notified_q_link($item).'<br />'.
252+
$this->plugin->utils_markup->name_email('', $item->email, $name_email_args);
253+
254+
case 'invalidated': // Queue entry was invalidated in this case.
255+
256+
return esc_html($event_label).' '.$this->plugin->utils_event->queue_invalidated_q_link($item).'<br />'.
257+
'<code style="font-size:90%;">'.esc_html($item->note_code).'</code>';
258+
}
259+
return esc_html($event_label); // Default case handler.
260+
}
261+
220262
/*
221263
* Public query-related methods.
222264
*/

comment-mail/includes/classes/menu-page-table-base.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -738,19 +738,23 @@ protected function column_comment_parent_id_before(\stdClass $item)
738738
*
739739
* @param \stdClass $item Item object; i.e. a row from the DB.
740740
* @param string $prefix Prefix for data associated w/ the key. Defaults to ``.
741-
* @param string $key A particular key to return. Defaults to `deliver`.
741+
* @param string $key A particular key to return. Defaults to `email`.
742742
*
743743
* @return string HTML markup for this table column.
744744
*/
745-
protected function column_deliver(\stdClass $item, $prefix = '', $key = 'deliver')
745+
protected function column_email(\stdClass $item, $prefix = '', $key = 'email')
746746
{
747747
if(!isset($item->{$key}))
748748
return ''; // Not possible.
749749

750750
if(!$item->{$key})
751751
return ''; // Not possible.
752752

753-
return esc_html($this->plugin->utils_i18n->deliver_label($item->{$key}));
753+
$name_email_args = array(
754+
'anchor_to' => 'search',
755+
'email_style' => 'font-weight:normal;',
756+
);
757+
return $this->plugin->utils_markup->name_email('', $item->{$key}, $name_email_args);
754758
}
755759

756760
/**
@@ -762,9 +766,9 @@ protected function column_deliver(\stdClass $item, $prefix = '', $key = 'deliver
762766
*
763767
* @return string HTML markup for this table column.
764768
*/
765-
protected function column_deliver_before(\stdClass $item)
769+
protected function column_email_before(\stdClass $item)
766770
{
767-
return $this->column_deliver($item, '', 'deliver_before');
771+
return $this->column_email($item, '', 'email_before');
768772
}
769773

770774
/**
@@ -810,22 +814,19 @@ protected function column_status_before(\stdClass $item)
810814
*
811815
* @param \stdClass $item Item object; i.e. a row from the DB.
812816
* @param string $prefix Prefix for data associated w/ the key. Defaults to ``.
813-
* @param string $key A particular key to return. Defaults to `note_code`.
817+
* @param string $key A particular key to return. Defaults to `deliver`.
814818
*
815819
* @return string HTML markup for this table column.
816820
*/
817-
protected function column_note_code(\stdClass $item, $prefix = '', $key = 'note_code')
821+
protected function column_deliver(\stdClass $item, $prefix = '', $key = 'deliver')
818822
{
819823
if(!isset($item->{$key}))
820824
return ''; // Not possible.
821825

822826
if(!$item->{$key})
823-
return ''; // Not applicable.
824-
825-
$note = $this->plugin->utils_event->queue_note_code_desc($item->{$key});
826-
$note = $this->plugin->utils_string->markdown_no_p($note); // HTML markup.
827+
return ''; // Not possible.
827828

828-
return $note; // HTML markup via simple MD parsing.
829+
return esc_html($this->plugin->utils_i18n->deliver_label($item->{$key}));
829830
}
830831

831832
/**
@@ -837,9 +838,9 @@ protected function column_note_code(\stdClass $item, $prefix = '', $key = 'note_
837838
*
838839
* @return string HTML markup for this table column.
839840
*/
840-
protected function column_note_code_before(\stdClass $item)
841+
protected function column_deliver_before(\stdClass $item)
841842
{
842-
return $this->column_note_code($item, '', 'note_code_before');
843+
return $this->column_deliver($item, '', 'deliver_before');
843844
}
844845

845846
/**

comment-mail/includes/classes/utils-event.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,55 @@ public function __construct()
3030
parent::__construct();
3131
}
3232

33+
/**
34+
* Queue event log; provide notified details.
35+
*
36+
* @since 141111 First documented version.
37+
*
38+
* @param \stdClass $row A queue event log entry row from the DB.
39+
*
40+
* @return string Details about why a notified event occurs; in the form of a `[?]` link.
41+
*/
42+
public function queue_notified_q_link(\stdClass $row)
43+
{
44+
$details = '<h3 style="margin-top:0;">'.sprintf(__('Queue Entry ID #%1$s was processed (notified) successfully on %2$s', $this->plugin->text_domain), esc_html($row->queue_id), esc_html($this->plugin->utils_date->i18n('M j, Y g:i a', $row->time))).'</h3>'.
45+
46+
'<i class="fa fa-info-circle fa-5x pmp-right"></i>'.
47+
'<p>'.__('When a queue entry is processed (notified) it means that an email notification was sent successfully; i.e. the subscriber was sent an email with details about a new reply on a specific post (or comment) they subscribed to.', $this->plugin->text_domain).'</p>'.
48+
'<p style="font-weight:bold;">'.__('This email notification was sent to:', $this->plugin->text_domain).'</p>'.
49+
'<ul style="margin-bottom:0;">'.
50+
' <li><code>'.esc_html($row->email).'</code></li>'.
51+
'</ul>';
52+
53+
return '<a href="#" class="pmp-q-link" data-toggle="alert" data-alert="'.esc_attr($details).'">'.__('[?]', $this->plugin->text_domain).'</a>';
54+
}
55+
56+
/**
57+
* Queue event log; provide invalidated details.
58+
*
59+
* @since 141111 First documented version.
60+
*
61+
* @param \stdClass $row A queue event log entry row from the DB.
62+
*
63+
* @return string Details about why an invalidated event occurs; in the form of a `[?]` link.
64+
*/
65+
public function queue_invalidated_q_link(\stdClass $row)
66+
{
67+
$note = $this->plugin->utils_event->queue_note_code_desc($row->note_code);
68+
$note = $this->plugin->utils_string->markdown_no_p($note);
69+
70+
$details = '<h3 style="margin-top:0;">'.sprintf(__('Queue Entry ID #%1$s was invalidated %2$s', $this->plugin->text_domain), esc_html($row->queue_id), esc_html($this->plugin->utils_date->i18n('M j, Y g:i a', $row->time))).'</h3>'.
71+
72+
'<i class="fa fa-info-circle fa-5x pmp-right"></i>'.
73+
'<p>'.__('An invalidation occurs whenever there is an unexpected scenario encountered during queue processing. This happens from time-to-time; i.e. it\'s usually not something to be alarmed about. For example, an invalidation may occur because you deleted a post, or comment, before a notification (already in the queue) was actually processed. It\'s not possible to send a notification regarding a post/comment that no longer exists, so an invalidation is actually a good thing in case like this. That\'s just one example, but it gives an idea of what can cause an invalidation.', $this->plugin->text_domain).'</p>'.
74+
'<p style="font-weight:bold;">'.__('This particular invalidation occured because:', $this->plugin->text_domain).'</p>'.
75+
'<ul class="pmp-list-items" style="margin-bottom:0;">'.
76+
' <li><code>'.esc_html($row->note_code).'</code> — '.$note.'</li>'.
77+
'</ul>';
78+
79+
return '<a href="#" class="pmp-q-link" data-toggle="alert" data-alert="'.esc_attr($details).'">'.__('[?]', $this->plugin->text_domain).'</a>';
80+
}
81+
3382
/**
3483
* Queue event log; note code to full description.
3584
*

0 commit comments

Comments
 (0)