Example #1
0
<?php

require __DIR__ . "/../bourbon/user.php";
$status_message = '';
// Status messages, default to nothing
$form_error = null;
$u = new User();
$u->auth(null);
$u->init(WEB::_get('id'));
if (!$u->valid()) {
    $status_message = WEB::_error('User couldn\'t be viewed. Check ID #!', null);
}
if (WEB::_action('generate_new_api_key')) {
    if (!$u->generateNewApiKey()) {
        $status_message = WEB::_error('Failed to Genereate New API Key!', null);
    }
}
// Handle Post Request
if (WEB::_req('POST')) {
    $user_name = WEB::_post('user_name');
    $user_email = WEB::_post('user_email');
    $user_password = WEB::_post('user_password');
    $user_notify = WEB::_post('user_notify');
    $form_error = $u->validateParams(array($user_name, $user_email, $user_password));
    $updateStatus = true;
    if (is_null($form_error)) {
        if (!is_null($user_name)) {
            $updateStatus = $u->updateUserName($user_name);
        }
        if ($updateStatus && !is_null($user_email)) {
            $updateStatus = $u->updateUserEmail($user_email);