[Fusionforge-commits] r13150 - in trunk/src: common/docman common/docman/actions common/docman/views www/docman/scripts

Franck VILLAUME nerville at fusionforge.org
Sat Apr 16 00:21:21 CEST 2011


Author: nerville
Date: 2011-04-16 00:21:21 +0200 (Sat, 16 Apr 2011)
New Revision: 13150

Modified:
   trunk/src/common/docman/Document.class.php
   trunk/src/common/docman/DocumentFactory.class.php
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/DocumentManager.class.php
   trunk/src/common/docman/actions/addsubdocgroup.php
   trunk/src/common/docman/actions/emptytrash.php
   trunk/src/common/docman/views/listfile.php
   trunk/src/common/docman/views/listtrashfile.php
   trunk/src/www/docman/scripts/DocManController.js
Log:
fix trash view & more OO code

Modified: trunk/src/common/docman/Document.class.php
===================================================================
--- trunk/src/common/docman/Document.class.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/Document.class.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -994,6 +994,14 @@
 		$this->sendNotice(false);
 		return true;
 	}
+
+	function createVersion() {
+
+	}
+
+	function deleteVersion() {
+
+	}
 }
 
 // Local Variables:

Modified: trunk/src/common/docman/DocumentFactory.class.php
===================================================================
--- trunk/src/common/docman/DocumentFactory.class.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/DocumentFactory.class.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -41,19 +41,19 @@
 	/**
 	 * The Documents dictionary.
 	 *
-	 * @var	array	Contains doc_group_id as key and the array of documents associated to that id. 
+	 * @var	array		Contains doc_group_id as key and the array of documents associated to that id. 
 	 */
 	var $Documents;
 
 	/**
 	 * The stateid limit
-	 * @var	int	Contains the stateid to limit return documents in getDocuments.
+	 * @var	integer	Contains the stateid to limit return documents in getDocuments.
 	 */
 	var $stateid;
 
 	/**
 	 * The doc_group_id limit
-	 * @var	int	Contains the doc_group id to limit return documents in getDocuments.
+	 * @var	integer	Contains the doc_group id to limit return documents in getDocuments.
 	 */
 	var $docgroupid;
 
@@ -66,14 +66,14 @@
 
 	/**
 	 * The columns order
-	 * @var	array	Contains the order of columns to sort before return documents in getDocuments.
+	 * @var	array		Contains the order of columns to sort before return documents in getDocuments.
 	 *		Default value is title order
 	 */
 	var $order = array('title');
 
 	/**
 	 * The limit
-	 * @var	int	Contains the limit of documents retrieve by getDocuments.
+	 * @var	integer	Contains the limit of documents retrieve by getDocuments.
 	 *		Default value is 0 which means NO LIMIT
 	 */
 	var $limit = 0;
