[Fusionforge-commits] r11805 - trunk/src/common/docman

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Dec 15 10:24:06 CET 2010


Author: nerville
Date: 2010-12-15 10:24:06 +0100 (Wed, 15 Dec 2010)
New Revision: 11805

Modified:
   trunk/src/common/docman/DocumentGroup.class.php
Log:
fix: no need to create new dg object => use this.
fix: document type and size

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2010-12-14 17:46:48 UTC (rev 11804)
+++ trunk/src/common/docman/DocumentGroup.class.php	2010-12-15 09:24:06 UTC (rev 11805)
@@ -464,6 +464,7 @@
 			if ($zip->extractTo($extractDir)) {
 				$zip->close();
 				if ($this->__injectContent($doc_group, $extractDir)) {
+					
 					return true;
 				} else {
 					$this->setError(_('Unable inject zipfile.'));
@@ -493,9 +494,8 @@
 			for ($i = 0; $i < count($dir_arr); $i++) {
 				if ($dir_arr[$i] != '.' && $dir_arr[$i] != '..') {
 					if (is_dir($directory.'/'.$dir_arr[$i])) {
-						$dg = new DocumentGroup($this->getGroup());
-						if ($dg->create($dir_arr[$i], $doc_group)) {
-							if (!$this->__injectContent($dg->getID(), $directory.'/'.$dir_arr[$i])) {
+						if ($this->create($dir_arr[$i], $doc_group)) {
+							if (!$this->__injectContent($this->getID(), $directory.'/'.$dir_arr[$i])) {
 								$this->setError(_('Unable to open directory for inject into tree'));
 								return false;
 							}
@@ -504,13 +504,16 @@
 						$d = new Document($this->getGroup());
 						if (function_exists('finfo_open')) {
 							$finfo = finfo_open(FILEINFO_MIME_TYPE);
-							$dir_arr_type = finfo_file($finfo, $dir_arr[$i]);
+							$dir_arr_type = finfo_file($finfo, $directory.'/'.$dir_arr[$i]);
 						} else {
 							$dir_arr_type = 'application/binary';
 						}
-						$data = fread(fopen($dir_arr[$i], 'r'), filesize($dir_arr[$i]));
+						$data = fread(fopen($directory.'/'.$dir_arr[$i], 'r'), filesize($directory.'/'.$dir_arr[$i]));
 						if (!$d->create($dir_arr[$i], $dir_arr_type, $data, $doc_group, 'no title', 'no description')) {
 							$this->setError(_('Unable to add document from zip injection.'));
+							return false;
+						} else {
+							unlink($directory.'/'.$dir_arr[$i]);
 						}
 					}
 				}




More information about the Fusionforge-commits mailing list