EventView.php
[Pman.Admin] / EventView.php
1 <?php
2
3
4 require_once 'Pman.php';
5
6 class Pman_Admin_EventView extends Pman
7 {
8     
9     function getAuth()
10     {
11         parent::getAuth();
12         $au = $this->getAuthUser();
13         if (!$au || $au->company()->comptype != 'OWNER') {
14             $this->jerrAuth();
15         }
16         return true;
17         
18         
19     }
20     
21     function get($id)
22     {
23         $ev = DB_DataObject::Factory('Events');
24         if (!$ev->get((int)$id)) {
25             $this->jerr("invalid id");
26         }
27         
28         // verify if not admin, then they should 
29         $g = DB_DataObject::Factory('Group_Members');
30         $grps = $g->listGroupMembership($this->authUser);
31        //var_dump($grps);
32         $isAdmin = $g->inAdmin;
33         
34         if (!$isAdmin && $ev->person_id != $this->authUser->id) {
35             $this->jerrAuth();
36         }
37         
38         // we have 2 bits of data available at present:
39         // core_event_audit
40         // the event file..
41         $d= DB_DataObject::factory('core_event_audit');
42         if (is_a($d,'DB_DataObject')) {
43             echo "<H2>Changed Data:</H2>";
44             $d->event_id = $ev->id;
45             foreach($d->fetchAll() as $d) {
46                 echo "{$d->name} SET TO: " . htmlspecialchars($d->newvalue) . "<br/>\n";
47             }
48         }
49         $fn =  date('/Y/m/d/'). $ev->id . ".php";strtotime($ev->event_when);
50         
51         $eid = $e->insert();
52         
53         $wa = DB_DataObject::factory('core_watch');
54         $wa->notifyEvent($e); // trigger any actions..
55         
56         
57         $ff  = HTML_FlexyFramework::get();
58         if (empty($ff->Pman['event_log_dir'])) {
59             return $e;
60         }
61         $file = $ff->Pman['event_log_dir']. date('/Y/m/d/'). $eid . ".php";
62         if (!file_exists(dirname($file))) {
63             mkdir(dirname($file),0700,true);
64         }
65         file_put_contents($file, var_export(array(
66             'REQUEST_URI' => empty($_SERVER['REQUEST_URI']) ? 'cli' : $_SERVER['REQUEST_URI'],
67             'GET' => empty($_GET) ? array() : $_GET,
68             'POST' => empty($_POST) ? array() : $_POST,
69         ), true));
70          
71         
72         if (file_exists())
73         
74         
75     }
76     
77     
78 }