Ejemplo n.º 1
0
/**
 * 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;
}
Ejemplo n.º 2
0
/**
 * Validate a user
 *
 * @param unknown_type $user_guid
 * @param unknown_type $code
 * @return unknown
 */
function uservalidationbyemail_validate_email($user_guid, $code)
{
    $user = get_entity($user_guid);
    $valid = $code == uservalidationbyemail_generate_code($user_guid, $user->email);
    if ($valid) {
        set_user_validation_status($user_guid, true, 'email');
    }
    return $valid;
}
Ejemplo n.º 3
0
/**
 * Send validation reminder to a specified user with
 * some parameters.
 *
 * @param ElggUser $user User to send the reminder to
 * @param int $enddate The end date in a unix timestamp
 * @param int $pastdays The days we've passed since the validation
 */
function send_validation_reminder_mail($user, $enddate, $pastdays)
{
    $daysleft = $enddate - $pastdays;
    $site = elgg_get_site_entity();
    $code = uservalidationbyemail_generate_code($user->getGUID(), $user->email);
    $link = $site->url . 'uservalidationbyemail/confirm?u=' . $user->getGUID() . '&c=' . $code;
    $subject = elgg_echo('validation_reminder:validate:token:subject', array($user->name, $site->name), $user->language);
    $body = elgg_echo('validation_reminder:validate:token:body', array($user->name, $pastdays, $site->name, $user->token, $link, $daysleft, $site->name, $site->url), $user->language);
    // Send validation email
    notify_user($user->guid, $site->guid, $subject, $body, array(), 'email');
}
Ejemplo n.º 4
0
/**
 * Request user validation email.
 * Send email out to the address and request a confirmation.
 *
 * @param int  $user_guid       The user's GUID
 * @param bool $admin_requested Was it requested by admin
 * @return mixed
 */
function uservalidationbyemail_request_validation($user_guid, $admin_requested = 'deprecated')
{
    if ($admin_requested != 'deprecated') {
        elgg_deprecated_notice('Second param $admin_requested no more used in uservalidationbyemail_request_validation function', 1.9);
    }
    $site = elgg_get_site_entity();
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    if ($user && $user instanceof ElggUser) {
        // Work out validate link
        $code = uservalidationbyemail_generate_code($user_guid, $user->email);
        $link = "{$site->url}uservalidationbyemail/confirm?u={$user_guid}&c={$code}";
        // Get email to show in the next page
        elgg_get_session()->set('emailsent', $user->email);
        $subject = elgg_echo('email:validate:subject', array($user->name, $site->name), $user->language);
        $body = elgg_echo('email:validate:body', array($user->name, $site->name, $link, $site->name, $site->url), $user->language);
        // Send validation email
        $result = notify_user($user->guid, $site->guid, $subject, $body, array(), 'email');
        return $result;
    }
    return FALSE;
}