Add test if module enabled before showing API information
This commit is contained in:
parent
190ee35e86
commit
3bf1b60be8
@ -83,6 +83,7 @@ if ($user->id <> $id && ! $canreaduser) accessforbidden();
|
|||||||
$langs->load("users");
|
$langs->load("users");
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("ldap");
|
$langs->load("ldap");
|
||||||
|
$langs->load("admin");
|
||||||
|
|
||||||
$object = new User($db);
|
$object = new User($db);
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
@ -824,59 +825,61 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// API key
|
if(! empty($conf->api->enabled)) {
|
||||||
$generated_api_key = '';
|
// API key
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
$generated_api_key = '';
|
||||||
$generated_password=getRandomPassword(false);
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
$generated_password=getRandomPassword(false);
|
||||||
print '<td>';
|
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
||||||
print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="'.$api_key.'" autocomplete="off">';
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Administrator
|
|
||||||
if (! empty($user->admin))
|
|
||||||
{
|
|
||||||
print '<tr><td>'.$langs->trans("Administrator").'</td>';
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->selectyesno('admin',GETPOST('admin'),1);
|
print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="'.$api_key.'" autocomplete="off">';
|
||||||
|
if (! empty($conf->use_javascript_ajax))
|
||||||
|
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
|
// Administrator
|
||||||
|
if (! empty($user->admin))
|
||||||
{
|
{
|
||||||
if (! empty($conf->use_javascript_ajax))
|
print '<tr><td>'.$langs->trans("Administrator").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $form->selectyesno('admin',GETPOST('admin'),1);
|
||||||
|
|
||||||
|
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
|
||||||
{
|
{
|
||||||
print '<script type="text/javascript">
|
if (! empty($conf->use_javascript_ajax))
|
||||||
$(function() {
|
{
|
||||||
$("select[name=admin]").change(function() {
|
print '<script type="text/javascript">
|
||||||
if ( $(this).val() == 0 ) {
|
$(function() {
|
||||||
$("input[name=superadmin]")
|
$("select[name=admin]").change(function() {
|
||||||
.prop("disabled", true)
|
if ( $(this).val() == 0 ) {
|
||||||
.prop("checked", false);
|
$("input[name=superadmin]")
|
||||||
$("select[name=entity]")
|
.prop("disabled", true)
|
||||||
.prop("disabled", false);
|
.prop("checked", false);
|
||||||
} else {
|
$("select[name=entity]")
|
||||||
$("input[name=superadmin]")
|
.prop("disabled", false);
|
||||||
.prop("disabled", false);
|
} else {
|
||||||
}
|
$("input[name=superadmin]")
|
||||||
});
|
.prop("disabled", false);
|
||||||
$("input[name=superadmin]").change(function() {
|
}
|
||||||
if ( $(this).is(":checked") ) {
|
});
|
||||||
$("select[name=entity]")
|
$("input[name=superadmin]").change(function() {
|
||||||
.prop("disabled", true);
|
if ( $(this).is(":checked") ) {
|
||||||
} else {
|
$("select[name=entity]")
|
||||||
$("select[name=entity]")
|
.prop("disabled", true);
|
||||||
.prop("disabled", false);
|
} else {
|
||||||
}
|
$("select[name=entity]")
|
||||||
});
|
.prop("disabled", false);
|
||||||
});
|
}
|
||||||
</script>';
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
$checked=($_POST["superadmin"]?' checked':'');
|
||||||
|
$disabled=($_POST["superadmin"]?'':' disabled');
|
||||||
|
print '<input type="checkbox" name="superadmin" value="1"'.$checked.$disabled.' /> '.$langs->trans("SuperAdministrator");
|
||||||
}
|
}
|
||||||
$checked=($_POST["superadmin"]?' checked':'');
|
print "</td></tr>\n";
|
||||||
$disabled=($_POST["superadmin"]?'':' disabled');
|
|
||||||
print '<input type="checkbox" name="superadmin" value="1"'.$checked.$disabled.' /> '.$langs->trans("SuperAdministrator");
|
|
||||||
}
|
}
|
||||||
print "</td></tr>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
@ -1270,7 +1273,7 @@ else
|
|||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
// API key
|
// API key
|
||||||
if($user->admin) {
|
if(! empty($conf->api->enabled) && $user->admin) {
|
||||||
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
if (! empty($object->api_key))
|
if (! empty($object->api_key))
|
||||||
@ -1849,7 +1852,7 @@ else
|
|||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
// API key
|
// API key
|
||||||
if($user->admin) {
|
if(! empty($conf->api->enabled) && $user->admin) {
|
||||||
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
|
print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
|
||||||
@ -2230,7 +2233,7 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if (! empty($conf->api->enabled) && ! empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
print "\n".'<script type="text/javascript">';
|
print "\n".'<script type="text/javascript">';
|
||||||
print '$(document).ready(function () {
|
print '$(document).ready(function () {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user