* Copyright 2000, Quentin Cregan/Sourceforge
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010, Franck Villaume - Capgemini
+ * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, Franck Villaume - TrivialDev
+ * http://fusionforge.org
*
- * This file is part of FusionForge.
- *
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
$no_gz_buffer=true;
require_once $gfcommon.'docman/DocumentFactory.class.php';
require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
require_once $gfcommon.'docman/include/utils.php';
-require_once $gfcommon.'docman/include/webdav.php';
-
$arr=explode('/',getStringFromServer('REQUEST_URI'));
$group_id=$arr[3];
$docid=$arr[4];
-$g =& group_get_object($group_id);
+$g = group_get_object($group_id);
if (!$g || !is_object($g)) {
exit_no_group();
} elseif ($g->isError()) {
$filename = 'docman-'.$g->getUnixName().'-'.$docid.'.zip';
$file = forge_get_config('data_path').'/'.$filename;
$zip = new ZipArchive;
- if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE)) {
+ if ( !$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) {
exit_error(_('Unable to open zip archive for backup'),'docman');
}
- if ( !docman_fill_zip($zip,$nested_groups,$df))
- exit_error(_('Unable to fill zip archive for backup'),'docman');
+ if ( !docman_fill_zip($zip,$nested_groups,$df))
+ exit_error(_('Unable to fill zip archive for backup'),'docman');
if ( !$zip->close())
exit_error(_('Unable to close zip archive for backup'),'docman');
session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($warning_msg));
}
} else if ( $docid == 'webdav' ) {
- $_SERVER['SCRIPT_NAME'] = '';
- /* we need the group id for check authentification. */
- $_SERVER["AUTH_TYPE"] = $group_id;
- if (!isset($_SERVER['PHP_AUTH_USER'])) {
- header('WWW-Authenticate: Basic realm="Webdav Access" (For anonymous access : click enter)');
- header('HTTP/1.0 401 Unauthorized');
- echo _('Webdav Access Canceled by user');
- die();
+ if (forge_get_config('use_webdav') && $g->useWebDav()) {
+ require_once $gfcommon.'docman/include/webdav.php';
+ $_SERVER['SCRIPT_NAME'] = '';
+ /* we need the group id for check authentification. */
+ $_SERVER["AUTH_TYPE"] = $group_id;
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('WWW-Authenticate: Basic realm="Webdav Access" (For anonymous access : click enter)');
+ header('HTTP/1.0 401 Unauthorized');
+ echo _('Webdav Access Canceled by user');
+ die();
+ }
+ $server = new HTTP_WebDAV_Server_Docman;
+ $server->ServeRequest();
+ } else {
+ $warning_msg = _('No webdav interface enabled.');
+ session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($warning_msg));
}
- $server = new HTTP_WebDAV_Server_Docman;
- $server->ServeRequest();
} else {
exit_error(_('No document to display - invalid or inactive document number.'),'docman');
}