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_entity_meta.inc.php,NONE,1.1 c


From: Patrick Walsh <address@hidden>
Subject: [Phpgroupware-cvs] CVS: cdb/inc class.cdb_entity_meta.inc.php,NONE,1.1 class.cdb_contact.inc.php,1.2,1.3 class.cdb_entity.inc.php,1.2,1.3 generic.class.php,1.1,1.2 class.cdb_contact_meta.inc.php,1.2,NONE
Date: Mon, 04 Feb 2002 13:55:25 -0500

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

Modified Files:
        class.cdb_contact.inc.php class.cdb_entity.inc.php 
        generic.class.php 
Added Files:
        class.cdb_entity_meta.inc.php 
Removed Files:
        class.cdb_contact_meta.inc.php 
Log Message:
Various updates


***** Error reading new file: [Errno 2] No such file or directory: 
'class.cdb_entity_meta.inc.php'
Index: class.cdb_contact.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_contact.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.cdb_contact.inc.php   28 Jan 2002 09:50:08 -0000      1.2
--- class.cdb_contact.inc.php   4 Feb 2002 18:55:22 -0000       1.3
***************
*** 27,38 ****
          @access public
  */
- 
        class cdb_contact extends cdb_generic
        {
!           /////////////////////////////////////////////////
!          ////////////// Public Functions /////////////////
!         /////////////////////////////////////////////////
!               var $_client; /* my subclass client */
!               var $_meta; /* my subclass meta */
                var $_personal;
                var $_internet;
--- 27,34 ----
          @access public
  */
        class cdb_contact extends cdb_generic
        {
!               var $_client; 
!               var $_meta; 
                var $_personal;
                var $_internet;
***************
*** 71,74 ****
--- 67,73 ----
                }
  
+           /////////////////////////////////////////////////
+          ////////////// Public Functions /////////////////
+         /////////////////////////////////////////////////
                /*!
                @function contact_id
***************
*** 118,121 ****
--- 117,121 ----
                        $this->_id = 
$this->_db->get_last_insert_id('cdb_entity_id',
                                        'entity_id');
+ 
                        // Create entry in entity_meta
                        $status = "active";
***************
*** 133,139 ****
--- 133,147 ----
                        $this->_db->query($sql,__LINE__,__FILE__);
                        
+                       $this->_meta = CreateObject('cdb.cdb_entity_meta');
+                       $this->_meta->load($this->id());
+ 
                        return $this->id();
                }
  
+         /*!
+         @function exists
+         @abstract Checks the existence of contact_id
+         @discussion Checks for the existence of contact_id
+         */
        function exists($contact_id)
        {
***************
*** 167,198 ****
                {
                        //TODO need to save the children if they are loaded
!                       if($this->id() && $this->exists($this->id()) && 
$this->can_write())
                        {
!                               // Build query
                                $sqlp = "UPDATE cdb_contact_main SET ";
!                               reset($this->_dirty);
!                               do
!                                       $key = key($this->_dirty);
!                                       switch($key)
                                        {
!                                               case 'note':
!                                                       // the note is in a 
diff table 
!                                                       // sine it's by itself, 
just do db now
!                                                       $sql2.='UPDATE 
cdb_entity_notes SET note="'.
!                                                                       
$this->get_note().'" WHERE entity_id="'.
!                                                                       
$this->id().'"';
!                                                       
$this->_db->query($sql2,__LINE__,__FILE__);
!                                                       break;
!                                               default:
!                                                       $sql.=$key.'="';
                                        }
!                                       $sql .= $this->_get($key) . '", ';
!                               while (next($this->_dirty));
!                               if ($sql) 
                                {
!                                       $sql .= 'contact_id="' . 
$this->get_contact_id() . '"' .
!                                                       ' WHERE 
contact_id="'.$this->get_contact_id() . '"';
!                                       
$this->_db->query($sqlp.$sql,__LINE__,__FILE__);
                                }
                                return TRUE;
                        }
--- 175,221 ----
                {
                        //TODO need to save the children if they are loaded
!                       if($this->id() && $this->exists($this->id()) && 
$this->can_write()
!                               && $this->get_loaded())
                        {
! 
!                               // Build update query
                                $sqlp = "UPDATE cdb_contact_main SET ";
!                               if ($this->_dirty_vars()) 
!                               {
!                                       $this->_meta->set_modified();
! 
!                                       reset($this->_dirty);
!                                       do
!                                               $key = key($this->_dirty);
!                                               switch($key)
!                                               {
!                                                       case 'note':
!                                                               // the note is 
in a diff table 
!                                                               // sine it's by 
itself, just do db now
!                                                               $sql2.='UPDATE 
cdb_entity_notes SET note="'.
!                                                                               
$this->get_note().'" WHERE entity_id="'.
!                                                                               
$this->id().'"';
!                                                               
$this->_db->query($sql2,__LINE__,__FILE__);
!                                                               
$this->_meta->set_modified();
!                                                               break;
!                                                       default:
!                                                               $sql.=$key.'="';
!                                               }
!                                               $sql .= $this->_get($key) . '", 
';
!                                       while (next($this->_dirty));
!                                       if ($sql) 
                                        {
!                                               $sql .= 'contact_id="' . 
$this->get_contact_id().'"'.
!                                                       ' WHERE 
contact_id="'.$this->get_contact_id().'"';
!                                               
$this->_db->query($sqlp.$sql,__LINE__,__FILE__);
                                        }
!                               }
! 
!                               // Save sub objects, if needed
!                               if ($this->_meta->_dirty_vars())
                                {
!                                       $this->_meta->save();
                                }
+ 
                                return TRUE;
                        }

Index: class.cdb_entity.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_entity.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.cdb_entity.inc.php    28 Jan 2002 09:49:51 -0000      1.2
--- class.cdb_entity.inc.php    4 Feb 2002 18:55:22 -0000       1.3
***************
*** 51,57 ****
                                //if entity_type='contact' and loaded==true 
then this contains
                                //the loaded contact data
!                               'contact_obj' => '',            
!                               //True when the object is already loaded
!                               'loaded'      => FALSE          
                        );
                }
--- 51,55 ----
                                //if entity_type='contact' and loaded==true 
then this contains
                                //the loaded contact data
!                               'contact_obj' => ''             
                        );
                }
