[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: cdb/inc class.cdb_contact.inc.php,1.3,1.4 class.
From: |
Patrick Walsh <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: cdb/inc class.cdb_contact.inc.php,1.3,1.4 class.cdb_contact_phone.inc.php,1.1,1.2 class.cdb_entity_meta.inc.php,1.1,1.2 class.cdb_generic.inc.php,1.1,1.2 class.cdb_phone.inc.php,1.1,1.2 class.cdb_template.inc.php,1.1,1.2 admin.inc.php,1.1.1.1,NONE functions.inc.php,1.4,NONE generic.class.php,1.3,NONE preferences.inc.php,1.1.1.1,NONE |
Date: |
Wed, 13 Feb 2002 17:35:05 -0500 |
Update of /cvsroot/phpgroupware/cdb/inc
In directory subversions:/tmp/cvs-serv31647/inc
Modified Files:
class.cdb_contact.inc.php class.cdb_contact_phone.inc.php
class.cdb_entity_meta.inc.php class.cdb_generic.inc.php
class.cdb_phone.inc.php class.cdb_template.inc.php
Removed Files:
admin.inc.php functions.inc.php generic.class.php
preferences.inc.php
Log Message:
Still getting the foundation setup
Index: class.cdb_contact.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_contact.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.cdb_contact.inc.php 4 Feb 2002 18:55:22 -0000 1.3
--- class.cdb_contact.inc.php 13 Feb 2002 22:35:02 -0000 1.4
***************
*** 168,181 ****
@syntax int save()
@discussion This will use the _dirty array to determine what needs
! to be written to the database and then write it. Returns true
on
! success and false on failure.
! @example1 $x->save();
*/
function save()
{
- //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
--- 168,223 ----
@syntax int save()
@discussion This will use the _dirty array to determine what needs
! to be written to the database and then write it. Returns true
when
! changes have been made and false if none have been made.
! @example1 if ($x->save())
! {
! print lang('Changes saved.');
! }
! else
! {
! print lang('No changes saved.');
! }
*/
function save()
{
if($this->id() && $this->exists($this->id()) &&
$this->can_write()
&& $this->get_loaded())
{
+ //TODO need to save the children if they are
loaded
+ if (isset($this->_client))
+ {
+ if ($this->_client->save())
+ {
+ $this->_meta->set_modified();
+ }
+ }
+ if (isset($this->_personal))
+ {
+ if ($this->_personal->save())
+ {
+ $this->_meta->set_modified();
+ }
+ }
+ if (isset($this->_internet))
+ {
+ if ($this->_internet->save())
+ {
+ $this->_meta->set_modified();
+ }
+ }
+ if (isset($this->_phone))
+ {
+ if ($this->_phone->save())
+ {
+ $this->_meta->set_modified();
+ }
+ }
+ if (isset($this->_address))
+ {
+ if ($this->_address->save())
+ {
+ $this->_meta->set_modified();
+ }
+ }
// Build update query
***************
*** 212,220 ****
}
! // Save sub objects, if needed
! if ($this->_meta->_dirty_vars())
! {
! $this->_meta->save();
! }
return TRUE;
--- 254,259 ----
}
! $this->_meta->save();
! $this->_dirty = array();
return TRUE;
***************
*** 242,245 ****
--- 281,285 ----
// Don't worry about the status (deleted vs. active)
here...
+ // Simultaneously check existence of contact_id and get
entity_id
if (! $entity_id = $this->exists($contact_id))
{
***************
*** 247,250 ****
--- 287,292 ----
}
$this->_id = $entity_id;
+ $this->_loaded = FALSE;
+ $this->_dirty = array();
// Now lookup the main contact info
***************
*** 275,278 ****
--- 317,327 ----
$this->_db->query($sql,__LINE__,__FILE__);
$this->_let('note',$this->_db->f('note'));
+
+ //TODO: Now load the meta object
+ $this->_meta = CreateObject('cdb.cdb_entity_meta');
+ $this->_meta->load($this->id());
+
+ $this->_loaded = TRUE;
+ return TRUE;
}
Index: class.cdb_contact_phone.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_contact_phone.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cdb_contact_phone.inc.php 11 Nov 2001 15:43:42 -0000 1.1
--- class.cdb_contact_phone.inc.php 13 Feb 2002 22:35:02 -0000 1.2
***************
*** 18,26 ****
class cdb_contact_phone extends cdb_generic
{
function cdb_contact_phone()
{
! $this->_=array(
! /* add vars that have get/let interface
! to this array. */
);
}
--- 18,28 ----
class cdb_contact_phone extends cdb_generic
{
+ var $_phone_list;
+
function cdb_contact_phone()
{
! $this->_db = $GLOBALS['phpgw']->db;
! /* add vars that have get/let interface to this array.
*/
! $this->_ = array(
);
}
***************
*** 30,35 ****
}
! function load($id)
{
}
--- 32,41 ----
}
! function load($contact_id)
{
+ //do sql, then set id
+ $sql = 'SELECT * FROM cdb_contact_phone WHERE
contact_id="' .
+ $contact_id . '"';
+ $this->_db->query($sql,__LINE__,__FILE__);
}
Index: class.cdb_entity_meta.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_entity_meta.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cdb_entity_meta.inc.php 4 Feb 2002 18:55:22 -0000 1.1
--- class.cdb_entity_meta.inc.php 13 Feb 2002 22:35:02 -0000 1.2
***************
*** 77,80 ****
--- 77,86 ----
}
+ /*!
+ @function save
+ @abstract Saves any changed meta data
+ @discussion Returns true if any data has changed and false if
nothing
+ has changed.
+ */
function save()
{
***************
*** 100,109 ****
' WHERE entity_id="' .
$this->id() . '"';
$this->_db->query($sqlp.$sql,__LINE__,__FILE__);
}
- return TRUE;
}
else
{
! //TODO: raise a major error!
return FALSE;
}
--- 106,121 ----
' WHERE entity_id="' .
$this->id() . '"';
$this->_db->query($sqlp.$sql,__LINE__,__FILE__);
+ $this->_modified = FALSE;
+ $this->_dirty = array();
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
}
}
else
{
! //TODO: raise a major error! Can't save an
unloaded class
return FALSE;
}
***************
*** 113,116 ****
--- 125,133 ----
{
$this->_loaded = FALSE;
+ $this->_modified = FALSE;
+ $this->_id = 0;
+
+ // Retrieve the type of entity. If the entity doesn't
exist,
+ // FALSE will be returned and we should return false as
well.
$entity = CreateObject('cdb.cdb_entity');
if (! $type = $entity->get_type($entity_id))
***************
*** 118,121 ****
--- 135,139 ----
return FALSE;
}
+
$this->_id = $entity_id;
Index: class.cdb_generic.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_generic.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cdb_generic.inc.php 11 Nov 2001 15:43:42 -0000 1.1
--- class.cdb_generic.inc.php 13 Feb 2002 22:35:02 -0000 1.2
***************
*** 16,89 ****
/* $Id$ */
- /* This class is extended by all cdb classes */
- class cdb_generic
- {
- var $_ = array();
- var $_dirty = array();
- var $_id = 0;
- var $grants = '';
! function cdb_generic()
{
! $this->grants =
$GLOBALS['phpgw']->acl->get_grants('cdb');
}
!
! function let($var, $val)
{
! if ($this->get($var) != $val)
{
! /* new value, so make it dirty */
$this->_dirty[$var] = 1;
$this->_[$var] = $val;
!
! return True; /* signal that a change was made */
}
- return False; /* signal that no change was made */
}
! function get($var)
{
return $this->_[$var];
}
!
! function dirty($dirty_prop)
{
! $this->_dirty[$dirty_prop] = 1;
}
! function id()
{
! return $this->_id;
}
!
! function exists($id)
{
! $id = intval($id);
! $query = "SELECT (contact_id) FROM
phpgw_cdb_contact_main WHERE contact_id=$id");
! $this->db->query($query,__LINE__,__FILE__);
! if($this->db->next_record())
! {
! return True;
! }
! return False;
}
! function can_read($id)
{
! if($this->grants & PHPGW_ACL_READ)
! {
! return True;
! }
! return False;
}
! function can_write($id)
{
! if($this->grants & PHPGW_ACL_EDIT)
! {
! return True;
! }
! return False;
}
}
?>
--- 16,163 ----
/* $Id$ */
! /* This class is extended by all cdb classes */
! class cdb_generic {
!
! /////////////////////////////////////////////////
! ////////////// Public Variables /////////////////
! /////////////////////////////////////////////////
! /* These vars are declared like: 'var $varname;' */
!
! /////////////////////////////////////////////////
! /////////////// Local Variables /////////////////
! /////////////////////////////////////////////////
! /* PHP does not support local vars. Use */
! /* 'var $_varname;' to signify local vars. */
!
! var $_ = array();
! var $_dirty = array();
! 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])
! {
! return TRUE;
! }
! else
{
! //TODO Raise a phpgw error and make a stink
! // but for now, just write a message:
! print ('Bad variable '.$var);
! return FALSE;
! }
! }
!
! function _let($var, $val)
! {
! if ($this->_var_valid($var) && $this->can_write()) {
! if ($this->_get($var) != $val)
{
! // new value, so make it dirty
$this->_dirty[$var] = 1;
$this->_[$var] = $val;
!
! return TRUE; //signal that a change was made
}
}
+ return FALSE; //signal that no change was made
+ }
! function _get($var)
! {
! if ($this->_var_valid($var) && $this->can_read())
{
return $this->_[$var];
}
! else
{
! return FALSE;
}
+ }
! function _dirty_vars()
! {
! if (is_array($this->_dirty) && count($this->_dirty)>0)
{
! return TRUE;
}
! else
{
! return FALSE;
}
+ }
! function dirty($dirty_prop)
! {
! if ($this->_var_exists($var))
{
! $this->_dirty[$dirty_prop]=1;
! return TRUE;
! }
! else
! {
! return FALSE;
}
+ }
! /////////////////////////////////////////////////
! ////////////// Public Functions /////////////////
! /////////////////////////////////////////////////
! function id()
! {
! return $this->_id;
! }
!
! /*!
! @function loaded
! @abstract Returns true if a entity is loaded in memory
! */
! function loaded()
! {
! return $this->_loaded;
! }
!
! function can_read($entity_id)
! {
! //TODO: check for read permissions
! $retval = TRUE;
! if(is_int($entity_id))
{
! // do stuff
! }
! else
! {
! $entity_id = $this->id();
! }
! return $retval;
! }
!
! function can_write($entity_id)
! {
! //TODO: check for write permissions
! $retval = TRUE;
! if(is_int($entity_id))
! {
! // do stuff
! }
! else
! {
! $entity_id = $this->id();
}
+ return $retval;
}
+
+ }
?>
Index: class.cdb_phone.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_phone.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cdb_phone.inc.php 11 Nov 2001 15:43:42 -0000 1.1
--- class.cdb_phone.inc.php 13 Feb 2002 22:35:02 -0000 1.2
***************
*** 23,27 ****
$this->_ = array(
'id' => '',
! 'type' => '',
'number' => ''
);
--- 23,27 ----
$this->_ = array(
'id' => '',
! 'type' => 0,
'number' => ''
);
***************
*** 32,39 ****
}
! function load($phone_id)
{
- //do sql, then set id
- $this->let("id", $phone_id);
}
--- 32,42 ----
}
! function load($phone_id, $type_id, $number)
! {
! $this->create($phone_id, $type_id, $number);
! }
!
! function create($phone_id, $type_id, $number)
{
}
Index: class.cdb_template.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/cdb/inc/class.cdb_template.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cdb_template.inc.php 11 Nov 2001 15:43:42 -0000 1.1
--- class.cdb_template.inc.php 13 Feb 2002 22:35:02 -0000 1.2
***************
*** 16,48 ****
/* $Id$ */
class cdb_xxx extends cdb_generic
{
function cdb_xxx()
{
/* add vars that have get/let interface to this array.
*/
! $this->_=array(
'zzz' => '',
'xxx' => ''
);
}
function get_zzz()
{
! return $this->get('zzz');
}
function let_zzz($new_zzz)
{
! return $this->let('zzz', $new_zzz);
}
function get_xxx()
{
! return $this->get('xxx');
}
function let_xxx($new_xxx)
{
! return $this->let('xxx', $new_xxx);
}
}
--- 16,73 ----
/* $Id$ */
+ /* This file is here merely to serve as an EXAMPLE of how to create
+ a class in cdb.
+ */
+
+ /*!
+ @class cdb_xxx
+ @abstract This class does xxx
+ @syntax CreateObject('cdb.cdb_xxx');
+ @example $x = CreateObject('cdb.cdb_xxx');
+ @author your_name_here
+ @copyright GPL
+ @package cdb
+ @access public
+ */
class cdb_xxx extends cdb_generic
{
function cdb_xxx()
{
+ var $_privatevarshere;
+ $this->_db = $GLOBALS['phpgw']->db;
+
/* add vars that have get/let interface to this array.
*/
! $this->_ = array(
'zzz' => '',
+ 'yyy' => 0,
'xxx' => ''
);
}
+ /*!
+ @function get_zzz
+ @abstract Get's the zzz property
+ @discussion Returns either x or y
+ @example1 $x->get_zzz();
+ */
function get_zzz()
{
! return $this->_get('zzz');
}
function let_zzz($new_zzz)
{
! // Check for sane data here before calling _let
! return $this->_let('zzz', $new_zzz);
}
function get_xxx()
{
! return $this->_get('xxx');
}
function let_xxx($new_xxx)
{
! return $this->_let('xxx', $new_xxx);
}
}
--- admin.inc.php DELETED ---
--- functions.inc.php DELETED ---
--- generic.class.php DELETED ---
--- preferences.inc.php DELETED ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: cdb/inc class.cdb_contact.inc.php,1.3,1.4 class.cdb_contact_phone.inc.php,1.1,1.2 class.cdb_entity_meta.inc.php,1.1,1.2 class.cdb_generic.inc.php,1.1,1.2 class.cdb_phone.inc.php,1.1,1.2 class.cdb_template.inc.php,1.1,1.2 admin.inc.php,1.1.1.1,NONE functions.inc.php,1.4,NONE generic.class.php,1.3,NONE preferences.inc.php,1.1.1.1,NONE,
Patrick Walsh <address@hidden> <=