[Fusionforge-commits] r12270 - in trunk: src/common/docman src/common/docman/actions src/common/docman/include src/common/docman/views src/www/docman tests/func/Docs

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Fri Feb 11 19:10:57 CET 2011


Author: nerville
Date: 2011-02-11 19:10:57 +0100 (Fri, 11 Feb 2011)
New Revision: 12270

Modified:
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/actions/emptytrash.php
   trunk/src/common/docman/actions/trashdir.php
   trunk/src/common/docman/actions/trashfile.php
   trunk/src/common/docman/include/utils.php
   trunk/src/common/docman/views/listfile.php
   trunk/src/common/docman/views/listtrashfile.php
   trunk/src/common/docman/views/menu.php
   trunk/src/common/docman/views/tree.php
   trunk/src/www/docman/index.php
   trunk/tests/func/Docs/createDocURLTest.php
Log:
new trash implementation : missing the trash view yet

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/DocumentGroup.class.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -449,24 +449,25 @@
 	}
 
 	/**
-	 * setStateID - set the state id of this document group
+	 * setStateID - set the state id of this document group.
 	 *
-	 * @param	int	State ID
-	 * @return	boolean success
+	 * @param	int	State ID.
+	 * @return	boolean success or not.
 	 * @access	public
 	 */
 	function setStateID($stateid) {
-		$res = db_query_params('UPDATE doc_groups SET stateid=$1
-							WHERE doc_group=$2
-							AND group_id=$3',
-							array($stateid,$this->getID(), $this->Group->getID())
-					);
+		return $this->__setValueinDB('stateid',$stateid);
+	}
 
-		if (!$res || db_affected_rows($res) < 1) {
-			$this->setOnUpdateError(_('DocumentGroup:').' '.db_error());
-			return false;
-		}
-		return true;
+	/**
+	 * setParentDocGroupId - set the parent doc_group id of this document group.
+	 *
+	 * @param	int	Parent Doc_group Id.
+	 * @return	boolean success or not.
+	 * @access	public
+	 */
+	function setParentDocGroupId($parentDocGroupId) {
+		return $this->__setValueinDB('parent_doc_group',$parentDocGroupId);
 	}
 
 	/**
@@ -555,6 +556,40 @@
 		}
 	}
 
+	/**
+	 * __setValueinDB - private function to update columns in db
+	 *
+	 * @param	string	the column to update
+	 * @param	int	the value to store
+	 * @return	boolean	success or not
+	 * @access	private
+	 */
+	private function __setValueinDB($column, $value) {
+		switch ($column) {
+			case "stateid":
+			case "parent_doc_group": {
+				$qpa = db_construct_qpa();
+				$qpa = db_construct_qpa($qpa, 'UPDATE doc_groups SET ');
+				$qpa = db_construct_qpa($qpa, $column);
+				$qpa = db_construct_qpa($qpa, '=$1
+								WHERE group_id=$2
+								AND doc_group=$3',
+								array($value,
+									$this->Group->getID(),
+									$this->getID()));
+				$res = db_query_qpa($qpa);
+				if (!$res || db_affected_rows($res) < 1) {
+					$this->setOnUpdateError(db_error().print_r($res));
+					return false;
+				}
+				break;
+			}
+			default:
+				$this->setOnUpdateError(_('wrong column name'));
+				return false;
+		}
+		return true;
+	}
 }
 
 // Local Variables:

Modified: trunk/src/common/docman/actions/emptytrash.php
===================================================================
--- trunk/src/common/docman/actions/emptytrash.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/actions/emptytrash.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -43,5 +43,5 @@
 	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
 
 $return_msg = _('Emptied Trash successfully.');
-session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
+session_redirect('/docman/?group_id='.$group_id.'&view=trashfile&feedback='.urlencode($return_msg));
 ?>

Modified: trunk/src/common/docman/actions/trashdir.php
===================================================================
--- trunk/src/common/docman/actions/trashdir.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/actions/trashdir.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -4,7 +4,7 @@
  *
  * Copyright 2000, Quentin Cregan/Sourceforge
  * Copyright 2002-2003, Tim Perdue/GForge, LLC
- * Copyright 2010, Franck Villaume - Capgemini
+ * Copyright 2010-2011, Franck Villaume - Capgemini
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -29,8 +29,6 @@
 global $g; //group object
 global $dirid; //id of doc_group
 global $group_id; // id of group
