Exemplo n.º 1
0
 public function signUp($login_name, $password, $email)
 {
     // to improve DB access it's better to pass id for object save
     // save user
     $user = new User();
     $user->setCulture($this->getCulture());
     $user->setName($login_name);
     // absolutely needed for i18n record creation here !
     // Get data from YML config file.
     $master_user_id = sfConfig::get('app_user_creation_master_id');
     $is_minor = sfConfig::get('app_user_creation_is_minor');
     $comment = sfConfig::get('app_user_creation_comment');
     $user->doSaveWithMetadata($master_user_id, $is_minor, $comment);
     // save private data
     $private_data = new UserPrivateData();
     $private_data->setLoginName($login_name);
     $private_data->setUsername($login_name);
     // username is used as nickname in forum, need to be set
     $private_data->setTopoName($user->getName());
     $private_data->setPassword($password);
     $private_data->setEmail($email);
     $private_data->setPreferedLanguageList($this->getCulturesForDocuments());
     $private_data->setId($user->getId());
     $private_data->setGroupId(4);
     $private_data->setRegistered(time());
     $private_data->save();
     // add this user to pending users and logged
     $user->addToGroups(array('pending', 'logged'));
     return true;
 }