@@ -113,7 +113,7 @@
 	/**
 	 * setStateID - call this before getDocuments() if you want to limit to a specific state.
 	 *
-	 * @param	int	The stateid from the doc_states table.
+	 * @param	integer	The stateid from the doc_states table.
 	 * @access	public
 	 */
 	function setStateID($stateid) {
@@ -123,7 +123,7 @@
 	/**
 	 * setDocGroupID - call this before getDocuments() if you want to limit to a specific doc_group.
 	 *
-	 * @param	int	The doc_group from the doc_groups table.
+	 * @param	integer	The doc_group from the doc_groups table.
 	 * @access	public
 	 */
 	function setDocGroupID($docgroupid) {
@@ -262,8 +262,8 @@
 	/**
 	 * getDocuments - returns an array of Document objects.
 	 *
-	 * @param	int	no cache : force reinit $this->Documents : default: cache is used
-	 * @return	array	Document objects.
+	 * @param	integer	no cache : force reinit $this->Documents : default: cache is used
+	 * @return	array		Document objects.
 	 * @access	public
 	 */
 	function &getDocuments($nocache = 0) {

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/DocumentGroup.class.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -157,7 +157,7 @@
 	/**
 	 * delete - delete a DocumentGroup.
 	 * WARNING delete is recursive and permanent
-	 * @param	int	Document Group Id, integer Project Group Id
+	 * @param	integer	Document Group Id, integer Project Group Id
 	 * @return	boolean	success
 	 * @access	public
 	 */
@@ -231,7 +231,7 @@
 	/**
 	 * fetchData - re-fetch the data for this DocumentGroup from the database.
 	 *
-	 * @param	int	ID of the doc_group.
+	 * @param	integer	ID of the doc_group.
 	 * @return	boolean	success
 	 * @access	public
 	 */
@@ -250,7 +250,7 @@
 	/**
 	 * getGroup - get the Group Object this DocumentGroup is associated with.
 	 *
-	 * @return Object Group.
+	 * @return	Object Group.
 	 * @access	public
 	 */
 	function &getGroup() {
@@ -260,7 +260,7 @@
 	/**
 	 * getID - get this DocumentGroup's ID.
 	 *
-	 * @return	int	The id #.
+	 * @return	integer	The id #.
 	 * @access	public
 	 */
 	function getID() {
@@ -270,7 +270,7 @@
 	/**
 	 * getID - get parent DocumentGroup's id.
 	 *
-	 * @return	int	The id #.
+	 * @return	integer	The id #.
 	 * @access	public
 	 */
 	function getParentID() {
@@ -290,7 +290,7 @@
 	/**
 	 * getState - get the state id.
 	 *
-	 * @return	int	The state id.
+	 * @return	integer	The state id.
 	 * @access	public
 	 */
 	function getState() {
@@ -301,7 +301,7 @@
 	 * update - update a DocumentGroup.
 	 *
 	 * @param	string	Name of the category.
-	 * @param	int	the doc_group id of the parent. default = 0
+	 * @param	integer	the doc_group id of the parent. default = 0
 	 * @return	boolean	success or not
 	 * @access	public
 	 */
@@ -354,17 +354,17 @@
 	}
 
 	/**
-	* hasDocuments - Recursive function that checks if this group or any of it childs has documents associated to it
-	*
-	* A group has associated documents if and only if there are documents associated to this
-	* group or to any of its childs
-	*
-	* @param	array	Array of nested groups information, fetched from DocumentGroupFactory class
-	* @param	object	The DocumentFactory object
-	* @param	int	(optional) State of the documents
-	* @return	boolean	success
-	* @access	public
-	*/
+	 * hasDocuments - Recursive function that checks if this group or any of it childs has documents associated to it
+	 *
+	 * A group has associated documents if and only if there are documents associated to this
+	 * group or to any of its childs
+	 *
+	 * @param	array	Array of nested groups information, fetched from DocumentGroupFactory class
+	 * @param	object	The DocumentFactory object
+	 * @param	int	(optional) State of the documents
+	 * @return	boolean	success
+	 * @access	public
+	 */
 	function hasDocuments(&$nested_groups, &$document_factory, $stateid = 0) {
 		$doc_group_id = $this->getID();
 		static $result = array();	// this function will probably be called several times so we better store results in order to speed things up
@@ -405,13 +405,13 @@
 	}
 
 	/**
-	* hasSubgroup - Checks if this group has a specified subgroup associated to it
-	*
-	* @param	array	Array of nested groups information, fetched from DocumentGroupFactory class
-	* @param	int	ID of the subgroup
-	* @return	boolean	success
-	* @access	public
-	*/
+	 * hasSubgroup - Checks if this group has a specified subgroup associated to it
+	 *
+	 * @param	array	Array of nested groups information, fetched from DocumentGroupFactory class
+	 * @param	int	ID of the subgroup
+	 * @return	boolean	success
+	 * @access	public
+	 */
 	function hasSubgroup(&$nested_groups, $doc_subgroup_id) {
 		$doc_group_id = $this->getID();
 

Modified: trunk/src/common/docman/DocumentManager.class.php
===================================================================
--- trunk/src/common/docman/DocumentManager.class.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/DocumentManager.class.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -45,8 +45,6 @@
 	 * Constructor.
 	 *
 	 * @param	object	The Group object to which this document is associated.
-	 * @param	int	The docid.
-	 * @param	array	The associative array of data.
 	 * @return	boolean	success.
 	 */
 	function DocumentManager(&$Group) {
@@ -77,7 +75,7 @@
 	/**
 	 * getTrashID - the trash doc_group id for this DocumentManager.
 	 *
-	 * @return	int	The trash doc_group id.
+	 * @return	integer	The trash doc_group id.
 	 */
 	function getTrashID() {
 		if (isset($this->data_array['trashid']))
@@ -97,6 +95,31 @@
 			return -1;
 		}
 	}
+
+	/**
+	 * cleanTrash - delete all items in trash for this DocumentManager
+	 *
+	 * @return	boolean	true on success
+	 */
+	function cleanTrash() {
+		$trashId = $this->getTrashID();
+		if ($trashId !== -1) {
+			db_begin();
+			$emptyFile = db_query_params('DELETE FROM doc_data WHERE stateid=$1 and group_id=$2', array('2', $this->Group->getID()));
+			if (!$emptyFile)	{
+				db_rollback();
+				return false;
+			}
+			$emptyDir = db_query_params('DELETE FROM doc_groups WHERE stateid=$1 and group_id=$2 and groupname !=$3', array('2', $this->Group->getID(), '.trash'));
+			if (!$emptyDir) {
+				db_rollback();
+				return false;
+			}
+			db_commit();
+			return true;
+		}
+		return false;
+	}
 }
 
 ?>

Modified: trunk/src/common/docman/actions/addsubdocgroup.php
===================================================================
--- trunk/src/common/docman/actions/addsubdocgroup.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/actions/addsubdocgroup.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -5,6 +5,7 @@
  * Copyright 2000, Quentin Cregan/Sourceforge
  * Copyright 2002-2003, Tim Perdue/GForge, LLC
  * Copyright 2010-2011, Franck Villaume - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -39,7 +40,7 @@
 	}
 }
 
-$groupname = $_POST['groupname'];
+$groupname = getStringFromRequest('groupname');
 
 $dg = new DocumentGroup($g);
 

Modified: trunk/src/common/docman/actions/emptytrash.php
===================================================================
--- trunk/src/common/docman/actions/emptytrash.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/actions/emptytrash.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -33,15 +33,12 @@
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 }
 
-/* you must first delete files before dirs because of database constraints */
-$emptyFile = db_query_params('DELETE FROM doc_data WHERE stateid=$1 and group_id=$2',array('2',$group_id));
-if (!$emptyFile)
-	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
+$dm = new DocumentManager(group_get_object($group_id));
+if (!$dm->cleanTrash()) {
+	$error_msg = _('Unable to clean trash');
+	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($error_msg));
+}
 
-$emptyDir = db_query_params('DELETE FROM doc_groups WHERE stateid=$1 and group_id=$2 and groupname !=$3',array('2',$group_id,'.trash'));
-if (!$emptyDir)
-	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=listtrashfile&feedback='.urlencode($return_msg));
 ?>

Modified: trunk/src/common/docman/views/listfile.php
===================================================================
--- trunk/src/common/docman/views/listfile.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/views/listfile.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -97,14 +97,14 @@
 					],
 
 		divAddItem:		jQuery('#additem'),
-		divEditDirectory:	jQuery('#editdocgroup'),
+		divEditDirectory:		jQuery('#editdocgroup'),
 		buttonAddItem:		jQuery('#docman-additem'),
 		buttonEditDirectory:	jQuery('#docman-editdirectory'),
 		docManURL:		'<?php util_make_uri("docman") ?>',
 		lockIntervalDelay:	60000, //in microsecond and if you change this value, please update the check value 600
-		divLeft:		jQuery('#left'),
-		divHandle:		jQuery('#handle'),
-		divRight:		jQuery('#right'),
+		divLeft:			jQuery('#left'),
+		divHandle:			jQuery('#handle'),
+		divRight:			jQuery('#right'),
 	});
 });
 

