Clean code

This commit is contained in:
Laurent Destailleur 2022-09-11 13:26:24 +02:00
parent a0dda0ed77
commit 60c39933d4
3 changed files with 10 additions and 11 deletions

View File

@ -77,14 +77,14 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
$head = dav_admin_prepare_head(); $head = dav_admin_prepare_head();
print dol_get_fiche_head($head, 'webdav', '', -1, 'action'); print dol_get_fiche_head($head, 'webdav', '', -1, '');
if ($action == 'edit') { if ($action == 'edit') {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent nomarginbottom">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val) { foreach ($arrayofparameters as $key => $val) {
@ -97,7 +97,7 @@ if ($action == 'edit') {
$label = $langs->trans($key); $label = $langs->trans($key);
if ($key == 'DAV_RESTICT_ON_IP') { if ($key == 'DAV_RESTICT_ON_IP') {
$label = $langs->trans("RESTRICT_ON_IP"); $label = $langs->trans("RESTRICT_ON_IP");
$label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); $tooltiphelp .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
} }
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
@ -120,19 +120,19 @@ if ($action == 'edit') {
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} else { } else {
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent nomarginbottom">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val) { foreach ($arrayofparameters as $key => $val) {
print '<tr class="oddeven"><td class="titlefieldmiddle">'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
$label = $langs->trans($key); $label = $langs->trans($key);
if ($key == 'DAV_RESTICT_ON_IP') { if ($key == 'DAV_RESTICT_ON_IP') {
$label = $langs->trans("RESTRICT_ON_IP"); $label = $langs->trans("RESTRICT_ON_IP");
$label .= ' <span class="opacitymedium">'.$langs->trans("Example").': '.$langs->trans("IPListExample").'</span>'; $tooltiphelp .= ' <span class="opacitymedium">'.$langs->trans("Example").': '.$langs->trans("IPListExample").'</span>';
} }
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td class="minwidth200">';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') { if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {

View File

@ -375,7 +375,7 @@ if (! in_array($umask, array('600', '660', '0600', '0660'))) {
} }
print $umask; print $umask;
if (! in_array($umask, array('600', '660', '0600', '0660'))) { if (! in_array($umask, array('600', '660', '0600', '0660'))) {
print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660'.')</span>'; print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660)</span>';
} }
print '<br>'; print '<br>';
print '<br>'; print '<br>';

View File

@ -66,7 +66,6 @@ if (empty($conf->dav->enabled)) {
accessforbidden(); accessforbidden();
} }
// Restrict API to some IPs // Restrict API to some IPs
if (!empty($conf->global->DAV_RESTRICT_ON_IP)) { if (!empty($conf->global->DAV_RESTRICT_ON_IP)) {
$allowedip = explode(' ', $conf->global->DAV_RESTRICT_ON_IP); $allowedip = explode(' ', $conf->global->DAV_RESTRICT_ON_IP);
@ -136,7 +135,7 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p
return true; return true;
}); });
$authBackend->setRealm(constant('DOL_APPLICATION_TITLE')); $authBackend->setRealm(constant('DOL_APPLICATION_TITLE').' - WebDAV');
@ -200,7 +199,7 @@ $lockBackend = new \Sabre\DAV\Locks\Backend\File($tmpDir.'/.locksdb');
$lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend); $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin); $server->addPlugin($lockPlugin);
// Support for html frontend // Support for the html browser
if (empty($conf->global->DAV_DISABLE_BROWSER)) { if (empty($conf->global->DAV_DISABLE_BROWSER)) {
$browser = new \Sabre\DAV\Browser\Plugin(); $browser = new \Sabre\DAV\Browser\Plugin();
$server->addPlugin($browser); $server->addPlugin($browser);