17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
18 require_once SQ_FUDGE_PATH.
'/datetime_field/datetime_field.inc';
41 function paintLogs(&$owner, &$o, &$ei, $keywords=NULL)
44 $prefix = $owner->getPrefix();
45 $invalid_dates = TRUE;
47 $log_types = include SQ_DATA_PATH.
'/private/system/core/internal_message_types.inc';
52 $_combo_box_name =
'sq_backend_log_type2';
54 $_combo_box_name =
'sq_backend_log_type';
57 if (isset($_REQUEST[$_combo_box_name])) {
58 $active_log_types = $_REQUEST[$_combo_box_name];
60 $active_log_types = (!empty($log_types) && isset($log_types[0])) ? Array($log_types[0]) : Array();
65 if (!is_array($active_log_types)) {
66 $active_log_types = array($active_log_types);
70 $selected_based_url =
'';
71 $selected_types = Array();
72 $o->openSection(translate(
'logged_messages'));
74 $type_options = Array();
75 foreach ($log_types as $type) {
77 if (strpos($type,
'asset') !== 0) {
82 if (in_array($type, $active_log_types)) {
83 $selected_types[] = $type;
85 $type_options[$type] = ucwords(str_replace(Array(
'.',
'_'),
' ', $type));
87 $date = date(
'Y-m-d H:s:i', time());
89 $date_parameters = Array(
90 'min' =>
'1990-01-01 00:00:00',
91 'max' =>
'2030-12-31 23:59:59',
93 'show' => Array(
'y',
'm',
'd',
'h',
'i',
's'),
106 $from_field =
new DateTime_Field($prefix.
'_date_from', $date, $date_parameters);
107 $to_field =
new DateTime_Field($prefix.
'_date_to', $date, $date_parameters);
109 $from_date = $to_date =
'';
113 if ($from_field->processField() && $from_field->value !=
'1990-01-01 00:00:00') {
114 $from_date = $from_field->value;
119 $from_field->setValue($from_date);
121 if ($to_field->processField() && $to_field->value !=
'1990-01-01 00:00:00') {
122 $to_date = $to_field->value;
124 $to_field->setValue($to_date);
127 if (!( empty($type_options) && empty($selected_types) )) {
129 $o->openField(translate(
'log_type'));
131 combo_box($_combo_box_name, $type_options, TRUE, $selected_types, 10);
137 $o->openField(translate(
'from'));
138 $from_field->printField();
141 $o->openField(translate(
'to'));
142 $to_field->printField();
145 if (isset($from_date) && isset($to_date) && $from_date > $to_date) {
146 echo
"<font color=\"red\"><b>ERROR : 'From' date provided is later than 'To' date. </b></font><br>";
147 $invalid_dates = FALSE;
149 normal_button($prefix.
'_go', translate(
'view'),
'this.form.submit()');
154 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
157 foreach($selected_types as $active_log_type) {
159 if (strpos($active_log_type,
'asset.linking') === 0) {
161 $minor_logs = $ms->getLogs($active_log_type, Array(
'minorid' => $owner->id,
'from_date' => $from_date,
'to_date' => $to_date));
162 $major_logs = $ms->getLogs($active_log_type, Array(
'majorid' => $owner->id,
'from_date' => $from_date,
'to_date' => $to_date));
163 $logs = array_merge($minor_logs, $major_logs);
165 }
else if (strpos($active_log_type,
'asset.workflow') === 0) {
168 if (isset($_REQUEST[
'sq_workflow_log_version'])) {
169 $o->addFormActionGetVar(
'sq_workflow_log_version', $_REQUEST[
'sq_workflow_log_version']);
170 $logs = $ms->getLogs($active_log_type, Array(
171 'assetid' => $owner->id,
172 'version' => $_REQUEST[
'sq_workflow_log_version'],
173 'from_date' => $from_date,
174 'to_date' => $to_date,
177 $user_logs = $ms->getLogs($active_log_type.
'.userlog', Array(
178 'assetid' => $owner->id,
179 'version' => $_REQUEST[
'sq_workflow_log_version'],
180 'from_date' => $from_date,
181 'to_date' => $to_date,
185 $logs = $ms->getLogs($active_log_type, Array(
'assetid' => $owner->id,
'from_date' => $from_date,
'to_date' => $to_date));
186 $user_logs = $ms->getLogs($active_log_type.
'.userlog', Array(
'assetid' => $owner->id,
'from_date' => $from_date,
'to_date' => $to_date));
189 $logs = array_merge($logs, $user_logs);
193 $logs = $ms->getLogs($active_log_type, Array(
'assetid' => $owner->id,
'from_date' => $from_date,
'to_date' => $to_date));
197 $all_logs = array_merge($all_logs, $logs);
201 usort($all_logs, Array(
'Messaging_Service',
'sortMessages'));
203 if (!empty($selected_types)) {
204 $selected_base_url = replace_query_string_vars(Array($_combo_box_name.
'[]' => NULL, $owner->type().
'_'.$owner->id.
'_start_at' => NULL,));
205 $selected_base_url .=
'&'.$_combo_box_name.
'[]='.implode(
'&'.$_combo_box_name.
'[]=', $selected_types);
210 if (empty($all_logs) || !$invalid_dates) {
212 if (!( empty($type_options) && empty($selected_base_url) )) {
213 echo
'<b>'.translate(
'no_logged_messages', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).
'</b>';
215 echo
'<b>'.translate(
'no_logged_messages_found', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).
'</b>';
220 $lm = $GLOBALS[
'SQ_SYSTEM']->lm;
222 <table
class=
"sq-backend-table">
224 <td
class=
"sq-backend-table-header" nowrap width=
"120"><?php echo translate(
'log_time'); ?></td>
225 <td
class=
"sq-backend-table-header" nowrap width=
"120"><?php echo translate(
'logged_by'); ?></td>
226 <td
class=
"sq-backend-table-header" width=
"100%"><?php echo translate(
'message'); ?></td>
231 $num_logs = count($all_logs);
232 $start_printing_at = 0;
233 if (isset($_REQUEST[$prefix.
'_start_at'])) {
234 $start_printing_at = (int) $_REQUEST[$prefix.
'_start_at'];
236 for ($i = $start_printing_at; $i < $num_logs; $i++) {
237 $log_data = $all_logs[$i];
241 <td
class=
"sq-backend-table-cell" nowrap><?php echo ts_iso8601($log_data[
'sent']); ?></td>
242 <td
class=
"sq-backend-table-cell" nowrap><?php echo $log_data[
'from_name']; ?></td>
243 <td
class=
"sq-backend-table-cell" width=
"100%"><b><?php echo $log_data[
'subject']; ?></b><br/><?php echo nl2br(htmlentities($log_data[
'body'])); ?></td>
247 if ($num_printed >= $num_per_page)
break;
251 <td colspan=
"3" align=
"center" class=
"sq-backend-table-header">
254 if ($start_printing_at > 0) {
257 <?php $next_url = $selected_base_url.
'&'.$prefix.
'_start_at='.($start_printing_at - $num_per_page); ?>
258 <a style=
"text-decoration: none;" href=
"<?php echo (htmlspecialchars($next_url)); ?>">
262 ?><span style=
"color: #84848F"><?php
265 << <?php echo translate(
'previous_page');
267 if ($start_printing_at > 0) {
273 <b><?php echo translate(
'page_number', (floor($start_printing_at / $num_per_page) + 1), ceil($num_logs / $num_per_page)); ?></b>
276 if (($start_printing_at + $num_per_page) < $num_logs) {
279 <?php $next_url = $selected_base_url.
'&'.$prefix.
'_start_at='.($start_printing_at + $num_per_page); ?>
280 <a style=
"text-decoration: none;" href=
"<?php echo (htmlspecialchars($next_url)); ?>">
284 ?><span style=
"color: #84848F"><?php
287 echo translate(
'next_page'); ?> >>
289 if (($start_printing_at + $num_per_page) < $num_logs) {
320 function processLogs(&$owner, &$o, &$ei)