3 trait Pman_Core_RooTrait {
5 var $validTables = false;
11 var $debugEnabled = true;
15 if (isset($this->_hasInit)) {
19 $this->_hasInit = true;
21 $boot = HTML_FlexyFramework::get();
23 $this->appName= $boot->appName;
24 $this->appNameShort= $boot->appNameShort;
25 $this->appModules= $boot->enable;
26 $this->isDev = empty($boot->Pman['isDev']) ? false : $boot->Pman['isDev'];
27 $this->appDisable = $boot->disable;
28 $this->appDisabled = explode(',', $boot->disable);
29 $this->version = $boot->version;
30 $this->uiConfig = empty($boot->Pman['uiConfig']) ? false : $boot->Pman['uiConfig'];
32 if (!empty($ff->Pman['local_autoauth']) &&
33 ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
34 ($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
41 function checkDebug($req = false)
43 $req = $req === false ? $_REQUEST : $req;
44 if (isset($req['_debug'])
50 method_exists($this->authUser,'canDebug')
52 $this->authUser->canDebug()
57 method_exists($this->authUser,'groups')
59 is_a($this->authUser, 'Pman_Core_DataObjects_Person')
61 in_array('Administrators', $this->authUser->groups('name'))
66 DB_DAtaObject::debuglevel((int)$req['_debug']);
71 function dataObject($tab)
73 if (is_array($this->validTables) && !in_array($tab, $this->validTables)) {
74 $this->jerr("Invalid url - not listed in validTables");
77 $tab = str_replace('/', '',$tab); // basic protection??
79 $x = DB_DataObject::factory($tab);
81 if (!is_a($x, 'DB_DataObject')) {
82 $this->jerr('invalid url - no dataobject');
93 static $permitError = false;
95 function onPearError($err)
97 static $reported = false;
102 if (Pman::$permitError) {
109 $out = $err->toString();
114 foreach($err->backtrace as $b) {
115 $ret[] = @$b['file'] . '(' . @$b['line'] . ')@' . @$b['class'] . '::' . @$b['function'];
121 //convert the huge backtrace into something that is readable..
122 $out .= "\n" . implode("\n", $ret);
130 function addEvent($act, $obj = false, $remarks = '')
132 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
136 $au = $this->getAuthUser();
138 $e = DB_DataObject::factory('Events');
139 $e->init($act,$obj,$remarks);
141 $e->event_when = date('Y-m-d H:i:s');
145 // fixme - this should be in onInsert..
146 $wa = DB_DataObject::factory('core_watch');
147 if (method_exists($wa,'notifyEvent')) {
148 $wa->notifyEvent($e); // trigger any actions..
151 $e->onInsert(isset($_REQUEST) ? $_REQUEST : array() , $this);
157 function checkPerm($obj, $lvl, $req= null)
159 if (!method_exists($obj, 'checkPerm')) {
162 if ($obj->checkPerm($lvl, $this->getAuthUser(), $req)) {
168 function getAuthUser()
170 die('Get auth user is not implement.');