本文整理汇总了PHP中users::create方法的典型用法代码示例。如果您正苦于以下问题:PHP users::create方法的具体用法?PHP users::create怎么用?PHP users::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users
的用法示例。
在下文中一共展示了users::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register($arguments)
{
// Create
if (Session::isLoggedIn()) {
return Error::set('You can\'t register if you\'re logged in!');
}
$this->view['valid'] = true;
$this->view['publicKey'] = Config::get('recaptcha:publicKey');
if (!empty($arguments) && $arguments[0] == 'save') {
if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) {
return Error::set('We could not find the captcha validation fields!');
}
$recaptcha = Recaptcha::check($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if (is_string($recaptcha)) {
return Error::set(Recaptcha::$errors[$recaptcha]);
}
if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
return Error::set('All forms are required.');
}
$users = new users(ConnectionFactory::get('mongo'));
$hideEmail = empty($_POST['hideEmail']) ? false : true;
$created = $users->create($_POST['username'], $_POST['password'], $_POST['email'], $hideEmail, null, true);
if (is_string($created)) {
return Error::set($created);
}
$users->authenticate($_POST['username'], $_POST['password']);
header('Location: ' . Url::format('/'));
}
}
示例2: import
/**
* Import an account.
*
* @param string $username The username to use.
* @param string $password The password to use.
*/
public function import($username, $password)
{
$data = $this->get($username);
$this->db->remove(array('username' => $this->clean($username)));
$users = new users(ConnectionFactory::get('mongo'));
$id = $users->create($username, $password, $data['email'], $data['hideEmail'], $this->groups[$data['mgroup']], true);
$newRef = MongoDBRef::create('users', $id);
$oldRef = MongoDBRef::create('unimportedUsers', $data['_id']);
$this->mongo->news->update(array('user' => $oldRef), array('$set' => array('user' => $newRef)));
$this->mongo->articles->update(array('user' => $oldRef), array('$set' => array('user' => $newRef)));
self::ApcPurge('get', $data['_id']);
}
示例3: array_merge
}
$data['roles'] = users::getRoles($dbh);
if (is_array($_SESSION['token'])) {
$data = array_merge($data, $_SESSION['token']);
}
$app->render('adminUserShow.html', $data);
});
$app->get('/admin/users/setStat/:userID/:status', $authenticateAdmin, function ($userID, $status) use($app) {
$dbh = getConnection();
users::setStatus($dbh, $userID, $status);
die;
});
$app->post('/admin/users/New/', $authenticateAdmin, function () use($app) {
$dbh = getConnection();
$userData = $app->request->post();
users::create($dbh, $userData);
die;
});
$app->post('/admin/users/:userID/', $authenticateAdmin, function ($userID) use($app) {
$dbh = getConnection();
$userData = $app->request->post();
users::update($dbh, $userID, $userData);
die;
});
$app->get('/admin/users/setRole/:userID/:roleID/', $authenticateAdmin, function ($userID, $roleID) use($app) {
$dbh = getConnection();
users::setRole($dbh, $userID, $roleID);
die;
});
$app->get('/admin/users/del/:userID/', $authenticateAdmin, function ($userID) use($app) {
$dbh = getConnection();