Modified: trunk/src/common/docman/views/listtrashfile.php
===================================================================
--- trunk/src/common/docman/views/listtrashfile.php	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/common/docman/views/listtrashfile.php	2011-04-15 22:21:21 UTC (rev 13150)
@@ -81,20 +81,23 @@
 
 jQuery(document).ready(function() {
 	controllerListTrash = new DocManListFileController({
-		groupId:		<?php echo $group_id ?>,
+		groupId:			<?php echo $group_id ?>,
 		tipsyElements:		[
 						{selector: '#docman-editdirectory', options:{delayIn: 500, delayOut: 0, fade: true}},
-						{selector: '#docman-deletedirectory', options:{delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '.docman-delete', 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-editfile', options:{gravity: 'ne', delayIn: 500, delayOut: 0, fade: true}},
-					],
+						],
 
-		divEditDirectory:	jQuery('#editdocgroup'),
+		divEditDirectory:		jQuery('#editdocgroup'),
 		buttonEditDirectory:	jQuery('#docman-editdirectory'),
 		docManURL:		'<?php util_make_uri("docman") ?>',
-		lockIntervalDelay:	60000 //in microsecond and if you change this value, please update the check value 600
+		lockIntervalDelay:	60000, //in microsecond and if you change this value, please update the check value 600
+		divLeft:			jQuery('#left'),
+		divHandle:			jQuery('#handle'),
+		divRight:			jQuery('#right'),
 	});
 });
 </script>
@@ -103,10 +106,11 @@
 	echo '<input id="submitemptytrash" type="submit" value="'. _('Delete permanently all documents with deleted status.') .'" >';
 	echo '</form></div>';
 
-	echo '<div style="float:left; width:17%; padding-right:3px; margin-right:2px; border-right: dashed 1px black;">';
+	echo '<div id="left" style="float:left; width:17%; min-width: 50px;">';
 	include ($gfcommon.'docman/views/tree.php');
 	echo '</div>';
-	echo '<div style="float:left; width:82%;">';
+	echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
+	echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
 	if ($DocGroupName) {
 		echo '<h3 class="docman_h3" >Directory : <i>'.$DocGroupName.'</i> ';
 		if ($DocGroupName != '.trash') {

Modified: trunk/src/www/docman/scripts/DocManController.js
===================================================================
--- trunk/src/www/docman/scripts/DocManController.js	2011-04-15 22:20:07 UTC (rev 13149)
+++ trunk/src/www/docman/scripts/DocManController.js	2011-04-15 22:21:21 UTC (rev 13150)
@@ -30,7 +30,7 @@
 DocManListFileController = function(params)
 {
 	this.lockInterval	= [];
-	this.params		= params;
+	this.params	= params;
 
 	if (typeof(jQuery(window).tipsy) == 'function') {
 		this.initTipsy();
@@ -42,7 +42,7 @@
 
 DocManAddItemController = function(params)
 {
-	this.params		= params;
+	this.params	= params;
 
 	if (typeof(jQuery(window).tipsy) == 'function') {
 		this.initTipsy();
@@ -52,7 +52,7 @@
 
 DocManMenuController = function(params)
 {
-	this.params		= params;
+	this.params	= params;
 
 	if (typeof(jQuery(window).tipsy) == 'function') {
 		this.initTipsy();
@@ -66,7 +66,9 @@
 	bindControls: function()
 	{
 		this.params.buttonEditDirectory.click(jQuery.proxy(this, "toggleEditDirectoryView"));
-		this.params.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
+		if (typeof(this.params.buttonAddItem) != 'undefined') {
+			this.params.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
+		}
 	},
 
 	resizableDiv:function() {




More information about the Fusionforge-commits mailing list