-global $dgf; // document group factory of this group
-global $d_arr; // documents array of this group
 
 if (!forge_check_perm('docman', $group_id, 'approve')) {
 	$return_msg = _('Document Manager Action Denied.');
@@ -39,7 +37,19 @@
 
 /* when moving a document group to trash, it's recursive and it's applied to documents that belong to these document groups */
 /* Get the document groups info */
+$df = new DocumentFactory($g);
+if ($df->isError())
+	exit_error($df->getErrorMessage(), 'docman');
+
+$dgf = new DocumentGroupFactory($g);
+if ($dgf->isError())
+	exit_error($dgf->getErrorMessage(), 'docman');
+
 $trashnested_groups =& $dgf->getNested();
+
+$df->setDocGroupID($dirid);
+$d_arr =& $df->getDocuments();
+
 $trashnested_docs = array();
 /* put the doc objects into an array keyed of the docgroup */
 foreach ($d_arr as $doc) {
@@ -51,8 +61,13 @@
 
 /* set this dirid to trash */
 $dg = new DocumentGroup($g, $dirid);
-$dg->setStateID('2');
+$currentParent = $dg->getParentID();
+if (!$dg->setStateID('2'))
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
 
-$return_msg = _('Directory moved to trash successfully.');
-session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
+if (!$dg->setParentDocGroupId('0'))
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$currentParent.'&error_msg='.urlencode($dg->getErrorMessage()));
+
+$return_msg = sprintf(_('Directory %s moved to trash successfully.'),$dg->getName());
+session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$currentParent.'&feedback='.urlencode($return_msg));
 ?>

Modified: trunk/src/common/docman/actions/trashfile.php
===================================================================
--- trunk/src/common/docman/actions/trashfile.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/actions/trashfile.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -47,6 +47,8 @@
 	if (!$d->setState('2'))
 		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 
+	if (!d->setDocGroupId('0'))
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 }
 $return_msg .= _('moved to trash successfully.');
 session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));

Modified: trunk/src/common/docman/include/utils.php
===================================================================
--- trunk/src/common/docman/include/utils.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/include/utils.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -71,14 +71,16 @@
 		foreach ($nested_groups[$docgroup] as $dg) {
 			$idhtml++;
 
-			if ($dirid == $dg->getID())
-				$idExposeTreeIndex = $idhtml;
+			if ($dg->getState() != 2) {
+				if ($dirid == $dg->getID())
+					$idExposeTreeIndex = $idhtml;
 
-			echo "
-				['".'<span class="JSCookTreeFolderClosed"><i><img alt="" src="\' + ctThemeXPBase + \'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="\' + ctThemeXPBase + \'folderopen1.gif"></i></span>'."', '".addslashes($dg->getName())."', '?group_id=".$group_id."&view=listfile&dirid=".$dg->getID()."', '', '',";
-					docman_recursive_display($dg->getID());
-			echo ",
-				],";
+				echo "
+					['".'<span class="JSCookTreeFolderClosed"><i><img alt="" src="\' + ctThemeXPBase + \'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="\' + ctThemeXPBase + \'folderopen1.gif"></i></span>'."', '".addslashes($dg->getName())."', '?group_id=".$group_id."&view=listfile&dirid=".$dg->getID()."', '', '',";
+						docman_recursive_display($dg->getID());
+				echo ",
+					],";
+			}
 		}
 	}
 }
@@ -124,7 +126,7 @@
 	}
 	if (isset($nested_docs[$docgroup]) && is_array($nested_docs[$docgroup])) {
 		foreach ($nested_docs[$docgroup] as $d) {
-			$d->setStateID($stateid);
+			$d->setState($stateid);
 		}
 	}
 }

Modified: trunk/src/common/docman/views/listfile.php
===================================================================
--- trunk/src/common/docman/views/listfile.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/views/listfile.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -40,9 +40,13 @@
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 }
 
-$DocGroupName = getNameDocGroup($dirid, $group_id);
-if (!$DocGroupName) {
-	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($g->getErrorMessage()));
+$DocGroupName = 0;
+
+if ($dirid) {
+	$DocGroupName = getNameDocGroup($dirid, $group_id);
+	if (!$DocGroupName) {
+		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($g->getErrorMessage()));
+	}
 }
 ?>
 
