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:
Markus Wang Halvorsen 2017-11-11 19:13:59 +01:00
parent 9241a0404a
commit bb965aadd2
3 changed files with 47 additions and 2 deletions

View File

@ -69,10 +69,10 @@ $users = $userManager->getAllUserData();
?> ?>
<tr> <tr>
<td><?= $uname; ?></td> <td><?= $uname ?></td>
<?php <?php
foreach($userManager->usergroups as $name => $group){ 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> </tr>
@ -80,6 +80,15 @@ $users = $userManager->getAllUserData();
<?php <?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> </table>
<input type="submit" class="btn" value="Lagre"> <input type="submit" class="btn" value="Lagre">
</form> </form>

View File

@ -20,10 +20,28 @@ if(!$userManager->isAdmin($uname)){
exit(); exit();
} }
$newUser;
if(isset($_POST['newuser'])){
$newUser = $_POST['newuser'];
}
// 2d array of usernames and their corresponding group flags // 2d array of usernames and their corresponding group flags
$userFlags = []; $userFlags = [];
foreach($_POST as $namegroup => $check){ foreach($_POST as $namegroup => $check){
// new user field, don't use that
if($namegroup == 'newuser'){
continue;
}
$data = explode('_', $namegroup); $data = explode('_', $namegroup);
if($data[0] == 'newuser'){
if(!$newUser){
continue;
}
$data[0] = $newUser;
}
if(!isset($userFlags[$data[0]])){ if(!isset($userFlags[$data[0]])){
$userFlags[$data[0]] = 0; $userFlags[$data[0]] = 0;
} }

View File

@ -136,3 +136,21 @@ header.admin {
border-bottom: 1px solid gray; border-bottom: 1px solid gray;
min-width: 100%; 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;
}