本文整理汇总了PHP中UsersPeer::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UsersPeer::createUser方法的具体用法?PHP UsersPeer::createUser怎么用?PHP UsersPeer::createUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsersPeer
的用法示例。
在下文中一共展示了UsersPeer::createUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUser
private function createUser($username, $raw_password)
{
$userinfo = array('username' => $username, 'password' => coreContext::getInstance()->getUser()->getSaltyHashedPassword($raw_password), 'userlevel' => $this->getOption('level', UsersPeer::USERLEVEL_USER), 'email' => trim($this->getOption('email', 'created@localhost')), 'location' => trim($this->getOption('location', 'localhost')));
//die(print_r($userinfo, true));
if (false === UsersPeer::createUser($userinfo)) {
$this->throwError('Could not create user.');
}
}
示例2: executeCreate
/**
* Create a new account.
*
* @return
*/
public function executeCreate($request)
{
if ($request->getMethod() != coreRequest::POST) {
// setup form
// development
/*
if (CORE_ENVIRONMENT==='dev')
{
$request->getParameterHolder()->add(array(
'username' => '...' . rand(1,1000),
'email' => '...',
'password'=>'xxxxx',
'password2'=>'xxxxx',
'location'=>'Foo Bar')
);
}*/
} else {
$validator = new coreValidator($this->getActionName());
if ($validator->validate($request->getParameterHolder()->getAll())) {
$this->username = trim($request->getParameter('username'));
$raw_password = trim($request->getParameter('password'));
if (UsersPeer::usernameExists($this->username)) {
$request->setError('username_duplicate', 'Sorry, that username is already taken, please pick another one.');
return coreView::SUCCESS;
}
$userinfo = array('username' => trim($request->getParameter('username')), 'password' => $this->getUser()->getSaltyHashedPassword($raw_password), 'email' => trim($request->getParameter('email')), 'location' => trim($request->getParameter('location', '')));
// username is available, create user
UsersPeer::createUser($userinfo);
// create user on the PunBB forum with same username and password
// NOT IN STAGING -- staging does not have a "test" forum database
if (coreContext::getInstance()->getConfiguration()->getEnvironment() !== 'staging' && coreConfig::get('app_path_to_punbb') !== null) {
try {
$forumAccountSuccess = PunBBUsersPeer::createAccount($userinfo);
} catch (coreException $e) {
$forumAccountSuccess = false;
}
if (!$forumAccountSuccess) {
$url = $this->getController()->genUrl('@contact');
$request->setError('forum_account', 'Oops, there was a problem while accessing the forum database.<br/>' . 'Please <a href="' . $url . '">contact the webmaster</a> with your username and password,<br/>' . 'and we will create your forum account as soon as possible.');
}
} else {
// STAGING
$forumAccountSuccess = false;
$request->setError('forum_account', '(Forum account NOT created in test environment)');
}
// send email confirmation
$mailer = new rtkMail();
$mailer->sendNewAccountConfirmation($userinfo['email'], $userinfo['username'], $raw_password);
return 'Done';
}
}
}