本文整理汇总了PHP中User::add方法的典型用法代码示例。如果您正苦于以下问题:PHP User::add方法的具体用法?PHP User::add怎么用?PHP User::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
function setup()
{
if (Admin::count_users() == 0 && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password'])) {
// Do setup
$user_id = User::add($_POST['email']);
User::signup($user_id, $_POST['username'], $_POST['password'], $this->config->encryption_salt);
$user = User::get_by_email($_POST['email']);
// Update session
$_SESSION['user_id'] = $user->id;
// Log login
if (isset($this->plugins->log)) {
$this->plugins->log->add($_SESSION['user_id'], 'user', NULL, 'signup');
}
Application::flash('success', 'You are now logged in to your app!');
// Go forth!
header('Location: ' . $this->url_for('admin', 'config'));
exit;
} else {
// Show setup form
if (Admin::count_users() == 0) {
Application::flash('info', 'Welcome to Rat!');
$this->loadView('admin/setup');
} else {
throw new RoutingException($this->uri, "Page not found");
}
}
}
示例2: user_add
function user_add()
{
$log = Log::getInstance();
$user = new User();
$storeid = isset($_POST['store']) ? $_POST['store'] : 0;
$user->firstname = isset($_POST['firstname']) ? $_POST['firstname'] : "";
$user->lastname = isset($_POST['lastname']) ? $_POST['lastname'] : "";
$user->username = isset($_POST['username']) ? $_POST['username'] : "";
$user->password = isset($_POST['passwd']) ? $_POST['passwd'] : "";
$user->ci = isset($_POST['ci']) ? $_POST['ci'] : "";
$user->active = isset($_POST['active']);
$user->level = isset($_POST['role']) ? $_POST['role'] : 0;
$user->address = isset($_POST['address']) ? $_POST['address'] : "";
$user->phone = isset($_POST['phone']) ? $_POST['phone'] : "";
$user->email = isset($_POST['email']) ? $_POST['email'] : "";
if ($user->add($storeid)) {
if ($_FILES['upload']['name']) {
$imagepath = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']) . "img/user/\${$user->id}.jpg";
if (move_uploaded_file($_FILES['upload']['tmp_name'], $imagepath)) {
$user->imagepath = $imagepath;
$user->update();
} else {
$log->addError("No fue posible subir imagen");
}
}
header("Location: index.php?pages=user_detail&user={$user->id}");
} else {
$log->addError("No fue posible agregar usuario, verifique que Usuario sea único.");
}
}
示例3: create
public function create()
{
if ($this->f3->exists('POST.create')) {
$user = new User($this->db);
$user->add();
$this->f3->reroute('/success/New User Created');
} else {
$this->f3->set('page_head', 'Create User');
$this->f3->set('view', 'user/create.htm');
}
}
示例4: register
function register()
{
$fname = $_POST['reg_first_name'];
$lname = $_POST['reg_last_name'];
$email = $_POST['reg_email'];
$password = $_POST['reg_password'];
if (strlen($fname) < 2 || strlen($lname) < 2 || !valid_email($email) || User::emailExists($email) || strlen(trim($password)) < 6) {
throw new Exception("Error when registering new user.");
}
User::add($email, md5($password), $fname, $lname);
redirect('/registered');
}
示例5: menu
public function menu()
{
if ($this->f3->exists('POST.create')) {
$user = new User($this->db);
$user->add();
$this->f3->reroute('/');
} else {
$item = new Item($this->db);
$this->f3->set('items', $item->getAllByCategoryId(1, 1));
$this->f3->set('view', 'user/item.html');
}
}
示例6: store
/**
* undocumented function
*
* @return void
* @author
**/
public function store()
{
$validator = $this->storeValid();
if ($validator->passes()) {
$input = $this->storeInput();
$user = User::add($input);
if ($user) {
return Redirect::route('admin.user')->withStatuses(['add' => 'Tambah Berhasil!']);
}
return Redirect::route('admin.user.create')->withErrors(['add' => 'Tambah Gagal!'])->withInput();
}
return Redirect::route('admin.user.create')->withErrors($validator)->withInput();
}
示例7: post_register
public function post_register()
{
$rules = Config::get('rules.register');
$validation = Validator::make(Input::get(), $rules);
if ($validation->passes()) {
if ($user = User::add(Input::get())) {
Auth::login($user);
return Redirect::to('/')->with('registered', TRUE);
}
return Event::first('500', 'You could not be registered due to a system error. We apologize for any inconvenience.');
}
return Redirect::to('/register')->with_input()->with_errors($validation);
}
示例8: doSignUp
public function doSignUp()
{
$user = new StdClass();
$fields = array('name' => Data::STR, 'lastname' => Data::STR, 'middlename' => Data::STR, 'email' => Data::STR, 'phone' => Data::INT, 'password' => Data::STR);
foreach ($fields as $field => $dataType) {
$user->{$field} = Data::get($field, '', $dataType);
}
$a = (object) array('success' => false, 'message' => '');
if (User::add($user)) {
$a->message = 'Пользователь успешно добавлен!';
$a->success = true;
} else {
$a->message = 'Ошибка при создании пользователя';
}
return $a;
}
示例9: addUser
function addUser()
{
$translator = new Translator();
$user = new User();
try {
$user->add($_POST);
echo <<<EOF
<div class="container">
<div class="page-header">
<h1>{$translator->User_registered}</h1>
</div>
<p class="lead">{$translator->User_registered_Desc}</p>
<p >{$translator->Error_Back}</p>
</div>
EOF;
} catch (Exception $e) {
echo <<<EOF
<div class="container">
<div class="page-header">
<h1>{$translator->Error_User_register}</h1>
</div>
EOF;
switch ($e->getCode()) {
case User::EXISTS:
echo " <p class=\"lead\">{$translator->Error_User_exists_Desc}</p>";
break;
case User::NO_DATA:
echo " <p class=\"lead\">{$translator->Error_User_no_data_Desc}</p>";
break;
case User::BAD_PASSWORD:
echo " <p class=\"lead\">{$translator->Error_User_bad_password_Desc}</p>";
break;
default:
echo " <p class=\"lead\">{$translator->Error_User_register_Desc}</p>";
Sendmail::toAdmin(var_export($e, true));
}
echo <<<EOF
<p >{$translator->Error_Back}</p>
</div>
EOF;
}
}
示例10: User
function add_user()
{
$do_api_user = new User();
if ($this->firstname == '' || $this->lastname == '') {
$this->setMessage("521", "First name, Last name required");
return false;
} elseif ($this->email == '') {
$this->setMessage("522", "Email Id Required");
return false;
} elseif ($this->username == '') {
$this->setMessage("523", "Username required.");
return false;
} elseif ($do_api_user->checkDuplicateUserName(trim($this->username))) {
$this->setMessage("524", "Username is already in use.");
return false;
} elseif ($this->password == '') {
$this->setMessage("525", "Password is required.");
return false;
} else {
$do_api_user->addNew();
$do_api_user->firstname = $this->firstname;
$do_api_user->lastname = $this->lastname;
$do_api_user->email = $this->email;
$do_api_user->username = $this->username;
$do_api_user->password = $this->password;
$do_api_user->company = $this->company;
$do_api_user->plan = $this->plan;
$do_api_user->regdate = date("Y-m-d");
$do_api_user->add();
$inserted_id = $do_api_user->getPrimaryKeyValue();
//$do_api_user->addUserAsContact($this->firstname,$this->lastname,$this->company,$this->email,$inserted_id);
// Lets create the Contact view now
$ContactView = new ContactView();
$ContactView->rebuildContactUserTable($inserted_id);
$this->email_work = $this->email;
$this->add_contact();
// adding the contact to the API key user
//$do_api_user->idcontact = $this->idcontact;
//$do_api_user->update();
$this->setValues(array("msg" => "User Added", "stat" => "ok", "code" => "520", "iduser" => $inserted_id, "contact" => $this->idcontact));
return true;
}
}
示例11: register
public function register()
{
if (post('register')) {
$pengguna = ['username' => post('username'), 'email' => post('email'), 'level' => 0, 'aktif' => 1];
$pelanggan = ['nama_lengkap' => post('nama'), 'alamat' => post('alamat'), 'kota' => post('kota'), 'telp' => post('telp')];
if (post('password') == post('passconf')) {
$pengguna['password'] = md5(post('password'));
}
if ($userId = User::add($pengguna)) {
$pelanggan['id_pengguna'] = $userId;
if (Customer::add($pelanggan)) {
set_alert('success', 'Registrasi berhasil, silahkan login ke akun yang baru saja anda buat');
redirect('login');
} else {
set_alert('error', 'Maaf registrasi gagal');
redirect('register');
}
}
}
return $this->render('form-register', ['heading' => 'Silahkan register']);
}
示例12: cmdAdd
public function cmdAdd()
{
Language::init();
//
$login = ArgsHolder::get()->shiftCommand();
$password = ArgsHolder::get()->shiftCommand();
$email = ArgsHolder::get()->shiftCommand();
if ($login === false || $email === false || $password === false) {
return io::out('Incorrect param count', IO::MESSAGE_FAIL) | 1;
}
$confirm = ArgsHolder::get()->getOption('confirmation');
// TODO Confirn not working
// TODO: Registration link without instance of Controller
$confirm = false;
io::out('Adding user: ~WHITE~' . $login . ' <' . $email . '>~~~', false);
try {
User::add(array("login" => $login, "password" => $password, "email" => $email));
} catch (UserException $e) {
return io::out(PHP_EOL . $e->getMessage(), IO::MESSAGE_FAIL) | 127;
}
io::done();
}
示例13: displayMain
public function displayMain()
{
global $smarty, $link;
$errors = array();
if (Tools::isSubmit('CreateUser')) {
if (!Validate::isEmail(Tools::getRequest('email')) || User::userExists(Tools::getRequest('email'))) {
$errors[] = 'The email is invalid or an account is already registered with this e-mail!';
} elseif (empty($_POST['passwd'])) {
$errors[] = 'The password is empty!';
} else {
$user = new User();
$user->copyFromPost();
$user->active = 1;
if ($user->add()) {
$address = new Address();
$address->copyFromPost();
$address->id_user = $user->id;
$address->is_default = 1;
if ($address->add()) {
$user->logined(array('id_address' => $address->id));
if (Tools::getRequest("step") == 2) {
Tools::redirect($link->getPage('CheckoutView'));
} else {
Tools::redirect($link->getPage('MyaccountView'));
}
return;
} else {
$errors = $address->_errors;
}
} else {
$errors = $user->_errors;
}
}
}
$countrys = Country::loadData(1, 500, null, null, array('active' => 1));
$smarty->assign(array('id_default_country' => Configuration::get('TM_DEFAULT_COUNTRY_ID'), 'countrys' => $countrys, 'step' => Tools::getRequest("step"), 'errors' => $errors));
return $smarty->fetch('join.tpl');
}
示例14: addEmployee
public static function addEmployee($name, $emp_id, $address_1, $address_2, $landmark, $city, $state, $pincode, $phone, $fax, $email, $website, $description)
{
$defaultPassword = 'findgaddi';
if (!empty($_SESSION['user']['company'])) {
//$retCode = User::add($name, '', $emp_id, $defaultPassword, $phone, $phone, $email, $address_1, $address_2, $landmark, $city, $state, $pincode, $_SESSION['user']['company']);
if (User::add($name, '', $emp_id, $defaultPassword, $phone, $phone, $email, $address_1, $address_2, $landmark, $city, $state, $pincode, $_SESSION['user']['company'])) {
User::activate(User::getIdByEmail($email));
$mEmployee = new User(User::getIdByEmail($email));
$mAddedBy = new User();
$mEmployee->SetAddedby($mAddedBy->getId());
Mailer::sendEmployeeAddedMessage($name, $emp_id, $email, $defaultPassword, $_SESSION['user']['company'], $mAddedBy->getFullname());
return Timeline::addTimelineEvent("staff_addition", "", "", $mEmployee->getId(), $mAddedBy->getId(), 1);
return true;
}
return false;
} else {
return false;
}
}
示例15: __autoload
function __autoload($className)
{
include_once "models/{$className}.php";
}
$users = new User("localhost", "root", "", "test");
if (!isset($_POST['action'])) {
print json_encode(0);
return;
}
switch ($_POST['action']) {
case 'get_users':
print $users->getUsers();
break;
case 'add_user':
$user = new stdClass();
$user = json_decode($_POST['user']);
print $users->add($user);
break;
case 'delete_user':
$user = new stdClass();
$user = json_decode($_POST['user']);
print $users->delete($user);
break;
case 'update_field_data':
$user = new stdClass();
$user = json_decode($_POST['user']);
print $users->updateValue($user);
break;
}
exit;