PHP Class Horde_ActiveSync_State_Mongo, horde

Collections used: - HAS_state: Holds sync state documents. - HAS_device: Holds device and device_user info. - _id: - device_type: The device's device_type. - device_agent: The client's user agent string. - device_rwstatus: The current RW status. - device_supported: An array of SUPPORTED properties. - device_properties: An array of device properties. - device_users: An array of each user with a known account on device with each entry containing: - device_user: - device_policykey: - HAS_map: Holds the incoming change (non-mail) map. - message_uid: The message's server uid. - sync_modtime: The modtime. - sync_key: The sync_key in effect when the change was imported. - sync_devid: The device_id sending the change. - sync_folderid: The folderid of the collection the change belongs to. - sync_user: The username. - sync_clientid: The client's clientid of incoming new items. - sync_deleted: Flag to indicate change was a deletion. - HAS_mailmap: Holds the incoming mail change map. - message_uid: The message's UID. - sync_key: The sync_key in effect when the change was imported. - sync_devid: The device_id sending the change. - sync_folderid: The folderid of the collection the change belongs to. - sync_user: The username. - sync_read: Flag to indicate change is a change in the /seen flag. - sync_flagged: Flag to indicate change is a change to the flagged status. - sync_deleted: Flag to indicate change is a message deletion. - HAS_cache: Holds the sync cache. - cache_user: - cache_devid: - cache_data: An object containing: - confirmed_synckeys: Array to hold synckeys for confirmation. - lasthbsyncstarted: Timestamp of the start of last heartbeat sync. - lastsyncendnormal: Timestamp of the last successfully ended sync. - timestamp: Timestamp of cache. - wait: Current wait interval. - hbinterval: Current heartbeat interval. - folders: Array of known folders. - hierarchy: Current hierarchy key. - collections: - pingheartbeat:
Inheritance: extends Horde_ActiveSync_State_Base, implements Horde_Mongo_Collection_Index
Mostrar archivo Open project: horde/horde

Protected Properties

Property Type Description
$_db MongoDB Mongo database
$_indexes array Mongo Indexes
$_mongo MongoClient Mongo connection
$_propertyMap

Public Methods

Method Description
__construct ( array $params = [] ) : Horde_ActiveSync_State_Sql Const'r
checkMongoIndices ( )
connect ( ) (Re)open backend storage connection.
createMongoIndices ( )
deleteSyncCache ( string $devid, string $user = null ) Delete a complete sync cache
deviceExists ( string $devId, string $user = null ) : integer Check that a given device id is known to the server. This is regardless of Provisioning status. If $user is provided, checks that the device is attached to the provided username.
disconnect ( ) Close the underlying backend storage connection.
getLastSyncTimestamp ( string $id = null, string $user = null ) : integer Get the last time the loaded device issued a SYNC request.
getSyncCache ( string $devid, string $user, array $fields = null ) : array Return the sync cache.
isDuplicatePIMAddition ( string $id ) : string Check and see that we didn't already see the incoming change from the client.
listDevices ( string $user = null, array $filter = [] ) : array List all devices that we know about.
loadDeviceInfo ( string $devId, string $user = null, array $params = [] ) : Horde_ActiveSync_Device Load the device object.
removeState ( array $options ) Explicitly remove a state from storage.
resetAllPolicyKeys ( ) Reset ALL device policy keys. Used when server policies have changed and you want to force ALL devices to pick up the changes. This will cause all devices that support provisioning to be reprovisioned.
save ( ) Save the current state to storage
saveSyncCache ( array $cache, string $devid, string $user, array $dirty = [] ) Save the provided sync_cache.
setDeviceInfo ( Horde_ActiveSync_Device $data, array $dirty = [] ) Set new device info
setDeviceProperties ( array $data, string $deviceId ) Set the device's properties as sent by a SETTINGS request.
setDeviceRWStatus ( string $devId, string $status ) Set a new remotewipe status for the device
setPolicyKey ( string $devId, integer $key ) Save a new device policy key to storage for the current user.
updateServerIdInState ( string $uid, string $serverid ) Update the serverid for a given folder uid in the folder's state object.
updateState ( string $type, array $change, integer $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA, string $user = null, string $clientid = '' ) Update the state to reflect changes

Protected Methods

