X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FCore_person_signup.php;h=a59f67d09c430106d492c9741c341a68911d7ed2;hp=c95f53482ae8c79f3a1e32f6513be30fcac33a4c;hb=HEAD;hpb=902bfe026ff82738cd80ec399dd2514bfc3681f8 diff --git a/DataObjects/Core_person_signup.php b/DataObjects/Core_person_signup.php index c95f5348..a59f67d0 100644 --- a/DataObjects/Core_person_signup.php +++ b/DataObjects/Core_person_signup.php @@ -3,7 +3,7 @@ /** * Table Definition for Person */ -require_once 'DB/DataObject.php'; +class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php'; class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject { @@ -22,80 +22,66 @@ class Pman_Core_DataObjects_Core_person_signup extends DB_DataObject public $verify_key; // int(11) public $verified; public $created_dt; // datetime(19) binary - -// function verify($key) -// { -// // if key matches verify_key -// // copy into person or other entity... -// // and delete.... -// if ($this->get("verify_key", $key)) { -// $p = DB_DataObject::factory('person'); -// $p->setFrom(array( -// 'honor' => $this->honor, -// 'name' => $this->name, -// 'email' => $this->email, -// 'firstname' => $this->firstname, -// 'lastname' => $this->lastname, -// 'firstname_alt' => $this->firstname_alt, -// 'lastname_alt' => $this->lastname_alt)); -// -// if ($p->insert()) { -// -// $temp_pwd = $p->generatePassword(); -// -// $this->delete(); -// -// //login -// @session_start(); -// -// $_SESSION['Hydra']['authUser'] = $p ? serialize($p) : false; -// -// //mail pwd -// $c = DB_DataObject::factory('core_email'); -// if (!$c->get('name', 'CORE_PERSON_SIGNUP_CONGRATULATION')) { -// $this->jerr("can not find template"); -// } -// $ret = $c->send(array( -// 'rcpts' => $this->email, -// 'honor' => $this->honor . ". " . $this->lastname, -// 'password' => $temp_pwd -// ), true); -// -// if (is_object($ret)) { -// return false; -// } -// return true; -// } else { -// return false; -// } -// } -// return false; -// } -// -// function convertTo($table) -// { -// $t = DB_DataObject::factory($table); -// $ret = $t->get('email', $this->email); -// if ($ret != 0) { -// return false; -// } else { -// $t->setFrom(array( -// 'honor' => $this->honor, -// 'name' => $this->name, -// 'email' => $this->email, -// 'firstname' => $this->firstname, -// 'lastname' => $this->lastname, -// 'firstname_alt' => $this->firstname_alt, -// 'lastname_alt' => $this->lastname_alt)); -// -// $t->insert(); -// return true; -// } -// } - - function sendVerification() + public $company_name; + public $person_type; + + public $person_id; + public $person_table; + + public $inviter_id; + + function convertTo($target = false) + { + if(!$target){ + return false; + } + + $roo = HTML_FlexyFramework::get()->page; + $old = clone($this); + // this shold not really happen... + if($target->get('email', $this->email)){ + return false; + } + + $target->setFrom($this->toArray()); + + $target->insert(); + + $this->person_id = $target->id; + $this->person_table = $target->tableName(); + $this->update($old); + + if(!empty($this->inviter_id) && method_exists($target, 'createFriend')){ + $target->createFriend($this->inviter_id); + } + + return $target; + } + + 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 $sent; + } + + function getEmailFrom() + { + if (empty($this->name)) { + return $this->email; + } + return '"' . addslashes($this->name) . '" <' . $this->email . '>'; } }