4 require_once 'Pman.php';
6 class Pman_Admin_EventView extends Pman
12 $au = $this->getAuthUser();
13 if (!$au || $au->company()->comptype != 'OWNER') {
23 $test = json_decode('afsdfasf');
25 print_R(JSON_ERROR_NONE);exit;
27 $ev = DB_DataObject::Factory('Events');
28 if (!$ev->get((int)$id)) {
29 $this->jerr("invalid id");
32 // verify if not admin, then they should
33 $g = DB_DataObject::Factory('group_members');
34 if (is_a($g, 'DB_DataObject')) {
35 $grps = $g->listGroupMembership($this->authUser);
37 $isAdmin = $g->inAdmin;
39 if (!$isAdmin && $ev->person_id != $this->authUser->id) {
45 echo '<PRE>'.htmlspecialchars(print_r($ev->toArray(),true))."</PRE>";
46 // we have 2 bits of data available at present:
49 $d= DB_DataObject::factory('core_event_audit');
50 if (is_a($d,'DB_DataObject')) {
51 echo "<H2>Changed Data:</H2>";
52 $d->event_id = $ev->id;
53 foreach($d->fetchAll() as $d) {
54 echo "{$d->name} SET TO: " . htmlspecialchars($d->newvalue) . "<br/>\n";
57 echo "<HR><H2>Posted Data:</H2>";
59 $ff = HTML_FlexyFramework::get();
60 if (empty($ff->Pman['event_log_dir'])) {
61 echo "not available (Pman[event_log_dir] not configured)";
64 if (function_exists('posix_getpwuid')) {
65 $uinfo = posix_getpwuid( posix_getuid () );
67 $user = $uinfo['name'];
69 $user = getenv('USERNAME'); // windows.
72 $file = $ff->Pman['event_log_dir']. "/{$user}" . date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".php";
73 if (file_exists($file)) {
74 echo '<PRE>' . htmlspecialchars(file_get_contents($file)). '</PRE>';
78 $file = $ff->Pman['event_log_dir']. "/{$user}" . date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".json";
79 if (!file_exists($file)) {
80 echo "not available (missing file) $file";
83 echo '<PRE>' . htmlspecialchars(print_r(json_decode(file_get_contents($file)), true)) . '</PRE>';
85 echo '<BR/><PRE>'. htmlspecialchars($ev->remarks) . '</PRE>';
87 $filesJ = json_decode(file_get_contents($file));
88 echo '<br /><PRE>Download files</PRE>';
91 foreach($filesJ->FILES as $k=>$f){
92 $ip = $ff->baseURL."/Images/events/". $ev->id . '/'. $f->tmp_name;
93 echo '<a href="'.$ip.'/download">' . htmlspecialchars( $k . ' - ' . $f->name ) . '</a><br/>';