RooTrait.php
[Pman.Core] / RooTrait.php
1 <?php
2
3 trait Pman_Core_RooTrait {
4     
5     function init() 
6     {
7         if (isset($this->_hasInit)) {
8             return;
9         }
10         
11         $this->_hasInit = true;
12         
13         $boot = HTML_FlexyFramework::get();
14         
15         $this->appName= $boot->appName;
16         $this->appNameShort= $boot->appNameShort;
17         $this->appModules= $boot->enable;
18         $this->isDev = empty($boot->Pman['isDev']) ? false : $boot->Pman['isDev'];
19         $this->appDisable = $boot->disable;
20         $this->appDisabled = explode(',', $boot->disable);
21         $this->version = $boot->version; 
22         $this->uiConfig = empty($boot->Pman['uiConfig']) ? false : $boot->Pman['uiConfig']; 
23         
24         if (!empty($ff->Pman['local_autoauth']) && 
25             ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
26             ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') 
27         ) {
28             $this->isDev = true;
29         }
30         
31     }
32     
33     function checkDebug($req = false)
34     {
35         $req =  $req === false  ? $_REQUEST : $req;
36         if (isset($req['_debug']) 
37                 && 
38                 $this->authUser
39                 &&
40                 (
41                     (
42                         method_exists($this->authUser,'canDebug')
43                         &&
44                         $this->authUser->canDebug()
45                     )
46                 ||
47                     (  
48                     
49                         method_exists($this->authUser,'groups') 
50                         &&
51                         is_a($this->authUser, 'Pman_Core_DataObjects_Person')
52                         &&
53                         in_array('Administrators', $this->authUser->groups('name'))
54                     )
55                 )
56                 
57             ){
58             DB_DAtaObject::debuglevel((int)$req['_debug']);
59         }
60         
61     }
62     
63     function checkDebugPost()
64     {
65         return (!empty($_GET['_post']) || !empty($_GET['_debug_post'])) && 
66                     $this->authUser && 
67                     method_exists($this->authUser,'groups') &&
68                     in_array('Administrators', $this->authUser->groups('name')); 
69         
70     }
71 }