DataObjects/Core_person_signup.php
[Pman.Core] / DataObjects / Core_person_signup.php
1 <?php
2
3 /**
4  * Table Definition for Person
5  */
6 require_once 'DB/DataObject.php';
7
8 class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject 
9 {
10     ###START_AUTOCODE
11     /* the code below is auto generated do not remove the above tag */
12
13     public $__table = 'core_person_signup';                          // table name
14     public $id;                              // int(11)  not_null primary_key auto_increment
15     public $email;                           // string(128)  not_null
16     public $name;                            // string(128)  not_null
17     public $firstname;                            // string(128)  not_null
18     public $lastname;                            // string(128)  not_null
19     public $firstname_alt;                            // string(128)  not_null
20     public $lastname_alt;                            // string(128)  not_null
21     public $honor;                            // string(128)  not_null
22     public $verify_key;                      // int(11)
23     public $verified;
24     public $created_dt;                      // datetime(19)  binary
25     public $company_name;
26     public $person_type;
27     
28     public $person_id;
29     public $person_table;
30  
31     function convertTo($target = false)
32     {
33         if(!$target){
34             return false;
35         }
36         
37         $roo = HTML_FlexyFramework::get()->page;
38         
39         // this shold not really happen...
40         if($target->get('email', $this->email)){
41             
42             return $target;
43         }
44         
45         $target->setFrom($this->toArray());
46         
47         $target->insert();
48         
49         $this->person_id = $target->id;
50         $this->person_table = $target->tableName();
51         $this->update();
52         // ok - deleting might not be a great idea.... - as we can not track already confirmed codes..
53         
54         //$this->delete();
55         
56         return $target;
57     }
58     
59     function sendVerification($template, $roo)
60     {
61         
62         $content = array(
63             'template'      => $template,
64             'person'        => $this,
65             'serverName'    => $_SERVER['SERVER_NAME'],
66             'baseURL'       => $roo->baseURL
67         );
68
69         $sent = DB_DataObject::factory('core_email')->send($content);
70         
71         if(!is_object($sent)){
72             return true;
73         }
74         
75         return $sent;
76     }
77     
78     function getEmailFrom()
79     {
80         if (empty($this->name)) {
81             return $this->email;
82         }
83         return '"' . addslashes($this->name) . '" <' . $this->email . '>';
84     }
85 }
86