dolibarr 20.0.0
dav.php
Go to the documentation of this file.
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
24// Load Dolibarr environment
25require '../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
28
29// Load translation files required by the page
30$langs->loadLangs(array("admin", "other", "agenda"));
31
32if (!$user->admin) {
34}
35
36// Parameters
37$action = GETPOST('action', 'aZ09');
38$backtopage = GETPOST('backtopage', 'alpha');
39
40if (empty($action)) {
41 $action = 'edit';
42}
43
44$arrayofparameters = array(
45 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
46 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
47 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
48 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>isModEnabled('ecm'))
49);
50
51// To fix when dire does not exists
52dol_mkdir($conf->dav->dir_output.'/temp');
53dol_mkdir($conf->dav->dir_output.'/public');
54dol_mkdir($conf->dav->dir_output.'/private');
55
56
57/*
58 * Actions
59 */
60
61include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
62
63if ($action == 'update') {
64 $action = 'edit';
65}
66
67
68/*
69 * View
70 */
71
72$help_url = 'EN:Module_DAV';
73
74llxHeader('', $langs->trans("DAVSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-dav');
75
76$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
77print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
78
79
80print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
81print '<input type="hidden" name="token" value="'.newToken().'">';
82
84
85print dol_get_fiche_head($head, 'webdav', '', -1, '');
86
87if ($action == 'edit') {
88 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
89 print '<input type="hidden" name="token" value="'.newToken().'">';
90 print '<input type="hidden" name="action" value="update">';
91
92 print '<table class="noborder centpercent nomarginbottom">';
93 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
94
95 foreach ($arrayofparameters as $key => $val) {
96 if (isset($val['enabled']) && empty($val['enabled'])) {
97 continue;
98 }
99
100 print '<tr class="oddeven"><td>';
101 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
102 $label = $langs->trans($key);
103 if ($key == 'DAV_RESTICT_ON_IP') {
104 $label = $langs->trans("RESTRICT_ON_IP");
105 $tooltiphelp .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
106 }
107 print $form->textwithpicto($label, $tooltiphelp);
108 print '</td><td>';
109 if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
110 print $langs->trans("AlwaysActive");
111 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
112 print $form->selectyesno($key, getDolGlobalString($key), 1);
113 } else {
114 print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'">';
115 }
116 print '</td></tr>';
117 }
118
119 print '</table>';
120
121 print '<br><div class="center">';
122 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
123 print '</div>';
124
125 print '</form>';
126 print '<br>';
127} else {
128 print '<table class="noborder centpercent nomarginbottom">';
129 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
130
131 foreach ($arrayofparameters as $key => $val) {
132 if (isset($val['enabled']) && empty($val['enabled'])) {
133 continue;
134 }
135
136 print '<tr class="oddeven"><td>';
137 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
138 $label = $langs->trans($key);
139 if ($key == 'DAV_RESTICT_ON_IP') {
140 $label = $langs->trans("RESTRICT_ON_IP");
141 $tooltiphelp .= ' <span class="opacitymedium">'.$langs->trans("Example").': '.$langs->trans("IPListExample").'</span>';
142 }
143 print $form->textwithpicto($label, $tooltiphelp);
144 print '</td><td class="minwidth200">';
145 if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
146 print $langs->trans("AlwaysActive");
147 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
148 print yn(getDolGlobalString($key));
149 } else {
150 print getDolGlobalString($key);
151 }
152 print '</td></tr>';
153 }
154
155 print '</table>';
156
157 print '<div class="tabsAction">';
158 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
159 print '</div>';
160}
161
162
163print dol_get_fiche_end();
164
165/*print '<div class="center">';
166print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
167print "</div>";
168*/
169print "</form>\n";
170
171
172clearstatcache();
173
174print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n";
175print "<br>";
176
177
178// Define $urlwithroot
179$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
180$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
181//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
182
183
184// Show message
185$message = '';
186$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">'.$urlwithroot.'/dav/fileserver.php</a>';
187
188$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', ''));
189$message .= '<div class="urllink"><input type="text" id="webdavpublicurl" class="quatrevingtpercent" value="'.$urlwithroot.'/dav/fileserver.php">';
190$message .= '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">';
191$message .= ' '.img_picto('', 'globe');
192$message .= '</a>';
193$message .= '</div>';
194$message .= ajax_autoselect('webdavpublicurl');
195
196$message .= '<br>';
197if (getDolGlobalString('DAV_ALLOW_PUBLIC_DIR')) {
198 $urlEntity = (isModEnabled('multicompany') ? '?entity=' . $conf->entity : '');
199 $url = '<a href="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '" target="_blank" rel="noopener noreferrer">' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '</a>';
200
201 $message .= img_picto('', 'globe') . ' ' . str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', ''));
202 $message .= '<div class="urllink"><input type="text" id="webdavurl" class="quatrevingtpercent" value="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '">';
203 $message .= '<a href="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '" target="_blank" rel="noopener noreferrer">';
204 $message .= ' ' . img_picto('', 'globe');
205 $message .= '</a>';
206 $message .= '</div>';
207 $message .= ajax_autoselect('webdavurl');
208 $message .= '<br>';
209}
210print $message;
211
212print '<br>';
213
214require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
215$version = Sabre\DAV\Version::VERSION;
216print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
217
218
219// End of page
220llxFooter();
221$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
if(!defined('CDAV_CONTACT_TAG')) if(!defined( 'CDAV_URI_KEY')) dav_admin_prepare_head()
Prepare array with list of tabs.
Definition dav.lib.php:50
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)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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'.
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 dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.