X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FCore_person_signup.php;h=a59f67d09c430106d492c9741c341a68911d7ed2;hp=dbd673a5112e6a4adb85d8a38db7c437160efc1c;hb=HEAD;hpb=100a32f9c241ff325789b281936cca7c6cd49752 diff --git a/DataObjects/Core_person_signup.php b/DataObjects/Core_person_signup.php index dbd673a5..a59f67d0 100644 --- a/DataObjects/Core_person_signup.php +++ b/DataObjects/Core_person_signup.php @@ -1,9 +1,9 @@ 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(); + if(!$target){ + return false; + } - $_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; - } + $roo = HTML_FlexyFramework::get()->page; + $old = clone($this); + // this shold not really happen... + if($target->get('email', $this->email)){ + return false; } - 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){ - $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(); + + 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 . '>'; } } - \ No newline at end of file