当前位置: 首页>>代码示例>>PHP>>正文


PHP User::add方法代码示例

本文整理汇总了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");
         }
     }
 }
开发者ID:Geekathon,项目名称:rat,代码行数:27,代码来源:admin_controller.php

示例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.");
    }
}
开发者ID:BackupTheBerlios,项目名称:rinventory-svn,代码行数:30,代码来源:user.php

示例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');
     }
 }
开发者ID:TomGB,项目名称:f3-crud,代码行数:11,代码来源:UserController.php

示例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');
 }
开发者ID:bennetimo,项目名称:comp3013,代码行数:12,代码来源:usermanager.php

示例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');
     }
 }
开发者ID:pouystat,项目名称:fatfree-master,代码行数:12,代码来源:UserController.php

示例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();
 }
开发者ID:whiterun,项目名称:bagikasih-v2,代码行数:19,代码来源:AdminUserController.php

示例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);
 }
开发者ID:bankorh,项目名称:ecom1_laravel,代码行数:13,代码来源:account.php

示例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;
 }
开发者ID:AlexOrfen,项目名称:Schedule,代码行数:16,代码来源:PageRegister.php

示例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;
        }
    }
开发者ID:jedaika,项目名称:Trainings,代码行数:45,代码来源:register_user.php

示例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;
     }
 }
开发者ID:jacquesbagui,项目名称:ofuz,代码行数:43,代码来源:OfuzApiMethodsPrivate.class.php

示例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']);
 }
开发者ID:gaiius,项目名称:tokonlen,代码行数:21,代码来源:function.php

示例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();
 }
开发者ID:point,项目名称:cassea,代码行数:22,代码来源:CmdUser.php

示例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');
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:38,代码来源:JoinView.php

示例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;
     }
 }
开发者ID:rusty1909,项目名称:Navigator,代码行数:19,代码来源:Company.php

示例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;
开发者ID:hendisantika,项目名称:json-crud2,代码行数:30,代码来源:Controller.php


注:本文中的User::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。