dolibarr  13.0.2
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 // 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 
52 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
53 
54 
55 
56 /*
57  * View
58  */
59 
60 
61 llxHeader('', $langs->trans("DAVSetup"), $wikihelp);
62 
63 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
64 print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
65 
66 
67 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
68 print '<input type="hidden" name="token" value="'.newToken().'">';
69 
70 $head = dav_admin_prepare_head();
71 
72 print dol_get_fiche_head($head, 'webdav', '', -1, 'action');
73 
74 if ($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 
152 
153 /*print '<div class="center">';
154 print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
155 print "</div>";
156 */
157 print "</form>\n";
158 
159 
160 clearstatcache();
161 
162 print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n";
163 print "<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>';
177 if (!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 }
184 print $message;
185 
186 print '<br><br><br>';
187 
188 require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
189 $version = Sabre\DAV\Version::VERSION;
190 print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
191 
192 
193 // End of page
194 llxFooter();
195 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if(!defined('CDAV_CONTACT_TAG')) if(!defined('CDAV_URI_KEY')) dav_admin_prepare_head()
Prepare array with list of tabs.
Definition: dav.lib.php:48
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)) $wikihelp
View.
Definition: agenda.php:120
llxHeader()
Empty header.
Definition: wrapper.php:45
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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 ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59