DataObjects/Core_enum.php
[Pman.Core] / DataObjects / Person.php
index b994b41..3df425f 100644 (file)
@@ -243,7 +243,7 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             
             return false;
             
-            $ff->page->jerr("Login not permited to outside companies");
+            //$ff->page->jerr("Login not permited to outside companies");
         }
         return true;
         
@@ -268,12 +268,14 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             $u = DB_DataObject::factory($this->tableName());
             if ($a->id && $u->get($a->id)) { //&& strlen($u->passwd)) {
               
-                return $u->verifyAuth();
+                return $u->verifyAuth();  // got authentication...
                 
     
             }
             
             unset($_SESSION[get_class($this)][$sesPrefix .'-auth']);
+            unset($_SESSION[get_class($this)][$sesPrefix .'-timeout']);
+            setcookie('Pman.timeout', -1, time() + (30*60), '/');
             
         }
         if (!$this->canInitializeSystem()) {
@@ -377,18 +379,22 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         if (!empty($_SESSION[get_class($this)][$sesPrefix .'-auth'])) {
             $a = unserialize($_SESSION[get_class($this)][$sesPrefix .'-auth']);
             
-            print_R($a);exit;
             $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..
+                
+                $_SESSION[get_class($this)][$sesPrefix .'-auth-timeout'] = time() + (30*60); // eg. 30 minutes
+                setcookie('Pman.timeout', time() + (30*60), time() + (30*60), '/');
+                
                 $user = clone ($u);
                 
-                if(!empty($a->_extra)){
-                    $user->_extra = $a->_extra;
-                }
-                return clone($u);
+                return clone($user);
+            
             }
             unset($_SESSION[get_class($this)][$sesPrefix .'-auth']);
+            unset($_SESSION[get_class($this)][$sesPrefix .'-timeout']);
+            setcookie('Pman.timeout', -1, time() + (30*60), '/');
+            
         }
         
         
@@ -459,9 +465,8 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         
         $d = $p->toArray();
         
-        if(!empty($this->_extra)){
-            $d['_extra'] = $this->_extra;
-        }
+        $_SESSION[get_class($this)][$sesPrefix .'-auth-timeout'] = time() + (30*60); // eg. 30 minutes
+        setcookie('Pman.timeout', time() + (30*60), time() + (30*60), '/');
         
         //var_dump(array(get_class($this),$sesPrefix .'-auth'));
         $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize((object)$d);
@@ -476,6 +481,8 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         
         $sesPrefix = $this->sesPrefix();
         
+        $_SESSION[get_class($this)][$sesPrefix .'-auth-timeout'] = -1;
+        
         $_SESSION[get_class($this)][$sesPrefix .'-auth'] = "";
         
     }    
@@ -1157,6 +1164,8 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         }
     }
     
+    // this is for the To: "{getEmailName()}" <email@address>
+    // not good for Dear XXXX, - use {person.firstname} for that.
     function getEmailName()
     {
         $name = array();
@@ -1177,7 +1186,7 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             
             $name = array_filter($name);
             
-            return $name;
+            return implode(' ', $name);
         }
         
         return $this->email;