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 //    function verify($key) 
29 //    {
30 //        // if key matches verify_key
31 //        // copy into person or other entity...
32 //        // and delete....
33 //        if ($this->get("verify_key", $key)) {
34 //            $p = DB_DataObject::factory('person');
35 //            $p->setFrom(array(
36 //                'honor' => $this->honor,
37 //                'name' => $this->name,
38 //                'email' => $this->email,
39 //                'firstname' => $this->firstname,
40 //                'lastname' => $this->lastname,
41 //                'firstname_alt' => $this->firstname_alt,
42 //                'lastname_alt' => $this->lastname_alt));
43 //
44 //            if ($p->insert()) {
45 //
46 //                $temp_pwd = $p->generatePassword();
47 //
48 //                $this->delete();
49 //
50 //                //login
51 //                @session_start();
52 //
53 //                $_SESSION['Hydra']['authUser'] = $p ? serialize($p) : false;
54 //
55 //                //mail pwd
56 //                $c = DB_DataObject::factory('core_email');
57 //                if (!$c->get('name', 'CORE_PERSON_SIGNUP_CONGRATULATION')) {
58 //                    $this->jerr("can not find template");
59 //                }
60 //                $ret = $c->send(array(
61 //                    'rcpts' => $this->email,
62 //                    'honor' => $this->honor . ". " . $this->lastname,
63 //                    'password' => $temp_pwd
64 //                        ), true);
65 //
66 //                if (is_object($ret)) {
67 //                    return false;
68 //                }
69 //                return true;
70 //            } else {
71 //                return false;
72 //            }
73 //        }
74 //        return false;
75 //    }
76 //
77 //    function convertTo($table) 
78 //    {
79 //        $t = DB_DataObject::factory($table);
80 //        $ret = $t->get('email', $this->email);
81 //        if ($ret != 0) {
82 //            return false;
83 //        } else {
84 //            $t->setFrom(array(
85 //                'honor' => $this->honor,
86 //                'name' => $this->name,
87 //                'email' => $this->email,
88 //                'firstname' => $this->firstname,
89 //                'lastname' => $this->lastname,
90 //                'firstname_alt' => $this->firstname_alt,
91 //                'lastname_alt' => $this->lastname_alt));
92 //
93 //            $t->insert();
94 //            return true;
95 //        }
96 //    }
97
98     function convertTo($target = false)
99     {
100         if(!$target){
101             return false;
102         }
103         
104         $roo = HTML_FlexyFramework::get()->page;
105         
106         if($target->get('email', $this->email)){
107             return $target;
108         }
109         
110         $target->setFrom($this->toArray());
111         
112         $target->insert();
113         
114         $this->delete();
115         
116         return $target;
117     }
118     
119     function sendVerification($template, $roo)
120     {
121         
122         $content = array(
123             'template'      => $template,
124             'person'        => $this,
125             'serverName'    => $_SERVER['SERVER_NAME'],
126             'baseURL'       => $roo->baseURL
127         );
128
129         $sent = DB_DataObject::factory('core_email')->send($content);
130         print_R($sent);exit;
131         if(!is_object($sent)){
132             return true;
133         }
134         
135         return false;
136     }
137     
138     function getEmailFrom()
139     {
140         if (empty($this->name)) {
141             return $this->email;
142         }
143         return '"' . addslashes($this->name) . '" <' . $this->email . '>';
144     }
145 }
146