Method Description
_checkCollision ( [type] $guid ) : [type]
_gc ( string $syncKey ) Garbage collector - clean up from previous sync requests.
_getMailMapChanges ( array $changes ) : array Return all available mailMap changes for the current folder.
_getPIMChangeTS ( array $changes ) : array Return an array of timestamps from the map table for the last client-initiated change for the provided uid. Used to avoid mirroring back changes to the client that it sent to the server.
_havePIMChanges ( ) : boolean Check for the existence of ANY entries in the map table for this device and user.
_loadState ( ) Load the state represented by $syncKey from storage.
_loadStateFromResults ( array $results ) Actually load the state data into the object from the query results.
_resetDeviceState ( string $id ) : void Reset the sync state for this device, for the specified collection.

Method Details

__construct() public method

Const'r
public __construct ( array $params = [] ) : Horde_ActiveSync_State_Sql
$params array Must contain: - connection: (Horde_Mongo_Client The Horde_Mongo instance.
return Horde_ActiveSync_State_Sql

_checkCollision() protected method

protected _checkCollision ( [type] $guid ) : [type]
$guid [type]
return [type]

_gc() protected method

Garbage collector - clean up from previous sync requests.
protected _gc ( string $syncKey )
$syncKey string The sync key

_getMailMapChanges() protected method

Return all available mailMap changes for the current folder.
protected _getMailMapChanges ( array $changes ) : array
$changes array The chagnes array
return array An array of hashes, each in the form of {uid} => array( Horde_ActiveSync::CHANGE_TYPE_FLAGS => true|false, Horde_ActiveSync::CHANGE_TYPE_DELETE => true|false )

_getPIMChangeTS() protected method

Return an array of timestamps from the map table for the last client-initiated change for the provided uid. Used to avoid mirroring back changes to the client that it sent to the server.
protected _getPIMChangeTS ( array $changes ) : array
$changes array The changes array, containing 'id' and 'type'.
return array An array of UID -> timestamp of the last client-initiated change for the specified uid, or null if none found.

_havePIMChanges() protected method

An extra database query for each sync, but the payoff is that we avoid having to stat every message change we send to the client if there are no client generated changes for this sync period.
protected _havePIMChanges ( ) : boolean
return boolean

_loadState() protected method

Load the state represented by $syncKey from storage.
protected _loadState ( )

_loadStateFromResults() protected method

Actually load the state data into the object from the query results.
protected _loadStateFromResults ( array $results )
$results array The results array from the state query.

_resetDeviceState() protected method

Reset the sync state for this device, for the specified collection.
protected _resetDeviceState ( string $id ) : void
$id string The collection to reset.
return void

checkMongoIndices() public method

public checkMongoIndices ( )

connect() public method

(Re)open backend storage connection.
public connect ( )

createMongoIndices() public method

public createMongoIndices ( )

deleteSyncCache() public method

Delete a complete sync cache
public deleteSyncCache ( string $devid, string $user = null )
$devid string The device id
$user string The user name.

deviceExists() public method

Check that a given device id is known to the server. This is regardless of Provisioning status. If $user is provided, checks that the device is attached to the provided username.
public deviceExists ( string $devId, string $user = null ) : integer
$devId string The device id to check.
$user string The device should be owned by this user.
return integer The numer of device entries found for the give devId, user combination. I.e., 0 == no device exists.

disconnect() public method

To be used during PING or looping SYNC operations.
public disconnect ( )

getLastSyncTimestamp() public method

Get the last time the loaded device issued a SYNC request.
public getLastSyncTimestamp ( string $id = null, string $user = null ) : integer
$id string The (optional) devivce id. If empty will use the currently loaded device.
$user string The (optional) user id. If empty wil use the currently loaded device.
return integer The timestamp of the last sync, regardless of collection

getSyncCache() public method

Return the sync cache.
public getSyncCache ( string $devid, string $user, array $fields = null ) : array
$devid string The device id.
$user string The user id.
$fields array An array of fields to return. Default is to return the full cache. @since 2.9.0
return array The current sync cache for the user/device combination.

isDuplicatePIMAddition() public method

This would happen e.g., if the client failed to receive the server response after successfully importing new messages.
public isDuplicatePIMAddition ( string $id ) : string
$id string The client id sent during message addition.
return string The UID for the given clientid, null if none found.

listDevices() public method

List all devices that we know about.
public listDevices ( string $user = null, array $filter = [] ) : array
$user string The username to list devices for. If empty, will return all devices.
$filter array An array of optional filters where the keys are field names and the values are values to prefix-match.
return array An array of device hashes

loadDeviceInfo() public method

Load the device object.
public loadDeviceInfo ( string $devId, string $user = null, array $params = [] ) : Horde_ActiveSync_Device
$devId string The device id to obtain
$user string The user to retrieve user-specific device info for
$params array Additional parameters: - force: (boolean) If true, reload the device info even if it's already loaded. Used to refresh values such as device_rwstatus that may have changed during a long running PING/SYNC. DEFAULT: false. @since 2.31.0
return Horde_ActiveSync_Device The device object

removeState() public method

Explicitly remove a state from storage.
public removeState ( array $options )
$options array An options array containing at least one of: - synckey: (string) Remove only the state associated with this synckey. DEFAULT: All synckeys are removed for the specified device. - devId: (string) Remove all information for this device. DEFAULT: None. If no device, a synckey is required. - user: (string) Restrict to removing data for this user only. DEFAULT: None - all users for the specified device are removed. - id: (string) When removing device state, restrict ro removing data only for this collection.

resetAllPolicyKeys() public method

Reset ALL device policy keys. Used when server policies have changed and you want to force ALL devices to pick up the changes. This will cause all devices that support provisioning to be reprovisioned.
public resetAllPolicyKeys ( )

save() public method

Save the current state to storage
public save ( )

saveSyncCache() public method

Save the provided sync_cache.
public saveSyncCache ( array $cache, string $devid, string $user, array $dirty = [] )
$cache array The cache to save.
$devid string The device id.
$user string The user id.
$dirty array An array of dirty properties. @since 2.9.0

setDeviceInfo() public method

Set new device info
public setDeviceInfo ( Horde_ActiveSync_Device $data, array $dirty = [] )
$data Horde_ActiveSync_Device The device information
$dirty array Array of dirty properties. @since 2.9.0

setDeviceProperties() public method

Set the device's properties as sent by a SETTINGS request.
public setDeviceProperties ( array $data, string $deviceId )
$data array The device settings
$deviceId string The device id.

setDeviceRWStatus() public method

Set a new remotewipe status for the device
public setDeviceRWStatus ( string $devId, string $status )
$devId string The device id.
$status string A Horde_ActiveSync::RWSTATUS_* constant.

setPolicyKey() public method

Save a new device policy key to storage for the current user.
public setPolicyKey ( string $devId, integer $key )
$devId string The device id
$key integer The new policy key

updateServerIdInState() public method

Needed when a folder is renamed on a client, but the UID must remain the same.
Since: 2.4.0
public updateServerIdInState ( string $uid, string $serverid )
$uid string The folder UID.
$serverid string The new serverid for this uid.

updateState() public method

Notes: If we are importing client changes, need to update the syncMapTable so we don't mirror back the changes on next sync. If we are exporting server changes, we need to track which changes have been sent (by removing them from $this->_changes) so we know which items to send on the next sync if a MOREAVAILBLE response was needed. If this is being called from a FOLDERSYNC command, update state accordingly.
public updateState ( string $type, array $change, integer $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA, string $user = null, string $clientid = '' )
$type string The type of change (change, delete, flags or foldersync)
$change array A stat/change hash describing the change. Contains: - id: (mixed) The message uid the change applies to. - serverid: (string) The backend server id for the folder. - folderuid: (string) The EAS folder UID for the folder. - parent: (string) The parent of the current folder, if any. - flags: (array) If this is a flag change, the state of the flags. - mod: (integer) The modtime of this change.
$origin integer Flag to indicate the origin of the change: Horde_ActiveSync::CHANGE_ORIGIN_NA - Not applicapble/not important Horde_ActiveSync::CHANGE_ORIGIN_PIM - Change originated from client
$user string The current sync user, only needed if change origin is CHANGE_ORIGIN_PIM
$clientid string client clientid sent when adding a new message.

Property Details

$_db protected_oe property

Mongo database
protected MongoDB $_db
return MongoDB

$_indexes protected_oe property

Mongo Indexes
protected array $_indexes
return array

$_mongo protected_oe property

Mongo connection
protected MongoClient $_mongo
return MongoClient

$_propertyMap protected_oe property

protected $_propertyMap