dolibarr 18.0.6
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
40
41
42$arrayofparameters = array(
43 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
44 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
45 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
46 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>isModEnabled('ecm'))
47);
48
49// To fix when dire does not exists
50dol_mkdir($conf->dav->dir_output.'/temp');
51dol_mkdir($conf->dav->dir_output.'/public');
52dol_mkdir($conf->dav->dir_output.'/private');
53
54
55/*
56 * Actions
57 */
58
59include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
60
61
62
63/*
64 * View
65 */
66
67$help_url = 'EN:Module_DAV';
68
69llxHeader('', $langs->trans("DAVSetup"), $help_url);
70
71$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
72print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
73
74
75print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
76print '<input type="hidden" name="token" value="'.newToken().'">';
77
79
80print dol_get_fiche_head($head, 'webdav', '', -1, '');
81
82if ($action == 'edit') {
83 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
84 print '<input type="hidden" name="token" value="'.newToken().'">';
85 print '<input type="hidden" name="action" value="update">';
86
87 print '<table class="noborder centpercent nomarginbottom">';
88 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
89
90 foreach ($arrayofparameters as $key => $val) {
91 if (isset($val['enabled']) && empty($val['enabled'])) {
92 continue;
93 }
94
95 print '<tr class="oddeven"><td>';
96 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
97 $label = $langs->trans($key);
98 if ($key == 'DAV_RESTICT_ON_IP') {
99 $label = $langs->trans("RESTRICT_ON_IP");
100 $tooltiphelp .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
101 }
102 print $form->textwithpicto($label, $tooltiphelp);
103 print '</td><td>';
104 if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
105 print $langs->trans("AlwaysActive");
106 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
107 print $form->selectyesno($key, getDolGlobalString($key), 1);
108 } else {
109 print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'">';
110 }
111 print '</td></tr>';
112 }
113
114 print '</table>';
115
116 print '<br><div class="center">';
117 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
118 print '</div>';
119
120 print '</form>';
121 print '<br>';
122} else {
123 print '<table class="noborder centpercent nomarginbottom">';
124 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
125
126 foreach ($arrayofparameters as $key => $val) {
127 if (isset($val['enabled']) && empty($val['enabled'])) {
128 continue;
129 }
130
131 print '<tr class="oddeven"><td>';
132 $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
133 $label = $langs->trans($key);
134 if ($key == 'DAV_RESTICT_ON_IP') {
135 $label = $langs->trans("RESTRICT_ON_IP");
136 $tooltiphelp .= ' <span class="opacitymedium">'.$langs->trans("Example").': '.$langs->trans("IPListExample").'</span>';
137 }
138 print $form->textwithpicto($label, $tooltiphelp);
139 print '</td><td class="minwidth200">';
140 if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
141 print $langs->trans("AlwaysActive");
142 } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
143 print yn(getDolGlobalString($key));
144 } else {
145 print getDolGlobalString($key);
146 }
147 print '</td></tr>';
148 }
149
150 print '</table>';
151
152 print '<div class="tabsAction">';
153 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
154 print '</div>';
155}
156
157
158print dol_get_fiche_end();
159
160/*print '<div class="center">';
161print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
162print "</div>";
163*/
164print "</form>\n";
165
166
167clearstatcache();
168
169print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n";
170print "<br>";
171
172
173// Define $urlwithroot
174$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
175$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
176//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
177
178
179// Show message
180$message = '';
181$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">'.$urlwithroot.'/dav/fileserver.php</a>';
182
183$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', ''));
184$message .= '<div class="urllink"><input type="text" id="webdavpublicurl" class="quatrevingtpercent" value="'.$urlwithroot.'/dav/fileserver.php">';
185$message .= '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">';
186$message .= ' '.img_picto('', 'globe');
187$message .= '</a>';
188$message .= '</div>';
189$message .= ajax_autoselect('webdavpublicurl');
190
191$message .= '<br>';
192if (getDolGlobalString('DAV_ALLOW_PUBLIC_DIR')) {
193 $urlEntity = (isModEnabled('multicompany') ? '?entity=' . $conf->entity : '');
194 $url = '<a href="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '" target="_blank" rel="noopener noreferrer">' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '</a>';
195
196 $message .= img_picto('', 'globe') . ' ' . str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', ''));
197 $message .= '<div class="urllink"><input type="text" id="webdavurl" class="quatrevingtpercent" value="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '">';
198 $message .= '<a href="' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . '" target="_blank" rel="noopener noreferrer">';
199 $message .= ' ' . img_picto('', 'globe');
200 $message .= '</a>';
201 $message .= '</div>';
202 $message .= ajax_autoselect('webdavurl');
203 $message .= '<br>';
204}
205print $message;
206
207print '<br>';
208
209require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
210$version = Sabre\DAV\Version::VERSION;
211print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
212
213
214// End of page
215llxFooter();
216$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:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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.