phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: cdb/inc class.cdb_address.inc.php,1.1,1.2


From: Brian Morel <address@hidden>
Subject: [Phpgroupware-cvs] CVS: cdb/inc class.cdb_address.inc.php,1.1,1.2
Date: Fri, 15 Feb 2002 14:26:39 -0500

Update of /cvsroot/phpgroupware/cdb/inc
In directory subversions:/tmp/cvs-serv5026

Modified Files:
        class.cdb_address.inc.php 
Log Message:
rewrote file for the new set up

Index: class.cdb_address.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_address.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cdb_address.inc.php   11 Nov 2001 15:43:42 -0000      1.1
--- class.cdb_address.inc.php   15 Feb 2002 19:26:35 -0000      1.2
***************
*** 20,29 ****
                function cdb_address()
                {
                        /* add vars that have get/let interface to this array. 
*/
                        $this->_ = array(
!                               'city'       => '',
!                               'street'     => '',
!                               'country'    => '',
!                               'postalcode' => ''
                        );
                }
--- 20,33 ----
                function cdb_address()
                {
+                       $this->_db = $GLOBALS['phpgw']->db;
                        /* add vars that have get/let interface to this array. 
*/
                        $this->_ = array(
!                               'contact_address_id'       => 0,
!                               'entity_id'                => 0,
!                               'address_category_id'      => 0,
!                               'address_city'             => '',
!                               'address_country'          => '',
!                               'postal_code'              => '',
!                               'address_street'           => ''
                        );
                }
***************
*** 31,82 ****
                function get_address_id()
                {
                }
  
                function get_city()
                {
!                       return $this->get('city');
                }
  
                function let_city($new_city)
                {
!                       return $this->let('city', $new_city);
                }
  
                function get_street()
                {
!                       return $this->get('street');
                }
  
                function let_street($new_street)
                {
!                       return $this->let('street', $new_street);
                }
  
                function get_country()
                {
!                       return $this->get('country');
                }
  
                function let_country($new_country)
                {
!                       return $this->let('country', $new_country);
                }
  
                function get_postalcode()
                {
!                       return $this->get('postalcode');
                }
  
                function let_postalcode($new_postalcode)
                {
!                       return $this->let('postalcode', $new_postalcode);
                }
  
                function save()
                {
!               }
  
!               function load($id)
!               {
                }
        }
--- 35,180 ----
                function get_address_id()
                {
+                       return $this->_get('contact_address_id');
+               }
+   
+               function get_type_name()
+               {
+                       $sql = 'SELECT address_category_name FROM 
cdb_contact_address_category'.
+                               'WHERE 
address_category_id="'.$this->_get('address_category_id').
+                               '"';
+                       $this->_db->query($sql,__LINE__,__FILE__);
+                       return $this->_db->f('address_category_name');
+               }
+   
+               function get_type()
+               {
+                       return (int)$this->_get('address_category_id');
+               }
+         
+               function let_type($new_type)
+               {
+                       return $this->_let('address_category_id', 
(int)$new_type);
                }
  
                function get_city()
                {
!                       return $this->_get('address_city');
                }
  
                function let_city($new_city)
                {
!                       return $this->_let('address_city', $new_city);
                }
  
                function get_street()
                {
!                       return $this->_get('address_street');
                }
  
                function let_street($new_street)
                {
!                       return $this->_let('address_street', $new_street);
                }
  
                function get_country()
                {
!                       return $this->_get('address_country');
                }
  
                function let_country($new_country)
                {
!                       return $this->_let('address_country', $new_country);
                }
  
                function get_postalcode()
                {
!                       return $this->_get('postal_code');
                }
  
                function let_postalcode($new_postalcode)
                {
!                       return $this->_let('postal_code', $new_postalcode);
                }
  
                function save()
                {
!                       // Build update query
!                       $sqlp = "UPDATE cdb_contact_phone SET ";
!                       if ($this->_dirty_vars())
!                       {
!                               reset($this->_dirty);
!                               do
!                                       $key = key($this->_dirty);
!                                       switch($key)
!                                       {
!                                               case 'contact_address_id' :
!                                                       break;
!                                               default:
!                                                       $sql.=$key.'="';
!                                                       $sql .= 
$this->_get($key) . '", ';
!                                       }
!                         
!                               while (next($this->_dirty));
! 
!                               if ($sql)
!                               {
!                                       $sql .= 'entity_id="' . $this->id().'"'.
!                                               ' WHERE 
contact_address_id="'.$this->get_address_id().'"';
!                                       
$this->_db->query($sqlp.$sql,__LINE__,__FILE__);
!                               }
!                               return TRUE;
!                       }
!                       else
!                       {
!                               return FALSE;
!                       }
!               }
! 
!               function load($address_id)
!               {
!                       $sql = 'SELECT * FROM cdb_contact_address WHERE 
contact_address_id="' .
!                               $address_id . '"';
!                       $this->_db->query($sql,__LINE__,__FILE__);
! 
!                       reset($this->_);
!                       do
!                               $key = key($this->_);
!                               $this->_let($key,$this->_db->f($key));
!                       while(next($this->_));
! 
!                       $this->_id = (int)$this->_db->f('entity_id');
! 
!                       $this->_loaded = TRUE;
!                       $this->_dirty = array();
! 
!                       return (int)$this->id();
!               }
!   
!               function create($entity_id, $type_id, $street, $city,
!                               $country, $postal_code, )
!               {
!                       $this->_loaded = TRUE;
!                       $this->_dirty = array();
!                       $sql = 'INSERT INTO cdb_contact_address ( ' .
!                               '"entity_id",' .
!                               '"address_category_id", ' .
!                               '"address_street", ' .
!                               '"address_city", ' .
!                               '"address_country", ' .
!                               '"postal_code" ' .
!                               ') VALUES ("' .
!                               $entity_id . '", "' .
!                               $type_id . '", "' .
!                               $street . '", "' .
!                               $city . '", "' .
!                               $country . '", "' .
!                               $postal_code . '" )';
!                       $to_be_returned = 
$this->_db->query($sql,__LINE__,__FILE__);
!                       $this->_id = $entity_id;
!                       $this->_let('contact_address_id',
!                       $this->_db->get_last_insert_id('cdb_contact_address',
!                               'contact_address_id'));
  
!                       return $to_be_returned;
                }
        }




reply via email to

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