Browse Source

Fixed calling role name instead of id

tags/v1.3^2
Teknikode 6 years ago
parent
commit
720874d32a
2 changed files with 20 additions and 3 deletions
  1. 4
    3
      admin/get_user.php
  2. 16
    0
      includes/classes/Role.class.php

+ 4
- 3
admin/get_user.php View File

@@ -29,13 +29,14 @@ if(isset($_POST))
<div class="row">
<h4>Roles</h4>
<?php
foreach ($user->roles as $role => $perm)
foreach ($user->roles as $role_name => $perm)
{
$role = Role::getRole($db, $role_name);
?>
<div class="form-group">
<label class="col-sm-3 control-label" for="<?php echo $user->id; ?>_<?php echo $role; ?>"><?php echo $role; ?></label>
<label class="col-sm-3 control-label" for="<?php echo $user->id; ?>_<?php echo $role['role_id']; ?>"><?php echo $role['role_name']; ?></label>
<div class="col-sm-9">
<button type="button" class="btn btn-danger btn-sm remove_user_role" id="<?php echo $user->id; ?>_<?php echo $role; ?>">Remove</button>
<button type="button" class="btn btn-danger btn-sm remove_user_role" id="<?php echo $user->id; ?>_<?php echo $role['role_id']; ?>">Remove</button>
</div>
</div>
<?php

+ 16
- 0
includes/classes/Role.class.php View File

@@ -65,5 +65,21 @@ class Role
}
return $roles;
}
public function getRole($db, $role_name)
{
$role_list = $db->select('roles', "role_name=?", array($role_name));
$roles = array();
foreach ($role_list as $role)
{
if (!is_array($role))
{
$roles = array($role_list);
break;
}
array_push($roles, $role);
}
return $roles;
}
}
?>

Loading…
Cancel
Save