Ejemplo n.º 1
0
        }
        if ($biography != '') {
            $user->setBiography($biography);
        }
        $user->save();
        // save the user
        $user->setLastLogin($user->getDateCreated());
        $user->save();
        // save last login as date created
        // log the event
        $logEvent = new Event(array('event_type_id' => 'create_user', 'user_1_id' => $user->getId()));
        $logEvent->save();
        // email confirmation
        $body = '<p>You have successfully registered for <a href="' . Url::base() . '">' . PIPELINE_NAME . '</a>.</p>';
        $body .= '<p>Your username is ' . formatUserLink($user->getID()) . '. Have fun!</p>';
        $newEmail = array('to' => $email, 'subject' => '[' . PIPELINE_NAME . '] Welcome to ' . PIPELINE_NAME . '!', 'message' => $body);
        Email::send($newEmail);
        // log us into the new account
        Session::signIn($user->getId());
        // link any email invites to this user
        Invitation::linkByEmail($email, $user->getID());
        // set confirm message and send us away
        Session::setMessage("Registration successful! Welcome aboard.");
        $json = array('success' => '1', 'successUrl' => Url::dashboard());
        echo json_encode($json);
        break;
    default:
        $json = array('error' => 'An error occurred. Please try again.');
        exit(json_encode($json));
        break;
}