3 * FusionForge Documentation Manager
5 * Copyright 2010-2011, Franck Villaume - Capgemini
6 * Copyright 2012-2016,2021, Franck Villaume - TrivialDev
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 /* please do not add require here : use www/docman/index.php to add require */
26 /* global variables used */
27 global $group_id; // id of the group
28 global $dirid; // id of the doc_group
29 global $HTML; // Layout object
33 if (!forge_check_perm('docman', $group_id, 'submit')) {
34 $warning_msg = _('Document Manager Access Denied');
35 session_redirect(DOCMAN_BASEURL.$group_id);
38 $stateidArr = array(1);
39 if (forge_check_perm('docman', $group_id, 'approve')) {
43 echo html_ao('script', array('type' => 'text/javascript'));
46 var controllerAddItem;
48 jQuery(document).ready(function() {
49 controllerAddItem = new DocManAddItemController({
50 injectZip: jQuery('#injectzip'),
51 submitZip: jQuery('#submitinjectzip')
55 jQuery(document).ready(function() {
56 jQuery("#tabs").tabs();
60 echo html_ac(html_ap() - 1);
61 echo html_ao('div', array('id' => 'tabs'));
62 $elementsLi = array();
63 $elementsLi[] = array('content' => util_make_link('#tabs-new-document', _('New Document'), array('id' => 'tab-new-document', 'title' => _('Submit a new document in this folder.')), true));
64 if (forge_check_perm('docman', $group_id, 'approve')) {
65 $elementsLi[] = array('content' => util_make_link('#tabs-new-folder', _('New Folder'), array('id' => 'tab-new-folder', 'title' => _('Create a folder based on this name.')), true));
66 $elementsLi[] = array('content' => util_make_link('#tabs-inject-tree', _('Inject Tree'), array('id' => 'tab-inject-tree', 'title' => _('Create a full folders tree using an compressed archive. Only ZIP format support.')), true));
68 echo $HTML->html_list($elementsLi);
69 echo html_ao('div', array('id' => 'tabs-new-document'));
70 echo html_ao('div', array('class' => 'docman_div_include', 'id' => 'addfile'));
71 include ($gfcommon.'docman/views/addfile.php');
72 echo html_ac(html_ap() -2);
74 if (forge_check_perm('docman', $group_id, 'approve')) {
75 echo html_ao('div', array('id' => 'tabs-new-folder'));
76 echo html_ao('div', array('class' => 'docman_div_include', 'id' => 'addsubdocgroup'));
77 include ($gfcommon.'docman/views/addsubdocgroup.php');
78 echo html_ac(html_ap() -2);
79 echo html_ao('div', array('id' => 'tabs-inject-tree'));
80 echo html_ao('div', array('class' => 'docman_div_include', 'id' => 'zipinject'));
81 if ($dgf->getNested($stateidArr) == NULL) {
82 echo $HTML->warning_msg(_('You MUST first create at least one folder to upload your archive.'));
84 echo $HTML->openForm(array('id' => 'injectzip', 'name' => 'injectzip', 'method' => 'post', 'action' => DOCMAN_BASEURL.$group_id.'&action=injectzip&dirid='.$dirid, 'enctype' => 'multipart/form-data'));
85 if (forge_get_config('use_manual_uploads')) {
86 echo html_e('input', array('type' => 'radio', 'id' => 'buttonFileZip', 'name' => 'type', 'value' => 'httpupload', 'checked' => 'checked', 'required' => 'required')).html_e('span', array(), _('File'), false);
87 echo html_e('input', array('type' => 'radio', 'id' => 'buttonManualUploadZip', 'name' => 'type', 'value' => 'manualupload', 'required' => 'required')).html_e('span', array(), _('Already-uploaded file'), false);
89 echo html_e('input', array('type' => 'hidden', 'name' => 'type', 'value' => 'httpupload'));
91 echo html_e('div', array('id' => 'upload_zip_p'), html_e('input', array('type' => 'file', 'id' => 'uploaded_zip', 'name' => 'uploaded_zip', 'required' => 'required')).
92 html_e('span', array(), '('._('max upload size')._(': ').human_readable_bytes(util_get_maxuploadfilesize()).')', false));
93 if (forge_get_config('use_manual_uploads')) {
94 $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming";
95 $manual_files_arr = ls($incoming, true, '/\.zip$/');
96 if (count($manual_files_arr)) {
97 echo html_e('div', array('id' => 'manual_upload_p'), html_build_select_box_from_arrays($manual_files_arr, $manual_files_arr, 'manual_path', '').
99 html_e('span', array(), sprintf(_('Pick a file already uploaded (by SFTP or SCP) to the <a href="%1$s">project\'s incoming directory</a> (%2$s).'),
100 'sftp://'.forge_get_config('shell_host').$incoming.'/', $incoming), false));
102 echo $HTML->warning_msg(sprintf(_('You need first to upload file in %s'), $incoming), array('id' => 'manual_upload_p'));
104 $javascript = <<<'EOS'
105 jQuery('#manual_upload_p').hide();
106 jQuery('#buttonFileZip').click(function() {
107 jQuery('#upload_zip_p').show();
108 jQuery('#uploaded_zip').attr('required', 'required');
109 jQuery('#manual_upload_p').hide();
111 jQuery('#buttonManualUploadZip').click(function() {
112 jQuery('#upload_zip_p').hide();
113 jQuery('#uploaded_zip').removeAttr('required');
114 jQuery('#manual_upload_p').show();
118 echo html_e('script', array( 'type'=>'text/javascript'), '//<![CDATA['."\n".'jQuery(function(){'.$javascript.'});'."\n".'//]]>');
120 echo html_e('p', array(), html_e('input', array('id' => 'submitinjectzip', 'type' => 'button', 'value' => _('Inject Tree'))));
121 echo $HTML->closeForm();
123 echo html_ac(html_ap() -2);
126 echo html_ac(html_ap() -1);