forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roles.php
129 lines (118 loc) · 5.26 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
<?php
/**
* @file roles.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 ||
!isset($_SESSION['user_id']) || empty($_SESSION['user_id']) ||
!isset($_SESSION['key']) || empty($_SESSION['key'])
){
die('Hacking attempt...');
}
/* do checks */
require_once $_SESSION['settings']['cpassman_dir'].'/sources/checks.php';
if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage())) {
$_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
include $_SESSION['settings']['cpassman_dir'].'/error.php';
exit();
}
//load help
require_once $_SESSION['settings']['cpassman_dir'].'/includes/language/'.$_SESSION['user_language'].'_admin_help.php';
//Get full list of groups
$arr_groups = array();
$rows = DB::query("SELECT id,title FROM ".$pre."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'].'
<img src="includes/images/users--plus.png" title="'.$LANG['add_role_tip'].'" onclick="OpenDialog(\'add_new_role\')" style="cursor:pointer;" />
<a onClick="refresh_roles_matrix()"><img src="includes/images/arrow_refresh.png" style="cursor:pointer" title="'.$LANG['refresh_matrix'].'" /></a>
<span style="float:right;margin-right:5px;"><img src="includes/images/question-white.png" style="cursor:pointer" title="'.$LANG['show_help'].'" onclick="OpenDialog(\'help_on_roles\')" /></span>
</div>
<div style="line-height:20px;" align="center">
<div id="matrice_droits"></div>
<div style="">
<img src="includes/images/arrow-180.png" style="display:none; cursor:pointer" id="roles_previous" onclick="refresh_roles_matrix(\'previous\')">
<img src="includes/images/arrow-0.png" style="display:none;cursor:pointer" id="roles_next" onclick="refresh_roles_matrix(\'next\')">
</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 ($pwComplexity as $complex) {
echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
}
echo '
</select>
</p>
</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>';
// 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 ($pwComplexity as $complex) {
echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
}
echo '
</select>
</p>
</div>';
// DIV FOR HELP
echo '
<div id="help_on_roles">
<div>'.$LANG['help_on_roles'].'</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>';
//call to roles.load.php
require_once 'roles.load.php';