mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
phpgw --> egw
This commit is contained in:
parent
94da0682cd
commit
2349c28fa8
@ -150,64 +150,64 @@ define('MAX_ENTRIES', 10);
|
||||
* @package Horde_SyncML
|
||||
*/
|
||||
class Horde_SyncML_State {
|
||||
|
||||
|
||||
var $_sessionID;
|
||||
|
||||
|
||||
var $_verProto;
|
||||
|
||||
|
||||
var $_msgID;
|
||||
|
||||
|
||||
var $_targetURI;
|
||||
|
||||
|
||||
var $_sourceURI;
|
||||
|
||||
|
||||
var $_version;
|
||||
|
||||
|
||||
var $_locName;
|
||||
|
||||
|
||||
var $_password;
|
||||
|
||||
|
||||
var $_isAuthorized;
|
||||
|
||||
|
||||
var $_uri;
|
||||
|
||||
|
||||
var $_uriMeta;
|
||||
|
||||
|
||||
var $_syncs = array();
|
||||
|
||||
|
||||
var $_clientAnchorNext = array(); // written to db after successful sync
|
||||
|
||||
|
||||
var $_serverAnchorLast = array();
|
||||
|
||||
|
||||
var $_serverAnchorNext = array(); // written to db after successful sync
|
||||
|
||||
|
||||
var $_clientDeviceInfo = array();
|
||||
|
||||
|
||||
// array list of changed items, which need to be synced to the client
|
||||
var $_changedItems;
|
||||
|
||||
|
||||
// array list of deleted items, which need to be synced to the client
|
||||
var $_deletedItems;
|
||||
|
||||
|
||||
// array list of added items, which need to be synced to the client
|
||||
var $_addedItems;
|
||||
|
||||
|
||||
// bool flag that we need to more data
|
||||
var $_syncStatus;
|
||||
|
||||
|
||||
var $_log = array();
|
||||
|
||||
|
||||
// stores if we received Alert 222 already
|
||||
var $_receivedAlert222 = false;
|
||||
|
||||
|
||||
// stores if we already requested the deviceinfo
|
||||
var $_devinfoRequested = false;
|
||||
|
||||
/*
|
||||
/*
|
||||
* store the mappings of egw uids to client uids
|
||||
*/
|
||||
var $_uidMappings = array();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of Horde_SyncML_State.
|
||||
*/
|
||||
@ -222,7 +222,7 @@ class Horde_SyncML_State {
|
||||
|
||||
$this->isAuthorized = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* store the sent global uid
|
||||
*/
|
||||
@ -237,7 +237,7 @@ class Horde_SyncML_State {
|
||||
if(isset($this->_uidMappings[$_sentEgwUid])) {
|
||||
return $this->_uidMappings[$_sentEgwUid];
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ class Horde_SyncML_State {
|
||||
{
|
||||
return $this->_addedItems[$_type];
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -297,20 +297,20 @@ class Horde_SyncML_State {
|
||||
{
|
||||
return $this->_changedItems[$_type];
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function &getDeletedItems($_type)
|
||||
{
|
||||
if(isset($this->_deletedItems[$_type]))
|
||||
{
|
||||
return $this->_deletedItems[$_type];
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getMoreDataPending()
|
||||
{
|
||||
return $this->_moreDataPending;
|
||||
@ -330,7 +330,7 @@ class Horde_SyncML_State {
|
||||
{
|
||||
return !empty($this->_wbxml);
|
||||
}
|
||||
|
||||
|
||||
function &getSyncStatus()
|
||||
{
|
||||
return $this->_syncStatus;
|
||||
@ -398,7 +398,7 @@ class Horde_SyncML_State {
|
||||
#Horde::logMessage('SyncML: syncState set to ==> ' . $_syncStatus, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$this->_syncStatus = $_syncStatus;
|
||||
}
|
||||
|
||||
|
||||
function setTargetURI($targetURI)
|
||||
{
|
||||
$this->_targetURI = $targetURI;
|
||||
@ -427,15 +427,15 @@ class Horde_SyncML_State {
|
||||
function isAuthorized()
|
||||
{
|
||||
if (!$this->_isAuthorized) {
|
||||
|
||||
|
||||
if(strstr($this->_locName,'@') === False)
|
||||
{
|
||||
$this->_locName .= '@'.$GLOBALS['phpgw_info']['server']['default_domain'];
|
||||
$this->_locName .= '@'.$GLOBALS['egw_info']['server']['default_domain'];
|
||||
}
|
||||
|
||||
#Horde::logMessage('SyncML: Authenticate ' . $this->_locName . ' - ' . $this->_password, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
|
||||
if($GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($this->_locName,$this->_password,'text','u'))
|
||||
|
||||
if($GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($this->_locName,$this->_password,'text','u'))
|
||||
{
|
||||
$this->_isAuthorized = true;
|
||||
#Horde::logMessage('SyncML_EGW: Authentication of ' . $this->_locName . '/' . $GLOBALS['sessionid'] . ' succeded' , __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
@ -450,13 +450,13 @@ class Horde_SyncML_State {
|
||||
{
|
||||
// store sessionID in a variable, because ->verify maybe resets that value
|
||||
$sessionID = session_id();
|
||||
if(!$GLOBALS['phpgw']->session->verify($sessionID, 'staticsyncmlkp3'))
|
||||
if(!$GLOBALS['egw']->session->verify($sessionID, 'staticsyncmlkp3'))
|
||||
Horde::logMessage('SyncML_EGW: egw session('.$sessionID. ') not verified ' , __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
}
|
||||
|
||||
return $this->_isAuthorized;
|
||||
}
|
||||
|
||||
|
||||
function clearSync($target)
|
||||
{
|
||||
unset($this->_syncs[$target]);
|
||||
@ -475,17 +475,17 @@ class Horde_SyncML_State {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getTargets()
|
||||
{
|
||||
if(count($this->_syncs) < 1)
|
||||
return FALSE;
|
||||
|
||||
|
||||
foreach($this->_syncs as $target => $sync)
|
||||
{
|
||||
$targets[] = $target;
|
||||
}
|
||||
|
||||
|
||||
return $targets;
|
||||
}
|
||||
|
||||
@ -728,23 +728,23 @@ class Horde_SyncML_State {
|
||||
case 'notes':
|
||||
return 'text/x-vnote';
|
||||
break;
|
||||
|
||||
|
||||
case 'calendar':
|
||||
case 'tasks':
|
||||
case 'caltasks':
|
||||
return 'text/x-vcalendar';
|
||||
break;
|
||||
|
||||
|
||||
case 'sifcalendar':
|
||||
case 'scal':
|
||||
return 'text/x-s4j-sife';
|
||||
break;
|
||||
|
||||
|
||||
case 'sifcontacts':
|
||||
case 'scard':
|
||||
return 'text/x-s4j-sifc';
|
||||
break;
|
||||
|
||||
|
||||
case 'siftasks':
|
||||
case 'stask':
|
||||
return 'text/x-s4j-sift';
|
||||
@ -754,7 +754,7 @@ class Horde_SyncML_State {
|
||||
case 'snote':
|
||||
return 'text/x-s4j-sifn';
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Horde::logMessage("SyncML: unrecognized content type '$_type'", __FILE__, __LINE__, PEAR_LOG_ERR);
|
||||
break;
|
||||
@ -769,15 +769,15 @@ class Horde_SyncML_State {
|
||||
case 'contacts':
|
||||
return 'contacts';
|
||||
break;
|
||||
|
||||
|
||||
case 'notes':
|
||||
return 'notes';
|
||||
break;
|
||||
|
||||
|
||||
case 'tasks':
|
||||
return 'tasks';
|
||||
break;
|
||||
|
||||
|
||||
case 'calendar':
|
||||
case 'caltasks':
|
||||
return 'calendar';
|
||||
@ -789,12 +789,12 @@ class Horde_SyncML_State {
|
||||
case 'scal':
|
||||
return 'sifcalendar';
|
||||
break;
|
||||
|
||||
|
||||
case 'sifcontacts':
|
||||
case 'scard':
|
||||
return 'sifcontacts';
|
||||
break;
|
||||
|
||||
|
||||
case 'siftasks':
|
||||
case 'stask':
|
||||
return 'siftasks';
|
||||
@ -819,17 +819,17 @@ class Horde_SyncML_State {
|
||||
*
|
||||
* This is passed as an option to the Horde API export functions.
|
||||
*/
|
||||
|
||||
|
||||
function getPreferedContentTypeClient($_sourceLocURI, $_targetLocURI = null) {
|
||||
$deviceInfo = $this->getClientDeviceInfo();
|
||||
|
||||
|
||||
if(isset($deviceInfo['dataStore'][$_sourceLocURI]['rxPreference']['contentType']))
|
||||
{
|
||||
return $this->adjustContentType($deviceInfo['dataStore'][$_sourceLocURI]['rxPreference']['contentType'], $_targetLocURI);
|
||||
}
|
||||
|
||||
|
||||
Horde::logMessage('SyncML: sourceLocURI ' . $_sourceLocURI .' not found', __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
|
||||
|
||||
if ($_targetLocURI != null)
|
||||
{
|
||||
return $this->adjustContentType($this->getPreferedContentType($_targetLocURI), $_targetLocURI);
|
||||
@ -905,7 +905,7 @@ class Horde_SyncML_State {
|
||||
}
|
||||
|
||||
$info = $dt->getObjectById($id);
|
||||
|
||||
|
||||
return $info->get('ClientDeviceInfo');
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
|
||||
{
|
||||
$mapID = $this->_locName . $this->_sourceURI . $type;
|
||||
|
||||
$db = clone($GLOBALS['phpgw']->db);
|
||||
$db = clone($GLOBALS['egw']->db);
|
||||
|
||||
$cols = array('map_timestamp');
|
||||
|
||||
|
@ -22,41 +22,41 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
|
||||
function endSync($currentCmdID, &$output) {
|
||||
global $registry;
|
||||
|
||||
|
||||
$state = &$_SESSION['SyncML.state'];
|
||||
|
||||
|
||||
$syncType = $this->_targetLocURI;
|
||||
|
||||
|
||||
$hordeType = $state->getHordeType($syncType);
|
||||
|
||||
|
||||
$refts = $state->getServerAnchorLast($syncType);
|
||||
$currentCmdID = $this->handleSync($currentCmdID,
|
||||
$hordeType,
|
||||
$syncType,
|
||||
$output,
|
||||
$refts);
|
||||
|
||||
|
||||
return $currentCmdID;
|
||||
}
|
||||
|
||||
function handleSync($currentCmdID, $hordeType, $syncType,&$output, $refts) {
|
||||
global $registry;
|
||||
|
||||
|
||||
// array of Items which got modified, but got never send to the client before
|
||||
$missedAdds = array();
|
||||
|
||||
$history = $GLOBALS['phpgw']->contenthistory;
|
||||
|
||||
$history = $GLOBALS['egw']->contenthistory;
|
||||
$state = &$_SESSION['SyncML.state'];
|
||||
$counter = 0;
|
||||
|
||||
|
||||
$changes = &$state->getChangedItems($hordeType);
|
||||
$deletes = &$state->getDeletedItems($hordeType);
|
||||
$adds = &$state->getAddedItems($hordeType);
|
||||
|
||||
|
||||
Horde::logMessage("SyncML: ".count($changes).' changed items found for '.$hordeType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde::logMessage("SyncML: ".count($deletes).' deleted items found for '.$hordeType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde::logMessage("SyncML: ".count($adds). ' added items found for '.$hordeType , __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
|
||||
|
||||
// handle changes
|
||||
if(is_array($changes)) {
|
||||
while($guid = array_shift($changes)) {
|
||||
@ -77,7 +77,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
Horde::logMessage("SyncML: unable to create change for $guid: locid not found in map", __FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Create a replace request for client.
|
||||
$contentType = $state->getPreferedContentTypeClient($this->_sourceLocURI, $this->_targetLocURI);
|
||||
$c = $registry->call($hordeType. '/export',
|
||||
@ -98,7 +98,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
|
||||
$currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Replace');
|
||||
$state->log('Server-Replace');
|
||||
|
||||
|
||||
// return if we have to much data
|
||||
if (++$counter >= MAX_ENTRIES
|
||||
&& isset($contentType['mayFragment'])
|
||||
@ -124,13 +124,13 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
Horde::logMessage("SyncML: delete $guid ignored, came from client", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$locid = $state->getLocID($syncType, $guid);
|
||||
if (!$locid) {
|
||||
Horde::logMessage("SyncML: unable to create delete for $guid: locid not found in map", __FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Horde::logMessage("SyncML: delete: $guid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
// Create a Delete request for client.
|
||||
$cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement();
|
||||
@ -139,7 +139,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
$currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Delete');
|
||||
$state->log('Server-Delete');
|
||||
$state->removeUID($syncType, $locid);
|
||||
|
||||
|
||||
$contentType = $state->getPreferedContentTypeClient($this->_sourceLocURI, $this->_targetLocURI);
|
||||
// return if we have to much data
|
||||
if(++$counter >= MAX_ENTRIES
|
||||
@ -160,7 +160,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
$adds = &$state->getAddedItems($hordeType);
|
||||
Horde::logMessage("SyncML: merged adds counter ".count($adds).' / '.$adds[0], __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
if(is_array($adds)) {
|
||||
while($guid = array_shift($adds)) {
|
||||
$guid_ts = $history->getTSforAction($guid, 'add');
|
||||
@ -172,9 +172,9 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
Horde::logMessage("SyncML: add: $guid ignored, came from client", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$locid = $state->getLocID($syncType, $guid);
|
||||
|
||||
|
||||
if ($locid && $refts == 0) {
|
||||
// For slow sync (ts=0): do not add data for which we
|
||||
// have a locid again. This is a heuristic to avoid
|
||||
@ -183,10 +183,10 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
continue;
|
||||
}
|
||||
Horde::logMessage("SyncML: add: $guid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
|
||||
|
||||
// Create an Add request for client.
|
||||
$contentType = $state->getPreferedContentTypeClient($this->_sourceLocURI, $this->_targetLocURI);
|
||||
|
||||
|
||||
$cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement();
|
||||
$c = $registry->call($hordeType . '/export',
|
||||
array(
|
||||
@ -194,7 +194,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
'contentType' => $contentType ,
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (!is_a($c, 'PEAR_Error')) {
|
||||
// Item in history but not in database. Strange, but can happen.
|
||||
$cmd->setContent($c);
|
||||
@ -206,7 +206,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
$cmd->setSourceURI($guid);
|
||||
$currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Add');
|
||||
$state->log('Server-Add');
|
||||
|
||||
|
||||
// return if we have to much data
|
||||
if(++$counter >= MAX_ENTRIES
|
||||
&& isset($contentType['mayFragment'])
|
||||
@ -219,31 +219,31 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
}
|
||||
}
|
||||
#Horde::logMessage("SyncML: handling sync ".$currentCmdID, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
|
||||
|
||||
$state->clearSync($syncType);
|
||||
|
||||
|
||||
return $currentCmdID;
|
||||
}
|
||||
|
||||
|
||||
function loadData() {
|
||||
global $registry;
|
||||
|
||||
|
||||
$state = &$_SESSION['SyncML.state'];
|
||||
$syncType = $this->_targetLocURI;
|
||||
$hordeType = $state->getHordeType($syncType);
|
||||
$refts = $state->getServerAnchorLast($syncType);
|
||||
|
||||
|
||||
Horde::logMessage("SyncML: reading changed items from database for $hordeType", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$state->setChangedItems($hordeType, $registry->call($hordeType. '/listBy', array('action' => 'modify', 'timestamp' => $refts)));
|
||||
|
||||
|
||||
Horde::logMessage("SyncML: reading deleted items from database for $hordeType", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$state->setDeletedItems($hordeType, $registry->call($hordeType. '/listBy', array('action' => 'delete', 'timestamp' => $refts)));
|
||||
|
||||
|
||||
Horde::logMessage("SyncML: reading added items from database for $hordeType", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$state->setAddedItems($hordeType, $registry->call($hordeType. '/listBy', array('action' => 'add', 'timestamp' => $refts)));
|
||||
|
||||
|
||||
$this->_syncDataLoaded = TRUE;
|
||||
|
||||
|
||||
return count($state->getChangedItems($hordeType)) +
|
||||
count($state->getDeletedItems($hordeType)) +
|
||||
count($state->getAddedItems($hordeType));
|
||||
|
Loading…
Reference in New Issue
Block a user