Browse Source

Added add user role

tags/v1.3^2
Teknikode 6 years ago
parent
commit
75d205fbf9
3 changed files with 45 additions and 1 deletions
  1. 28
    0
      admin/add_user_role.php
  2. 16
    0
      includes/classes/Role.class.php
  3. 1
    1
      templates/default/js/admin.js

+ 28
- 0
admin/add_user_role.php View File

@@ -0,0 +1,28 @@
<?php
require_once('../includes/config.php');
if(isset($_POST))
{
if ($logged_in)
{
$user_id = rawurldecode($_POST['id']);
$role_name = rawurldecode($_POST['role']);
$role = Role::getRole($db, $role_name);
if ($role)
{
$userTools->insertUserRoles($user_id, array($role['role_id']));
}
else
{
echo "Invalid Role";
}
}
else
{
echo "You need to be logged in";
}
}
else
{
echo "POST not set";
}
?>

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

@@ -24,6 +24,22 @@ class Role
return isset($this->permissions[$permission]);
}
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;
}
public function getRoles($db)
{
$role_list = $db->select('roles', "1=?", array(1));

+ 1
- 1
templates/default/js/admin.js View File

@@ -7,7 +7,7 @@ function update_user_list(search)
success: function(html)
{
$(".user_list").html(html);
//linkUserAddRole('.add_user_role');
linkUserAddRole('.add_user_role');
//linkUserRemoveRole('.remove_role');
//linkUserDelete('.user_delete');
}

Loading…
Cancel
Save