@@ -56,6 +60,7 @@
 						{selector: '#docman-additem', options:{delayIn: 500, delayOut: 0, fade: true}},
 						{selector: '#docman-editdirectory', options:{delayIn: 500, delayOut: 0, fade: true}},
 						{selector: '#docman-deletedirectory', options:{delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#docman-trashdirectory', options:{delayIn: 500, delayOut: 0, fade: true}},
 						{selector: '.docman-downloadaszip', options:{delayIn: 500, delayOut: 0, fade: true}},
 						{selector: '.docman-viewfile', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
 						{selector: '.docman-reserveddocument', options:{delayIn: 500, delayOut: 0, fade: true}},
@@ -79,256 +84,270 @@
 </script>
 
 <?php
-echo '<h3 class="docman_h3" >Directory : <i>'.$DocGroupName.'</i> ';
-if (forge_check_perm('docman', $group_id, 'approve')) {
-	echo '<a href="#" id="docman-editdirectory" ';
-	if ($use_tooltips)
-		echo 'title="'._('Edit this directory').'"';
+echo '<div style="float:left; width:17%; padding-right:3px; margin-right:2px; border-right: dashed 1px black;">';
+include ($gfcommon.'docman/views/tree.php');
+echo '</div>';
+echo '<div style="float:left; width:82%;">';
+if (!$DocGroupName) {
+	echo '<p class="warning">'. _('No documents to display') .'</p>';
+} else {
+	echo '<h3 class="docman_h3" >Directory : <i>'.$DocGroupName.'</i> ';
+	if (forge_check_perm('docman', $group_id, 'approve')) {
+		echo '<a href="#" id="docman-editdirectory" ';
+		if ($use_tooltips)
+			echo 'title="'._('Edit this directory').'"';
 
-	echo ' >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
-	// do not uncomment the line : trash directory is not correctly implemented
-	//echo '<a href="?group_id='.$group_id.'&action=trashdir&dirid='.$dirid.'">'. html_image('docman/trash-empty.png',22,22,array('alt'=>'trashdir')). '</a>';
-	if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid])) {
-		echo '<a href="?group_id='.$group_id.'&action=deldir&dirid='.$dirid.'" id="docman-deletedirectory" ';
+		echo ' >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
+		echo '<a href="?group_id='.$group_id.'&action=trashdir&dirid='.$dirid.'" id="docman-trashdirectory" ';
 		if ($use_tooltips)
-			echo ' title="'._('Permanently delete this directory').'" ';
+			echo 'title="'._('Move this directory and his content to trash').'" ';
+		echo '>'. html_image('docman/trash-empty.png',22,22,array('alt'=>'trashdir')). '</a>';
+		if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid])) {
+			echo '<a href="?group_id='.$group_id.'&action=deldir&dirid='.$dirid.'" id="docman-deletedirectory" ';
+			if ($use_tooltips)
+				echo ' title="'._('Permanently delete this directory').'" ';
 
-		echo '>'. html_image('docman/delete-directory.png',22,22,array('alt'=>'deldir')). '</a>';
+			echo '>'. html_image('docman/delete-directory.png',22,22,array('alt'=>'deldir')). '</a>';
+		}
 	}
-}
 
-if (forge_check_perm('docman', $group_id, 'submit')) {
-	echo '<a href="#" id="docman-additem" ';
-	if ($use_tooltips)
-		echo 'title="'. _('Add a new item in this directory') . '" ';
+	if (forge_check_perm('docman', $group_id, 'submit')) {
+		echo '<a href="#" id="docman-additem" ';
+		if ($use_tooltips)
+			echo 'title="'. _('Add a new item in this directory') . '" ';
 
-	echo '>'. html_image('docman/insert-directory.png',22,22,array('alt'=>'additem')). '</a>';
-}
+		echo '>'. html_image('docman/insert-directory.png',22,22,array('alt'=>'additem')). '</a>';
+	}
 
-echo '<a href="/docman/view.php/'.$group_id.'/zip/full/'.$dirid.'" ';
-if ($use_tooltips)
-	echo 'class="docman-downloadaszip" title="'. _('Download this directory as a zip') . '" ';
+	echo '<a href="/docman/view.php/'.$group_id.'/zip/full/'.$dirid.'" ';
+	if ($use_tooltips)
+		echo 'class="docman-downloadaszip" title="'. _('Download this directory as a zip') . '" ';
 
-echo '>' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
+	echo '>' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
 
-echo '</h3>';
+	echo '</h3>';
 
