Commit a54b359f authored by Franco Fichtner's avatar Franco Fichtner

system: add email and comment field to users; closes #1731

While there, improve navigation and signaling a bit.
parent baa7ec88
...@@ -119,7 +119,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -119,7 +119,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
exit; exit;
} elseif ($act == 'new' || $act == 'edit') { } elseif ($act == 'new' || $act == 'edit') {
// edit user, load or init data // edit user, load or init data
$fieldnames = array('user_dn', 'descr', 'expires', 'scope', 'uid', 'priv', 'ipsecpsk', 'lifetime', 'otp_seed'); $fieldnames = array('user_dn', 'descr', 'expires', 'scope', 'uid', 'priv', 'ipsecpsk', 'lifetime', 'otp_seed', 'email', 'comment');
if (isset($id)) { if (isset($id)) {
if (isset($a_user[$id]['authorizedkeys'])) { if (isset($a_user[$id]['authorizedkeys'])) {
$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']); $pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
...@@ -195,7 +195,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -195,7 +195,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
echo json_encode($keyData); echo json_encode($keyData);
} }
exit; exit;
} elseif ($act =='delApiKey' && isset($id)) { } elseif ($act =='delApiKey' && isset($id)) {
$username = $a_user[$id]['name']; $username = $a_user[$id]['name'];
if (!empty($pconfig['api_delete'])) { if (!empty($pconfig['api_delete'])) {
$authFactory = new \OPNsense\Auth\AuthenticationFactory(); $authFactory = new \OPNsense\Auth\AuthenticationFactory();
...@@ -331,6 +331,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -331,6 +331,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($userent['disabled']); unset($userent['disabled']);
} }
if (!empty($pconfig['email'])) {
$userent['email'] = $pconfig['email'];
} elseif (isset($userent['email'])) {
unset($userent['email']);
}
if (!empty($pconfig['comment'])) {
$userent['comment'] = $pconfig['comment'];
} elseif (isset($userent['comment'])) {
unset($userent['comment']);
}
if (isset($id)) { if (isset($id)) {
$a_user[$id] = $userent; $a_user[$id] = $userent;
} else { } else {
...@@ -344,15 +356,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -344,15 +356,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($pconfig['chkNewCert'])) { if (!empty($pconfig['chkNewCert'])) {
// redirect to cert manager when a new cert is requested for this user // redirect to cert manager when a new cert is requested for this user
header(url_safe('Location: /system_certmanager.php?act=new&userid=%s', array(count($a_user) - 1))); header(url_safe('Location: /system_certmanager.php?act=new&userid=%s', array(isset($id) ? $id : count($a_user) - 1)));
} else { } else {
header(url_safe('Location: /system_usermanager.php')); header(url_safe('Location: /system_usermanager.php?act=edit&userid=%s&savemsg=%s', array(isset($id) ? $id : count($a_user) - 1, get_std_save_message())));
exit; exit;
} }
} }
} elseif (isset($id)) {
header(url_safe('Location: /system_usermanager.php?userid=%s', array($id)));
exit;
} else { } else {
header(url_safe('Location: /system_usermanager.php')); header(url_safe('Location: /system_usermanager.php'));
exit; exit;
...@@ -584,6 +593,24 @@ $( document ).ready(function() { ...@@ -584,6 +593,24 @@ $( document ).ready(function() {
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<td><a id="help_for_email" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("E-Mail");?></td>
<td>
<input name="email" type="text" value="<?= $pconfig['email'] ?>" />
<div class="hidden" for="help_for_email">
<?= gettext('User\'s e-mail address, for your own information only') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_comment" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Comment");?></td>
<td>
<textarea name="comment" id="comment" class="form-control" cols="65" rows="3"><?= $pconfig['comment'] ?></textarea>
<div class="hidden" for="help_for_comment">
<?= gettext('User comment, for your own information only') ?>
</div>
</td>
</tr>
<tr> <tr>
<td><a id="help_for_expires" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Expiration date"); ?></td> <td><a id="help_for_expires" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Expiration date"); ?></td>
<td> <td>
...@@ -866,9 +893,8 @@ $( document ).ready(function() { ...@@ -866,9 +893,8 @@ $( document ).ready(function() {
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<input name="save" id="save" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" /> <button name="save" id="save" type="submit" class="btn btn-primary" value="save" /><?= gettext('Save') ?></button>
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" <button name="cancel" id="cancel" type="submit" class="btn btn-default" value="cancel" /><?= gettext('Cancel') ?></button>
onclick="window.location.href='<?=isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_usermanager.php';?>'" />
<?php <?php
if (isset($id) && !empty($a_user[$id])) :?> if (isset($id) && !empty($a_user[$id])) :?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" /> <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment