DataObjects/Core_person_signup.php
[Pman.Core] / DataObjects / Core_person_signup.php
index 5e09678..819bac3 100644 (file)
@@ -22,6 +22,8 @@ class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject
     public $verify_key;                      // int(11)
     public $verified;
     public $created_dt;                      // datetime(19)  binary
+    public $company_name;
+    public $person_type;
 
 //    function verify($key) 
 //    {
@@ -93,9 +95,49 @@ class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject
 //        }
 //    }
 
-    function sendVerification($roo)
+    function verified()
     {
+        $hydra_person = DB_DataObject::factory('hydra_person');
         
+        if($hydra_person->get('email', $this->email)){
+            return $hydra_person;
+        }
+        
+        $hydra_person->setFrom($this->toArray());
+        $hydra_person->employer_name = $this->company_name;
+        
+        $hydra_person->insert();
+        
+        $this->delete();
+        
+        return $hydra_person;
+    }
+    
+    function sendVerification($template, $roo)
+    {
+        
+        $content = array(
+            'template'      => $template,
+            'person'        => $this,
+            'serverName'    => $_SERVER['SERVER_NAME'],
+            'baseURL'       => $roo->baseURL
+        );
+
+        $sent = DB_DataObject::factory('core_email')->send($content);
+        
+        if(!is_object($sent)){
+            return true;
+        }
+        
+        return false;
+    }
+    
+    function getEmailFrom()
+    {
+        if (empty($this->name)) {
+            return $this->email;
+        }
+        return '"' . addslashes($this->name) . '" <' . $this->email . '>';
     }
 }