***************
*** 70,78 ****
                        unset $this->_org;
                        unset $this->_contact;
!                       $this->_let('loaded',FALSE);
                        $this->_id = 0;
  
!                       $sql = 'SELECT * FROM cdb_entity_id WHERE ';
!                       $sql .= 'entity_id="'.$entity_id.'"';
                        $this->_db->query($sql,__LINE__,__FILE__);
                        if ($this->_db->next_record())
--- 68,76 ----
                        unset $this->_org;
                        unset $this->_contact;
!                       $this->_loaded = FALSE;
                        $this->_id = 0;
  
!                       $sql = 'SELECT * FROM cdb_entity_id WHERE ' .
!                               'entity_id="'.$entity_id.'"';
                        $this->_db->query($sql,__LINE__,__FILE__);
                        if ($this->_db->next_record())
***************
*** 87,91 ****
                                        if ($this->_contact->load($contact_id))
                                        {
!                                               $this->_let('loaded',TRUE);
                                                return $this->id();
                                        }
--- 85,89 ----
                                        if ($this->_contact->load($contact_id))
                                        {
!                                               $this->_loaded = TRUE;
                                                return $this->id();
                                        }
***************
*** 101,105 ****
                                        if ($this->_org->load($org_id))
                                        {
!                                               $this->_let('loaded',TRUE);
                                                return $this->id();
                                        }
--- 99,103 ----
                                        if ($this->_org->load($org_id))
                                        {
!                                               $this->_loaded = TRUE;
                                                return $this->id();
                                        }
***************
*** 132,136 ****
                        unset $this->_org;
                        unset $this->_contact;
!                       $this->_let('loaded',FALSE);
                        $this->_id = 0;
  
--- 130,134 ----
                        unset $this->_org;
                        unset $this->_contact;
!                       $this->_loaded = FALSE;
                        $this->_id = 0;
  
***************
*** 142,146 ****
                                {
                                        $this->_id = $this->_contact->id();
!                                       $this->_let('loaded',TRUE);
                                        return $this->id();
                                }
--- 140,144 ----
                                {
                                        $this->_id = $this->_contact->id();
!                                       $this->_loaded = TRUE;
                                        return $this->id();
                                }
***************
*** 160,164 ****
                                        
$this->_db->query($sql,__LINE__,__FILE__);
                                        $this->_id = 
