MTrackWeb/Roo.php
[web.mtrack] / MTrackWeb / Roo.php
1 <?php
2
3
4 require_once 'Pman/Roo.php';
5
6
7 /**
8  * This extends the standard Roo API
9  *
10  * however it has to verify that we send data protected, as it's pretty open!!!
11  *
12  * 
13  *
14  */
15
16 class MTrackWeb_Roo extends Pman_Roo
17 {
18     var $validTables = array(
19         'mtrack_ticket', /// all of these MUST have applyFilters, and check authenication..
20         'Mtrack_ticket', /// all of these MUST have applyFilters, and check authenication..
21         'mtrack_change',
22         'core_enum',
23         'Person',
24         'mtrack_milestone',
25         'Projects',
26         'Images',
27         'mtrack_repos'
28         
29     );
30     
31     function getAuth() {
32         Pman::getAuth(); // load company!
33         $au = $this->getAuthUser();
34         $this->authUser =  false;
35         if ($au) {
36            $this->authUser = $au;
37         }
38         
39         return true;
40     }
41     
42     function delete()
43     {
44         $this->jerr("Delete not permitted yet...");
45         // only post requests..???
46         // need perms sorting out first.
47     }
48     
49     function checkPerm($obj, $lvl, $req=null)
50     {
51         if ($this->authUser) {
52             $res = parent::checkPerm($obj,$lvl,$req);
53             
54             if ($res) {
55                 return $res;
56             }
57         }
58         
59         if ($this->authUser && $this->authUser->company()->comptype == 'OWNER') {
60             return true;
61         }
62         // these checks only apply to non-company users.
63         
64         // normally allowed, but we have more restrictions...
65         switch($obj->tablename()) {
66             case 'core_enum':
67                 if (empty($req['etype'])) {
68                     return false;
69                 }
70                 if ($lvl != 'S') {
71                     return false;
72                 }
73                 
74                 switch ($req['etype']) {
75                    // case 'severity':
76                     case 'classification':
77                     case 'severity':
78                     case 'resolution':
79                     case 'priority':
80                     case 'ticketstate':                    
81                      
82                     
83                     // not a member of the company..
84                     // not allowed in..
85                     return true;
86                 }
87                 return false;
88             
89             default:
90                 return false;
91                 
92             
93             
94         }
95         
96         
97         
98     }
99 }