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         
52         $res = parent::checkPerm($obj,$lvl,$req);
53         if ($res) {
54             return $res;
55         }
56         
57         
58         if ($this->authUser && $this->authUser->company()->comptype == 'OWNER') {
59             return true;
60         }
61         // these checks only apply to non-company users.
62         
63         // normally allowed, but we have more restrictions...
64         switch($obj->tablename()) {
65             case 'core_enum':
66                 if (empty($req['etype'])) {
67                     return false;
68                 }
69                 if ($lvl != 'S') {
70                     return false;
71                 }
72                 
73                 switch ($req['etype']) {
74                    // case 'severity':
75                     case 'classification':
76                     case 'severity':
77                     case 'resolution':
78                     case 'priority':
79                     case 'ticketstate':                    
80                      
81                     
82                     // not a member of the company..
83                     // not allowed in..
84                     return true;
85                 }
86                 return false;
87             
88             default:
89                 return false;
90                 
91             
92             
93         }
94         
95         
96         
97     }
98 }