Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F8224370
kolab_sync_backend_device.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
kolab_sync_backend_device.php
View Options
<?php
/**
*
*/
class
kolab_sync_backend_device
implements
Syncroton_Backend_IDevice
{
/**
* Kolab Sync backend
*
* @var kolab_sync_backend
*/
protected
$backend
;
public
function
__construct
()
{
$this
->
backend
=
kolab_sync_backend
::
get_instance
();
}
/**
* create new device
*
* @param Syncroton_Model_IDevice $_device
* @return Syncroton_Model_IDevice
*/
public
function
create
(
Syncroton_Model_IDevice
$device
)
{
$id
=
sha1
(
mt_rand
().
microtime
());
$created
=
$this
->
backend
->
device_create
(
array
(
'ID'
=>
$id
,
'TYPE'
=>
$device
->
devicetype
,
// 'OWNERID' => $device->owner_id,
'POLICYID'
=>
isset
(
$device
->
policy_id
)
?
$device
->
policy_id
:
1
,
'POLICYKEY'
=>
isset
(
$device
->
policykey
)
?
$device
->
policykey
:
null
,
'USERAGENT'
=>
isset
(
$device
->
useragent
)
?
$device
->
useragent
:
''
,
'ACSVERSION'
=>
isset
(
$device
->
acsversion
)
?
$device
->
acsversion
:
''
,
'REMOTEWIPE'
=>
isset
(
$device
->
remotewipe
)
?
$device
->
remotewipe
:
null
),
$device
->
deviceid
);
return
$this
->
get
(
$device
->
deviceid
);
}
/**
* @param string $_id
* @throws Syncroton_Exception_NotFound
* @return Syncroton_Model_IDevice
*/
public
function
get
(
$id
)
{
$device
=
$this
->
backend
->
device_get
(
$id
);
if
(
empty
(
$device
))
{
throw
new
Syncroton_Exception_NotFound
(
'id not found'
);
}
$device
=
new
Syncroton_Model_Device
(
array
(
'id'
=>
$device
[
'ID'
],
'deviceid'
=>
$id
,
'devicetype'
=>
$device
[
'TYPE'
],
// @TODO: set owner_id if really needed
// 'owner_id' => $device['OWNERID'],
'policy_id'
=>
$device
[
'POLICYID'
],
'policykey'
=>
$device
[
'POLICYKEY'
],
'useragent'
=>
$device
[
'USERAGENT'
],
'acsversion'
=>
$device
[
'ACSVERSION'
],
'remotewipe'
=>
$device
[
'REMOTEWIPE'
],
'pingfolder'
=>
$device
[
'PINGFOLDER'
],
'pinglifetime'
=>
$device
[
'PINGLIFETIME'
],
));
if
(!
$device
instanceof
Syncroton_Model_IDevice
)
{
throw
new
Syncroton_Exception_NotFound
(
'id not found'
);
}
return
$device
;
}
/**
* return device for this user
*
* @param string $userId
* @param string $deviceId
* @throws Syncroton_Exception_NotFound
* @return Syncroton_Model_Device
*/
public
function
getUserDevice
(
$ownerId
,
$deviceId
)
{
return
$this
->
get
(
$deviceId
);
}
public
function
delete
(
$id
)
{
if
(
$id
instanceof
Syncroton_Model_IDevice
)
{
$id
=
$id
->
deviceid
;
}
$result
=
$this
->
backend
->
device_delete
(
$id
);
return
$result
;
}
public
function
update
(
Syncroton_Model_IDevice
$device
)
{
$data
=
array
(
'ACSVERSION'
=>
$device
->
acsversion
,
'POLICYKEY'
=>
$device
->
policykey
,
'PINGFOLDER'
=>
$device
->
pingfolder
,
'PINGLIFETIME'
=>
$device
->
pinglifetime
,
'REMOTEWIPE'
=>
$device
->
remotewipe
);
$updated
=
$this
->
backend
->
device_update
(
$data
,
$device
->
deviceid
);
return
$this
->
get
(
$device
->
deviceid
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Jul 9, 9:47 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1052699
Default Alt Text
kolab_sync_backend_device.php (3 KB)
Attached To
Mode
R4 syncroton
Attached
Detach File
Event Timeline
Log In to Comment