Пример #1
0
    $_POST['expires'] = $now;
    $_POST['signed_up'] = $now;
    $_POST['updated'] = $now;
    $_POST['userdata'] = json_encode(array());
    unset($_POST['verify_pass']);
    unset($_POST['_states']);
    unset($_POST['_countries']);
    $u = new User($_POST);
    $u->put();
    Versions::add($u);
    if (!$u->error) {
        $this->add_notification(__('Member added.'));
        $this->hook('user/add', $_POST);
        $this->redirect('/user/admin');
    }
    $page->title = __('An Error Occurred');
    echo __('Error Message') . ': ' . $u->error;
} else {
    $u = new User();
    $u->type = Appconf::user('User', 'default_role');
    $u->types = User::allowed_roles();
    $u->failed = $f->failed;
    $u = $f->merge_values($u);
    $u->_states = user\Data::states();
    $u->_countries = user\Data::countries();
    $page->title = __('Add Member');
    $page->add_script('/js/json2.js');
    $page->add_script('/js/jstorage.js');
    $page->add_script('/js/jquery.autosave.js');
    echo $tpl->render('user/add', $u);
}
Пример #2
0
    echo $res;
    return;
}
if (!User::require_login()) {
    $page->title = __('Members');
    echo $this->run('user/login');
    return;
}
$u = User::$user;
$form = new Form('post', $this);
$form->data = $u->orig();
$form->data->password = '';
$form->data = $form->merge_values($form->data);
$form->data->failed = $form->failed;
$form->data->_states = user\Data::states();
$form->data->_countries = user\Data::countries();
$page->title = __('Update Profile');
echo $form->handle(function ($form) use($u, $page) {
    if (user\Rules::email_in_use($_POST['email'], User::val('id'))) {
        $form->failed[] = 'email-in-use';
        return false;
    }
    $u->name = $_POST['name'];
    $u->email = $_POST['email'];
    if (!empty($_POST['password'])) {
        $u->password = User::encrypt_pass($_POST['password']);
    }
    $u->about = $_POST['about'];
    $u->phone = $_POST['phone'];
    $u->address = $_POST['address'];
    $u->address2 = $_POST['address2'];