3 * FusionForge Documentation Manager
5 * Copyright 2000, Quentin Cregan/Sourceforge
6 * Copyright 2002-2003, Tim Perdue/GForge, LLC
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2011, Roland Mas
9 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
10 * Copyright 2012-2016,2021, Franck Villaume - TrivialDev
11 * http://fusionforge.org
13 * This file is part of FusionForge. FusionForge is free software;
14 * you can redistribute it and/or modify it under the terms of the
15 * GNU General Public License as published by the Free Software
16 * Foundation; either version 2 of the Licence, or (at your option)
19 * FusionForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 /* please do not add require here : use www/docman/index.php to add require */
30 /* global variables used */
31 global $g; // group object
32 global $group_id; // id of the group
33 global $dirid; //id of the doc_group
34 global $dm; // the Document Manager object
35 global $HTML; // Layout object
38 global $childgroup_id;
41 $actionurl = DOCMAN_BASEURL.$group_id.'&action=addfile&dirid='.$dirid;
42 $redirecturl = DOCMAN_BASEURL.$group_id.'&view=listfile&dirid='.$dirid;
43 // plugin projects-hierarchy support
44 if (isset($childgroup_id) && $childgroup_id) {
45 $g = group_get_object($childgroup_id);
46 $actionurl .= '&childgroup_id='.$childgroup_id;
47 $redirecturl .= '&childgroup_id='.$childgroup_id;
50 $dgf = new DocumentGroupFactory($g);
51 if ($dgf->isError()) {
52 exit_error($dgf->getErrorMessage(), 'docman');
54 if (!forge_check_perm('docman', $group_id, 'submit')) {
55 $warning_msg = _('Document Manager Action Denied.');
56 session_redirect($redirecturl);
58 echo html_ao('script', array('type' => 'text/javascript'));
61 var controllerAddFile;
63 jQuery(document).ready(function() {
64 controllerAddFile = new DocManAddFileController({
65 fileRow: jQuery('#filerow'),
66 urlRow: jQuery('#urlrow'),
67 pathRow: jQuery('#pathrow'),
68 editRow: jQuery('#editrow'),
69 editNameRow: jQuery('#editnamerow'),
70 buttonFile: jQuery('#buttonFile'),
71 buttonUrl: jQuery('#buttonUrl'),
72 buttonManualUpload: jQuery('#buttonManualUpload'),
73 buttonEditor: jQuery('#buttonEditor')
79 echo html_ac(html_ap() - 1);
80 echo html_ao('div', array('class' => 'docmanDivIncluded'));
81 if ($dgf->getNested($stateidArr) == NULL) {
82 $dg = new DocumentGroup($g);
85 $error_msg = $dg->getErrorMessage();
86 session_redirect(DOCMAN_BASEURL.$group_id);
89 if ($dg->create(_('Uncategorized Submissions'))) {
90 session_redirect(DOCMAN_BASEURL.$group_id.'&view=additem');
93 echo $HTML->warning_msg(_('You MUST first create at least one folder to store your document.'));
95 /* display the add new documentation form */
96 echo $HTML->openForm(array('name' => 'adddata', 'action' => $actionurl, 'method' => 'post', 'enctype' => 'multipart/form-data'));
97 echo $HTML->listTableTop(array(), array(), 'infotable');
99 $cells[][] = _('Document Title').utils_requiredField();
100 $cells[][] = html_e('input', array('pattern' => '.{5,}', 'placeholder' => _('Document Title').' '.sprintf(_('(at least %s characters)'), DOCMAN_TITLE_MIN_SIZE), 'title' => _('Document Title')._(': ')._('Refers to the relatively brief title of the document (e.g. How to use the download server).'), 'type' => 'text', 'name' => 'title', 'size' => 40, 'maxlength' => DOCMAN_TITLE_MAX_SIZE, 'required' => 'required'));
101 echo $HTML->multiTableRow(array(), $cells);
103 $cells[][] = _('Description') .utils_requiredField();
104 $cells[][] = html_e('textarea', array('minlength' => 10, 'placeholder' => _('Description').' '.sprintf(_('(at least %s characters)'), DOCMAN_DESCRIPTION_MIN_SIZE), 'title' => util_gen_cross_ref_hints(), 'name' => 'description', 'rows' => 5, 'cols' => 50, 'maxlength' => DOCMAN_DESCRIPTION_MAX_SIZE, 'required' => 'required'), '', false);
105 echo $HTML->multiTableRow(array(), $cells);
107 $cells[][] = _('Comment');
108 $cells[][] = html_e('textarea', array('placeholder' => _('Add free comment'), 'name' => 'vcomment', 'rows' => 5, 'cols' => 50, 'maxlength' => DOCMAN_COMMENT_MAX_SIZE), '', false);
109 echo $HTML->multiTableRow(array(), $cells);
111 $cells[][] = _('Type of Document') .utils_requiredField();
112 $nextcell = html_e('input', array('type' => 'radio', 'id' => 'buttonFile', 'name' => 'type', 'value' => 'httpupload', 'checked' => 'checked', 'required' => 'required')).html_e('span', array(), _('File'), false).
113 html_e('input', array('type' => 'radio', 'id' => 'buttonUrl', 'name' => 'type', 'value' => 'pasteurl', 'required' => 'required')).html_e('span', array(), _('URL'), false);
114 if (forge_get_config('use_manual_uploads')) {
115 $nextcell .= html_e('input', array('type' => 'radio', 'id' => 'buttonManualUpload', 'name' => 'type', 'value' => 'manualupload', 'required' => 'required')).html_e('span', array(), _('Already-uploaded file'), false);
117 if ($g->useCreateOnline()) {
118 $nextcell .= html_e('input', array('type' => 'radio', 'id' => 'buttonEditor', 'name' => 'type', 'value' => 'editor', 'required' => 'required')).html_e('span', array(), _('Create online'), false);
120 $cells[][] = $nextcell;
121 echo $HTML->multiTableRow(array(), $cells);
123 $cells[][] = _('Upload File').utils_requiredField();
124 $cells[][] = html_e('input', array('type' => 'file', 'required' => 'required', 'name' => 'uploaded_data')).
125 html_e('span', array(), '('._('max upload size')._(': ').human_readable_bytes(util_get_maxuploadfilesize()).')', false);
126 echo $HTML->multiTableRow(array('id' => 'filerow'), $cells);
128 $cells[][] = _('URL').utils_requiredField();
129 $cells[][] = html_e('input', array('type' => 'url', 'name' => 'file_url', 'size' => '30', 'placeholder' => _('Enter a valid URL'), 'pattern' => 'ftp://.+|https?://.+'));
130 echo $HTML->multiTableRow(array('id' => 'urlrow', 'class' => 'hide'), $cells);
131 if (forge_get_config('use_manual_uploads')) {
133 $cells[][] = _('File').utils_requiredField();
134 $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming";
135 $manual_files_arr = ls($incoming, true);
136 if (count($manual_files_arr)) {
137 $cells[][] = html_build_select_box_from_arrays($manual_files_arr, $manual_files_arr, 'manual_path', '').
139 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).'),
140 'sftp://'.forge_get_config('shell_host').$incoming.'/', $incoming), false);
142 $cells[][] = html_e('p', array('class' => 'warning'), sprintf(_('You need first to upload file in %s'),$incoming), false);
144 echo $HTML->multiTableRow(array('id' => 'pathrow', 'class' => 'hide'), $cells);
147 $cells[][] = _('File Name').utils_requiredField();
148 $cells[][] = html_e('input', array('type' => 'text', 'name' => 'name', 'size' => '30'));
149 echo $HTML->multiTableRow(array('id' => 'editnamerow', 'class' => 'hide'), $cells);
150 echo html_ao('tr', array('id' => 'editrow', 'class' => 'hide'));
151 echo html_e('td', array(), _('Set the content to your file')._(':'));
152 $GLOBALS['editor_was_set_up'] = false;
154 /* name must be details !!! if name = data then nothing is displayed */
155 $params['name'] = 'details';
156 $params['height'] = "300";
157 $params['body'] = "";
158 $params['group'] = $group_id;
159 plugin_hook("text_editor", $params);
160 if (!$GLOBALS['editor_was_set_up']) {
161 echo html_e('td', array(), html_e('textarea', array('name' => 'details', 'rows' => 5, 'cols' => 80), '', false));
163 unset($GLOBALS['editor_was_set_up']);
164 echo html_ac(html_ap() - 1);
167 echo html_ao('td', array('colspan' => 2));
168 echo html_e('input', array('type' => 'hidden', 'name' => 'doc_group', 'value' => $dirid));
169 echo html_ac(html_ap() - 2);
172 $cells[][] = _('Folder that document belongs to');
173 $cells[][] = $dm->showSelectNestedGroups($dgf->getNested($stateidArr), 'doc_group', false, $dirid);
174 echo $HTML->multiTableRow(array(), $cells);
176 if (forge_check_perm('docman', $group_id, 'approve')) {
178 $cells[][] = _('Status of that document');
179 $cells[][] = doc_get_state_box('xzxz', array(2)); /** no direct deleted status */
180 echo $HTML->multiTableRow(array(), $cells);
182 echo $HTML->listTableBottom();
183 echo $HTML->addRequiredFieldsInfoBox();
184 if ($g->useDocmanSearch()) {
185 echo html_e('p', array(), _('Both fields Title & Description are used by the document search engine.'), false);
187 echo html_e('div', array('class' => 'docmanSubmitDiv'), html_e('input', array('type' => 'submit', 'name' => 'submit', 'value' => _('Submit Information'))));
188 echo $HTML->closeForm();
190 echo html_ac(html_ap() - 1);