dolibarr  16.0.5
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 require '../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
26 require_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 
31 if (!$user->admin) {
33 }
34 
35 // Parameters
36 $action = GETPOST('action', 'aZ09');
37 $backtopage = GETPOST('backtopage', 'alpha');
38 
39 
40 
41 $arrayofparameters = array(
42  'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
43  'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
44  'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
45  'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
46 );
47 
48 // To fix when dire does not exists
49 dol_mkdir($conf->dav->dir_output.'/temp');
50 dol_mkdir($conf->dav->dir_output.'/public');
51 dol_mkdir($conf->dav->dir_output.'/private');
52 
53 
54 /*
55  * Actions
56  */
57 
58 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
59 
60 
61 
62 /*
63  * View
64  */
65 
66 $help_url = 'EN:Module_DAV';
67 
68 llxHeader('', $langs->trans("DAVSetup"), $help_url);
69 
70 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
71 print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
72 
73 
74 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
75 print '<input type="hidden" name="token" value="'.newToken().'">';
76 
77 $head = dav_admin_prepare_head();
78 
79 print dol_get_fiche_head($head, 'webdav', '', -1, 'action');
80 
81 if ($action == 'edit') {
82  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
83  print '<input type="hidden" name="token" value="'.newToken().'">';
84  print '<input type="hidden" name="action" value="update">';
85 
86  print '<table class="noborder centpercent">';
87  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
88 
89  foreach ($arrayofparameters as $key => $val) {
90  if (isset($val['enabled']) && empty($val['enabled'])) {
91  continue;
92  }
93 
94  print '<tr class="oddeven"><td>';
95  $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
96  $label = $langs->trans($key);
97  if ($key == 'DAV_RESTICT_ON_IP') {
98  $label = $langs->trans("RESTRICT_ON_IP");
99  $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
100  }
101  print $form->textwithpicto($label, $tooltiphelp);
102  print '</td><td>';
103  if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
104  print $langs->trans("AlwaysActive");
105  } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
106  print $form->selectyesno($key, $conf->global->$key, 1);
107  } else {
108  print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'">';
109  }
110  print '</td></tr>';
111  }
112 
113  print '</table>';
114 
115  print '<br><div class="center">';
116  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
117  print '</div>';
118 
119  print '</form>';
120  print '<br>';
121 } else {
122  print '<table class="noborder centpercent">';
123  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
124 
125  foreach ($arrayofparameters as $key => $val) {
126  print '<tr class="oddeven"><td class="titlefieldmiddle">';
127  $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
128  $label = $langs->trans($key);
129  if ($key == 'DAV_RESTICT_ON_IP') {
130  $label = $langs->trans("RESTRICT_ON_IP");
131  $label .= ' <span class="opacitymedium">'.$langs->trans("Example").': '.$langs->trans("IPListExample").'</span>';
132  }
133  print $form->textwithpicto($label, $tooltiphelp);
134  print '</td><td>';
135  if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
136  print $langs->trans("AlwaysActive");
137  } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
138  print yn($conf->global->$key);
139  } else {
140  print $conf->global->$key;
141  }
142  print '</td></tr>';
143  }
144 
145  print '</table>';
146 
147  print '<div class="tabsAction">';
148  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
149  print '</div>';
150 }
151 
152 
153 print dol_get_fiche_end();
154 
155 /*print '<div class="center">';
156 print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
157 print "</div>";
158 */
159 print "</form>\n";
160 
161 
162 clearstatcache();
163 
164 print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n";
165 print "<br>";
166 
167 
168 // Define $urlwithroot
169 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
170 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
171 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
172 
173 
174 // Show message
175 $message = '';
176 $url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">'.$urlwithroot.'/dav/fileserver.php</a>';
177 
178 $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', ''));
179 $message .= '<div class="urllink"><input type="text" id="webdavpublicurl" class="quatrevingtpercent" value="'.$urlwithroot.'/dav/fileserver.php">';
180 $message .= '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank" rel="noopener noreferrer">';
181 $message .= ' '.img_picto('', 'globe');
182 $message .= '</a>';
183 $message .= '</div>';
184 $message .= ajax_autoselect('webdavpublicurl');
185 
186 $message .= '<br>';
187 if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) {
188  $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
189  $url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank" rel="noopener noreferrer">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
190 
191  $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', ''));
192  $message .= '<div class="urllink"><input type="text" id="webdavurl" class="quatrevingtpercent" value="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'">';
193  $message .= '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank" rel="noopener noreferrer">';
194  $message .= ' '.img_picto('', 'globe');
195  $message .= '</a>';
196  $message .= '</div>';
197  $message .= ajax_autoselect('webdavurl');
198  $message .= '<br>';
199 }
200 print $message;
201 
202 print '<br>';
203 
204 require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
205 $version = Sabre\DAV\Version::VERSION;
206 print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
207 
208 
209 // End of page
210 llxFooter();
211 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
ajax_autoselect
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
Definition: functions.lib.php:9681
dav_admin_prepare_head
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
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59