DataObjects/Core_person_signup.php
[Pman.Core] / DataObjects / Core_person_signup.php
index 6a2add2..cb996cd 100644 (file)
@@ -27,6 +27,9 @@ class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject
     
     public $person_id;
     public $person_table;
+    
+    public $invite_id;
+    public $friend_table;
  
     function convertTo($target = false)
     {
@@ -35,10 +38,14 @@ class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject
         }
         
         $roo = HTML_FlexyFramework::get()->page;
-        
+        $old = clone($this);
         // this shold not really happen...
         if($target->get('email', $this->email)){
             
+            $this->person_id = $target->id;
+            $this->person_table = $target->tableName();
+            $this->update($old);
+            
             return $target;
         }
         
@@ -48,10 +55,17 @@ class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject
         
         $this->person_id = $target->id;
         $this->person_table = $target->tableName();
-        $this->update();
-        // ok - deleting might not be a great idea.... - as we can not track already confirmed codes..
+        $this->update($old);
         
-        //$this->delete();
+        if(!empty($this->invite_id) && !empty($this->friend_table)){
+            $friend = DB_DataObject::factory($this->friend_table);
+            $friend->setFrom(array(
+                'person_id' => $this->invite_id,
+                'friend_id' => $target->id
+            ));
+            
+            $friend->insert();
+        }
         
         return $target;
     }