[Fusionforge-commits] r12157 - in branches/Branch_5_1/src/common/docman: actions views

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Feb 4 14:43:57 CET 2011


Author: lolando
Date: 2011-02-04 14:43:56 +0100 (Fri, 04 Feb 2011)
New Revision: 12157

Modified:
   branches/Branch_5_1/src/common/docman/actions/addfile.php
   branches/Branch_5_1/src/common/docman/views/addfile.php
Log:
Manual uploads (SCP/SFTP) for the docman

Modified: branches/Branch_5_1/src/common/docman/actions/addfile.php
===================================================================
--- branches/Branch_5_1/src/common/docman/actions/addfile.php	2011-02-04 13:35:57 UTC (rev 12156)
+++ branches/Branch_5_1/src/common/docman/actions/addfile.php	2011-02-04 13:43:56 UTC (rev 12157)
@@ -38,6 +38,8 @@
 $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');
 
@@ -115,6 +117,32 @@
 		$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));

Modified: branches/Branch_5_1/src/common/docman/views/addfile.php
===================================================================
--- branches/Branch_5_1/src/common/docman/views/addfile.php	2011-02-04 13:35:57 UTC (rev 12156)
+++ branches/Branch_5_1/src/common/docman/views/addfile.php	2011-02-04 13:43:56 UTC (rev 12157)
@@ -43,21 +43,31 @@
 	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>';
@@ -89,6 +99,9 @@
 						<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');
 			}
@@ -108,6 +121,19 @@
 						.' <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()




More information about the Fusionforge-commits mailing list