1<?php 2/* Copyright (C) 2008-2019 Laurent Destailleur <eldy@users.sourceforge.net> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18/** 19 * \file htdocs/admin/dav.php 20 * \ingroup dav 21 * \brief Page to setup DAV server 22 */ 23 24require '../main.inc.php'; 25require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 26require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; 27 28// Load translation files required by the page 29$langs->loadLangs(array("admin", "other", "agenda")); 30 31if (!$user->admin) 32 accessforbidden(); 33 34// Parameters 35$action = GETPOST('action', 'aZ09'); 36$backtopage = GETPOST('backtopage', 'alpha'); 37 38 39 40$arrayofparameters = array( 41 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1), 42 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2), 43 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1), 44 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled) 45); 46 47 48/* 49 * Actions 50 */ 51 52include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; 53 54 55 56/* 57 * View 58 */ 59 60 61llxHeader('', $langs->trans("DAVSetup"), $wikihelp); 62 63$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; 64print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup'); 65 66 67print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">'; 68print '<input type="hidden" name="token" value="'.newToken().'">'; 69 70$head = dav_admin_prepare_head(); 71 72print dol_get_fiche_head($head, 'webdav', '', -1, 'action'); 73 74if ($action == 'edit') 75{ 76 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; 77 print '<input type="hidden" name="token" value="'.newToken().'">'; 78 print '<input type="hidden" name="action" value="update">'; 79 80 print '<table class="noborder centpercent">'; 81 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; 82 83 foreach ($arrayofparameters as $key => $val) 84 { 85 if (isset($val['enabled']) && empty($val['enabled'])) continue; 86 87 print '<tr class="oddeven"><td>'; 88 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); 89 $label = $langs->trans($key); 90 if ($key == 'DAV_RESTICT_ON_IP') { 91 $label = $langs->trans("RESTRICT_ON_IP"); 92 $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); 93 } 94 print $form->textwithpicto($label, $tooltiphelp); 95 print '</td><td>'; 96 if ($key == 'DAV_ALLOW_PRIVATE_DIR') 97 { 98 print $langs->trans("AlwaysActive"); 99 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') 100 { 101 print $form->selectyesno($key, $conf->global->$key, 1); 102 } else { 103 print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">'; 104 } 105 print '</td></tr>'; 106 } 107 108 print '</table>'; 109 110 print '<br><div class="center">'; 111 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">'; 112 print '</div>'; 113 114 print '</form>'; 115 print '<br>'; 116} else { 117 print '<table class="noborder centpercent">'; 118 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; 119 120 foreach ($arrayofparameters as $key => $val) 121 { 122 print '<tr class="oddeven"><td>'; 123 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); 124 $label = $langs->trans($key); 125 if ($key == 'DAV_RESTICT_ON_IP') { 126 $label = $langs->trans("RESTRICT_ON_IP"); 127 $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); 128 } 129 print $form->textwithpicto($label, $tooltiphelp); 130 print '</td><td>'; 131 if ($key == 'DAV_ALLOW_PRIVATE_DIR') 132 { 133 print $langs->trans("AlwaysActive"); 134 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') 135 { 136 print yn($conf->global->$key); 137 } else { 138 print $conf->global->$key; 139 } 140 print '</td></tr>'; 141 } 142 143 print '</table>'; 144 145 print '<div class="tabsAction">'; 146 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; 147 print '</div>'; 148} 149 150 151print dol_get_fiche_end(); 152 153/*print '<div class="center">'; 154print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">'; 155print "</div>"; 156*/ 157print "</form>\n"; 158 159 160clearstatcache(); 161 162print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n"; 163print "<br>"; 164 165 166// Define $urlwithroot 167$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); 168$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file 169//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current 170 171 172// Show message 173$message = ''; 174$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>'; 175$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}')); 176$message .= '<br>'; 177if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) 178{ 179 $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : ''); 180 $url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>'; 181 $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}')); 182 $message .= '<br>'; 183} 184print $message; 185 186print '<br><br><br>'; 187 188require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php'; 189$version = Sabre\DAV\Version::VERSION; 190print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>'; 191 192 193// End of page 194llxFooter(); 195$db->close(); 196