[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: sync/inc class.todo_base.inc.php,NONE,1.1
From: |
Dave Hall <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: sync/inc class.todo_base.inc.php,NONE,1.1 |
Date: |
Sun, 04 May 2003 05:00:58 -0400 |
Update of /cvsroot/phpgroupware/sync/inc
In directory subversions:/tmp/cvs-serv392/inc
Added Files:
class.todo_base.inc.php
Log Message:
this is likely to still be dodgy
--- NEW FILE ---
<?php
/**************************************************************************\
* phpGroupWare - Sync
*
* http://www.phpgroupware.org *
* Written by Dave Hall [skwashd AT phpgroupware.org]
*
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/*!
@class_start notes_base
@abstract Abstract Class for syncing notes data
*/
class notes_base
{
var $implementation; //type of implementation in non
abstract class
var $implemented_methods = null;
//class containters
var $common; //container for common object
var $notes; //container for bo notes object
function notes_base()
{
/* This will be uncommented soon
if(strcasecmp(get_class($this), 'notes_base')
== 0)
{
trigger_error('Cannot instantiate
abstract class ' . get_class($this), E_USER_ERROR);
return NULL;
}*/
$this->common = createObject('sync.common_' .
$this->implementation);
$this->notes = createObject('notes.bo');
}
/*!
* @function get_dirty_recs
* @abstract returns a list of records which were
editted/created since last sync
* @param $get_all - boolean - get all records - ignore
the last sync timestamp
*/
function get_dirty_recs($get_all = false)
{
$lastmod = (int) ( (bool) $get_all ? 0 :
$this->common->lastsync);
$dirty_recs = $this->notes->_list('', '', '',
'', $lastmod);
foreach($dirty_recs as $rec_id => $rec_vals)
{
$mapped_recs[$rec_id] =
$this->map_record($record, false);
}
return $mapped_recs;
}
/*!
* @function map_record
* @abstract ABSTRACT METHOD additional field
manipulation before export/import
* @param $record - the record to be manipulated
* @param $to_phpgw - is record going to phpgw? (import
- true/ export - false)
*/
function map_record($record, $to_phpgw=true)
{
return $record;
}
/*!
* @function phpgw_add
* @abstract add a new record to the phpgw notes
repository
* @param $note - notes content
* @param $public - boolean - is record public?
* @param $cat - mapped category_id to be used
*/
function phpgw_add($note, $public=true,
$category_id='', $remote_id)
{
$note['access'] = (bool) $public;
$note['content'] = $note;
$note['category']= (int) $category_id;
$remote_id = (int) $remote_id;
$phpgw_id = $this->notes->save($note);
$this->common->update_match($phpgw_id,
$remote_id, PHPGW_SYNC_STATUS_ACTIVE);
}
/*!
* @function phpgw_archive
* @abstract archive a record in the phpgw notes
repository - record remains in phpgw but is no longer sync'd
* @param $phpgw_id - record_id in phpgw notess
repsository
* @param $remote_id - record_id in remote system/device
notes system
*/
function phpgw_archive($phpgw_id, $remote_id)
{
$phpgw_id = (int) $phpgw_id;
$remote_id = (int) $remote_id;
$this->common->update_match($phpgw_id,
$remote_id, PHPGW_SYNC_STATUS_ARCHIVED);
}
/*!
* @function phpgw_delete
* @abstract delete a record from the phpgw notes
repository
* @param $phpgw_id - record_id in phpgw notes
repsository
* @param $remote_id - record_id in remote system/device
contacts system
*/
function phpgw_delete($phpgw_id, $remote_id)
{
$phpgw_id = (int) $phpgw_id;
$remote_id = (int) $remote_id;
$this->notes->delete($phpgw_id);
$this->common->update_match($phpgw_id,
$remote_id, PHPGW_SYNC_STATUS_DELETED);
}
/*!
* @function phpgw_update
* @abstract update an exiting record in the phpgw notes
repository - it will add it if it doesn't exist
* @param $note - contents of note
* @param $public - boolean - is record public?
* @param $cat - mapped category_id to be used
* @params $ids - array of ids - phpgw and remote
*/
function phpgw_update($note, $public=true,
$category_id='', $ids)
{
$remote_id = (int) $ids['remote'];
$status = $this->common->find_match($remote_id);
if($status === false)//must be new
{
$this->phpgw_add($record, $public,
$category_id, $remote_id)
}
if($status == PHPGW_SYNC_STATUS_ACTIVE)//all
others are irrelevant
{
$note['id'] = (int)
$ids['phpgw'];
$note['access'] = (bool)
$public;
$note['content'] = $note;
$note['category'] = (int)
$category_id;
$phpgw_id = $this->notes->save($note);
$this->common->update_match($phpgw_id,
$remote_id, PHPGW_SYNC_STATUS_ACTIVE);
}
}
}
/*!
@class_end notes_base
*/
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: sync/inc class.todo_base.inc.php,NONE,1.1,
Dave Hall <address@hidden> <=