forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roles.load.php
239 lines (223 loc) · 5.62 KB
/
roles.load.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
/**
* @file roles.load.php
* @author Nils Laumaillé
* @version 2.1
* @copyright (c) 2009-2011 Nils Laumaillé
* @licensing GNU AFFERO GPL 3.0
* @link http://www.teampass.net
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
if (!isset($_SESSION['CPM'] ) || $_SESSION['CPM'] != 1)
die('Hacking attempt...');
?>
<script type="text/javascript">
$(function() {
$("#add_new_role").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 400,
height: 220,
title: "<?php echo $txt["give_function_title"];?>",
buttons: {
"<?php echo $txt["save_button"];?>": function() {
$.post(
"sources/roles.queries.php",
{
type : "add_new_role",
name : $("#new_function").val(),
complexity : $("#new_role_complexity").val()
},
function(data){
if(data[0].error == "no"){
$("#new_function").val("");
$("#add_new_role").dialog("close");
refresh_roles_matrix("reload");
}
},
"json"
);
},
"<?php echo $txt["cancel_button"];?>": function() {
$(this).dialog("close");
}
}
});
$("#delete_role").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 400,
height: 150,
title: "<?php echo $txt["admin_action"];?>",
buttons: {
"<?php echo $txt["ok"];?>": function() {
$.post(
"sources/roles.queries.php",
{
type : "delete_role",
id : $("#delete_role_id").val()
},
function(data){
if(data[0].error == "no"){
$("#delete_role").dialog("close");
refresh_roles_matrix("reload");
}
},
"json"
);
},
"<?php echo $txt["cancel_button"];?>": function() {
$(this).dialog("close");
}
}
});
$("#edit_role").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 400,
height: 250,
title: "<?php echo $txt["admin_action"];?>",
buttons: {
"<?php echo $txt["ok"];?>": function() {
$.post(
"sources/roles.queries.php",
{
type : "edit_role",
id : $("#edit_role_id").val(),
start : $('#role_start').val(),
title : $("#edit_role_title").val(),
complexity : $("#edit_role_complexity").val()
},
function(data){
$("#edit_role_title").val("");
$("#edit_role").dialog("close");
refresh_roles_matrix("reload");
}
);
},
"<?php echo $txt["cancel_button"];?>": function() {
$(this).dialog("close");
}
}
});
$("#help_on_roles").dialog({
bgiframe: false,
modal: false,
autoOpen: false,
width: 850,
height: 500,
title: "<?php echo $txt["admin_help"];?>",
buttons: {
"<?php echo $txt["close"];?>": function() {
$(this).dialog("close");
}
},
open: function(){
$("#accordion").accordion({ autoHeight: false, navigation: true, collapsible: true, active: false });
}
});
refresh_roles_matrix();
});
//###########
//## FUNCTION : Change the actual right of the role other the select folder
//###########
function tm_change_role(role,folder,cell_id,allowed){
$("#div_loading").show();
$.post(
"sources/roles.queries.php",
{
type : "change_role_via_tm",
role : role,
folder : folder,
cell_id : cell_id,
allowed : allowed
},
function(data){
refresh_roles_matrix("reload");
$("#div_loading").hide();
}
);
}
function delete_this_role(id,name){
$("#delete_role_id").val(id);
$("#delete_role_show").html(name);
$("#delete_role").dialog("open");
}
function edit_this_role(id,name,complexity){
$("#edit_role_id").val(id);
$("#edit_role_show").html(name);
$("#edit_role_title").val(name);
$("#edit_role_complexity").val(complexity);
$("#edit_role").dialog("open");
}
function allow_pw_change_for_role(id, value){
$("#div_loading").show();
//Send query
$.post(
"sources/roles.queries.php",
{
type : "allow_pw_change_for_role",
id : id,
value : value
},
function(data){
if (value == 0)
$("#img_apcfr_"+id).attr("src","includes/images/ui-text-field-password-red.png");
else
$("#img_apcfr_"+id).attr("src","includes/images/ui-text-field-password-green.png");
$("#div_loading").hide();
}
);
}
/**
*
* @access public
* @return void
**/
function refresh_roles_matrix(order){
//clean up
$("#roles_next, #roles_previous").hide();
//manage start query
if(order == "next"){
var start = $('#next_role').val();
}else if(order == "previous"){
var start = $('#previous_role').val();
}else if(order == "reload"){
var start = $('#role_start').val();
}else{
var start = 0;
}
$('#role_start').val(start);
//send query
$.post(
"sources/roles.queries.php",
{
type : "refresh_roles_matrix",
start : start
},
function(data){
//decrypt data
data = $.parseJSON(data);
$("#matrice_droits").html("");
if (data.new_table != "") {
$("#matrice_droits").html(data.new_table);
if(data.next < data.all) {
$("#roles_next").show();
}
if(data.next >= 9 && data.previous >= 0) {
$("#roles_previous").show();
}
//manage next & previous arrows
$('#next_role').val(data.next);
$('#previous_role').val(data.previous);
}
}
);
}
</script>