RooTrait.php
[Pman.Core] / RooTrait.php
index 752a9c4..54e44aa 100644 (file)
@@ -30,19 +30,83 @@ trait Pman_Core_RooTrait {
         
     }
     
+    function checkDebug($req = false)
+    {
+        $req =  $req === false  ? $_REQUEST : $req;
+        if (isset($req['_debug']) 
+                && 
+                $this->authUser
+                &&
+                (
+                    (
+                        method_exists($this->authUser,'canDebug')
+                        &&
+                        $this->authUser->canDebug()
+                    )
+                ||
+                    (  
+                    
+                        method_exists($this->authUser,'groups') 
+                        &&
+                        is_a($this->authUser, 'Pman_Core_DataObjects_Person')
+                        &&
+                        in_array('Administrators', $this->authUser->groups('name'))
+                    )
+                )
+                
+            ){
+            DB_DAtaObject::debuglevel((int)$req['_debug']);
+        }
+        
+    }
+    
     function checkDebugPost()
     {
         return (!empty($_GET['_post']) || !empty($_GET['_debug_post'])) && 
                     $this->authUser && 
                     method_exists($this->authUser,'groups') &&
                     in_array('Administrators', $this->authUser->groups('name')); 
+        
     }
     
-    function checkDebug($req = false)
+    /*
+     * From Pman.php
+     */
+    
+    static $permitError = false;
+    
+    function onPearError($err)
     {
-        /*
-         * Not allow to doing this
-         */
-        return false;
+        static $reported = false;
+        if ($reported) {
+            return;
+        }
+        
+        if (Pman::$permitError) {
+             
+            return;
+            
+        }
+        
+        $reported = true;
+        $out = $err->toString();
+        
+        $ret = array();
+        $n = 0;
+        
+        foreach($err->backtrace as $b) {
+            $ret[] = @$b['file'] . '(' . @$b['line'] . ')@' .   @$b['class'] . '::' . @$b['function'];
+            if ($n > 20) {
+                break;
+            }
+            $n++;
+        }
+        //convert the huge backtrace into something that is readable..
+        $out .= "\n" . implode("\n",  $ret);
+     
+        print_R($out);exit;
+        
+        $this->jerr($out);
+        
     }
 }