DataObjects/I18n.php
[Pman.Core] / DataObjects / Person.php
index 167fce3..a595cf8 100644 (file)
@@ -253,6 +253,10 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     //   ---------------- authentication / passwords and keys stuff  ----------------
     function isAuth()
     {
+        
+        @session_start();
+       
+        
         $db = $this->getDatabaseConnection();
         // we combine db + project names,
         // otherwise if projects use different 'auth' objects
@@ -261,19 +265,18 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         $sesPrefix = $ff->appNameShort .'-' .get_class($this) .'-'.$db->dsn['database'] ;
         
         
-        @session_start();
          
         if (!empty($_SESSION[get_class($this)][$sesPrefix .'-auth'])) {
             // in session...
             $a = unserialize($_SESSION[get_class($this)][$sesPrefix .'-auth']);
             
-            $u = DB_DataObject::factory('Person');
+            
+            $u = DB_DataObject::factory($this->tableName());
             if ($a->id && $u->get($a->id)) { //&& strlen($u->passwd)) {
               
                 return $u->verifyAuth();
                 
-   
-                return true;
+    
             }
             
             unset($_SESSION[get_class($this)][$sesPrefix .'-auth']);
@@ -376,13 +379,15 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         $sesPrefix = $ff->appNameShort .'-' .get_class($this) .'-'.$db->dsn['database'] ;
         
         
-        
-        
+        //var_dump(array(get_class($this),$sesPrefix .'-auth'));
+       
         if (!empty($_SESSION[get_class($this)][$sesPrefix .'-auth'])) {
             $a = unserialize($_SESSION[get_class($this)][$sesPrefix .'-auth']);
             
-            $u = DB_DataObject::factory($this->getTableName()); // allow extending this ...
-            if ($u->get($a->id)) { /// && strlen($u->passwd)) {
+            
+            $u = DB_DataObject::factory($this->tableName()); // allow extending this ...
+            $u->autoJoin();
+            if ($u->get($a->id)) { /// && strlen($u->passwd)) {  // should work out the pid .. really..
                 return clone($u);
             }
             unset($_SESSION[get_class($this)][$sesPrefix .'-auth']);
@@ -428,7 +433,7 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     function login()
     {
         $this->isAuth(); // force session start..
-        if (!$this->verifyAuth()) {
+        if (!$this->verifyAuth()) { // check for company valid..
             return false;
         }
         $db = $this->getDatabaseConnection();
@@ -452,9 +457,16 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         $ff= HTML_FlexyFramework::get();
         $sesPrefix = $ff->appNameShort .'-' .get_class($this) .'-'.$db->dsn['database'] ;
 
-        @session_start();
-        var_dump(array(get_class($this),$sesPrefix .'-auth'));
-        $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize($this);
+        
+        // we should not store the whole data in the session - otherwise it get's huge.
+        $p = DB_DAtaObject::Factory($this->tableName());
+        $p->get($this->pid());
+        
+        //var_dump(array(get_class($this),$sesPrefix .'-auth'));
+        $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize((object)$p->toArray());
+        // ensure it's written so that ajax calls can fetch it..
+        
+        
         
     }
     function logout()
@@ -463,12 +475,11 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         $db = $this->getDatabaseConnection();
         $ff= HTML_FlexyFramework::get();
         $sesPrefix = $ff->appNameShort .'-' .get_class($this) .'-'.$db->dsn['database'] ;
-        @session_start();
-        $_SESSION[get_class($this)][$sesPrefix .'-auth'] = "";
-       
         
+         $_SESSION[get_class($this)][$sesPrefix .'-auth'] = "";
        
         
+        
     }    
     function genPassKey ($t) 
     {
@@ -484,11 +495,13 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     {
         
         if (substr($this->passwd,0,1) == '$') {
+            
             return crypt($val,$this->passwd) == $this->passwd ;
         }
         // old style md5 passwords...- cant be used with courier....
         return md5($val) == $this->passwd;
     }
+    
     function setPassword($value) 
     {
         $salt='';