Admins can now set groups for new users
new users meaning users who don't already have any usergroups set
This commit is contained in:
parent
9241a0404a
commit
bb965aadd2
|
@ -69,10 +69,10 @@ $users = $userManager->getAllUserData();
|
|||
?>
|
||||
|
||||
<tr>
|
||||
<td><?= $uname; ?></td>
|
||||
<td><?= $uname ?></td>
|
||||
<?php
|
||||
foreach($userManager->usergroups as $name => $group){
|
||||
echo '<td><input type="checkbox" ' . (($groupFlag & $group) ? 'checked' : '') . ' name="' . $uname . '_' . $name . '">' . $name . '</td>';
|
||||
echo '<td><input type="checkbox" ' . (($groupFlag & $group) ? 'checked' : '') . ' name="' . $uname . '_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
@ -80,6 +80,15 @@ $users = $userManager->getAllUserData();
|
|||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<tr class="newuserrow">
|
||||
<td class="newuserelement"><input type="text" name="newuser" class="newuserinput"></td>
|
||||
<?php
|
||||
foreach($userManager->usergroups as $name => $group){
|
||||
echo '<td><input type="checkbox" name="newuser_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" class="btn" value="Lagre">
|
||||
</form>
|
||||
|
|
|
@ -20,10 +20,28 @@ if(!$userManager->isAdmin($uname)){
|
|||
exit();
|
||||
}
|
||||
|
||||
$newUser;
|
||||
if(isset($_POST['newuser'])){
|
||||
$newUser = $_POST['newuser'];
|
||||
}
|
||||
|
||||
// 2d array of usernames and their corresponding group flags
|
||||
$userFlags = [];
|
||||
foreach($_POST as $namegroup => $check){
|
||||
// new user field, don't use that
|
||||
if($namegroup == 'newuser'){
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = explode('_', $namegroup);
|
||||
if($data[0] == 'newuser'){
|
||||
if(!$newUser){
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[0] = $newUser;
|
||||
}
|
||||
|
||||
if(!isset($userFlags[$data[0]])){
|
||||
$userFlags[$data[0]] = 0;
|
||||
}
|
||||
|
|
|
@ -136,3 +136,21 @@ header.admin {
|
|||
border-bottom: 1px solid gray;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.usergroupcheckbox {
|
||||
margin-right: .3em;
|
||||
}
|
||||
|
||||
.newuserrow {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.newuserelement {
|
||||
background-color: #ddd;
|
||||
border-bottom: 2px dotted gray;
|
||||
}
|
||||
|
||||
.newuserelement input {
|
||||
border: none;
|
||||
background-color: #ddd;
|
||||
}
|
Loading…
Reference in New Issue