function templateAssignEntryChanges($var, $entry, $rev_num, $remove_invoice = false) { global ${$var}; $rev_num = (int) $rev_num; if (count($entry) && $rev_num > 0) { $Q_rev = mysql_query("select * from `entry_log` where `entry_id` = '" . $entry['entry_id'] . "' and `rev_num` = '" . $rev_num . "' limit 1"); if (!mysql_num_rows($Q_rev)) { // Assigning all the var with zero value ${$var}->assign('log_time', 0); ${$var}->assign('log_action_real', ''); ${$var}->assign('log_user_id', 0); ${$var}->assign('log_user', ''); ${$var}->assign('log_changes', array()); } else { $thislog = mysql_fetch_assoc($Q_rev); $thislog['log_data'] = unserialize($thislog['log_data']); ${$var}->assign('log_time', $thislog['log_time']); ${$var}->assign('log_action_real', printEntryLog($thislog, false, true)); ${$var}->assign('log_user_id', $thislog['user_id']); $user = getUser($thislog['user_id']); if (count($user)) { ${$var}->assign('log_user', $user['user_name']); } else { ${$var}->assign('log_user', 'ERROR'); } $changes = array(); if ($remove_invoice) { foreach ($thislog['log_data'] as $var2 => $value) { if (substr($var2, 0, 7) == 'invoice') { unset($thislog['log_data'][$var2]); } } } foreach (readEntryLog($thislog) as $change) { $changes[] = strip_tags($change); } ${$var}->assign('log_changes', $changes); } } else { ${$var}->assign('log_time', 0); ${$var}->assign('log_action_real', ''); ${$var}->assign('log_user_id', 0); ${$var}->assign('log_user', ''); ${$var}->assign('log_changes', array()); } }
function printEntryLog($log, $printData = FALSE, $to_return = FALSE) { // Prints out, in text, what the log contains for this element $return = ""; if ($printData) { $changes = readEntryLog($log); foreach ($changes as $change) { $return .= '<li>' . $change . '</li>' . chr(10); } } else { if ($log['log_action'] == 'add') { $return .= _('New entry.'); } elseif ($log['log_action'] == 'edit') { $emails = false; switch ($log['log_action2']) { case 'invoice_readyfor': $return .= 'Booking klar til fakturering'; break; case 'invoice_made': $return .= 'Faktura ble opprettet'; break; case 'invoice_sent': // Not in use? $return .= _('Invoice is registered as sent.'); break; case 'invoice_payed': $return .= 'Betaling er register på faktura'; break; case 'confirm': case 'comfirm': $return .= _('Confirmation was sent.'); break; case 'confirm_email': case 'comfirm_email': $return .= _('Confirmation email is sent to'); $emails = true; break; case 'ical_sent': $return .= _('Icalendar element is sent to'); $emails = true; break; case '': $return .= _('Entry was edited.'); break; default: break; } if ($emails) { // Printing emails if (isset($log['log_data']['emails'])) { if (is_array($log['log_data']['emails'])) { $return .= ' '; foreach ($log['log_data']['emails'] as $email) { $return .= $email; if ($i < count($log['log_data']['emails'])) { $return .= ', '; } } $return .= '.'; } else { $return .= ' ' . $log['log_data']['emails'] . '.'; } } } } } if ($to_return) { return $return; } else { echo $return; } }