[sync] [patch] is this the right way to use DataTree?

Anthony Mills amills at gascard.net
Thu Feb 12 15:01:27 PST 2004


I'm tring to use DataTree to store SyncML $ids.  Is this right?

Anthony

Index: State.php
===================================================================
RCS file: /repository/framework/SyncML/SyncML/State.php,v
retrieving revision 1.7
diff -r1.7 State.php
169a170,171
 >     
 >     var $_datatree;
182,183c184,185
<         
<         
---
 >
 >
185a188,195
 >         $dt = DateTree:factory('sql');
 >
 >         $driver = $conf['datatree']['driver'];
 >         $params = Horde::getDriverConfig('datatree', $driver);
 >         $params = array_merge($params, array( 'group' => 'syncml.ids' ));
 >
 >         $this->_datatree = &DataTree::singleton($driver, $params);
 >
273,275d282
<             Horde::logMessage('$this->_locName: ' . $this->_locName, 
__FILE__,                                                                
__LINE__,  PEAR_LOG_ERR);
<             Horde::logMessage('$this->_password: ' . $this->_password, 
__FILE_                                                               _, 
__LINE__,  PEAR_LOG_ERR);
<             
281,282d287
<         Horde::logMessage('isAuthorized: ' . $this->_isAuthorized, 
__FILE__, 
_                                                               
_LINE__,  PEAR_LOG_ERR);
<         
309,310c314,320
<     
<     function getUID($type, $shared) {
---
 >
 >     function getLocID($guid)
 >     {
 >         $id = $this->_datatree->getId($guid);
 >         $gid = $this->_datatree->get($id);
 >         
 >         return $gid->get('locid');
313c323,349
<     function setUID($type, $shared, $locid) {
---
 >     function setUID($type, $locid, $guid)
 >     {
 >         //set $locid
 >         $gid = &new DataTreeObject($guid);
 >         $gid->set('type', $type);
 >         $gid->set('locid', $locid);
 >         $this->_datatree->add($gid);
 >
 >         //set $globaluid
 >         $lid = &new DataTreeObject($this->_locName . 
$this->_sourceURI . 
$type                                                                . 
$locid);
 >         $lid->set('globaluid', $locid);
 >         $this->_datatree->add($lid);
 >     }
 >
 >     function getGlobalUID($type, $locid)
 >     {
 >         $id = $this->_datatree->getId($this->_locName . 
$this->_sourceURI . 
$t                                                               ype . 
$locid);
 >         $lid = $this->_datatree->get($id);
 >         return $lid->get('globaluid');
 >     }
 >
 >     function removeUID($type, $locid)
 >     {
 >         $id = $this->_datatree->getId($this->_locName . 
$this->_sourceURI . 
$t                                                               ype . 
$locid);
 >         $lid = $this->_datatree->get($id);
 >         $this->_datatree->remove($lid->get('globaluid'));
 >         $this->_datatree->remove($lid);



More information about the sync mailing list