Display additional device information from syncroton database

This commit is contained in:
Aleksander Machniak 2013-04-09 13:45:41 +02:00
parent 1df25c1984
commit 2c74dc6037
4 changed files with 54 additions and 4 deletions

View file

@ -330,7 +330,14 @@ class kolab_activesync extends rcube_plugin
self::ASYNC_KEY => $this->serialize_metadata($metadata)));
}
/**
* Device update
*
* @param array $device Device data
* @param string $id Device ID
*
* @return bool True on success, False on failure
*/
public function device_update($device, $id)
{
$devices_list = $this->list_devices();
@ -362,7 +369,6 @@ class kolab_activesync extends rcube_plugin
return $result;
}
/**
* Device delete.
*
@ -427,6 +433,31 @@ class kolab_activesync extends rcube_plugin
return $result;
}
/**
* Device information (from syncroton database)
*
* @param string $id Device ID
*
* @return array Device data
*/
public function device_info($id)
{
$db = $this->rc->get_dbh();
$table = $db->table_name('syncroton_device');
if (in_array($table, $db->list_tables())) {
$fields = array('devicetype', 'acsversion', 'useragent', 'friendlyname', 'os',
'oslanguage', 'phonenumber');
$result = $db->query("SELECT " . $db->array2list($fields, 'ident')
. " FROM $table WHERE owner_id = ? AND id = ?",
$this->rc->user->ID, $id);
if ($result && ($sql_arr = $db->fetch_assoc($result))) {
return $sql_arr;
}
}
}
/**
* Helper method to decode saved IMAP metadata

View file

@ -80,6 +80,18 @@ class kolab_activesync_ui
$table->add('title', $this->plugin->gettext('imageformat'));
$table->add(null, html::label($field_id, $checkbox->show() . ' ' . $this->plugin->gettext('laxpiclabel')));
*/
// read-only device information
$info = $this->plugin->device_info($this->device['ID']);
if (!empty($info)) {
foreach ($info as $key => $value) {
if ($value) {
$table->add('title', Q($this->plugin->gettext($key)));
$table->add(null, Q($value));
}
}
}
if ($attrib['form']) {
$this->rc->output->add_gui_object('editform', $attrib['form']);
}

View file

@ -29,5 +29,12 @@ $labels['notsupported'] = 'Your server does not support metadata/annotations';
$labels['devicedeleteconfirm'] = 'Do you really want to delete the configuration for this device?';
$labels['successfullydeleted'] = 'The device configuration was successfully removed';
$labels['devicenotfound'] = 'Unable to read device configuration';
$labels['devicetype'] = 'Device type';
$labels['acsversion'] = 'Protocol version';
$labels['useragent'] = 'User agent';
$labels['friendlyname'] = 'Friendly name';
$labels['os'] = 'Operating system';
$labels['oslanguage'] = 'OS language';
$labels['phonenumber'] = 'Phone number';
?>

View file

@ -19,9 +19,9 @@
<email>bruederli@kolabsys.com</email>
<active>yes</active>
</lead>
<date>2012-08-29</date>
<date>2013-04-09</date>
<version>
<release>0.9</release>
<release>1.0</release>
<api>1.0</api>
</version>
<stability>