$description = getStringFromRequest('description');
$file_url = getStringFromRequest('file_url');
$uploaded_data = getUploadedFile('uploaded_data');
+$uploaded_filename = getUploadedFile('uploaded_filename');
+$manual_path = getStringFromRequest('manual_path');
$type = getStringFromRequest('type');
$name = getStringFromRequest('name');
$uploaded_data_name = $uploaded_data['name'];
break;
}
+ case 'manualupload' : {
+ if (!forge_get_config('use_manual_uploads')) {
+ $return_msg = _('Manual uploads disabled.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+ }
+
+ $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
+ $filename = $incoming.'/'.$manual_path;
+
+ if (!util_is_valid_filename($manual_path) || !is_file($filename)) {
+ $return_msg = _('Invalid file name.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+ }
+
+ if (function_exists('finfo_open')) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $uploaded_data_type = finfo_file($finfo, $filename);
+ } else {
+ $uploaded_data_type = 'application/binary';
+ }
+ $stat = stat($filename);
+ $data = fread(fopen($filename, 'r'), $stat['size']);
+ $file_url = '';
+ $uploaded_data_name = $manual_path;
+ break;
+ }
default: {
$return_msg = _('Unknown type submission.');
session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
function displayRowFile() {
document.getElementById('filerow').style.display = '';
document.getElementById('urlrow').style.display = 'none';
+ document.getElementById('pathrow').style.display = 'none';
document.getElementById('editrow').style.display = 'none';
document.getElementById('editnamerow').style.display = 'none';
}
function displayRowUrl() {
document.getElementById('filerow').style.display = 'none';
document.getElementById('urlrow').style.display = '';
+ document.getElementById('pathrow').style.display = 'none';
document.getElementById('editrow').style.display = 'none';
document.getElementById('editnamerow').style.display = 'none';
}
function displayRowEditor() {
document.getElementById('filerow').style.display = 'none';
document.getElementById('urlrow').style.display = 'none';
+ document.getElementById('pathrow').style.display = 'none';
document.getElementById('editrow').style.display = '';
document.getElementById('editnamerow').style.display = '';
}
+ function displayRowManual() {
+ document.getElementById('filerow').style.display = 'none';
+ document.getElementById('urlrow').style.display = 'none';
+ document.getElementById('pathrow').style.display = '';
+ document.getElementById('editrow').style.display = 'none';
+ document.getElementById('editnamerow').style.display = 'none';
+ }
</script>
<?php
echo '<p><strong>'. _('Document Title:') .'</strong> '. _('Refers to the relatively brief title of the document (e.g. How to use the download server).'). '</p>';
<strong>'. _('Type of Document') .'</strong>'.utils_requiredField()
.'</td><td>
<input type="radio" name="type" value="httpupload" onClick="javascript:displayRowFile()" />'. _('File') .'<input type="radio" name="type" value="pasteurl" onClick="javascript:displayRowUrl()" />'. _('URL');
+ if (forge_get_config('use_manual_uploads')) {
+ echo '<input type="radio" name="type" value="manualupload" onClick="javascript:displayRowManual()" />'. _('Already-uploaded file');
+ }
if ($g->useCreateOnline()) {
echo '<input type="radio" name="type" value="editor" onClick="javascript:displayRowEditor()" />'. _('Create online');
}
.' <input type="text" name="file_url" size="30" />
</td>
</tr>
+ <tr id="pathrow" style="display:none">
+ <td style="text-align:right;">
+ <strong>'. _('File') .'</strong>'. utils_requiredField() . '</td><td>';
+
+ $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
+ $manual_files_arr=ls($incoming,true);
+ echo html_build_select_box_from_arrays($manual_files_arr,$manual_files_arr,'manual_path','');
+ echo '<br />';
+ printf(_('Pick a file already uploaded (by SFTP or SCP) to the <a href="%2$s">project\'s incoming directory</a> (%1$s).'),
+ $incoming, "sftp://" . forge_get_config ('web_host') . $incoming . "/");
+ echo '
+ </td>
+ </tr>
<tr id="editnamerow" style="display:none">
<td style="text-align:right;">
<strong>'. _('File Name') .'</strong>'. utils_requiredField()