dolibarr 21.0.0-beta
dav.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2019 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
29
41// Load translation files required by the page
42$langs->loadLangs(array("admin", "other", "agenda"));
43
44if (!$user->admin) {
46}
47
48// Parameters
49$action = GETPOST('action', 'aZ09');
50$backtopage = GETPOST('backtopage', 'alpha');
51
52if (empty($action)) {
53 $action = 'edit';
54}
55
56$arrayofparameters = array(
57 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
58 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
59 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
60 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>isModEnabled('ecm'))
61);
62
63// To fix when dire does not exists
64dol_mkdir($conf->dav->dir_output.'/temp');
65dol_mkdir($conf->dav->dir_output.'/public');
66dol_mkdir($conf->dav->dir_output.'/private');
67
68
69/*
70 * Actions
71 */
72
73include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
74
75if ($action == 'update') {
76 $action = 'edit';
77}
78
79
80/*
81 * View
82 */
83
84$help_url = 'EN:Module_DAV';
85
86llxHeader('', $langs->trans("DAVSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-dav');
87
88$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
89print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
90
91
92print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
93print '<input type="hidden" name="token" value="'.newToken().'">';
94
96
97print dol_get_fiche_head($head, 'webdav', '', -1, '');
98
99if ($action == 'edit') {
100 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
101 print '<input type="hidden" name="token" value="'.newToken().'">';
102 print '<input type="hidden" name="action" value="update">';
103
104 print '<table class="noborder centpercent nomarginbottom">';
105 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
106
107 foreach ($arrayofparameters as $key => $val) {
108 if (isset($val['enabled']) && empty($val['enabled'])) {
109 continue;
110 }
111
112 print '<tr class="oddeven"><td>';
113 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
114 $label = $langs->trans($key);
115 if ($key == 'DAV_RESTICT_ON_IP') {
116 $label = $langs->trans("RESTRICT_ON_IP");
117 $tooltiphelp .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
118 }
119 print $form->textwithpicto($label, $tooltiphelp);
120 print '</td><td>';
121 if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
122 print $langs->trans("AlwaysActive");
123 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
124 print $form->selectyesno($key, getDolGlobalString($key), 1);
125 } else {
126 print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'">';
127 }
128 print '</td></tr>';
129 }
130
131 print '</table>';
132
133 print '<br><div class="center">';
134 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
135 print '</div>';
136
137 print '</form>';
138 print '<br>';
139} else {
140 print '<table class="noborder centpercent nomarginbottom">';
141 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
142
143 foreach ($arrayofparameters as $key => $val) {
144 if (isset($val['enabled']) && empty($val['enabled'])) {
145 continue;
146 }
147
148 print '<tr class="oddeven"><td>';
149 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
150 $label = $langs->trans($key);
151 if ($key == 'DAV_RESTICT_ON_IP') {
152 $label = $langs->trans("RESTRICT_ON_IP");
153 $tooltiphelp .= ' <span class="opacitymedium">'.$langs->trans("Example").': '.$langs->trans("IPListExample").'</span>';
154 }
155 print $form->textwithpicto($label, $tooltiphelp);
156 print '</td><td class="minwidth200">';
157 if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
158 print $langs->trans("AlwaysActive");
159 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
160 print yn(getDolGlobalString($key));
161 } else {
162 print getDolGlobalString($key);
163 }
164 print '</td></tr>';
165 }
166
167 print '</table>';
168
169 print '<div class="tabsAction">';
170 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
171 print '</div>';
172}
173
174
175print dol_get_fiche_end();
176
177/*print '<div class="center">';
178print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
179print "</div>";
180*/
181print "</form>\n";
182
183
184clearstatcache();
185
186print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n";
187print "<br>";
188
189
190// Define $urlwithroot
191$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
192$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
193//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
194
195
196// Show message
197$message = '';
198$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">'.$urlwithroot.'/dav/fileserver.php</a>';
199
200$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', ''));
201$message .= '<div class="urllink"><input type="text" id="webdavpublicurl" class="quatrevingtpercent" value="'.$urlwithroot.'/dav/fileserver.php">';
202$message .= '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">';
203$message .= ' '.img_picto('', 'globe');
204$message .= '</a>';
205$message .= '</div>';
206$message .= ajax_autoselect('webdavpublicurl');
207
208$message .= '<br>';
209if (getDolGlobalString('DAV_ALLOW_PUBLIC_DIR')) {
210 $urlEntity = (isModEnabled('multicompany') ? '?entity=' . $conf->entity : '');
211 $url = '<a href="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '" target="_blank" rel="noopener noreferrer">' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '</a>';
212
213 $message .= img_picto('', 'globe') . ' ' . str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', ''));
214 $message .= '<div class="urllink"><input type="text" id="webdavurl" class="quatrevingtpercent" value="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '">';
215 $message .= '<a href="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '" target="_blank" rel="noopener noreferrer">';
216 $message .= ' ' . img_picto('', 'globe');
217 $message .= '</a>';
218 $message .= '</div>';
219 $message .= ajax_autoselect('webdavurl');
220 $message .= '<br>';
221}
222print $message;
223
224print '<br>';
225
226require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
227$version = Sabre\DAV\Version::VERSION;
228print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
229
230
231// End of page
232llxFooter();
233$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
if(!defined('CDAV_CONTACT_TAG')) if(!defined( 'CDAV_URI_KEY')) dav_admin_prepare_head()
Prepare array with list of tabs.
Definition dav.lib.php:51
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.