From 2c74dc6037a8ca78e7e1e6c94811b68a440d7cd3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 9 Apr 2013 13:45:41 +0200 Subject: [PATCH] Display additional device information from syncroton database --- plugins/kolab_activesync/kolab_activesync.php | 35 +++++++++++++++++-- .../kolab_activesync/kolab_activesync_ui.php | 12 +++++++ .../kolab_activesync/localization/en_US.inc | 7 ++++ plugins/kolab_activesync/package.xml | 4 +-- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/plugins/kolab_activesync/kolab_activesync.php b/plugins/kolab_activesync/kolab_activesync.php index 0238f116..19604afa 100644 --- a/plugins/kolab_activesync/kolab_activesync.php +++ b/plugins/kolab_activesync/kolab_activesync.php @@ -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 diff --git a/plugins/kolab_activesync/kolab_activesync_ui.php b/plugins/kolab_activesync/kolab_activesync_ui.php index a1912554..6e796cc6 100644 --- a/plugins/kolab_activesync/kolab_activesync_ui.php +++ b/plugins/kolab_activesync/kolab_activesync_ui.php @@ -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']); } diff --git a/plugins/kolab_activesync/localization/en_US.inc b/plugins/kolab_activesync/localization/en_US.inc index 2399b13e..8f94a518 100644 --- a/plugins/kolab_activesync/localization/en_US.inc +++ b/plugins/kolab_activesync/localization/en_US.inc @@ -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'; ?> diff --git a/plugins/kolab_activesync/package.xml b/plugins/kolab_activesync/package.xml index 09e8d668..dfdd3e30 100644 --- a/plugins/kolab_activesync/package.xml +++ b/plugins/kolab_activesync/package.xml @@ -19,9 +19,9 @@ bruederli@kolabsys.com yes - 2012-08-29 + 2013-04-09 - 0.9 + 1.0 1.0