[20792] fix : added consistency status for types/ places associations where directory dones not exist

Pascal Vilarem <[email protected]>
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20792
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20792
Author:   maat
Date:     2009-11-17 17:34:52 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
fix : added consistency status for types/places associations where directory dones not exist

Modified Paths:
--------------
    modules/ged/trunk/inc/class.flow_client.inc.php
    modules/ged/trunk/inc/class.ged_dm.inc.php

Modified: modules/ged/trunk/inc/class.flow_client.inc.php
===================================================================
--- modules/ged/trunk/inc/class.flow_client.inc.php	2009-11-17 16:55:38 UTC (rev 20791)
+++ modules/ged/trunk/inc/class.flow_client.inc.php	2009-11-17 17:34:52 UTC (rev 20792)
@@ -188,8 +188,15 @@
 				$new_place=null;
 				$new_place=$this->ged_dm->get_type_place($new_file['doc_type'],$element['project_root']);
 				
-				if ( !isset($new_place))
+				if ( isset($new_place))
 				{
+					if(!$this->ged_dm->exist($new_place))
+					{
+						$this->ged_dm->delete_type_place($new_place);
+					}
+				}
+				else
+				{
 					$new_place=$element['parent_id'];
 				}
 				$new_file['parent_id']=$new_place;

Modified: modules/ged/trunk/inc/class.ged_dm.inc.php
===================================================================
--- modules/ged/trunk/inc/class.ged_dm.inc.php	2009-11-17 16:55:38 UTC (rev 20791)
+++ modules/ged/trunk/inc/class.ged_dm.inc.php	2009-11-17 17:34:52 UTC (rev 20792)
@@ -451,6 +451,9 @@
 						$this->delete_element ( $child['element_id'] );
 					}
 			
+				//delete type place
+				$this->delete_type_place($element_id);
+			
 		}
 		
 		// Effacement des ACLS
@@ -3035,6 +3038,9 @@
 		$sql="SELECT ged_elements.*, ged_current_version.*, ged_elements.description as descriptione, ged_current_version.description as descriptionv ";
 		$sql.="FROM ( ged_elements ";
 		$sql.="INNER JOIN ged_versions as ged_current_version ";
+		$sql="SELECT ged_elements.*, ged_current_version.*, ged_elements.description as descriptione, ged_current_version.description as descriptionv ";
+		$sql.="FROM ( ged_elements ";
+		$sql.="INNER JOIN ged_versions as ged_current_version ";
 		$sql.="ON ged_elements.element_id=ged_current_version.element_id ) ";
 		$sql.="WHERE ged_elements.name like '%".$query."%' OR ged_elements.description like '%".$query."%' OR ged_elements.reference like '%".$query."%' ";
 		$sql.="OR  ged_current_version.description like '%".$query."%' ";
@@ -3047,9 +3053,6 @@
 		while ($this->db->next_record())
 		{
 			$element_id=$this->db->f('element_id');
-			$version_id=$this->db->f('version_id');
-			$version_status=$this->db->f('status');
-			
 			if ( $this->can_write($element_id) || $this->can_read($element_id) && ( (! isset($this->acl[$element_id]['statuses'])) || empty( $this->acl[$element_id]['statuses'] ) || ( is_array($this->acl[$element_id]['statuses'] ) && in_array($version_status, $this->acl[$element_id]['statuses'])) ))
 			{
 				$docs[$i]['element_id']=$element_id;
@@ -3397,6 +3400,19 @@
 		return($result);
 	}
 	
+	function delete_type_place($element_id)
+	{
+		
+		$db2 = clone($this->db);
+		$sql="DELETE FROM ged_types_places WHERE element_id='".$element_id."'";
+		$db2->query($sql, __LINE__, __FILE__);				
+		$db2->unlock();		
+		$db2->free(); 
+		unset($db2);			
+		return($result);
+		
+	}
+	
 	function list_types_places($project_root_id)
 	{
 		$places=null;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.