X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FCore_person_signup.php;h=a59f67d09c430106d492c9741c341a68911d7ed2;hp=cc3829a133271242cade773e7712f9782032de2a;hb=HEAD;hpb=334d02c2f17634d38771be3e3d313ee9948d5b83 diff --git a/DataObjects/Core_person_signup.php b/DataObjects/Core_person_signup.php index cc3829a1..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) + public $company_name; + public $person_type; + + public $person_id; + public $person_table; + + public $inviter_id; + + function convertTo($target = false) { - // 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; - } + if(!$target){ + return false; } - 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 convertTo($table) + + function sendVerification($template, $roo) { - $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(); + $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 sendMail() + + function getEmailFrom() { - + if (empty($this->name)) { + return $this->email; + } + return '"' . addslashes($this->name) . '" <' . $this->email . '>'; } }