? patch
Index: inc/class.contacts_ldap.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.contacts_ldap.inc.php,v
retrieving revision 1.11.2.5.2.7
diff -c -r1.11.2.5.2.7 class.contacts_ldap.inc.php
*** inc/class.contacts_ldap.inc.php	10 Feb 2004 13:51:17 -0000	1.11.2.5.2.7
--- inc/class.contacts_ldap.inc.php	9 Mar 2004 17:27:43 -0000
***************
*** 867,891 ****
  		/* This is where the real work of delete() is done, shared class file contains calling function */
  		function delete_($id)
  		{
! 			if (!$GLOBALS['phpgw_info']['server']['ldap_contact_context'])
! 			{
! 				return False;
! 			}
  
! 			$sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber='.$id);
! 			$ldap_fields = ldap_get_entries($this->ldap, $sri);
! 
! 			if ($ldap_fields[0]['dn'])
  			{
! 				$err = ldap_delete($this->ldap,$ldap_fields[0]['dn']);
! 
! 				$this->db->query("DELETE FROM $this->ext_table WHERE contact_id='$id' AND contact_owner='"
! 				. $this->account_id . "'",__LINE__,__FILE__);
  			}
  			else
  			{
! 				return False;
  			}
  		}
  
  		// This is for the admin script deleteaccount.php
--- 867,905 ----
  		/* This is where the real work of delete() is done, shared class file contains calling function */
  		function delete_($id)
  		{
! 			$response= $GLOBALS['phpgw']->hooks->process(array(
! 								'location' => 'delete_addressbook',
! 								'contact_id' => $cid )
! 							);
  
! 			if( $response )
  			{
! 				$return_value = $response;
  			}
  			else
  			{
! 				if (!$GLOBALS['phpgw_info']['server']['ldap_contact_context'])
! 				{
! 					return False;
! 				}
! 
! 				$sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber='.$id);
! 				$ldap_fields = ldap_get_entries($this->ldap, $sri);
! 
! 				if ($ldap_fields[0]['dn'])
! 				{
! 					$err = ldap_delete($this->ldap,$ldap_fields[0]['dn']);
! 
! 					$this->db->query("DELETE FROM $this->ext_table WHERE contact_id='$id' AND contact_owner='"
! 					. $this->account_id . "'",__LINE__,__FILE__);
! 					$return_value = False;
! 				}
! 				else
! 				{
! 					return False;
! 				}
  			}
+ 			return $return_value;
  		}
  
  		// This is for the admin script deleteaccount.php
Index: inc/class.contacts_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.contacts_sql.inc.php,v
retrieving revision 1.17.2.2.2.56
diff -c -r1.17.2.2.2.56 class.contacts_sql.inc.php
*** inc/class.contacts_sql.inc.php	2 Mar 2004 19:05:05 -0000	1.17.2.2.2.56
--- inc/class.contacts_sql.inc.php	9 Mar 2004 17:27:43 -0000
***************
*** 2405,2441 ****
  		*/
  		function delete($cid, $contact_type='', $transaction=True)
  		{
! 			$type = ($contact_type)? $contact_type : $this->search_contact_type_id($this->get_type_contact($cid));
! 			$type = ($type == $this->_contact_person) ? 'person' : 'org';
! 
! 			if(empty($entity_keys))
! 			{
! 				$entity_keys = array('contact_id',
! 						// $type= org | person therefore: here goes person_id or org_id
! 						$type.'_id',
! 						// in addition: here goes my_person_id or my_org_id
! 						'my_'.$type.'_id',
! 						'addr_contact_id',
! 						'note_contact_id',
! 						'other_contact_id',
! 						'comm_contact_id');
! 			}
! 			if($transaction)
! 			{
! 				$this->transaction_begin();
  			}
! 			foreach ($entity_keys as $key)
! 			{
! 				$return_value = $this->_delete(sql_criteria::_equal($key, $cid), PHPGW_SQL_RUN_SQL);
! 			}
! 			if($transaction)
  			{
! 				$this->transaction_end();
  			}
! 			
! 			if ($contact_type == $this->_contact_person)
  			{
! 				$this->finalize_delete($cid);
  			}
  			return $return_value;
  		}
