本文整理汇总了PHP中User::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP User::Create方法的具体用法?PHP User::Create怎么用?PHP User::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Register
public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array(), $groups = null)
{
$encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
$attributes = new UserAttribute($additionalFields);
if ($this->CreatePending()) {
$user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
} else {
$user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
}
$user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
$user->ChangeCustomAttributes($attributeValues);
if ($groups != null) {
$user->WithGroups($groups);
}
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
foreach (ReservationEvent::AllEvents() as $event) {
$user->ChangeEmailPreference($event, true);
}
}
$userId = $this->_userRepository->Add($user);
$this->AutoAssignPermissions($userId);
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
ServiceLocator::GetEmailService()->Send(new AccountCreationEmail($user, ServiceLocator::GetServer()->GetUserSession()));
}
return $user;
}
示例2: Register
public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array())
{
$encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
$attributes = new UserAttribute($additionalFields);
if ($this->CreatePending()) {
$user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
} else {
$user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
}
$user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
$user->ChangeCustomAttributes($attributeValues);
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
foreach (ReservationEvent::AllEvents() as $event) {
$user->ChangeEmailPreference($event, true);
}
}
$userId = $this->_userRepository->Add($user);
$this->AutoAssignPermissions($userId);
$addgroupname = Configuration::Instance()->GetKey(ConfigKeys::NEW_USER_GROUP);
// Match group name to group_id
$addgroupid_res = ServiceLocator::GetDatabase()->Query(new AdHocCommand("select group_id from groups where name = '{$addgroupname}'"));
while ($row = $addgroupid_res->GetRow()) {
$addgroupid = $row['group_id'];
}
//Add user to group
if ($addgroupid != NULL) {
ServiceLocator::GetDatabase()->Execute(new AdHocCommand("insert into user_groups(user_id, group_id) VALUES ({$userId}, {$addgroupid})"));
}
return $user;
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Input::all();
$validation = Validator::make($input, User::$rules);
if ($validation->passes()) {
User::Create($input);
return Redirect::route('users.index');
}
return Redirect::route('users.create')->withInput()->withErrors($validation)->with('message', 'There ware validation errors.');
}
示例4: Login
public static function Login($username, $password)
{
$password = crypt($password, $username);
//Хорошо бы на SHA-2 заменить
$userData = DB::Get()->Select('SELECT * FROM User WHERE email=:email AND `password`=:password', array('email' => $username, 'password' => $password));
// echo $username.$password;
if (isset($userData[0])) {
Session::CreateSession($userData[0]['id']);
return User::Create($userData[0]);
}
return false;
}
示例5: Users
public function Users()
{
//codes for data validation
$validate = Validator::make(Input::all(), ['u_name' => 'required', 'regno' => 'required|unique:users|min:2|max:20', 'email' => 'email|required|unique:users', 'password' => 'required|confirmed', 'course' => 'required', 'nation' => 'required', 'role' => 'required']);
if ($validate->passes()) {
$data = Input::all();
User::Create(array('u_name' => $data['u_name'], 'regno' => $data['regno'], 'email' => $data['email'], 'gender' => $data['gender'], 'password' => Hash::make($data['password']), 'course' => $data['course'], 'nation' => $data['nation'], 'role' => $data['role']));
//return Redirect::to('SignUp');
return Redirect::to('SignUp')->with('success', 'Thanks Data is successful Send');
} else {
return Redirect::to('SignUp')->withErrors($validate);
}
}
示例6: __construct
public function __construct()
{
$this->Infos['Title'] = Language::Get('com.sbb.page.register');
// If logged in, redirect to start page
if (isset($_COOKIE['sbb_Token']) || Session::Read('UserID')) {
header("Location: index.php");
}
$Message = '';
if (isset($_POST['Register'])) {
// Captcha doesn't work
/*if($_POST['Captcha'] != $_SESSION['Captcha']) {
$message = '{lang=com.sbb.captcha.wrong}';
}
else*/
if (Register::Check($_POST)) {
User::Create($_POST['Username'], $_POST['Password'], $_POST['Email']);
$Message = Language::Get('com.sbb.register.success');
} else {
$Message = '<b>' . Language::Get('com.sbb.error') . ':</b><ul><li>' . implode('</li><li>', Register::GetError()) . '</li></ul>';
}
}
// Füllt die Variablen im TPL
SBB::Template()->Assign(array('Message' => $Message, 'Page' => 'Register'));
}
示例7: dirname
<?php
require dirname(__FILE__) . '/../fx.php';
while (@ob_end_clean()) {
}
$skipping = true;
$page = 1;
while ($page !== false) {
$followers = Twitter::GetFollowers('ta_follows', $page);
foreach ($followers as $f) {
$exists = User::Exists($f['screen_name']);
if ($exists or $skipping) {
continue;
}
$skipping = false;
$user = Twitter::Follow($headers['x-twittersenderscreenname']);
if (User::Create($f)) {
echo $f['screen_name'] . " created\n";
Twitter::Tweet('d ' . $f['screen_name'] . ' Welcome to Follows from TwitApps. Send your email address by direct message to @ta_follows to activate this service.');
} else {
echo 'Failed to create user for ' . $f['screen_name'] . ': ' . mysql_error() . "\n";
}
}
if (count($followers) == 100) {
$page++;
} else {
$page = false;
}
}
示例8: htmlspecialchars
if (!empty($_POST['email']) && preg_match('/^[a-z0-9][a-z0-9\\._-]+@[a-z0-9][a-z0-9\\.-]+\\.[a-z0-9]{2,4}$/i', $_POST['email'])) {
if (!User::Exist(array('email' => $_POST['email']))) {
View::$vars->data['email'] = htmlspecialchars(trim($_POST['email']));
} else {
View::$vars->errors['email'] = Language::GetText('error_email_unavailable');
}
} else {
View::$vars->errors['email'] = Language::GetText('error_email');
}
### Create user if no errors were found
if (empty(View::$vars->errors)) {
View::$vars->data['confirm_code'] = User::CreateToken();
View::$vars->data['status'] = 'new';
View::$vars->data['password'] = md5(View::$vars->data['password']);
Plugin::Trigger('register.before_create');
User::Create(View::$vars->data);
View::$vars->message = Language::GetText('success_registered');
View::$vars->message_type = 'success';
$replacements = array('confirm_code' => View::$vars->data['confirm_code'], 'host' => HOST, 'sitename' => $config->sitename);
$mail = new Mail();
$mail->LoadTemplate('welcome', $replacements);
$mail->Send(View::$vars->data['email']);
Plugin::Trigger('register.create');
unset(View::$vars->data);
} else {
View::$vars->message = Language::GetText('errors_below');
View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
View::$vars->message_type = 'error';
}
}
// Output Page
示例9: elseif
} elseif (!$captcha) {
throw new Exception("Captcha was not provided", 400);
} else {
// Validate Captcha
$recaptcha = new \ReCaptcha\ReCaptcha(GOOGLE_RECAPTCHA_PRIVATE_KEY);
$verify = $recaptcha->verify($captcha, $app->request->getIp());
if (!$verify->isSuccess()) {
throw new Exception("Humanity not confirmed", 400);
}
// Create user
$user = new User();
$user->email = $email;
$user->name = $name;
$user->avatar = '';
$password = $user->createRandomPassword(6);
if ($user_id = $user->Create()) {
// Send email
$message = "Greetings {$name}!\n\nYour password:\n\n" . $password;
if (!Mail::send($email, $name, "Account created", $message)) {
throw new Exception("Error sending email", 500);
}
$app->render_json(["id" => $user_id]);
// Create the user token for the first time
Token::Update($user_id);
} else {
throw new Exception("Something went wrong!", 500);
}
}
}
});
/* Delete User
示例10: array
Viewer::AddData("user_name", $user_name);
Viewer::AddData("user_email", $user_email);
if (!empty($user_name) && !empty($user_email) && !empty($_POST["user_password"]) && !empty($_POST["user_password2"])) {
if ($_POST["user_password"] != $_POST["user_password2"]) {
$error_message = I18n::L("Passwords mismatch.");
} else {
if (!Support::IsEMail($user_email)) {
$error_message = I18n::L("Wrong E-mail address.");
} else {
if (User::FindUser($user_name)) {
$error_message = I18n::L("Username «%s» is already taken, please find another username.", array($user_name));
} else {
if (User::FindUserByEmail($user_email)) {
$error_message = I18n::L("This email «%s» is already regesitered, please use another email.", array($user_email));
} else {
$obj = User::Add(User::Create($user_name, $user_email, $_POST["user_password"]));
if ($obj->user_id) {
Session::StartUser($obj);
header("Location:" . PREFIX . "/dashboard/");
exit;
} else {
$error_message = I18n::L("Error while registring user.");
}
//todo: add some error log
}
}
}
}
} else {
if (!empty($_POST["register"])) {
$error_message = I18n::L("Please fill all required fields.");
示例11: User
require_once "../Classes/User.class.php";
require_once "../Classes/VerifyEmail.class.php";
$user = new User();
$VEmail = new VerifyEmail();
if (isset($PARAMS['username']) && isset($PARAMS['password']) && isset($PARAMS['email'])) {
$user->username = $PARAMS['username'];
$user->Find();
if (!$user->variables) {
$VEmail->email = $PARAMS['email'];
$VEmail->Find();
if (!$VEmail->variables) {
$user->username = $PARAMS['username'];
$user->password = md5(base64_encode($PARAMS['password']));
$user->create_date = date("Ymd");
$user->email = $PARAMS['email'];
$user->Create();
$VEmail->email = $PARAMS['email'];
$VEmail->code = getNewCode();
$VEmail->username = $PARAMS['username'];
$VEmail->Create();
sendVerificationEmail($VEmail->email, $user->username, $VEmail->code);
$datos = array("status" => "OK");
print_r(json_encode($datos));
} elseif (!$VEmail->verified) {
$datos = array("status" => "inUseNotVerified");
print_r(json_encode($datos));
} else {
$datos = array("status" => "emailInUse");
print_r(json_encode($datos));
}
} else {
示例12:
header("Location: welcome.php");
}
catch( Exception $e )
{
View::Obj()->Exception($e);
}
}
else
{
try
{
if ( isset($_POST["user"]) )
{
if ( @$_POST["pass"] == @$_POST["pass2"] )
User::Create($_POST);
}
if ( !Auth::Obj()->Authenticated() )
{
View::Obj()->Title("Cuber - Sign up!");
View::Obj()->MainView("signup");
}
else
{
header("Location: welcome.php");
}
}
catch( Exception $e )
{
示例13: htmlspecialchars
$website = (empty($matches[1]) ? 'http://' : '') . $website;
$data['website'] = htmlspecialchars(trim($website));
} else {
$errors['website'] = 'Invalid website';
}
}
// Validate about me
if (!empty($_POST['about_me']) && !ctype_space($_POST['about_me'])) {
$data['about_me'] = htmlspecialchars(trim($_POST['about_me']));
}
### Create user if no errors were found
if (empty($errors)) {
// Create user
$data['password'] = md5($data['password']);
$data['status'] = 'new';
$id = User::Create($data);
$user = new User($id);
$user->Approve('create');
unset($data);
// Output message
$message = 'Member has been added.';
$message_type = 'success';
} else {
$message = 'The following errors were found. Please correct them and try again.';
$message .= '<br /><br /> - ' . implode('<br /> - ', $errors);
$message_type = 'error';
}
}
// Output Header
include 'header.php';
?>
示例14: createUser
public function createUser($empid, $uname, $pass, $role)
{
if (User::Create($empid, $uname, $pass, $role)) {
echo 1;
} else {
echo 0;
}
}
示例15: StopWatch
require_once ROOT_DIR . 'lib/Common/Helpers/namespace.php';
echo "<h1>Booked Scheduler Data Load</h1>";
$stopWatch = new StopWatch();
$stopWatch->Start();
$numberOfResources = 10;
$numberOfUsers = 1000;
$numberOfReservations = 5000;
$numberOfAccessories = 20;
$users = array();
$resources = array();
$db = ServiceLocator::GetDatabase();
// USERS
$db->Execute(new AdHocCommand("delete from users where fname ='load' and lname = 'test'"));
$userRepo = new UserRepository();
for ($i = 0; $i < $numberOfUsers; $i++) {
$user = User::Create("load{$i}", "test{$i}", "email {$i}", "username {$i}", "en_us", "America/Chicago", "7b6aec38ff9b7650d64d0374194307bdde711425", "3b3dbb9b");
$userId = $userRepo->Add($user);
$users[] = $user;
}
echo "Loaded {$numberOfUsers} users<br/>";
// RESOURCES
$db->Execute(new AdHocCommand("delete from resources where name like 'load%'"));
$resourceRepo = new ResourceRepository();
for ($i = 0; $i < $numberOfResources; $i++) {
$resource = BookableResource::CreateNew("load{$i}", 1);
$resourceId = $resourceRepo->Add($resource);
$resources[] = $resource;
}
echo "Loaded {$numberOfResources} resources<br/>";
// ACCESSORIES
$db->Execute(new AdHocCommand("delete from accessories where accessory_name like 'load%'"));