dav.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. /**
  18. * \file htdocs/admin/dav.php
  19. * \ingroup dav
  20. * \brief Page to setup DAV server
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
  25. // Load translation files required by the page
  26. $langs->loadLangs(array("admin", "other", "agenda"));
  27. if (!$user->admin)
  28. accessforbidden();
  29. // Parameters
  30. $action = GETPOST('action', 'alpha');
  31. $backtopage = GETPOST('backtopage', 'alpha');
  32. $arrayofparameters = array(
  33. 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
  34. 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
  35. 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
  36. 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
  37. );
  38. /*
  39. * Actions
  40. */
  41. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  42. /*
  43. * View
  44. */
  45. llxHeader('', $langs->trans("DAVSetup"), $wikihelp);
  46. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  47. print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
  48. print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  49. print '<input type="hidden" name="token" value="'.newToken().'">';
  50. $head = dav_admin_prepare_head();
  51. dol_fiche_head($head, 'webdav', '', -1, 'action');
  52. if ($action == 'edit')
  53. {
  54. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  55. print '<input type="hidden" name="token" value="'.newToken().'">';
  56. print '<input type="hidden" name="action" value="update">';
  57. print '<table class="noborder centpercent">';
  58. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  59. foreach ($arrayofparameters as $key => $val)
  60. {
  61. if (isset($val['enabled']) && empty($val['enabled'])) continue;
  62. print '<tr class="oddeven"><td>';
  63. $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
  64. $label = $langs->trans($key);
  65. if ($key == 'DAV_RESTICT_ON_IP') {
  66. $label = $langs->trans("RESTRICT_ON_IP");
  67. $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
  68. }
  69. print $form->textwithpicto($label, $tooltiphelp);
  70. print '</td><td>';
  71. if ($key == 'DAV_ALLOW_PRIVATE_DIR')
  72. {
  73. print $langs->trans("AlwaysActive");
  74. }
  75. elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR')
  76. {
  77. print $form->selectyesno($key, $conf->global->$key, 1);
  78. }
  79. else
  80. {
  81. print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
  82. }
  83. print '</td></tr>';
  84. }
  85. print '</table>';
  86. print '<br><div class="center">';
  87. print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
  88. print '</div>';
  89. print '</form>';
  90. print '<br>';
  91. }
  92. else
  93. {
  94. print '<table class="noborder centpercent">';
  95. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  96. foreach ($arrayofparameters as $key => $val)
  97. {
  98. print '<tr class="oddeven"><td>';
  99. $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
  100. $label = $langs->trans($key);
  101. if ($key == 'DAV_RESTICT_ON_IP') {
  102. $label = $langs->trans("RESTRICT_ON_IP");
  103. $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
  104. }
  105. print $form->textwithpicto($label, $tooltiphelp);
  106. print '</td><td>';
  107. if ($key == 'DAV_ALLOW_PRIVATE_DIR')
  108. {
  109. print $langs->trans("AlwaysActive");
  110. }
  111. elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR')
  112. {
  113. print yn($conf->global->$key);
  114. }
  115. else
  116. {
  117. print $conf->global->$key;
  118. }
  119. print '</td></tr>';
  120. }
  121. print '</table>';
  122. print '<div class="tabsAction">';
  123. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  124. print '</div>';
  125. }
  126. dol_fiche_end();
  127. /*print '<div class="center">';
  128. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  129. print "</div>";
  130. */
  131. print "</form>\n";
  132. clearstatcache();
  133. print '<span class="opacitymedium">'.$langs->trans("WebDAVSetupDesc")."</span><br>\n";
  134. print "<br>";
  135. // Define $urlwithroot
  136. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  137. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  138. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  139. // Show message
  140. $message = '';
  141. $url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
  142. $message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url);
  143. $message .= '<br>';
  144. if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
  145. {
  146. $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
  147. $url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
  148. $message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url);
  149. $message .= '<br>';
  150. }
  151. print $message;
  152. print '<br><br><br>';
  153. require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
  154. $version = Sabre\DAV\Version::VERSION;
  155. print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
  156. // End of page
  157. llxFooter();
  158. $db->close();