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 checkDebugPost()
73 return (!empty($_GET['_post']) || !empty($_GET['_debug_post'])) &&
75 method_exists($this->authUser,'groups') &&
76 in_array('Administrators', $this->authUser->groups('name'));
80 function dataObject($tab)
82 if (is_array($this->validTables) && !in_array($tab, $this->validTables)) {
83 $this->jerr("Invalid url - not listed in validTables");
86 $tab = str_replace('/', '',$tab); // basic protection??
88 $x = DB_DataObject::factory($tab);
90 if (!is_a($x, 'DB_DataObject')) {
91 $this->jerr('invalid url - no dataobject');
101 static $permitError = false;
103 function onPearError($err)
105 static $reported = false;
110 if (Pman::$permitError) {
117 $out = $err->toString();
122 foreach($err->backtrace as $b) {
123 $ret[] = @$b['file'] . '(' . @$b['line'] . ')@' . @$b['class'] . '::' . @$b['function'];
129 //convert the huge backtrace into something that is readable..
130 $out .= "\n" . implode("\n", $ret);
138 function addEvent($act, $obj = false, $remarks = '')
140 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
144 $au = $this->getAuthUser();
146 $e = DB_DataObject::factory('Events');
147 $e->init($act,$obj,$remarks);
149 $e->event_when = date('Y-m-d H:i:s');
153 // fixme - this should be in onInsert..
154 $wa = DB_DataObject::factory('core_watch');
155 if (method_exists($wa,'notifyEvent')) {
156 $wa->notifyEvent($e); // trigger any actions..
159 $e->onInsert(isset($_REQUEST) ? $_REQUEST : array() , $this);
165 function getAuthUser()
167 if (!empty($this->authUser)) {
168 return $this->authUser;
170 $ff = HTML_FlexyFramework::get();
171 $tbl = empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable'];
173 $u = DB_DataObject::factory( $tbl );
177 $this->authUser =$u->getAuthUser();
178 return $this->authUser ;