phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] addressbook/inc/class.soaddressbook.inc.php, 1.14.2.3


From: nomail
Subject: [Phpgroupware-cvs] addressbook/inc/class.soaddressbook.inc.php, 1.14.2.3.2.24
Date: Sat, 21 Aug 2004 07:53:12 +0200

Update of /addressbook/inc
Modified Files:
        Branch: Version-0_9_16-branch
          class.soaddressbook.inc.php

date: 2004/08/21 05:53:12;  author: jarg;  state: Exp;  lines: +55 -1

Log Message:
Bugfix #9046, #9700
=====================================================================
Index: addressbook/inc/class.soaddressbook.inc.php
diff -u addressbook/inc/class.soaddressbook.inc.php:1.14.2.3.2.23 
addressbook/inc/class.soaddressbook.inc.php:1.14.2.3.2.24
--- addressbook/inc/class.soaddressbook.inc.php:1.14.2.3.2.23   Tue Mar  2 
19:04:05 2004
+++ addressbook/inc/class.soaddressbook.inc.php Sat Aug 21 05:53:12 2004
@@ -361,6 +361,7 @@
                {
                        $principal['owner'] = $fields['owner'];
                        $principal['access'] = 
$fields['tab_person_data']['ispublic'];
+                       $preferred_force_addr = 
$fields['tab_address']['addr_preferred'];
 
                        if(is_array($fields['tab_cats']['my_cats']))
                        {
@@ -437,6 +438,21 @@
                        
                        $this->execute_queries($queries);
                        
+                       if($preferred_force_addr && $preferred_force_addr!='')
+                        {
+                                $preferred_force_addr = 
$this->get_preferred_location($person_id, $preferred_force_addr);
+
+                                $this->contacts->edit_location_by_contact(
+                                       $person_id,
+                                       array('addr_preferred' => 'N'),
+                                       PHPGW_SQL_RUN_SQL);
+
+                                $this->contacts->edit_location(
+                                       $preferred_force_addr,
+                                       array('addr_preferred' => 'Y'),
+                                       PHPGW_SQL_RUN_SQL);
+                        }
+
                        /* Update the first and last name in accounts */
                        $account_id = 
$this->contacts->get_account_id($person_id);
                        if($account_id)
@@ -456,6 +472,7 @@
                {
                        $principal['owner'] = $fields['owner'];
                        $principal['access'] = 
$fields['tab_org_data']['ispublic'];
+                       $preferred_force_addr = 
$fields['tab_address']['addr_preferred'];
 
                        if(is_array($fields['tab_cats']['my_cats']))
                        {
@@ -497,8 +514,45 @@
                                              
$fields['tab_others']['other_value'], $org_id);
                        
                        $this->execute_queries($queries);
+
+                       if($preferred_force_addr && $preferred_force_addr!='')
+                        {
+                                $preferred_force_addr = 
$this->get_preferred_location($org_id, $preferred_force_addr);
+
+                                $this->contacts->edit_location_by_contact(
+                                       $org_id,
+                                       array('addr_preferred' => 'N'),
+                                       PHPGW_SQL_RUN_SQL);
+
+                                $this->contacts->edit_location(
+                                       $preferred_force_addr,
+                                       array('addr_preferred' => 'Y'),
+                                       PHPGW_SQL_RUN_SQL);
+                        }
                }
 
+               function get_preferred_location($contact_id, $preferred_forced)
+                {
+                        $addr_tmp = 
$this->contacts->get_addr_contact_data($contact_id);
+                        if(is_array($addr_tmp))
+                        {
+                                foreach($addr_tmp as $data)
+                               {
+                                       
if($preferred_forced==$data['key_addr_id'])
+                                       {
+                                               return $preferred_forced;
+                                       }
+                                       else
+                                       {
+                                               
$locations[$data['key_addr_id']] = $data;
+                                       }
+                               }
+                        }
+                        ksort($locations);
+                        end($locations);
+                        return key($locations);
+                }
+
                /**
                * This function call to edit_location from contact object
                * See the documentation in contact objet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]