forked from 418sec/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roles.php
162 lines (151 loc) · 6.89 KB
/
roles.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
<?php
/**
* @package roles.php
* @author Nils Laumaillé <nils@teampass.net>
* @version 2.1.27
* @copyright 2009-2019 Nils Laumaillé
* @license GNU GPL-3.0
* @link https://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 ||
!isset($_SESSION['user_id']) || empty($_SESSION['user_id']) ||
!isset($_SESSION['key']) || empty($_SESSION['key'])
) {
die('Hacking attempt...');
}
// Load config
if (file_exists('../includes/config/tp.config.php')) {
include_once '../includes/config/tp.config.php';
} elseif (file_exists('./includes/config/tp.config.php')) {
include_once './includes/config/tp.config.php';
} else {
throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1);
}
/* do checks */
require_once $SETTINGS['cpassman_dir'].'/sources/checks.php';
if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage())) {
$_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
include $SETTINGS['cpassman_dir'].'/error.php';
exit();
}
require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
//Get full list of groups
$arr_groups = array();
$rows = DB::query("SELECT id,title FROM ".prefix_table("nested_tree"));
foreach ($rows as $reccord) {
$arr_groups[$reccord['id']] = $reccord['title'];
}
//display
echo '
<div class="title ui-widget-content ui-corner-all">
'.$LANG['admin_functions'].'
<button title="'.htmlentities(strip_tags($LANG['add_role_tip']), ENT_QUOTES).'" onclick="OpenDialog(\'add_new_role\')" class="button" style="font-size:16px;">
<span class="fa fa-plus"></span>
</button>
<span class="normal"><input id="filter_roles" type="text" class="ui-widget ui-corner-all" value="" placeholder="No filter" /></span>
<button title="'.htmlentities(strip_tags($LANG['refresh_matrix']), ENT_QUOTES).'" onclick="refresh_roles_matrix()" class="button" style="font-size:16px;">
<span class="fa fa-refresh"></span>
</button>
<button onclick="refresh_roles_matrix(\'previous\')" class="button roles_previous" style="font-size:16px;">
<span class="fa fa-arrow-left"></span>
</button>
<button onclick="refresh_roles_matrix(\'next\')" class="button roles_next" style="font-size:16px;">
<span class="fa fa-arrow-right"></span>
</button>
</div>
<div style="line-height:20px;" align="center">
<div id="matrice_droits"></div>
<div style="">
<button onclick="refresh_roles_matrix(\'previous\')" class="button roles_previous" style="font-size:16px;">
<span class="fa fa-arrow-left"></span>
</button>
<button onclick="refresh_roles_matrix(\'next\')" class="button roles_next" style="font-size:16px;">
<span class="fa fa-arrow-right"></span>
</button>
</div>
</div>
<input type="hidden" id="selected_function" />
<input type="hidden" id="next_role" value="0" />
<input type="hidden" id="previous_role" value="0" />
<input type="hidden" id="role_start" value="0" />
<input type="hidden" id="change_role" value="0" />
<input type="hidden" id="change_folder" value="0" />
<input type="hidden" id="change_line" value="0" />';
// DIV FOR ADDING A ROLE
echo '
<div id="add_new_role" style="">
<div style="text-align:center;padding:2px;display:none;" class="ui-state-error ui-corner-all" id="new_role_error"></div>
<p>
<label for="new_function" class="form_label_100">'.$LANG['name'].'</label><input type="text" id="new_function" size="40" />
</p>
<p>
<label for="new_role_complexity" class="form_label">'.$LANG['complex_asked'].' :</label>
<select id="new_role_complexity" class="input_text text ui-widget-content ui-corner-all">
<option value="">---</option>';
foreach ($SETTINGS_EXT['pwComplexity'] as $complex) {
echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
}
echo '
</select>
</p>
<div id="add_role_loader" style="display:none;text-align:center;margin-top:20px;">
<i class="fa fa-cog fa-spin"></i> '.$LANG['please_wait'].'...
</div>
</div>';
// DIV FOR DELETING A ROLE
echo '
<div id="delete_role" style="display:none;">
<div>'.$LANG['confirm_del_role'].'</div>
<div style="font-weight:bold;text-align:center;color:#FF8000;text-align:center;font-size:13pt;" id="delete_role_show"></div>
<input type="hidden" id="delete_role_id" />
<div id="delete_role_loader" style="display:none;text-align:center;margin-top:20px;">
<i class="fa fa-cog fa-spin"></i> '.$LANG['please_wait'].'...
</div>
</div>';
// DIV FOR EDITING A ROLE
echo '
<div id="edit_role" style="display:none;">
<div style="text-align:center;padding:2px;display:none;" class="ui-state-error ui-corner-all" id="edit_role_error"></div>
<div>'.$LANG['confirm_edit_role'].'</div>
<div style="font-weight:bold;text-align:center;color:#FF8000;text-align:center;font-size:13pt;" id="edit_role_show"></div>
<input type="hidden" id="edit_role_id" />
<label for="edit_role_title" class="form_label">'.$LANG['new_role_title'].'</label><input type="text" id="edit_role_title" size="40" />
<p>
<label for="edit_role_complexity" class="form_label">'.$LANG['complex_asked'].' :</label>
<select id="edit_role_complexity" class="input_text text ui-widget-content ui-corner-all">
<option value="">---</option>';
foreach ($SETTINGS_EXT['pwComplexity'] as $complex) {
echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
}
echo '
</select>
</p>
<div id="edit_role_loader" style="display:none;text-align:center;margin-top:20px;">
<i class="fa fa-cog fa-spin"></i> '.$LANG['please_wait'].'...
</div>
</div>';
// DIV FOR TYPE OF RIGHTS
echo '
<div id="type_of_rights">
<div>'.$LANG['right_types_label'].'</div>
<div style="margin-top:10px; text-align:center;">
<input type="radio" name="right_types_radio" id="right_write" /><label for="right_write">'.$LANG['write'].'</label>
<input type="radio" name="right_types_radio" id="right_read" /><label for="right_read">'.$LANG['read'].'</label>
<input type="radio" name="right_types_radio" id="right_noaccess" /><label for="right_noaccess">'.$LANG['no_access'].'</label>
</div>
<div style="margin:10px 0 0 30px; display:none;" id="div_delete_option">
<input type="checkbox" id="right_nodelete" /> '.$LANG['role_cannot_delete_item'].'<br />
<input type="checkbox" id="right_noedit" /> '.$LANG['role_cannot_edit_item'].'
</div>
<div id="role_rights_loader" style="display:none;text-align:center;margin-top:20px;">
<i class="fa fa-cog fa-spin"></i> '.$LANG['please_wait'].'...
</div>
</div>';
//call to roles.load.php
require_once 'roles.load.php';