[Fusionforge-commits] r11682 - in trunk/src/common/docman: . actions

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Dec 1 15:25:25 CET 2010


Author: nerville
Date: 2010-12-01 15:25:25 +0100 (Wed, 01 Dec 2010)
New Revision: 11682

Modified:
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/actions/injectzip.php
Log:
start implement injectZip method in dg object

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2010-12-01 13:39:45 UTC (rev 11681)
+++ trunk/src/common/docman/DocumentGroup.class.php	2010-12-01 14:25:25 UTC (rev 11682)
@@ -189,6 +189,16 @@
 	}
 
 	/**
+	 * injectZip - unzip the attachment and create the directory tree if needed
+	 *
+	 * @param	array	uploaded data
+	 * @return	boolean	success or not
+	 */
+	function injectZip($uploaded_data) {
+		return true;
+	}
+
+	/**
 	 * fetchData - re-fetch the data for this DocumentGroup from the database.
 	 *
 	 * @param	int	ID of the doc_group.

Modified: trunk/src/common/docman/actions/injectzip.php
===================================================================
--- trunk/src/common/docman/actions/injectzip.php	2010-12-01 13:39:45 UTC (rev 11681)
+++ trunk/src/common/docman/actions/injectzip.php	2010-12-01 14:25:25 UTC (rev 11682)
@@ -24,7 +24,7 @@
 
 /* please do not add require here : use www/docman/index.php to add require */
 /* global variables used */
-global $g; //group object
+global $g; // group object
 global $group_id; // id of group
 
 session_require_perm('docman', $group_id, 'approve');
@@ -32,10 +32,30 @@
 $doc_group = getIntFromRequest('dirid');
 $uploaded_data = getUploadedFile('uploaded_data');
 
-$return_msg = _('Zip injected successfully.');
-$return_url = '/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg);
-if ($doc_group)
-	$return_url .= '&dirir='.$doc_group;
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Document Action Denied.');
+	if ($doc_group) {
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'&warning_msg='.urlencode($return_msg));
+	} else {
+		session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
+	}
+} else {
+	$dg = new DocumentGroup($g,$doc_group);
 
-session_redirect($return_url);
+	if ($dg->isError())
+		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($dg->getErrorMessage()));
+
+	if (!$dg->injectZip($uploaded_data)) {
+		$return_msg = _('Error: Zip rejected');
+		$return_url = '/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg);
+	} else {
+		$return_msg = _('Zip injected successfully.');
+		$return_url = '/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg);
+	}
+
+	if ($doc_group)
+		$return_url .= '&dirir='.$doc_group;
+
+	session_redirect($return_url);
+}
 ?>




More information about the Fusionforge-commits mailing list