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-2013, 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
35 // plugin projects-hierarchy
36 $actionurl = '?group_id='.$group_id.'&action=addfile&dirid='.$dirid;
37 $redirecturl = '/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid;
38 if (isset($childgroup_id) && $childgroup_id) {
39 $g = group_get_object($childgroup_id);
40 $actionurl .= '&childgroup_id='.$childgroup_id;
41 $redirecturl .= '&childgroup_id='.$childgroup_id;
44 $dgf = new DocumentGroupFactory($g);
46 exit_error($dgf->getErrorMessage(), 'docman');
48 $dgh = new DocumentGroupHTML($g);
50 exit_error($dgh->getErrorMessage(), 'docman');
52 if (!forge_check_perm('docman', $group_id, 'submit')) {
53 $return_msg = _('Document Manager Action Denied.');
54 session_redirect($redirecturl.'&warning_msg='.urlencode($return_msg));
58 <script type="text/javascript">//<![CDATA[
59 var controllerAddFile;
61 jQuery(document).ready(function() {
62 controllerAddFile = new DocManAddFileController({
63 fileRow: jQuery('#filerow'),
64 urlRow: jQuery('#urlrow'),
65 pathRow: jQuery('#pathrow'),
66 editRow: jQuery('#editrow'),
67 editNameRow: jQuery('#editnamerow'),
68 buttonFile: jQuery('#buttonFile'),
69 buttonUrl: jQuery('#buttonUrl'),
70 buttonManualUpload: jQuery('#buttonManualUpload'),
71 buttonEditor: jQuery('#buttonEditor')
77 echo '<div class="docmanDivIncluded">';
78 if ($dgf->getNested() == NULL) {
79 $dg = new DocumentGroup($g);
82 session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($dg->getErrorMessage()));
84 if ($dg->create('Uncategorized Submissions')) {
85 session_redirect('/docman/?group_id='.$group_id.'&view=additem');
88 echo '<div class="warning">'. _('You MUST first create at least one folder to store your document.') .'</div>';
90 /* display the add new documentation form */
91 echo '<p><strong>'. _('Document Title')._(': ').'</strong> '. _('Refers to the relatively brief title of the document (e.g. How to use the download server).'). '</p>';
92 echo '<p><strong>'. _('Description')._(': ').'</strong> '. _('A brief description to be placed just under the title.') .'</p>';
93 if ($g->useDocmanSearch())
94 echo '<p>'._('Both fields are used by the document search engine.').'</p>';
96 echo '<form name="adddata" action="'.$actionurl.'" method="post" enctype="multipart/form-data">';
97 echo '<table class="infotable">
100 '. _('Document Title').utils_requiredField()
102 .'<input pattern=".{5,}" placeholder="'._('Document Title').'" title="'.sprintf(_('(at least %1$s characters)'), 5).'" type="text" name="title" size="40" maxlength="255" required="required" /> '
103 .sprintf(_('(at least %1$s characters)'), 5)
108 '. _('Description') .utils_requiredField()
110 .'<input pattern=".{10,}" placeholder="'._('Description').'" title="'.sprintf(_('(at least %1$s characters)'), 10).'" type="text" name="description" size="50" maxlength="255" required="required" /> '
111 .sprintf(_('(at least %1$s characters)'), 10)
116 '. _('Type of Document') .utils_requiredField()
118 <input type="radio" id="buttonFile" name="type" value="httpupload" checked="checked" required="required" />'. _('File') .
119 '<input type="radio" id="buttonUrl" name="type" value="pasteurl" required="required" />'. _('URL');
120 if (forge_get_config('use_manual_uploads')) {
121 echo '<input type="radio" id="buttonManualUpload" name="type" value="manualupload" required="required" />'. _('Already-uploaded file');
123 if ($g->useCreateOnline()) {
124 echo '<input type="radio" id="buttonEditor" name="type" value="editor" required="required" />'. _('Create online');
130 '. _('Upload File') .utils_requiredField()
132 .'<input type="file" required="required" name="uploaded_data" size="30" />'.sprintf(_('(max upload size: %1$s)'),human_readable_bytes(util_get_maxuploadfilesize())).'
135 <tr id="urlrow" style="display:none">
137 '. _('URL') . utils_requiredField()
139 .'<input type="url" name="file_url" size="30" placeholder="'._('Enter a valid URL').'" pattern="ftp://.+|https?://.+" />
142 <tr id="pathrow" style="display:none">
144 '. _('File') . utils_requiredField() . '</td><td>';
146 $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming";
147 $manual_files_arr = ls($incoming, true);
148 if (count($manual_files_arr)) {
149 echo html_build_select_box_from_arrays($manual_files_arr, $manual_files_arr, 'manual_path', '');
151 printf(_('Pick a file already uploaded (by SFTP or SCP) to the <a href="%2$s">project\'s incoming directory</a> (%1$s).'),
152 $incoming, "sftp://" . forge_get_config('web_host') . $incoming . "/");
157 echo ' <p class="warning">';
158 printf(_('You need first to upload file in %s'),$incoming);
163 echo ' <tr id="editnamerow" style="display:none">
165 '. _('File Name') . utils_requiredField()
167 .'<input type="text" name="name" size="30" />
170 <tr id="editrow" style="display:none">
172 $GLOBALS['editor_was_set_up'] = false;
174 /* name must be details !!! if name = data then nothing is displayed */
175 $params['name'] = 'details';
176 $params['height'] = "300";
177 $params['body'] = "";
178 $params['group'] = $group_id;
179 plugin_hook("text_editor", $params);
180 if (!$GLOBALS['editor_was_set_up']) {
181 echo '<textarea name="details" rows="5" cols="80"></textarea>';
183 unset($GLOBALS['editor_was_set_up']);
188 echo ' <tr><td colspan="2"><input type="hidden" name="doc_group" value="'.$dirid.'"></td></tr>';
193 '. _('Documents folder that document belongs in').'
195 $dgh->showSelectNestedGroups($dgf->getNested(), 'doc_group', false, $dirid);
200 if (forge_check_perm('docman', $group_id, 'approve')) {
204 '. _('Status of that document').'
206 doc_get_state_box('xzxz', 2); /**no direct deleted status */
212 echo '<span>'.utils_requiredField() .' '. _('Mandatory fields').'</span>';
213 echo ' <div class="docmanSubmitDiv">
214 <input type="submit" name="submit" value="'. _('Submit Information'). '" />