--- 2405,2467 ----
  		*/
  		function delete($cid, $contact_type='', $transaction=True)
  		{
! 			// check for hooks saying "do not delete"
! 			$hook_response= $GLOBALS['phpgw']->hooks->process(array(
! 								'location' => 'delete_addressbook',
! 								'contact_id' => $cid )
! 							);
! 							
! 			$negative_apps=false;
! 			foreach($hook_response as $application => $response)
! 			{
! 				if(is_array($response))
! 				{
! 					if(!$response['can_delete'])
! 					{
! 						$negative_apps[$application]=$response['reason'];
! 					}
! 				}
  			}
! 
! 			if( $negative_apps )
  			{
! 				$return_value = $negative_apps;
  			}
! 			else
  			{
! 				$type = ($contact_type)? $contact_type : $this->search_contact_type_id($this->get_type_contact($cid));
! 				$type = ($type == $this->_contact_person) ? 'person' : 'org';
! 
! 
! 				if(empty($entity_keys))
! 				{
! 					$entity_keys = array('contact_id',
! 							// $type= org | person therefore: here goes person_id or org_id
! 							$type.'_id',
! 							// in addition: here goes my_person_id or my_org_id
! 							'my_'.$type.'_id',
! 							'addr_contact_id',
! 							'note_contact_id',
! 							'other_contact_id',
! 							'comm_contact_id');
! 				}
! 				if($transaction)
! 				{
! 					$this->transaction_begin();
! 				}
! 				foreach ($entity_keys as $key)
! 				{
! 					$return_value = $this->_delete(sql_criteria::_equal($key, $cid), PHPGW_SQL_RUN_SQL);
! 				}
! 				if($transaction)
! 				{
! 					$this->transaction_end();
! 				}
! 
! 				if ($contact_type == $this->_contact_person)
! 				{
! 					$this->finalize_delete($cid);
! 				}
  			}
  			return $return_value;
  		}
***************
*** 2449,2465 ****
  		*/
  		function delete_contact($cid, $contact_type='', $action=PHPGW_SQL_RUN_SQL)
  		{
! 			$type = ($contact_type)? $contact_type : $this->search_contact_type_id($this->get_type_contact($cid));
! 			$type = ($type == $this->_contact_person) ? 'person' : 'org';
! 			if ($action == PHPGW_SQL_RUN_SQL)
! 			{
! 				$this->transaction_begin();
! 			}
! 			$return_value[] = $this->_delete(sql_criteria::_equal('contact_id', $cid), $action);
! 			$return_value[] = $this->_delete(sql_criteria::_equal($type.'_id', $cid), $action);
! 			if ($action == PHPGW_SQL_RUN_SQL)
! 			{
! 				$this->transaction_end();
  			}
  			return $return_value;
  		}
--- 2475,2515 ----
  		*/
  		function delete_contact($cid, $contact_type='', $action=PHPGW_SQL_RUN_SQL)
  		{
! 			// check for hooks saying "do not delete"
! 			$response= $GLOBALS['phpgw']->hooks->process(array(
! 								'location' => 'delete_addressbook',
! 								'contact_id' => $cid )
! 							);
!                         $negative_apps=false;
!                         foreach($hook_response as $application => $response)
!                         {
!                                 if(is_array($response))
!                                 {
!                                         if(!$response['can_delete'])
!                                         {
!                                                 $negative_apps[$application]=$response['reason'];
!                                         }
!                                 }
!                         }
!                                                                                                                
!                         if( $negative_apps )
!                         {
!                                 $return_value = $negative_apps;
!                         }
! 			else
! 			{
! 				$type = ($contact_type)? $contact_type : $this->search_contact_type_id($this->get_type_contact($cid));
! 				$type = ($type == $this->_contact_person) ? 'person' : 'org';
! 				if ($action == PHPGW_SQL_RUN_SQL)
! 				{
! 					$this->transaction_begin();
! 				}
! 				$return_value[] = $this->_delete(sql_criteria::_equal('contact_id', $cid), $action);
! 				$return_value[] = $this->_delete(sql_criteria::_equal($type.'_id', $cid), $action);
! 				if ($action == PHPGW_SQL_RUN_SQL)
! 				{
! 					$this->transaction_end();
! 				}
  			}
  			return $return_value;
  		}
