4 require_once 'Pman.php';
6 class Pman_Admin_EventView extends Pman
12 $au = $this->getAuthUser();
13 if (!$au || $au->company()->comptype != 'OWNER') {
21 function get($id, $opts = Array())
23 $ev = DB_DataObject::Factory('Events');
24 if (!$ev->get((int)$id)) {
25 $this->jerr("invalid id");
28 // verify if not admin, then they should
29 $g = DB_DataObject::Factory('core_group_member');
30 if (is_a($g, 'DB_DataObject')) {
31 $grps = $g->listGroupMembership($this->authUser);
33 $isAdmin = $g->inAdmin;
35 if (!$isAdmin && $ev->person_id != $this->authUser->id) {
41 echo '<PRE>'.htmlspecialchars(print_r($ev->toArray(),true))."</PRE>";
42 // we have 2 bits of data available at present:
45 $d= DB_DataObject::factory('core_event_audit');
46 if (is_a($d,'DB_DataObject')) {
47 echo "<H2>Changed Data:</H2>";
48 $d->event_id = $ev->id;
49 foreach($d->fetchAll() as $d) {
50 echo "{$d->name} SET TO: " . htmlspecialchars($d->newvalue) . "<br/>\n";
53 echo "<HR><H2>Posted Data:</H2>";
55 $logdir = DB_DAtaObject::Factory('Events')->logDir();
58 echo "not available (Pman[storedir] not configured)";
62 $file = $logdir. date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".php";
63 if (file_exists($file)) {
64 echo '<PRE>' . htmlspecialchars(file_get_contents($file)). '</PRE>';
68 $file = $logdir. date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".json";
69 if (!file_exists($file)) {
70 echo "not available (missing file) $file";
73 echo '<PRE>' . htmlspecialchars(print_r(json_decode(file_get_contents($file)), true)) . '</PRE>';
75 if (!empty($ev->remarks)) {
76 echo "<HR><H2>Remarks:</H2>";
78 echo '<BR/><PRE>'. htmlspecialchars($ev->remarks) . '</PRE>';
80 $json = json_decode($ev->remarks, JSON_PRETTY_PRINT);
82 if(json_last_error() == JSON_ERROR_NONE){
83 echo "<HR><H2>JSON DECODE Data:</H2>";
84 echo '<PRE>' . print_r($json, true) . '</PRE>';
87 if (!empty($filesJ->FILES )) {
88 $filesJ = json_decode(file_get_contents($file));
89 echo '<br /><PRE>Download files</PRE>';
92 foreach($filesJ->FILES as $k=>$f){
93 $ip = $this->baseURL."/Images/events/". $ev->id . '/'. $f->tmp_name;
94 echo '<a target="_new" href="'.$ip.'/download">' . htmlspecialchars( $k . ' - ' . $f->name ) . '</a><br/>';