PHP Класс Horde_ActiveSync_State_Sql, horde

Needs a number of SQL tables present: syncStateTable (horde_activesync_state): sync_timestamp: - The timestamp of last sync sync_key: - The syncKey for the last sync sync_pending: - If the last sync resulted in a MOREAVAILABLE, this contains a list of UIDs that still need to be sent to the client. sync_data: - Any state data that we need to track for the specific syncKey. Data such as current folder list on the client (for a FOLDERSYNC) and IMAP email UIDs (for Email collections during a SYNC). sync_devid: - The device id. sync_folderid:- The folder id for this sync. sync_user: - The user for this synckey. sync_mod: - The last modification stamp. syncMapTable (horde_activesync_map): message_uid - The server uid for the object sync_modtime - The time the change was received from the client and applied to the server data store. sync_key - The syncKey that was current at the time the change was received. sync_devid - The device id this change was done on. sync_user - The user that initiated the change. syncDeviceTable (horde_activesync_device): device_id - The unique id for this device device_type - The device type the client identifies itself with device_agent - The user agent string sent by the device device_policykey - The current policykey for this device device_rwstatus - The current remote wipe status for this device syncUsersTable (horde_activesync_device_users): device_user - A username attached to the device device_id - The device id device_policykey - The provisioned policykey for this device/user combination.
Автор: Michael J Rubinsky ([email protected])
Наследование: extends Horde_ActiveSync_State_Base
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_db Horde_Db_Adapter DB handle
$_syncCacheTable string The Synccache table. Holds the sync cache and is used to cache info about SYNC and PING request that are only sent a single time. Also stores data supported looping SYNC requests.
$_syncDeviceTable string Device information table. Holds information about each client.
$_syncMailMapTable string The Sync Mail Map table. Same principle as self::_syncMapTable, but for email collection data.
$_syncMapTable string The Sync Map table. This table temporarily holds information about changes received FROM the client and is used to prevent mirroring back changes to the client that originated there.
$_syncStateTable string State table name. This table holds the device's current state.
$_syncUsersTable string Users table. Holds information specific to a user.

Открытые методы

Метод Описание
__construct ( array $params = [] ) : Horde_ActiveSync_State_Sql Const'r
connect ( ) (Re)open backend storage connection.
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.
isDuplicatePIMChange ( string $uid, string $synckey ) : boolean Check if the UID provided was altered during the SYNC_KEY provided.
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.
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
updateSyncStamp ( ) Update the syncStamp in the collection state, outside of any other changes.

Защищенные методы

Метод Описание
_checkCollision ( string $guid ) : boolean Check for the (rare) possibility of a synckey collision between collections.
_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.

Описание методов

__construct() публичный Метод

Const'r
public __construct ( array $params = [] ) : Horde_ActiveSync_State_Sql
$params array Must contain: - db: (Horde_Db_Adapter_Base) The Horde_Db instance.
Результат Horde_ActiveSync_State_Sql

_checkCollision() защищенный Метод

Check for the (rare) possibility of a synckey collision between collections.
protected _checkCollision ( string $guid ) : boolean
$guid string The GUID portion of the synckey to check.
Результат boolean true if there was a collision.

_gc() защищенный Метод

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

_getMailMapChanges() защищенный Метод

Return all available mailMap changes for the current folder.
protected _getMailMapChanges ( array $changes ) : array
$changes array The changes array
Результат 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, Horde_ActiveSync::CHANGE_TYPE_DRAFT => true|false, )

_getPIMChangeTS() защищенный Метод

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, each entry a hash containing 'id' and 'type' keys.
Результат array An array of UID -> timestamp of the last client-initiated change for the specified UIDs, or null if none found.

_havePIMChanges() защищенный Метод

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
Результат boolean

_loadState() защищенный Метод

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

_loadStateFromResults() защищенный Метод

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() защищенный Метод

Reset the sync state for this device, for the specified collection.
protected _resetDeviceState ( string $id ) : void
$id string The collection to reset.
Результат void

connect() публичный Метод

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

deleteSyncCache() публичный Метод

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

deviceExists() публичный Метод

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.
Результат integer The numer of device entries found for the give devId, user combination. I.e., 0 == no device exists.

disconnect() публичный Метод

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

getLastSyncTimestamp() публичный Метод

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.
Результат integer The timestamp of the last sync, regardless of collection

getSyncCache() публичный Метод

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
Результат array The current sync cache for the user/device combination.

isDuplicatePIMAddition() публичный Метод

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.
Результат string The UID for the given clientid, null if none found.

isDuplicatePIMChange() публичный Метод

Check if the UID provided was altered during the SYNC_KEY provided.
С версии: 2.31.0
public isDuplicatePIMChange ( string $uid, string $synckey ) : boolean
$uid string The UID to check.
$synckey string The synckey to check.
Результат boolean True if the provided UID was updated during the SYNC for the synckey provided.

listDevices() публичный Метод

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 match.
Результат array An array of device hashes

loadDeviceInfo() публичный Метод

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
Результат Horde_ActiveSync_Device The device object

removeState() публичный Метод

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() публичный Метод

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() публичный Метод

Save the current state to storage
public save ( )

saveSyncCache() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

updateServerIdInState() публичный Метод

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

updateState() публичный Метод

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

updateSyncStamp() публичный Метод

Used to prevent extremely large differences in syncStamps for clients and collections that don't often have changes and the backend server doesn't keep separate syncStamp values per collection.
public updateSyncStamp ( )

Описание свойств

$_db защищенное свойство

DB handle
protected Horde_Db_Adapter $_db
Результат Horde_Db_Adapter

$_syncCacheTable защищенное свойство

The Synccache table. Holds the sync cache and is used to cache info about SYNC and PING request that are only sent a single time. Also stores data supported looping SYNC requests.
protected string $_syncCacheTable
Результат string

$_syncDeviceTable защищенное свойство

Device information table. Holds information about each client.
protected string $_syncDeviceTable
Результат string

$_syncMailMapTable защищенное свойство

The Sync Mail Map table. Same principle as self::_syncMapTable, but for email collection data.
protected string $_syncMailMapTable
Результат string

$_syncMapTable защищенное свойство

The Sync Map table. This table temporarily holds information about changes received FROM the client and is used to prevent mirroring back changes to the client that originated there.
protected string $_syncMapTable
Результат string

$_syncStateTable защищенное свойство

State table name. This table holds the device's current state.
protected string $_syncStateTable
Результат string

$_syncUsersTable защищенное свойство

Users table. Holds information specific to a user.
protected string $_syncUsersTable
Результат string