$this->_db->get_last_insert_id('cdb_entity_id','entity_id');
!                                       $this->_let('loaded',TRUE);
                                        return $this->id();
                                }
--- 158,162 ----
                                        
$this->_db->query($sql,__LINE__,__FILE__);
                                        $this->_id = 
$this->_db->get_last_insert_id('cdb_entity_id','entity_id');
!                                       $this->_loaded = TRUE;
                                        return $this->id();
                                }
***************
*** 183,188 ****
                        //TODO: call contact.delete or org.delete
                }
! 
!           function exists($entity_id)
        {
                if (!is_int($entity_id))
--- 181,189 ----
                        //TODO: call contact.delete or org.delete
                }
!               /*!
!               @function exists
!               @abstract See if entity exists
!               */
!           function exists($entity_id='')
        {
                if (!is_int($entity_id))
***************
*** 205,213 ****
                @function get_type
                @abstract Get's the entity type
!               @discussion Returns either "contact" or "organization"
                */
!               function get_type()
                {
!                       return $this->_get('entity_type');
                }
  
--- 206,241 ----
                @function get_type
                @abstract Get's the entity type
!               @discussion Returns either "contact" or "organization" -- gets 
the
!                       type of the currently loaded id or if entity_id is 
passed, 
!                       checks that id instead.
!               @example1 $x->get_type();
!               @example2 $x->get_type(123);
                */
!               function get_type($entity_id='')
                {
!                       if (is_int($entity_id))
!                       {
!                               $sql = 'SELECT * FROM cdb_entity_id WHERE ' .
!                                       'entity_id="'.$entity_id.'"';
!                               $this->_db->query($sql,__LINE__,__FILE__);
!                               $contact_id = $this->_db->f('contact_id');
!                               $org_id = $this->_db->f('organization_id');
!                               if ($contact_id) 
!                               {
!                                       return 'contact';
!                               }
!                               else if ($org_id)
!                               {
!                                       return 'organization';
!                               }
!                               else
!                               {
!                                       return FALSE;
!                               }
!                       }
!                       else
!                       {
!                               return $this->_get('entity_type');
!                       }
                }
  

Index: generic.class.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/generic.class.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** generic.class.php   28 Jan 2002 09:50:50 -0000      1.1
--- generic.class.php   4 Feb 2002 18:55:22 -0000       1.2
***************
*** 35,44 ****
        var $_id = 0;
        var $_db;
  
    /////////////////////////////////////////////////
   ///////////// Private Functions /////////////////
  /////////////////////////////////////////////////
!       function _var_exists($var)
        {
                if (isset($this->_[$var]) 
                {
--- 35,51 ----
        var $_id = 0;
        var $_db;
+     var $_loaded;
  
    /////////////////////////////////////////////////
   ///////////// Private Functions /////////////////
  /////////////////////////////////////////////////
!       function _var_valid($var)
        {
+               if (! $this->_loaded)
+               {
+                       //TODO raise an error
+                       print ('Class not loaded');
+                       return FALSE;
+               }
                if (isset($this->_[$var]) 
                {
***************
*** 53,59 ****
                }
        }
        function _let($var, $val) 
        {
!               if ($this->_var_exists($var)) {
                        if ($this->_get($var) != $val) 
                        {
--- 60,67 ----
                }
        }
+ 
        function _let($var, $val) 
        {
!               if ($this->_var_valid($var)) {
                        if ($this->_get($var) != $val) 
                        {
***************
*** 70,74 ****
        function _get($var) 
        {
!               if ($this->_var_exists($var)) 
                {
                        return $this->_[$var];
--- 78,82 ----
        function _get($var) 
        {
!               if ($this->_var_valid($var)) 
                {
                        return $this->_[$var];
***************
*** 80,83 ****
--- 88,103 ----
        }
  
+     function _dirty_vars()
+       {
+               if (is_array($this->_dirty) && count($this->_dirty)>0)
+               {
+                       return TRUE;
+               }
+               else
+               {
+                       return FALSE;
+               }
+       }
+ 
        function dirty($dirty_prop) 
        {
***************
*** 99,102 ****
--- 119,131 ----
        {
                return $this->_id;
+       }
+ 
+       /*!
+       @function loaded
+       @abstract Returns true if a entity is loaded in memory
+       */
+       function loaded()
+       {
+               return $this->_loaded;
        }
  

--- class.cdb_contact_meta.inc.php DELETED ---




reply via email to

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