dav.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /* Copyright (C) 2008-2018 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 <http://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_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
  34. 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
  35. );
  36. /*
  37. * Actions
  38. */
  39. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  40. /*
  41. * View
  42. */
  43. llxHeader('', $langs->trans("DAVSetup"), $wikihelp);
  44. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  45. print load_fiche_titre($langs->trans("DAVSetup"),$linkback,'title_setup');
  46. print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  47. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  48. $head=dav_admin_prepare_head();
  49. dol_fiche_head($head, 'webdav', '', -1, 'action');
  50. if ($action == 'edit')
  51. {
  52. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  53. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  54. print '<input type="hidden" name="action" value="update">';
  55. print '<table class="noborder" width="100%">';
  56. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  57. foreach($arrayofparameters as $key => $val)
  58. {
  59. if (isset($val['enabled']) && empty($val['enabled'])) continue;
  60. print '<tr class="oddeven"><td>';
  61. print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
  62. print '</td><td>';
  63. if ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR')
  64. {
  65. print $form->selectyesno($key, $conf->global->$key, 1);
  66. }
  67. else
  68. {
  69. print '<input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '">';
  70. }
  71. print '</td></tr>';
  72. }
  73. print '</table>';
  74. print '<br><div class="center">';
  75. print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
  76. print '</div>';
  77. print '</form>';
  78. print '<br>';
  79. }
  80. else
  81. {
  82. print '<table class="noborder" width="100%">';
  83. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  84. foreach($arrayofparameters as $key => $val)
  85. {
  86. print '<tr class="oddeven"><td>';
  87. print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
  88. print '</td><td>';
  89. if ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR')
  90. {
  91. print yn($conf->global->$key);
  92. }
  93. else
  94. {
  95. print $conf->global->$key;
  96. }
  97. print '</td></tr>';
  98. }
  99. print '</table>';
  100. print '<div class="tabsAction">';
  101. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  102. print '</div>';
  103. }
  104. dol_fiche_end();
  105. /*print '<div class="center">';
  106. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  107. print "</div>";
  108. */
  109. print "</form>\n";
  110. clearstatcache();
  111. print $langs->trans("WebDAVSetupDesc")."<br>\n";
  112. print "<br>";
  113. // Define $urlwithroot
  114. $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  115. $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  116. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  117. // Show message
  118. $message='';
  119. $url='<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
  120. $message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url);
  121. $message.='<br>';
  122. print $message;
  123. // End of page
  124. llxFooter();
  125. $db->close();