Index: trunk/contactcenter/inc/class.so_group.inc.php
===================================================================
--- trunk/contactcenter/inc/class.so_group.inc.php	(revision 4754)
+++ trunk/contactcenter/inc/class.so_group.inc.php	(revision 5131)
@@ -93,4 +93,40 @@
 		}
 		
+                function touchContacts( $pContacts )
+                {
+                   
+                    $qSelect =  'SELECT A.id_contact from phpgw_cc_contact A,'.
+                                'phpgw_cc_contact_conns B WHERE '.
+                                'A.id_contact = B.id_contact and B.id_connection in('.implode( ',' , $pContacts ).')';
+                    
+                    
+                    $qUpdate = 'UPDATE phpgw_cc_contact '.
+                               'SET last_status = \'U\', last_update = \''.time().'000\' '.
+                               'WHERE id_contact IN( '.$qSelect.' )';   
+                    
+                      if (!$this->db->query($qUpdate))
+                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
+                }
+                
+                function touchContactsByGroup ( $pIdGroup )
+                {
+                    $qSelect = 'SELECT A.id_contact from phpgw_cc_contact A,'.
+			'phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D where '.
+			'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
+			' and '.
+			' D.id_connection = C.id_connection and D.id_group = '.$pIdGroup;
+
+                    
+                    $qUpdate = 'UPDATE phpgw_cc_contact '.
+                             'SET last_status = \'U\', last_update = \''.time().'000\' '.
+                             'WHERE id_contact IN( '.$qSelect.' )';   
+   
+
+                    if (!$this->db->query($qUpdate))
+			exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
+			
+                    
+                }
+                
 		function delete($data)
 		{
@@ -423,74 +459,4 @@
 		}
 
-		function verifyContact($email, $name, $phone)
-		{
-			if ($email) {
-			
-				$query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'.
-				'phpgw_cc_contact_conns B, phpgw_cc_connections C where '.
-				'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
-				'and B.id_typeof_contact_connection = 1 and '.
-				"A.id_owner ='" .$this->owner."' and C.connection_value = '".$email. "'";
-
-				if (!$this->db->query($query))
-				{	
-					exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
-				}
-			 
-				$return = false;
-			
-				while($this->db->next_record())
-				{
-					$row = $this->db->row();
-					$return[] =  $row['names_ordered']; 
-				}
-			} 
-			
-			if (!$return && $phone) { 
-
-				$query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'.
-				'phpgw_cc_contact_conns B, phpgw_cc_connections C where '.
-				'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
-				'and B.id_typeof_contact_connection = 2 and '.
-				"A.id_owner ='" .$this->owner."' and C.connection_value = '".$phone. "'";
-
-				if (!$this->db->query($query))
-				{	
-					exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
-				}
-			 
-				$return = false;
-			
-				while($this->db->next_record())
-				{
-					$row = $this->db->row();
-					$return[] =  $row['names_ordered']; 
-				}
-
-			}
-			
-			if (!$return && $name) { 
-
-				$query = "select names_ordered, C.id_connection from phpgw_cc_contact where id_owner = '" . $this->owner . "' and RTRIM(names_ordered) = '". $name. "'";
-
-				if (!$this->db->query($query))
-				{	
-					exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
-				}
-			 
-				$return = false;
-			
-				while($this->db->next_record())
-				{
-					$row = $this->db->row();
-					$return[] =  $row['names_ordered']; 
-				}
-
-			}
-		    $return[] =  $row['id_connection'];
-
-			return $return;
-		}		
-
 		function verifySharedContact($owner,$email)
 		{
@@ -588,5 +554,8 @@
 		function updateContactsByGroup($id_group, $contacts)
 		{
-						
+                        //Atualiza timestamp de status dos contatos afetados
+                        $this -> touchContacts($contacts);
+                        $this -> touchContactsByGroup($id_group);
+                        ///---------------------------------------------------//
 			$query = 'select C.id_connection from phpgw_cc_contact A,'.
 			'phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D where '.
@@ -724,4 +693,104 @@
 		}
 		
+		
+		function verifyContact($email, $name, $phone) 
+	 	                { 
+								if($email && $phone && $name){
+								
+									$query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'. 
+	 	                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
+	 	                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
+	 	                                'and B.id_typeof_contact_connection = 1 and '. 
+	 	                                "A.id_owner ='" .$this->owner."' and (C.connection_value = '".$email. "' or C.connection_value = '".$phone. "') and RTRIM(A.names_ordered) = '". $name. "'"; 
+								
+									if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+								}
+	 	                        if (!$return && $email) { 
+	 	                         
+	 	                                $query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'. 
+	 	                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
+	 	                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
+	 	                                'and B.id_typeof_contact_connection = 1 and '. 
+	 	                                "A.id_owner ='" .$this->owner."' and C.connection_value = '".$email. "' and RTRIM(A.names_ordered) = '". $name. "'"; 
+	 	 
+	 	                                if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+	 	                        }  	               
+	 	                        if (!$return && $phone) {  
+	 	 
+										$query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'. 
+	 	                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
+	 	                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
+	 	                                'and B.id_typeof_contact_connection = 2 and '. 
+	 	                                "A.id_owner ='" .$this->owner."' and C.connection_value = '".$phone. "' and RTRIM(A.names_ordered) = '". $name. "'"; 
+	 	 
+	 	                                if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+	 	 
+	 	                        } 
+
+	 	                        if (!$return && $name) {  
+	 	 
+	 	                                $query = "
+										select A.names_ordered, C.id_connection 
+										
+										from phpgw_cc_contact A, 
+											phpgw_cc_contact_conns B, 
+											phpgw_cc_connections C
+										where A.id_contact = B.id_contact and B.id_connection = C.id_connection and
+										B.id_typeof_contact_connection = 2 and
+										A.id_owner = '" . $this->owner . "' and RTRIM(A.names_ordered) = '". $name. "'"; 
+	 	 
+	 	                                if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+	 	 
+	 	                        } 
+	 	                    $return[] =  $row['id_connection']; 
+
+	 	                        return $return; 
+	 	                } 
+		
+		
 	}
 ?>
