Formatting fixes, fix parsing params from account requests, initial code for the simple interface flag.

This commit is contained in:
Brian Lycett 2022-03-31 15:50:32 +01:00
parent 6a648c7684
commit 2ff87e98dc
8 changed files with 78 additions and 38 deletions

View File

@ -76,14 +76,24 @@ render_js_username_check();
<input type="text" class="form-control invisible" name="group_name" id="group_name" placeholder="Group name" onkeyup="check_entity_name_validity(document.getElementById('group_name').value,'new_group_div');"><button id="add_group" class="form-control btn btn-primary btn-sm invisible" type="submit">Add</button> <input type="text" class="form-control invisible" name="group_name" id="group_name" placeholder="Group name" onkeyup="check_entity_name_validity(document.getElementById('group_name').value,'new_group_div');"><button id="add_group" class="form-control btn btn-primary btn-sm invisible" type="submit">Add</button>
</form> </form>
</div> </div>
<input class="form-control" id="search_input" type="text" placeholder="Search..">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Group name</th> <th>Group name</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="grouplist">
<script>
$(document).ready(function(){
$("#search_input").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#grouplist tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<?php <?php
foreach ($groups as $group){ foreach ($groups as $group){
print " <tr>\n <td><a href='${THIS_MODULE_PATH}/show_group.php?group_name=" . urlencode($group) . "'>$group</a></td>\n </tr>\n"; print " <tr>\n <td><a href='${THIS_MODULE_PATH}/show_group.php?group_name=" . urlencode($group) . "'>$group</a></td>\n </tr>\n";

View File

@ -54,6 +54,7 @@ $people = ldap_get_user_list($ldap_connection);
<form action="<?php print $THIS_MODULE_PATH; ?>/new_user.php" method="post"> <form action="<?php print $THIS_MODULE_PATH; ?>/new_user.php" method="post">
<button type="button" class="btn btn-light"><?php print count($people);?> account<?php if (count($people) != 1) { print "s"; }?></button> &nbsp; <button id="add_group" class="btn btn-default" type="submit">New user</button> <button type="button" class="btn btn-light"><?php print count($people);?> account<?php if (count($people) != 1) { print "s"; }?></button> &nbsp; <button id="add_group" class="btn btn-default" type="submit">New user</button>
</form> </form>
<input class="form-control" id="search_input" type="text" placeholder="Search..">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
@ -64,7 +65,17 @@ $people = ldap_get_user_list($ldap_connection);
<th>Member of</th> <th>Member of</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="userlist">
<script>
$(document).ready(function(){
$("#search_input").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#userlist tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<?php <?php
foreach ($people as $account_identifier => $attribs){ foreach ($people as $account_identifier => $attribs){

View File

@ -82,24 +82,24 @@ if (isset($_GET['account_request'])) {
$givenname[0]=filter_var($_GET['first_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); $givenname[0]=filter_var($_GET['first_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$new_account_r['givenname'] = $givenname; $new_account_r['givenname'] = $givenname;
$givenname['count'] = 1; unset($new_account_r['givenname']['count']);
$sn[0]=filter_var($_GET['last_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); $sn[0]=filter_var($_GET['last_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$new_account_r['sn'][0] = $sn; $new_account_r['sn'] = $sn;
$sn['count'] = 1; unset($new_account_r['sn']['count']);
$uid[0] = generate_username($givenname,$sn); $uid[0] = generate_username($givenname[0],$sn[0]);
$new_account_r['uid'][0] = $uid; $new_account_r['uid'] = $uid;
$uid['count'] = 1; unset($new_account_r['uid']['count']);
if ($ENFORCE_SAFE_SYSTEM_NAMES == TRUE) { if ($ENFORCE_SAFE_SYSTEM_NAMES == TRUE) {
$cn[0] = "$givenname$sn"; $cn[0] = $givenname[0] . $sn[0];
} }
else { else {
$cn[0] = "$givenname $sn"; $cn[0] = $givenname[0] . " " . $sn[0];
} }
$new_account_r['cn'] = $cn; $new_account_r['cn'] = $cn;
$cn['count'] = 1; unset($new_account_r['cn']['count']);
$mail[0]=filter_var($_GET['email'], FILTER_SANITIZE_EMAIL); $mail[0]=filter_var($_GET['email'], FILTER_SANITIZE_EMAIL);
if ($mail[0] == "") { if ($mail[0] == "") {
@ -112,7 +112,7 @@ if (isset($_GET['account_request'])) {
$disabled_email_tickbox = FALSE; $disabled_email_tickbox = FALSE;
} }
$new_account_r['mail'] = $mail; $new_account_r['mail'] = $mail;
$mail['count'] = 1; unset($new_account_r['mail']['count']);
} }
@ -121,7 +121,6 @@ if (isset($_POST['create_account'])) {
$password = $_POST['password']; $password = $_POST['password'];
$new_account_r['password'][0] = $password; $new_account_r['password'][0] = $password;
$account_identifier = $new_account_r[$account_attribute][0]; $account_identifier = $new_account_r[$account_attribute][0];
$this_cn=$cn[0]; $this_cn=$cn[0];
$this_mail=$mail[0]; $this_mail=$mail[0];
$this_givenname=$givenname[0]; $this_givenname=$givenname[0];
@ -310,7 +309,7 @@ $tabindex=1;
<?php render_dynamic_field_js(); ?> <?php render_dynamic_field_js(); ?>
<div class="container"> <div class="container">
<div class="col-sm-8"> <div class="col-sm-8 col-md-offset-2">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading text-center"><?php print $page_title; ?></div> <div class="panel-heading text-center"><?php print $page_title; ?></div>

View File

@ -18,8 +18,10 @@ $to_update = array();
if ($SMTP['host'] != "") { $can_send_email = TRUE; } else { $can_send_email = FALSE; } if ($SMTP['host'] != "") { $can_send_email = TRUE; } else { $can_send_email = FALSE; }
$LDAP['default_attribute_map']["uidnumber"] = array("label" => "UID"); if ($SIMPLE_INTERFACE == FALSE) {
$LDAP['default_attribute_map']["gidnumber"] = array("label" => "GID"); $LDAP['default_attribute_map']["uidnumber"] = array("label" => "UID");
$LDAP['default_attribute_map']["gidnumber"] = array("label" => "GID");
}
$LDAP['default_attribute_map']["mail"] = array("label" => "Email", "onkeyup" => "check_if_we_should_enable_sending_email();"); $LDAP['default_attribute_map']["mail"] = array("label" => "Email", "onkeyup" => "check_if_we_should_enable_sending_email();");
$attribute_map = ldap_complete_account_attribute_array(); $attribute_map = ldap_complete_account_attribute_array();

View File

@ -21,8 +21,15 @@ if (isset($_POST['change_password'])) {
render_header("$ORGANISATION_NAME account manager - password changed"); render_header("$ORGANISATION_NAME account manager - password changed");
?> ?>
<div class="alert alert-success"> <div class="container">
<p class="text-center">Your password has been changed.</p> <div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-success">
<div class="panel-heading">Success</div>
<div class="panel-body">
Your password has been updated.
</div>
</div>
</div>
</div> </div>
<?php <?php
render_footer(); render_footer();
@ -58,7 +65,7 @@ if (isset($mismatched)) { ?>
<script type="text/javascript">$(document).ready(function(){ $("#StrengthProgressBar").zxcvbnProgressBar({ passwordInput: "#password" });});</script> <script type="text/javascript">$(document).ready(function(){ $("#StrengthProgressBar").zxcvbnProgressBar({ passwordInput: "#password" });});</script>
<div class="container"> <div class="container">
<div class="col-sm-6"> <div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading text-center">Change your password</div> <div class="panel-heading text-center">Change your password</div>

View File

@ -23,6 +23,8 @@
#Optional #Optional
$SIMPLE_INTERFACE = ((strcasecmp(getenv('SIMPLE_INTERFACE'),'TRUE') == 0) ? TRUE : FALSE);
$LDAP['account_attribute'] = (getenv('LDAP_ACCOUNT_ATTRIBUTE') ? getenv('LDAP_ACCOUNT_ATTRIBUTE') : 'uid'); $LDAP['account_attribute'] = (getenv('LDAP_ACCOUNT_ATTRIBUTE') ? getenv('LDAP_ACCOUNT_ATTRIBUTE') : 'uid');
$LDAP['group_attribute'] = (getenv('LDAP_GROUP_ATTRIBUTE') ? getenv('LDAP_GROUP_ATTRIBUTE') : 'cn'); $LDAP['group_attribute'] = (getenv('LDAP_GROUP_ATTRIBUTE') ? getenv('LDAP_GROUP_ATTRIBUTE') : 'cn');
$LDAP['group_ou'] = (getenv('LDAP_GROUP_OU') ? getenv('LDAP_GROUP_OU') : 'groups'); $LDAP['group_ou'] = (getenv('LDAP_GROUP_OU') ? getenv('LDAP_GROUP_OU') : 'groups');

View File

@ -50,7 +50,7 @@ else {
?> ?>
<div class="container"> <div class="container">
<div class="col-sm-8"> <div class="col-sm-8 col-sm-offset-2">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading text-center">Log in</div> <div class="panel-heading text-center">Log in</div>

View File

@ -83,22 +83,31 @@ EoT;
include_once "mail_functions.inc.php"; include_once "mail_functions.inc.php";
$sent_email = send_email($ACCOUNT_REQUESTS_EMAIL,"$ORGANISATION_NAME account requests",$mail_subject,$mail_body); $sent_email = send_email($ACCOUNT_REQUESTS_EMAIL,"$ORGANISATION_NAME account requests",$mail_subject,$mail_body);
if ($sent_email) { if ($sent_email) { ?>
$sent_email_message = " Thank you. The request was sent and the administrator will process it as soon as possible.";
}
else {
$sent_email_message = " Unfortunately the request wasn't sent because of a technical problem.";
}
?>
<div class="container"> <div class="container">
<div class="col-sm-8"> <div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-default"> <div class="panel panel-success">
<div class="panel-body"><?php print $sent_email_message; ?></div> <div class="panel-heading">Thank you</div>
<div class="panel-body">
The request was sent and the administrator will process it as soon as possible.
</div>
</div>
</div>
</div>
<?php }
else { ?>
<div class="container">
<div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-danger">
<div class="panel-heading">Error</div>
<div class="panel-body">
Unfortunately the account request wasn't sent because of a technical issue.
</div>
</div> </div>
</div> </div>
</div> </div>
<?php <?php
}
render_footer(); render_footer();
exit(0); exit(0);
@ -106,7 +115,7 @@ EoT;
} }
?> ?>
<div class="container"> <div class="container">
<div class="col-sm-8"> <div class="col-sm-8 col-sm-offset-2">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">