/
admin_privilege.php
104 lines (83 loc) · 2.96 KB
/
admin_privilege.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
require_once 'is_admin.php';
require_once 'header.php';
require_once 'acl_class.php';
require_once 'add_delete_record.php';
function display_data($table_name)
{
$acl = new data_manipulation();
$get = $acl->get_data($table_name);
return $get;
}//end display_data()
function display_role()
{
$get_role = display_data('role');
$display = '';
foreach ($get_role as $value)
{
$val = $value['role'];
$id = 'role'.$value['id'];
$display .= "<option class='privilege_display' id='$id'
name='{$val}' value='{$val}'>{$val}</option>";
}
return $display;
}//end display_role()
function get_action()
{
$get_action = display_data('action');
return $get_action;
}//end get_action()
function display_resource_action()
{
$get_resource = display_data('resource');
$display = '';
$count_resource = 0;
$count_action = 0;
foreach ($get_resource as $value)
{
$count_resource++;
$val = $value['resource'];
$id = 'resource'.$value['id'];
$display .= "<tr><td class='privilege_display'><label id='{$id}'
name='{$val}'>{$val}</label>  </td> ";
// Getting action table data.
$get_action = get_action();
foreach ($get_action as $value_action)
{
$count_action++;
$val_action = $value_action['operation'];
$id_action = $id.'action'.$value_action['id'];
$display .= "<td class='privilege_display'>
<input id='{$id_action}' type='checkbox' name='{$val_action}' value='{$val_action}'>
 {$val_action}    </td> ";
}
if ($count_action >= 2)
{
$display .= "<td class='privilege_display'>
<input id='all_{$id}' type='checkbox' name='all' value='all_{$id}'>
  all    </td> ";
}
$display .= '<br/> </tr>';
}//end foreach
$count_action /= 2;
$display .= "<input id='count_action' type='hidden' name='count_action' value='{$count_action}'>";
$display .= "<input id='count_resource' type='hidden' name='count_resource' value='{$count_resource}'>";
return $display;
}//end display_resource_action()
?>
<form class='form_admin_privilege' action='admin_privilege.php'>
<label class='privilege_display'>Role  </label>
<select id='role' name='role'>
<option selected='true' value='select' disabled>select</option>;
<?php echo display_role(); ?>
</select>
<table class="table-responsive">
<?php echo display_resource_action(); ?>
<div id='reload'>
<input id='privilege_data_hidden' type='hidden' value='<?php echo $acl->privilege_data(); ?>'>
</div>
</table>
<br/><input id='set_privilege' class="btn btn-primary" type='button' value='Update'>
</form>
<?php require 'footer.html'; ?>
<script src="js/admin_privilege.js?version=132"></script>