-if (forge_check_perm('docman', $group_id, 'approve')) {
-	echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
-	echo '<h4 class="docman_h4">'. _('Edit this directory') .'</h4>';
-	include ($gfcommon.'docman/views/editdocgroup.php');
-	echo '</div>';
-	echo '<div class="docman_div_include" id="additem" style="display:none">';
-	echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
-	include ($gfcommon.'docman/views/additem.php');
-	echo '</div>';
-}
-
-if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
-	$tabletop = array('<input id="checkall" type="checkbox" onchange="controllerListFile.checkAll()" />', '', _('Filename'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'));
-	$classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
 	if (forge_check_perm('docman', $group_id, 'approve')) {
-		$tabletop[] = _('Actions');
-		$classth[] = 'unsortable';
+		echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
+		echo '<h4 class="docman_h4">'. _('Edit this directory') .'</h4>';
+		include ($gfcommon.'docman/views/editdocgroup.php');
+		echo '</div>';
+		echo '<div class="docman_div_include" id="additem" style="display:none">';
+		echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
+		include ($gfcommon.'docman/views/additem.php');
+		echo '</div>';
 	}
-	echo '<div class="docmanDiv">';
-	echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
-	$time_new = 604800;
-	foreach ($nested_docs[$dirid] as $d) {
-		echo '<tr>';
-		echo '<td>';
-		if (!$d->getLocked() && !$d->getReserved()) {
-			echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" class="checkeddocid" onchange="controllerListFile.checkgeneral()" />';
-		} else {
-			if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
-				echo '<input type="checkbox" name="disabled" disabled="disabled"';
+
+	if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
+		$tabletop = array('<input id="checkall" type="checkbox" onchange="controllerListFile.checkAll()" />', '', _('Filename'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'));
+		$classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
+		if (forge_check_perm('docman', $group_id, 'approve')) {
+			$tabletop[] = _('Actions');
+			$classth[] = 'unsortable';
+		}
+		echo '<div class="docmanDiv">';
+		echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
+		$time_new = 604800;
+		foreach ($nested_docs[$dirid] as $d) {
+			echo '<tr>';
+			echo '<td>';
+			if (!$d->getLocked() && !$d->getReserved()) {
+				echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" class="checkeddocid" onchange="controllerListFile.checkgeneral()" />';
 			} else {
-				echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" class="checkeddocid" onchange="controllerListFile.checkgeneral()" />';
+				if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
+					echo '<input type="checkbox" name="disabled" disabled="disabled"';
+				} else {
+					echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" class="checkeddocid" onchange="controllerListFile.checkgeneral()" />';
+				}
 			}
-		}
-		echo '</td>';
-		switch ($d->getFileType()) {
-			case "URL": {
-				$docurl = $d->getFileName();
-				break;
+			echo '</td>';
+			switch ($d->getFileType()) {
+				case "URL": {
+					$docurl = $d->getFileName();
+					break;
+				}
+				default: {
+					$docurl = util_make_uri('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()));
+				}
 			}
-			default: {
-				$docurl = util_make_uri('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()));
-			}
-		}
-		echo '<td><a href="'.$docurl.'" class="docman-viewfile"';
-		if ($use_tooltips)
-			echo ' title="'._('View this document').'"';
-
-		echo ' >';
-		echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
-		echo '</a></td>';
-		echo '<td>';
-		if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
-			$html_image_attr = array();
-			$html_image_attr['alt'] = _('new');
-			$html_image_attr['class'] = 'docman-newdocument';
+			echo '<td><a href="'.$docurl.'" class="docman-viewfile"';
 			if ($use_tooltips)
-				$html_image_attr['title'] = _('Created or updated since less than 7 days');
-			echo html_image('docman/new.png', '14', '14', $html_image_attr);
-		}
-		echo ' '.$d->getFileName();
-		echo '</td>';
-		echo '<td>'.$d->getName().'</td>';
-		echo '<td>'.$d->getDescription().'</td>';
-		echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
-		echo '<td>';
-		if ( $d->getUpdated() ) {
-			echo date(_('Y-m-d H:i'), $d->getUpdated());
-		} else {
-			echo date(_('Y-m-d H:i'), $d->getCreated());
-		}
-		echo '</td>';
-		echo '<td>';
-		if ($d->getReserved()) {
-			$html_image_attr = array();
-			$html_image_attr['alt'] = _('Reserved Document');
-			$html_image_attr['class'] = 'docman-reserveddocument';
-			if ($use_tooltips)
-				$html_image_attr['title'] = _('Reserved Document');
+				echo ' title="'._('View this document').'"';
 
-			echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
-		} else {
-			echo $d->getStateName().'</td>';
-		}
-		echo '<td>';
-		switch ($d->getFileType()) {
-			case "URL": {
-				echo "--";
-				break;
+			echo ' >';
+			echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
+			echo '</a></td>';
+			echo '<td>';
+			if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
+				$html_image_attr = array();
+				$html_image_attr['alt'] = _('new');
+				$html_image_attr['class'] = 'docman-newdocument';
+				if ($use_tooltips)
+					$html_image_attr['title'] = _('Created or updated since less than 7 days');
+				echo html_image('docman/new.png', '14', '14', $html_image_attr);
 			}
-			default: {
-				$metric = 'B';
-				$size = $d->getFileSize();
-				if ($size > 1024 ) {
-					$metric = 'KB';
-					$size = floor($size/1024);
+			echo ' '.$d->getFileName();
+			echo '</td>';
+			echo '<td>'.$d->getName().'</td>';
+			echo '<td>'.$d->getDescription().'</td>';
+			echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
+			echo '<td>';
+			if ( $d->getUpdated() ) {
+				echo date(_('Y-m-d H:i'), $d->getUpdated());
+			} else {
+				echo date(_('Y-m-d H:i'), $d->getCreated());
+			}
+			echo '</td>';
+			echo '<td>';
+			if ($d->getReserved()) {
+				$html_image_attr = array();
+				$html_image_attr['alt'] = _('Reserved Document');
+				$html_image_attr['class'] = 'docman-reserveddocument';
+				if ($use_tooltips)
+					$html_image_attr['title'] = _('Reserved Document');
+
+				echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
+			} else {
+				echo $d->getStateName().'</td>';
+			}
+			echo '<td>';
+			switch ($d->getFileType()) {
+				case "URL": {
+					echo "--";
+					break;
+				}
+				default: {
+					$metric = 'B';
+					$size = $d->getFileSize();
 					if ($size > 1024 ) {
-						$metric = 'MB';
+						$metric = 'KB';
 						$size = floor($size/1024);
+						if ($size > 1024 ) {
+							$metric = 'MB';
+							$size = floor($size/1024);
+						}
 					}
+					echo $size . $metric;
+					echo '</td>';
 				}
-				echo $size . $metric;
-				echo '</td>';
 			}
-		}
 
-		if (forge_check_perm('docman', $group_id, 'approve')) {
-			echo '<td>';
-			/* should we steal the lock on file ? */
-			if ($d->getLocked()) {
-				if ($d->getLockedBy() == $u->getID()) {
-					$d->setLock(0);
-					/* if you change the 60000 value above, please update here too */
-				} elseif ((time() - $d->getLockdate()) > 600) {
-					$d->setLock(0);
+			if (forge_check_perm('docman', $group_id, 'approve')) {
+				echo '<td>';
+				/* should we steal the lock on file ? */
+				if ($d->getLocked()) {
+					if ($d->getLockedBy() == $u->getID()) {
+						$d->setLock(0);
+						/* if you change the 60000 value above, please update here too */
+					} elseif ((time() - $d->getLockdate()) > 600) {
+						$d->setLock(0);
+					}
 				}
-			}
-			if (!$d->getLocked() && !$d->getReserved()) {
-				echo '<a class="docman-movetotrash" href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
-				if ($use_tooltips)
-					echo ' title="'. _('Move this document to trash') .'"';
-
-				echo ' >'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash this document'))). '</a>';
-
-				echo '<a class="docman-editfile" href="#" onclick="javascript:controllerListFile.toggleEditFileView(\''.$d->getID().'\')" ';
-				if ($use_tooltips)
-					echo ' title="'. _('Edit this document') .'" ';
-
-				echo '>'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
-
-				echo '<a class="docman-reservefile" href="?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
-				if ($use_tooltips)
-					echo ' title="'. _('Reserve this document for later edition') .'" ';
-
-				echo '>'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve this document'))). '</a>';
-			} else {
-				if ($d->getReservedBy() != $u->getID()) {
-					if (forge_check_perm('docman', $group_id, 'admin')) {
-						echo '<a class="docman-enforcereservation" href="?group_id='.$group_id.'&action=enforcereserve&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
-						if ($use_tooltips)
-							echo ' title="'. _('Enforce reservation') .'" ';
-
-						echo '>'.html_image('docman/enforce-document.png',22,22,array('alt'=>_('Enforce reservation')));
-					}
-				} else {
+				if (!$d->getLocked() && !$d->getReserved()) {
 					echo '<a class="docman-movetotrash" href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
 					if ($use_tooltips)
-						echo ' title="'. _('Move this document to trash') .'" ';
+						echo ' title="'. _('Move this document to trash') .'"';
 
-					echo '>'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash this document'))). '</a>';
+					echo ' >'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash this document'))). '</a>';
+
 					echo '<a class="docman-editfile" href="#" onclick="javascript:controllerListFile.toggleEditFileView(\''.$d->getID().'\')" ';
 					if ($use_tooltips)
 						echo ' title="'. _('Edit this document') .'" ';
 
 					echo '>'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
-					echo '<a class="docman-releasereservation" href="?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
+
+					echo '<a class="docman-reservefile" href="?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
 					if ($use_tooltips)
-						echo ' title="'. _('Release reservation') .'" ';
+						echo ' title="'. _('Reserve this document for later edition') .'" ';
 
-					echo '>'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
+					echo '>'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve this document'))). '</a>';
+				} else {
+					if ($d->getReservedBy() != $u->getID()) {
+						if (forge_check_perm('docman', $group_id, 'admin')) {
+							echo '<a class="docman-enforcereservation" href="?group_id='.$group_id.'&action=enforcereserve&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
+							if ($use_tooltips)
+								echo ' title="'. _('Enforce reservation') .'" ';
+
+							echo '>'.html_image('docman/enforce-document.png',22,22,array('alt'=>_('Enforce reservation')));
+						}
+					} else {
+						echo '<a class="docman-movetotrash" href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
+						if ($use_tooltips)
+							echo ' title="'. _('Move this document to trash') .'" ';
+
+						echo '>'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash this document'))). '</a>';
+						echo '<a class="docman-editfile" href="#" onclick="javascript:controllerListFile.toggleEditFileView(\''.$d->getID().'\')" ';
+						if ($use_tooltips)
+							echo ' title="'. _('Edit this document') .'" ';
+
+						echo '>'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
+						echo '<a class="docman-releasereservation" href="?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
+						if ($use_tooltips)
+							echo ' title="'. _('Release reservation') .'" ';
+
+						echo '>'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
+					}
 				}
+				if ($d->isMonitoredBy($u->getID())) {
+					$option = 'remove';
+					$titleMonitor = _('Stop monitoring this document');
+				} else {
+					$option = 'add';
+					$titleMonitor = _('Start monitoring this document');
+				}
+				echo '<a class="docman-monitorfile" href="?group_id='.$group_id.'&action=monitorfile&option='.$option.'&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
+				if ($use_tooltips)
+					echo ' title="'.$titleMonitor.'" ';
+
+				echo '>'.html_image('docman/monitor-'.$option.'document.png',22,22,array('alt'=>$titleMonitor)). '</a>';
+				echo '</td>';
 			}
-			if ($d->isMonitoredBy($u->getID())) {
-				$option = 'remove';
-				$titleMonitor = _('Stop monitoring this document');
-			} else {
-				$option = 'add';
-				$titleMonitor = _('Start monitoring this document');
-			}
-			echo '<a class="docman-monitorfile" href="?group_id='.$group_id.'&action=monitorfile&option='.$option.'&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" ';
+			echo '</tr>';
+		}
+		echo $HTML->listTableBottom();
+		echo '</div>';
+		echo '<div class="docmanDiv"><p>';
+		echo _('Mass Actions for selected files:');
+		if (forge_check_perm('docman', $group_id, 'approve')) {
+			echo '<a class="docman-movetotrash" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
 			if ($use_tooltips)
-				echo ' title="'.$titleMonitor.'" ';
+				echo ' title="'. _('Move to trash') .'" ';
 
-			echo '>'.html_image('docman/monitor-'.$option.'document.png',22,22,array('alt'=>$titleMonitor)). '</a>';
-			echo '</td>';
-		}
-		echo '</tr>';
-	}
-	echo $HTML->listTableBottom();
-	echo '</div>';
-	echo '<div class="docmanDiv"><p>';
-	echo _('Mass Actions for selected files:');
-	if (forge_check_perm('docman', $group_id, 'approve')) {
-		echo '<a class="docman-movetotrash" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
-		if ($use_tooltips)
-			echo ' title="'. _('Move to trash') .'" ';
+			echo '>'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash'))). '</a>';
+			echo '<a class="docman-reservefile" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
+			if ($use_tooltips)
+				echo ' title="'. _('Reserve for later edition') .'" ';
 
-		echo '>'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash'))). '</a>';
-		echo '<a class="docman-reservefile" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
-		if ($use_tooltips)
-			echo ' title="'. _('Reserve for later edition') .'" ';
+			echo '>'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve'))). '</a>';
+			echo '<a class="docman-releasereservation" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
+			if ($use_tooltips)
+				echo ' title="'. _('Release reservation') .'" ';
 
-		echo '>'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve'))). '</a>';
-		echo '<a class="docman-releasereservation" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
-		if ($use_tooltips)
-			echo ' title="'. _('Release reservation') .'" ';
+			echo '>'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
+			echo '<a class="docman-monitorfile" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=add&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
+			if ($use_tooltips)
+				echo ' title="'. _('Start monitoring') .'" ';
 
-		echo '>'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
-		echo '<a class="docman-monitorfile" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=add&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
-		if ($use_tooltips)
-			echo ' title="'. _('Start monitoring') .'" ';
+			echo '>'.html_image('docman/monitor-adddocument.png',22,22,array('alt'=>_('Start monitoring'))). '</a>';
+			echo '<a class="docman-monitorfile" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
+			if ($use_tooltips)
+				echo ' title="'. _('Stop monitoring') .'" ';
 
-		echo '>'.html_image('docman/monitor-adddocument.png',22,22,array('alt'=>_('Start monitoring'))). '</a>';
-		echo '<a class="docman-monitorfile" href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" ';
+			echo '>'.html_image('docman/monitor-removedocument.png',22,22,array('alt'=>_('Stop monitoring'))). '</a>';
+		}
+		echo '<a class="docman-downloadaszip" href="#" onClick="window.location.href=\'/docman/view.php/'.$group_id.'/zip/selected/\'+controllerListFile.buildUrlByCheckbox()" ';
 		if ($use_tooltips)
-			echo ' title="'. _('Stop monitoring') .'" ';
+			echo ' title="'. _('Download as a zip') . '" ';
 
-		echo '>'.html_image('docman/monitor-removedocument.png',22,22,array('alt'=>_('Stop monitoring'))). '</a>';
+		echo '>' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'Download as Zip')). '</a>';
+		echo '</p></div>';
+		if (forge_check_perm('docman', $group_id, 'approve')) {
+			include ($gfcommon.'docman/views/editfile.php');
+		}
+	} else {
+		echo '<p class="warning">'._('No documents to display').'</p>';
 	}
-	echo '<a class="docman-downloadaszip" href="#" onClick="window.location.href=\'/docman/view.php/'.$group_id.'/zip/selected/\'+controllerListFile.buildUrlByCheckbox()" ';
-	if ($use_tooltips)
-		echo ' title="'. _('Download as a zip') . '" ';
-
-	echo '>' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'Download as Zip')). '</a>';
-	echo '</p></div>';
-	if (forge_check_perm('docman', $group_id, 'approve')) {
-		include ($gfcommon.'docman/views/editfile.php');
-	}
 }
+echo '</div>';
+echo '<div style="clear:both"; />';
 ?>
\ No newline at end of file

Modified: trunk/src/common/docman/views/listtrashfile.php
===================================================================
--- trunk/src/common/docman/views/listtrashfile.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/views/listtrashfile.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -27,6 +27,7 @@
 /* please do not add require here : use www/docman/index.php to add require */
 /* global variables used */
 global $df; // document factory
+global $dgf;
 global $nested_groups; // flat groups array
 
 if (!forge_check_perm('docman', $group_id, 'approve')) {
@@ -36,31 +37,19 @@
 
 $df->setStateID('2');
 $d_trash_arr =& $df->getDocuments();
+$dg_trash_arr =& $dgf->getNested('2');
 
-if (!$d_trash_arr || count($d_trash_arr) < 1) {
+if ((!$d_trash_arr || count($d_trash_arr) < 1) && (!$dg_trash_arr || count($dg_trash_arr) < 1)) {
 	echo '<div class="warning">'._('Trash is empty').'</div>';
 } else {
-?>
-<script type="text/javascript">
-function displayTrashDiv() {
-	if ( 'none' == document.getElementById('listtrash').style.display ) {
-		document.getElementById('listtrash').style.display = 'block';
-	} else {
-		document.getElementById('listtrash').style.display = 'none';
-	}
-}
-</script>
-<?php
+
 	echo '<form id="emptytrash" name="emptytrash" method="post" action="?group_id='.$group_id.'&action=emptytrash" >';
 	echo '<ul>';
-	echo '<li><input id="submitemptytrash" type="button" value="'. _('Delete permanently all documents with deleted status.') .'" onclick="javascript:doIt(\'emptytrash\')" ></li>';
+	echo '<li><input id="submitemptytrash" type="submit" value="'. _('Delete permanently all documents with deleted status.') .'" ></li>';
 	echo '</ul>';
 	echo '</form>';
-	echo '<ul>';
-	echo '<li><a href="#" onclick="javascript:displayTrashDiv()">'. _('Select documents to be resurrected from deleted status.') .'</a></li>';
-	echo '</ul>';
-	echo '<div id="listtrash" style="display:none;" >';
-	docman_display_documents($nested_groups, $df, true, 2, 0);
-	echo '</div>';
+
+	var_dump($d_trash_arr);
+	var_dump($dg_trash_arr);
 }
 ?>

Modified: trunk/src/common/docman/views/menu.php
===================================================================
--- trunk/src/common/docman/views/menu.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/views/menu.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -50,6 +50,7 @@
 	controllerMenu = new DocManMenuController({
 		tipsyElements:	[
 					{selector: '#addItemDocmanMenu', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+					{selector: '#listFileDocmanMenu', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
 					{selector: '#searchDocmanMenu', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
 					{selector: '#trashDocmanMenu', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
 					{selector: '#pendingDocmanMenu', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
@@ -61,6 +62,14 @@
 </script>
 <?
 
+$menu_text[] = _('List files & Directories');
+$menu_links[] = '/docman/?group_id='.$group_id.'&view=listfile&dirid=0';
+if ($use_tooltips) {
+	$menu_attr[] = array('title' => _('View the files and the directories in 2 panels. Left a directory tree, right a list of files of specific directory'), 'id' => 'listFileDocmanMenu');
+} else {
+	$menu_attr[] = array();
+}
+
 if (forge_check_perm('docman', $group_id, 'submit')) {
 	$menu_text[] = _('Add new item');
 	$menu_links[] = '/docman/?group_id='.$group_id.'&view=additem';

Modified: trunk/src/common/docman/views/tree.php
===================================================================
--- trunk/src/common/docman/views/tree.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/common/docman/views/tree.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -61,7 +61,7 @@
 <script type="text/javascript">
 	var myMenu =
 		[
-			['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + myThemeXPBase + 'folder1.gif" /></i></span><span id="ctItemID0" class="JSCookTreeFolderOpen"><i><img alt="" src="' + myThemeXPBase + 'folderopen1.gif" /></i></span>', '/', '<?php echo '?group_id='.$group_id ?>', '', '', <?php docman_recursive_display(0); ?>
+			['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + myThemeXPBase + 'folder1.gif" /></i></span><span id="ctItemID0" class="JSCookTreeFolderOpen"><i><img alt="" src="' + myThemeXPBase + 'folderopen1.gif" /></i></span>', '/', '<?php echo '?group_id='.$group_id.'&view=listfile' ?>', '', '', <?php docman_recursive_display(0); ?>
 			]
 		];
 

Modified: trunk/src/www/docman/index.php
===================================================================
--- trunk/src/www/docman/index.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/src/www/docman/index.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -131,18 +131,14 @@
 
 site_project_header(array('title'=>$title,'group'=>$group_id,'toptab'=>'docman'));
 
-echo '<div width:100%;">';
+echo '<div>';
 include ($gfcommon.'docman/views/menu.php');
 echo '</div>';
-echo '<div style="float:left; width:17%;">';
-include ($gfcommon.'docman/views/tree.php');
-echo '</div>';
 
-echo '<div style="float:right; width:82%;">';
+echo '<div>';
 include ($gfcommon.'docman/views/views.php');
 echo '</div>';
 
-echo '<div style="clear:both; margin-bottom:5px;" />';
 site_project_footer(array());
 
 ?>

Modified: trunk/tests/func/Docs/createDocURLTest.php
===================================================================
--- trunk/tests/func/Docs/createDocURLTest.php	2011-02-11 14:06:33 UTC (rev 12269)
+++ trunk/tests/func/Docs/createDocURLTest.php	2011-02-11 18:10:57 UTC (rev 12270)
@@ -1,7 +1,7 @@
 <?php
 /*
  * Copyright (C) 2010 Alcatel-Lucent
- * Copyright 2010, Franck Villaume - Capgemini
+ * Copyright 2010-2011, Franck Villaume - Capgemini
  *
  * This file is part of FusionForge.
  *
@@ -14,23 +14,23 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *              
+ *
  * You should have received a copy of the GNU General Public License
  * along with FusionForge; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
- */             
+ */
 
-/*              
+/*
  * Standard Alcatel-Lucent disclaimer for contributing to open source
- *              
+ *
  * "The test suite ("Contribution") has not been tested and/or
  * validated for release as or in products, combinations with products or
  * other commercial use. Any use of the Contribution is entirely made at
  * the user's own responsibility and the user can not rely on any features,
  * functionalities or performances Alcatel-Lucent has attributed to the
  * Contribution.
- *              
+ *
  * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
  * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
@@ -67,6 +67,7 @@
 
 		$this->gotoProject('ProjectA');
 		$this->clickAndWait("link=Docs");
+		$this->clickAndWait("link=List files & Directories");
 		$this->clickAndWait("link=Uncategorized Submissions");
 		$this->clickAndWait("//img[@alt='Move to trash this document']");
 		$this->assertTextPresent("moved to trash successfully");




More information about the Fusionforge-commits mailing list