Example #1
0
<?php

require "../php/init.php";
$mainUser = new User();
if (!$mainUser->inRole(1)) {
    die('nope. not allowed!');
}
$userId = Input::get('id');
$user = new User($userId);
$oldRoles = $user->showRoles($userId);
if ($userData = Input::get('info')) {
    $newRoles = $userData['roles'];
    unset($userData['roles']);
    if (Input::get('add')) {
        echo 'ADD USER<br>';
        print_r($userData);
        echo '<br>';
        print_r($newRoles);
        $salt = Hash::salt(32);
        $user->create(array('username' => $userData['username'], 'password' => Hash::make($userData['password'], $salt), 'salt' => $salt, 'name_first' => $userData['name_first'], 'name_last' => $userData['name_last'], 'email' => $userData['email'], 'joined' => date('Y-m-d H:i:s'), 'group_id' => 1));
    } else {
        try {
            $user->update($userData, $userId);
        } catch (Exception $e) {
            echo $e;
            $error = true;
        }
        if (!$error) {
            foreach ($oldRoles as $key => $oldRole) {
                if (!in_array($key, $newRoles)) {
                    User::removeFromRole($userId, $key);
Example #2
0
            <label for="name_first">First Name</label>
            <input type="text" class="form-control" id="name_first" placeholder="First name">
          </div>
          <div class="form-group">
            <label for="name_last">Last Name</label>
            <input type="text" class="form-control" id="name_last" placeholder="Last name">
          </div>
          <div class="form-group">
            <label for="email">Email</label>
            <input type="email" class="form-control" id="email" placeholder="Email">
          </div>
          <div class="form-group">
            <label for="roles">Roles</label>
            <select id="roles" multiple class="form-control">
              <?php 
$roles = User::showRoles();
foreach ($roles as $id => $name) {
    echo '<option value="' . $id . '">' . $name . '</option>';
}
?>
            </select>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="dataModalcancButton">Close</button>
        <button type="sumbit" 
                class="btn btn-primary" 
                data-loading-text="<i class='fa fa-spinner fa-pulse'></i> Updating"
                data-complete-text="Finished!" 
                data-error-text="Error" 
Example #3
0
<?php

require "../php/init.php";
$userId = Input::get('id');
if (is_numeric($userId)) {
    $outArray = array();
    $userInfo = User::listUsers($userId);
    unset($userInfo->password);
    unset($userInfo->salt);
    unset($userInfo->joined);
    $userInfo->roles = User::showRoles($userId);
    header("Content-type: application/json");
    print json_encode($userInfo);
}