本文整理汇总了PHP中elgg_set_user_validation_status函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_set_user_validation_status函数的具体用法?PHP elgg_set_user_validation_status怎么用?PHP elgg_set_user_validation_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_set_user_validation_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uservalidationbyemail_validate_email
/**
* Validate a user
*
* @param int $user_guid
* @param string $code
* @return bool
*/
function uservalidationbyemail_validate_email($user_guid, $code)
{
$user = get_entity($user_guid);
if ($code == uservalidationbyemail_generate_code($user_guid, $user->email)) {
return elgg_set_user_validation_status($user_guid, true, 'email');
}
return false;
}
示例2: uservalidationbyemail_validate_email
/**
* Validate a user
*
* @param int $user_guid
* @param string $code
* @return bool
*/
function uservalidationbyemail_validate_email($user_guid, $code)
{
$user = get_entity($user_guid);
$site_url = elgg_get_site_url();
$matches = elgg_build_hmac([(int) $user_guid, $user->email, $site_url])->matchesToken($code);
if (!$matches) {
return false;
}
return elgg_set_user_validation_status($user_guid, true, 'email');
}
示例3: socialink_register_user_hook
/**
* Validate a new user if he/she comes from some social networks
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param mixed $return_value current return value
* @param array $params supplied params
*
* @return void
*/
function socialink_register_user_hook($hook, $type, $return_value, $params)
{
$result = $return_value;
if (!empty($params) && is_array($params)) {
$user = elgg_extract("user", $params);
if (elgg_instanceof($user, "user")) {
$network = get_input("network");
switch ($network) {
case "facebook":
case "wordpress":
// user is validated by facebook or wordpress
elgg_set_user_validation_status($user->getGUID(), true, "email");
break;
}
}
}
return $result;
}
示例4: handle
/**
* {@inheritdoc}
*/
protected function handle()
{
$admin = $this->option('admin');
$notify = $this->option('notify');
$email = $this->ask('Enter account email: ');
list($username, ) = explode('@', $email, 2);
$username = $this->ask("Enter account username [{$username}]: ", $username);
$password = $this->ask('Enter account password (leave empty to autegenerate): ', null, true, false);
if (empty($password)) {
$password = generate_random_cleartext_password();
}
$name = $this->ask("Enter account display name [{$username}]: ", $username);
$guid = register_user($username, $password, $name, $email);
$user = get_entity($guid);
$user->admin_created = true;
elgg_set_user_validation_status($user->guid, true, 'cli');
$params = ['user' => $user, 'password' => $password];
if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
$ia = elgg_set_ignore_access(true);
$user->delete();
elgg_set_ignore_access($ia);
throw new RegistrationException(elgg_echo('registerbad'));
}
if ($admin) {
$ia = elgg_set_ignore_access(true);
$user->makeAdmin();
elgg_set_ignore_access($ia);
}
if ($notify) {
$subject = elgg_echo('useradd:subject', array(), $user->language);
$body = elgg_echo('useradd:body', array($name, elgg_get_site_entity()->name, elgg_get_site_entity()->url, $username, $password), $user->language);
notify_user($user->guid, elgg_get_site_entity()->guid, $subject, $body, ['password' => $password]);
}
if ($user->isAdmin()) {
system_message("New admin user has been registered [guid: {$user->guid}]");
} else {
system_message("New user has been registered [guid: {$user->guid}]");
}
}
示例5: disable_new_user
/**
*
* Disable a new user pending email verification
*
* @param type $hook
* @param type $type
* @param type $return
* @param type $params
* @return type
*/
function disable_new_user($hook, $type, $value, $params)
{
$user = elgg_extract('user', $params);
if (!elgg_get_plugin_setting('email_validate', PLUGIN_ID)) {
return;
}
// no clue what's going on, so don't react.
if (!$user instanceof \ElggUser) {
return;
}
// another plugin is requesting that registration be terminated
// no need for uservalidationbyemail
if (!$value) {
return $value;
}
// has the user already been validated?
if (elgg_get_user_validation_status($user->guid) == true) {
return $value;
}
// disable user to prevent showing up on the site
// set context so our canEdit() override works
elgg_push_context('stormpath_new_user');
$hidden_entities = access_get_show_hidden_status();
access_show_hidden_entities(TRUE);
// Don't do a recursive disable. Any entities owned by the user at this point
// are products of plugins that hook into create user and might need
// access to the entities.
// @todo That ^ sounds like a specific case...would be nice to track it down...
$user->disable('stormpath_new_user', FALSE);
// set user as unvalidated and send out validation email
elgg_set_user_validation_status($user->guid, FALSE);
// trigger the stormpath email validation
elgg_pop_context();
access_show_hidden_entities($hidden_entities);
return $value;
}
示例6: uservalidationbyemail_validate_email
/**
* Validate a user
*
* @param int $user_guid
* @param string $code
* @return bool
* @deprecated 2.3
*/
function uservalidationbyemail_validate_email($user_guid, $code = null)
{
elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated. Validation now relies on signed URL API', '2.3');
elgg_signed_request_gatekeeper();
return elgg_set_user_validation_status($user_guid, true, 'email');
}
示例7: foreach
}
if ($avatar_error) {
foreach ($files as $file) {
$file->delete();
}
} else {
$user->x1 = 0;
$user->x2 = 0;
$user->y1 = 0;
$user->y2 = 0;
$user->icontime = time();
elgg_create_river_item(array('view' => 'river/user/default/profileiconupdate', 'action_type' => 'update', 'subject_guid' => $user->guid, 'object_guid' => $user->guid));
}
$filehandler->delete();
}
elgg_set_user_validation_status($user->guid, true, 'FAKER');
if ($user->save()) {
$success++;
set_user_notification_setting($user->guid, 'email', false);
set_user_notification_setting($user->guid, 'site', true);
} else {
$error++;
}
}
}
if ($errors) {
system_message(elgg_echo('faker:gen_users:error', array($success, $error, implode('<br />', $exceptions))));
} else {
system_message(elgg_echo('faker:gen_users:success', array($success)));
}
forward(REFERER);
示例8: uservalidationbyemail_validate_new_admin_user
/**
* Make sure any admin users are automatically validated
*
* @param string $event
* @param string $type
* @param ElggUser $user
*/
function uservalidationbyemail_validate_new_admin_user($event, $type, $user)
{
if ($user instanceof ElggUser && !$user->validated) {
elgg_set_user_validation_status($user->guid, TRUE, 'admin_user');
}
}
示例9: array
// note: To catch all new users, even those created by an admin,
// register for the create, user event instead.
// only passing vars that aren't in ElggUser.
$params = array('user' => $new_user, 'password' => $password, 'friend_guid' => $friend_guid, 'invitecode' => $invitecode, 'photo_url' => $photo_url, 'provider' => $provider, 'provider_uid' => $provider_uid);
$metadata = array('description' => get_input('description'), "{$provider}_url" => get_input('profile_url'), "{$provider}" => get_input($provider), 'website' => get_input('website_url'), 'first_name' => get_input('first_name'), 'last_name' => get_input('last_name'), 'gender' => get_input('gender'), 'language' => get_input('language'), 'age' => get_input('age'), 'birthdate' => mktime(0, 0, 0, get_input('birthmonth'), get_input('birthday'), get_input('birthyear')), 'contactemail' => get_input('contactemail'), 'phone' => get_input('phone'));
foreach (array('address', 'country', 'region', 'city', 'zip') as $location_element) {
if (get_input($location_element, false)) {
$location[] = get_input($location_element);
}
}
if ($location) {
$metadata['location'] = implode(', ', $location);
}
// we have received a verified email from a provider
if ($verified) {
elgg_set_user_validation_status($new_user->guid, true, 'hybridauth');
}
foreach ($metadata as $md_name => $md_value) {
create_metadata($new_user->guid, $md_name, $md_value, '', $new_user->guid, ACCESS_PRIVATE, true);
}
if ($photo_url) {
$icon_sizes = elgg_get_config('icon_sizes');
$filehandler = new ElggFile();
$filehandler->owner_guid = $new_user->guid;
foreach ($icon_sizes as $size => $dimensions) {
$image = get_resized_image_from_existing_file($photo_url, $dimensions[0], $dimensions[1], $dimensions[2]);
$image = get_resized_image_from_existing_file($photo_url, $dimensions['w'], $dimensions['h'], $dimensions['square'], 0, 0, 0, 0, $dimensions['upscale']);
$filehandler->setFilename("profile/{$new_user->guid}{$size}.jpg");
$filehandler->open('write');
$filehandler->write($image);
$filehandler->close();
示例10: elgg_signed_request_gatekeeper
<?php
elgg_signed_request_gatekeeper();
$user_guid = get_input('u', FALSE);
// new users are not enabled by default.
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$user = get_entity($user_guid);
if (!$user || !elgg_set_user_validation_status($user_guid, true, 'email')) {
register_error(elgg_echo('email:confirm:fail'));
forward();
}
system_message(elgg_echo('email:confirm:success'));
elgg_push_context('uservalidationbyemail_validate_user');
$user->enable();
elgg_pop_context();
try {
login($user);
} catch (LoginException $e) {
register_error($e->getMessage());
}
access_show_hidden_entities($access_status);
forward();
示例11: pam_handler
/**
* Can we allow the user with the credentials to log in?
* Check stormpath, create the user if they can log in and don't exist
* Enable the user if they can log in but were waiting for email verification
*
* @param type $credentials
* @return boolean
*/
function pam_handler($credentials)
{
// try to authenticate first
$application = get_application();
$authResult = $application->authenticate($credentials['username'], $credentials['password']);
$account = $authResult->account;
if (!$account || strtolower($account->status) != 'enabled') {
return false;
}
// we need to search hidden users too
// in case of email confirmation disabling
$show_hidden = access_get_show_hidden_status();
access_show_hidden_entities(true);
// we have an account and it's enabled
// see if we have a matching account here
// check if logging in with email address
if (strpos($credentials['username'], '@') !== false) {
$users = get_user_by_email($credentials['username']);
$user = $users[0];
} else {
$user = get_user_by_username($credentials['username']);
}
// custom context gives us permission to do this
elgg_push_context('stormpath_validate_user');
// if we don't have a user we need to create one
if (!$user) {
$user = new \ElggUser();
$user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
$user->email = $account->email;
$user->name = $account->fullName;
$user->access_id = ACCESS_PUBLIC;
$user->salt = _elgg_generate_password_salt();
$user->password = generate_user_password($user, $credentials['password']);
$user->owner_guid = 0;
// Users aren't owned by anyone, even if they are admin created.
$user->container_guid = 0;
// Users aren't contained by anyone, even if they are admin created.
$user->language = get_current_language();
$user->save();
$user->__stormpath_user = $account->href;
elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
// Turn on email notifications by default
set_user_notification_setting($user->getGUID(), 'email', true);
}
// see if we need to enable/verify the user
if (!$user->isEnabled() && in_array($user->disable_reason, array('stormpath_new_user', 'uservalidationbyemail_new_user'))) {
$user->enable();
$user->__stormpath_user = $account->href;
elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
}
elgg_pop_context();
access_show_hidden_entities($show_hidden);
if ($user && $user->isEnabled()) {
return true;
}
return false;
}
示例12: eg_reg_user
function eg_reg_user($email, $password)
{
//$ar=str_split("@",$email);
$ar = explode("@", $email);
$username = $ar[0];
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
if ($user = get_user_by_username($username)) {
for ($tmp = 2; $tmp < 1000; $tmp++) {
if (!($user = get_user_by_username($username . $tmp))) {
$username .= $tmp;
break;
}
}
}
access_show_hidden_entities($access_status);
$ia = elgg_set_ignore_access(true);
$guid1 = register_user($username, $password, $username, $email);
elgg_set_user_validation_status($guid1, true, 'manual');
elgg_set_ignore_access($ia);
return $username;
}
示例13: ldap_auth_create_user
/**
* Create a new user from the data provided by LDAP
*
* @param string $username
* @param string $password
* @param array $data Data fetched from LDAP
*/
function ldap_auth_create_user($username, $password, $data)
{
// Check that we have the values. register_user() will take
// care of more detailed validation.
$firstname = elgg_extract('firstname', $data);
$lastname = elgg_extract('lastname', $data);
$email = elgg_extract('mail', $data);
// Combine firstname and lastname
$name = implode(' ', array($firstname, $lastname));
try {
$guid = register_user($username, $password, $name, $email);
} catch (Exception $e) {
register_error($e->getMessage());
return false;
}
if (!$guid) {
register_error(elgg_echo('ldap_auth:no_register'));
elgg_log("Failed to create an account for LDAP user {$username}");
return false;
}
$user = get_entity($guid);
// Allow plugins to respond to the registration
$params = array('user' => $user, 'ldap_entry' => $data);
if (!elgg_trigger_plugin_hook('register', 'user', $params, true)) {
// For some reason one of the plugins returned false.
// This most likely means that something went wrong
// and we will have to remove the user.
$user->delete();
register_error(elgg_echo('registerbad'));
return false;
}
// Validate the user
elgg_set_user_validation_status($guid, true, 'LDAP plugin based validation');
return true;
}
示例14: simplesaml_register_user
/**
* Register a user in Elgg based on information provided by the Service Provider (SP).
*
* @param string $name the (display)name of the new user
* @param string $email the email address of the user
* @param string $saml_source the name of the SP this information came from
* @param bool $validate do we need to validate the email address of this new users
* @param string $username the username provided by the SP (optional)
*
* @return bool|ElggUser the new user, false on failure
*/
function simplesaml_register_user($name, $email, $saml_source, $validate = false, $username = "")
{
$result = false;
if (!empty($name) && !empty($email) && !empty($saml_source)) {
// check which username to use
if (!empty($username)) {
// make sure the username is unique
$username = simplesaml_generate_unique_username($username);
} else {
// create a username from email
$username = simplesaml_generate_username_from_email($email);
}
if (!empty($username)) {
// generate a random password
$password = generate_random_cleartext_password();
try {
$user_guid = register_user($username, $password, $name, $email);
if (!empty($user_guid)) {
$new_user = get_user($user_guid);
if (!$validate) {
// no need for extra validation. We trust this user
elgg_set_user_validation_status($new_user->getGUID(), true, "simplesaml");
}
$params = array("user" => $new_user, "password" => $password, "friend_guid" => null, "invitecode" => null);
if (!elgg_trigger_plugin_hook("register", "user", $params, true)) {
register_error(elgg_echo("registerbad"));
} else {
$result = $new_user;
}
}
} catch (Exception $e) {
register_error($e->getMessage());
}
} else {
register_error(elgg_echo("registration:usernamenotvalid"));
}
}
return $result;
}
示例15: elgg_set_context
elgg_set_context($context);
// we have no local users, create a new one
$user = new \ElggUser();
$user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
$user->email = $account->email;
$user->name = $account->fullName;
$user->access_id = ACCESS_PUBLIC;
$user->salt = _elgg_generate_password_salt();
// set invalid PW that will never work for local login. This can be changed by the user later
// but won't leave a secondary local login by accident
$user->password = _elgg_generate_password_salt();
$user->owner_guid = 0;
// Users aren't owned by anyone, even if they are admin created.
$user->container_guid = 0;
// Users aren't contained by anyone, even if they are admin created.
$user->language = get_current_language();
$user->save();
$user->__stormpath_user = $account->href;
elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
// Turn on email notifications by default
set_user_notification_setting($user->getGUID(), 'email', true);
// done with our extra permissions
elgg_pop_context();
login($user, true);
if ($user[0]->language) {
$message = elgg_echo('loginok', array(), $user[0]->language);
} else {
$message = elgg_echo('loginok');
}
system_message($message);
forward($login_forward);