DataObjects/Core_event_audit.php
[Pman.Core] / DataObjects / Person.php
index 51842d3..08f805f 100644 (file)
@@ -116,6 +116,16 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     {
         return empty($this->name) ? $this->email : $this->name;
     } 
+    function verifyAuth()
+    { 
+        $ff= HTML_FlexyFramework::get();
+        if (!empty($ff->Pman['auth_comptype']) && $ff->Pman['auth_comptype'] != $this->company()->comptype) {
+            $ff->page->jerr("Login not permited to outside companies");
+        }
+        return true;
+        
+    }    
+   
    
     //   ---------------- authentication / passwords and keys stuff  ----------------
     function isAuth()
@@ -128,8 +138,11 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             $a = unserialize($_SESSION[__CLASS__][$sesPrefix .'-auth']);
             $u = DB_DataObject::factory('Person');
             if ($u->get($a->id)) { //&& strlen($u->passwd)) {
+                $u->verifyAuth();
+                
                 return true;
             }
+            
             $_SESSION[__CLASS__][$sesPrefix .'-auth'] = '';
             
         }
@@ -194,6 +207,7 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     function login()
     {
         $this->isAuth(); // force session start..
+        $this->verifyAuth();
          $db = $this->getDatabaseConnection();
         $sesPrefix = $db->dsn['database'];
         $_SESSION[__CLASS__][$sesPrefix .'-auth'] = serialize($this);
@@ -272,6 +286,9 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         
         $aur = $this->toArray();
         
+        if ($this->id < 1) {
+            return $aur;
+        }
         
         
         //DB_DataObject::debugLevel(1);
@@ -321,10 +338,14 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     {
          //DB_DataObject::debugLevel(1);
         // find out all the groups they are a member of.. + Default..
+        
+        // ------ INIITIALIZE IF NO GROUPS ARE SET UP.
+        
         $g = DB_DataObject::Factory('Group_Rights');
         if (!$g->count()) {
             $g->genDefault();
         }
+        
         if ($this->id < 0) {
             return $g->adminRights(); // system is not set up - so they get full rights.
         }
@@ -342,8 +363,11 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             
         }
         
+        // ------ STANDARD PERMISSION HANDLING.
+        
         $g = DB_DataObject::Factory('Group_Members');
         $grps = $g->listGroupMembership($this);
+       // print_r($grps);
         $isAdmin = $g->inAdmin;
         //echo '<PRE>'; print_r($grps);var_dump($isAdmin);
         // the load all the perms for those groups, and add them all together..