forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfolders.load.php
254 lines (239 loc) · 8.94 KB
/
folders.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
/**
* @file folders.load.php
* @author Nils Laumaillé
* @version 2.1.22
* @copyright (c) 2009-2014 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() {
//Prepare creation dialogbox
$("#open_add_group_div").click(function() {
$("#div_add_group").dialog("open");
});
$("#div_add_group").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 250,
height: 330,
title: "<?php echo $LANG['add_new_group'];?>",
buttons: {
"<?php echo $LANG['save_button'];?>": function() {
add_new_folder();
},
"<?php echo $LANG['cancel_button'];?>": function() {
$(this).dialog("close");
}
}
});
$("#help_on_folders").dialog({
bgiframe: false,
modal: false,
autoOpen: false,
width: 850,
height: 500,
title: "<?php echo $LANG["admin_help"];?>",
buttons: {
"<?php echo $LANG["close"];?>": function() {
$(this).dialog("close");
}
},
open: function() {
$("#accordion").accordion({ autoHeight: false, navigation: true, collapsible: true, active: false });
}
});
$("#div_edit_folder").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 250,
height: 330,
title: "<?php echo $LANG['at_category'];?>",
open: function(event, ui) {
var id = $("#folder_id_to_edit").val();
//update dialogbox with data
$("#edit_folder_title").val($("#title_"+id).text());
$("#edit_folder_renewal_period").val($("#renewal_"+id).text());
$("#edit_folder_complexite").val($("#renewal_id_"+id).val());
$("#edit_parent_id").val($("#parent_id_"+id).val());
},
buttons: {
"<?php echo $LANG['save_button'];?>": function() {
if ($('#edit_folder_complexite').val() == "") {
$("#edit_folder_show_error").html("<?php echo $LANG['error_group_complex'];?>").show();
return;
}if ($('#edit_folder_title').val() == "") {
$("#edit_folder_show_error").html("<?php echo $LANG['error_group_label'];?>").show();
return;
}
//prepare data
var data = '{"id":"'+$("#folder_id_to_edit").val()+'", "title":"'+$('#edit_folder_title').val().replace(/"/g,'"') + '", "complexity":"'+$('#edit_folder_complexite').val().replace(/"/g,'"')+'", '+
'"parent_id":"'+$('#edit_parent_id').val().replace(/"/g,'"')+'", "renewal_period":"'+$('#edit_folder_renewal_period').val().replace(/"/g,'"')+'"}';
//send query
$.post(
"sources/folders.queries.php",
{
type : "update_folder",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
//Check errors
if (data[0].error == "error_group_exist") {
$("#edit_folder_show_error").html("<?php echo $LANG['error_group_exist'];?>").show();
LoadingPage();
} else if (data[0].error == "error_html_codes") {
$("#edit_folder_show_error").html("<?php echo $LANG['error_html_codes'];?>").show();
LoadingPage();
} else {
$("#folder_id_to_edit").val(""); //clear id
window.location.href = "index.php?page=manage_folders";
}
},
"json"
);
},
"<?php echo $LANG['cancel_button'];?>": function() {
//clear id
$("#folder_id_to_edit").val("");
//Close
$(this).dialog("close");
}
}
});
});
function supprimer_groupe(id)
{
if (confirm("<?php echo $LANG['confirm_delete_group'];?>")) {
//send query
$.post(
"sources/folders.queries.php",
{
type : "delete_folder",
id : id
},
function(data) {
RefreshPage("form_groupes");
}
);
}
}
function Changer_Droit_Complexite(id,type)
{
var droit = 0;
if (type == "creation") {
if ($("#cb_droit_"+id).prop("checked") == true) droit = 1;
type = "modif_droit_autorisation_sans_complexite";
} else if (type == "modification") {
if ($("#cb_droit_modif_"+id).prop("checked") == true) droit = 1;
type = "modif_droit_modification_sans_complexite";
}
//send query
$.post(
"sources/folders.queries.php",
{
type : type,
id : id,
droit : droit
}
);
}
function add_new_folder()
{
//Check if renewal_period is an integer
if (isInteger(document.getElementById("add_node_renewal_period").value) == false) {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_renawal_period_not_integer'];?>";
$("#addgroup_show_error").show();
} else if (document.getElementById("new_rep_complexite").value == "") {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_group_complex'];?>";
$("#addgroup_show_error").show();
} else {
if (document.getElementById("ajouter_groupe_titre").value != "" && document.getElementById("parent_id").value != "na") {
$("#addgroup_show_error").hide();
LoadingPage();
//prepare data
var data = '{"title":"'+$('#ajouter_groupe_titre').val().replace(/"/g,'"') + '", "complexity":"'+$('#new_rep_complexite').val().replace(/"/g,'"')+'", '+
'"parent_id":"'+$('#parent_id').val().replace(/"/g,'"')+'", "renewal_period":"'+$('#add_node_renewal_period').val().replace(/"/g,'"')+'"}';
//send query
$.post(
"sources/folders.queries.php",
{
type : "add_folder",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
//Check errors
if (data[0].error == "error_group_exist") {
$("#div_add_group").dialog("open");
$("#addgroup_show_error").html("<?php echo $LANG['error_group_exist'];?>");
$("#addgroup_show_error").show();
LoadingPage();
} else if (data[0].error == "error_html_codes") {
$("#div_add_group").dialog("open");
$("#addgroup_show_error").html("<?php echo $LANG['error_html_codes'];?>");
$("#addgroup_show_error").show();
LoadingPage();
} else {
window.location.href = "index.php?page=manage_folders";
}
},
"json"
);
} else {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_fields_2'];?>";
$("#addgroup_show_error").show();
}
}
}
/**
*
* @access public
* @return void
**/
function open_edit_folder_dialog(id)
{
$("#folder_id_to_edit").val(id);
$("#div_edit_folder").dialog("open");
}
/**
*
**/
function delete_multiple_folders()
{
var list_i = "";
$(".cb_selected_folder:checked").each(function() {
var elem = $(this).attr("id").split("-");
if (list_i == "") list_i = elem[1];
else list_i = list_i+';'+elem[1];
});
if (list_i != "" && $("#action_on_going").val("") == "") {
LoadingPage();
$("#action_on_going").val("multiple_folders");
var data = '{"foldersList":"'+list_i+'"}';
//send query
$.post(
"sources/folders.queries.php",
{
type : "delete_multiple_folders",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
RefreshPage("form_groupes");
$("#action_on_going").val("");
LoadingPage();
},
"json"
);
}
}
</script>