Add laxpic settings + some code cleanup

This commit is contained in:
Thomas 2011-09-28 12:51:55 +02:00
parent e23fead4c4
commit 5c054b1094
6 changed files with 46 additions and 28 deletions

View file

@ -57,6 +57,7 @@ function kolab_zpush_config()
if (data.id && data.id == active_device) {
$('#config-device-alias').val(data.devicealias);
$('#config-device-mode').val(data.syncmode);
$('#config-device-laxpic').prop('checked', data.laxpic ? true : false);
$('input.subscription').each(function(i, elem){
var key = elem.value;
@ -83,7 +84,8 @@ function kolab_zpush_config()
cmd: 'save',
id: active_device,
devicealias: $('#config-device-alias').val(),
syncmode: $('#config-device-mode option:selected').val()
syncmode: $('#config-device-mode option:selected').val(),
laxpic: $('#config-device-laxpic').get(0).checked ? 1 : 0
};
data.subscribed = {};
@ -102,9 +104,9 @@ function kolab_zpush_config()
// callback function when saving has completed
function save_complete(p)
{
if (p.success && p.devicename) {
$('#devices-table tr.selected span.devicealias').html(p.devicename);
rcmail.env.devices[p.id].ALIAS = p.devicename;
if (p.success && p.devicealias) {
$('#devices-table tr.selected span.devicealias').html(p.devicealias);
rcmail.env.devices[p.id].ALIAS = p.devicealias;
}
}

View file

@ -84,23 +84,23 @@ class kolab_zpush extends rcube_plugin
public function json_command()
{
$cmd = get_input_value('cmd', RCUBE_INPUT_GPC);
$device_id = get_input_value('id', RCUBE_INPUT_GPC);
$imei = get_input_value('id', RCUBE_INPUT_GPC);
switch ($cmd) {
case 'load':
$result = array();
$this->init_imap();
$devices = $this->list_devices();
if ($device = $devices[$device_id]) {
$result['id'] = $device_id;
if ($device = $devices[$imei]) {
$result['id'] = $imei;
$result['devicealias'] = $device['ALIAS'];
$result['syncmode'] = intval($device['MODE']);
$result['laxpic'] = intval($device['LAXPIC']);
$result['subscribed'] = array();
foreach ($this->folders_meta() as $folder => $meta) {
if ($meta[$device_id]['S'])
$result['subscribed'][$folder] = intval($meta[$device_id]['S']);
if ($meta[$imei]['S'])
$result['subscribed'][$folder] = intval($meta[$imei]['S']);
}
$this->rc->output->command('plugin.zpush_data_ready', $result);
@ -113,22 +113,31 @@ class kolab_zpush extends rcube_plugin
case 'save':
$this->init_imap();
$devices = $this->list_devices();
$syncmode = get_input_value('syncmode', RCUBE_INPUT_POST);
$syncmode = intval(get_input_value('syncmode', RCUBE_INPUT_POST));
$devicealias = get_input_value('devicealias', RCUBE_INPUT_POST);
$laxpic = intval(get_input_value('laxpic', RCUBE_INPUT_POST));
$subsciptions = get_input_value('subscribed', RCUBE_INPUT_POST);
$err = false;
if ($device = $devices[$device_id]) {
if ($device = $devices[$imei]) {
// update device config if changed
if ($devicealias != $this->root_meta['DEVICE'][$device_id]['ALIAS'] ||
$syncmode != $this->root_meta['DEVICE'][$device_id]['MODE'] ||
$subsciptions[self::ROOT_MAILBOX] != $this->root_meta['FOLDER'][$device_id]['S']) {
$this->root_meta['DEVICE'][$device_id]['MODE'] = $syncmode;
$this->root_meta['DEVICE'][$device_id]['ALIAS'] = $devicealias;
$this->root_meta['FOLDER'][$device_id]['S'] = intval($subsciptions[self::ROOT_MAILBOX]);
if ($devicealias != $this->root_meta['DEVICE'][$imei]['ALIAS'] ||
$syncmode != $this->root_meta['DEVICE'][$imei]['MODE'] ||
$laxpic != $this->root_meta['DEVICE'][$imei]['LAXPIC'] ||
$subsciptions[self::ROOT_MAILBOX] != $this->root_meta['FOLDER'][$imei]['S']) {
$this->root_meta['DEVICE'][$imei]['MODE'] = $syncmode;
$this->root_meta['DEVICE'][$imei]['ALIAS'] = $devicealias;
$this->root_meta['DEVICE'][$imei]['LAXPIC'] = $laxpic;
$this->root_meta['FOLDER'][$imei]['S'] = intval($subsciptions[self::ROOT_MAILBOX]);
$err = !$this->rc->imap->set_metadata(self::ROOT_MAILBOX,
array(self::ACTIVESYNC_KEY => $this->serialize_metadata($this->root_meta)));
// update cached meta data
if (!$err) {
$this->cache->remove('devicemeta');
$this->cache->write('devicemeta', $this->rc->imap->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY));
}
}
// iterate over folders list and update metadata if necessary
foreach ($this->folders_meta() as $folder => $meta) {
@ -136,8 +145,8 @@ class kolab_zpush extends rcube_plugin
if ($folder == self::ROOT_MAILBOX)
continue;
if ($subsciptions[$folder] != $meta[$device_id]['S']) {
$meta[$device_id]['S'] = intval($subsciptions[$folder]);
if ($subsciptions[$folder] != $meta[$imei]['S']) {
$meta[$imei]['S'] = intval($subsciptions[$folder]);
$this->folders_meta[$folder] = $meta;
unset($meta['TYPE']);
@ -155,7 +164,7 @@ class kolab_zpush extends rcube_plugin
$this->cache->remove('folders');
$this->cache->write('folders', $this->folders_meta);
$this->rc->output->command('plugin.zpush_save_complete', array('success' => !$err, 'id' => $device_id, 'devicename' => Q($devicealias)));
$this->rc->output->command('plugin.zpush_save_complete', array('success' => !$err, 'id' => $imei, 'devicealias' => Q($devicealias)));
}
if ($err)
@ -180,10 +189,7 @@ class kolab_zpush extends rcube_plugin
$this->init_imap();
// checks if IMAP server supports any of METADATA, ANNOTATEMORE, ANNOTATEMORE2
if ($this->rc->imap->get_capability('METADATA') || $this->rc->imap->get_capability('ANNOTATEMORE') || $this->rc->imap->get_capability('ANNOTATEMORE2')) {
$this->list_devices();
}
else {
if (!($this->rc->imap->get_capability('METADATA') || $this->rc->imap->get_capability('ANNOTATEMORE') || $this->rc->imap->get_capability('ANNOTATEMORE2'))) {
$this->rc->output->show_message($this->gettext('notsupported'), 'error');
}

View file

@ -74,6 +74,11 @@ class kolab_zpush_ui
$select->add(array($this->config->gettext('modeauto'), $this->config->gettext('modeflat'), $this->config->gettext('modefolder')), array('-1', '0', '1'));
$table->add('title', html::label($field_id, $this->config->gettext('syncmode')));
$table->add(null, $select->show('-1'));
$field_id = 'config-device-laxpic';
$checkbox = new html_checkbox(array('name' => 'laxpic', 'value' => '1', 'id' => $field_id));
$table->add('title', $this->config->gettext('imageformat'));
$table->add(null, html::label($field_id, $checkbox->show() . ' ' . $this->config->gettext('laxpiclabel')));
return $table->show($attrib);
}

View file

@ -12,9 +12,12 @@ $labels['synchronize'] = 'Synchronisieren';
$labels['withalarms'] = 'Mit Erinnerungen';
$labels['syncsettings'] = 'Synchronisationseinstellungen';
$labels['deviceconfig'] = 'Gerätekonfiguration';
$labels['folderstosync'] = 'Order zum Symchronisieren';
$labels['folderstosync'] = 'Order zum Synchronisieren';
$labels['deletedevice'] = 'Gerät löschen';
$labels['imageformat'] = 'Bildformat';
$labels['laxpiclabel'] = 'Erlaube PNG- und GIF-Bilder';
$labels['introtext'] = 'Wählen Sie das zu konfigurierende Gerät aus';
$labels['nodevices'] = 'Es sind noch keine Geräte registriert.<br/><br/>Um ein neues Gerät anzumelden, verbinden Sie dieses zuerst mit dem Server. Eine Anleitung dazu finden Sie im <a href="http://wiki.kolab.org/Z_push#Clients">Wiki</a>. Anschliessend laden Sie diese Seite neu und das Gerät wird hier aufgelistet.';
$labels['savingdata'] = 'Daten werden gespeichert...';
$labels['savingerror'] = 'Fehler beim Speichern';
$labels['notsupported'] = 'Ihr Server unterstützt keine Activesync-Konfiguration';

View file

@ -3,7 +3,7 @@
$labels = array();
$labels['tabtitle'] = 'Activesync';
$labels['devices'] = 'Devices';
$labels['devicealias'] = 'Device Name';
$labels['devicealias'] = 'Device name';
$labels['syncmode'] = 'Sync Mode';
$labels['modeauto'] = 'Determine automatically';
$labels['modeflat'] = 'Force flat mode';
@ -13,7 +13,9 @@ $labels['withalarms'] = 'With alarms';
$labels['syncsettings'] = 'Synchronization settings';
$labels['deviceconfig'] = 'Device configration';
$labels['folderstosync'] = 'Folders to synchronize';
$labels['deletedevice'] = 'Delete Device';
$labels['deletedevice'] = 'Delete device';
$labels['imageformat'] = 'Image format';
$labels['laxpiclabel'] = 'Allow PNG and GIF images';
$labels['introtext'] = 'Select a device to configure';
$labels['nodevices'] = 'There are currently no devices registered.<br/><br/>In order to register a device, please connect it to the server first, using <a href="http://wiki.kolab.org/Z_push#Clients">the instructions in the Wiki</a>. Afterwards the device should become available for configuration here.';
$labels['savingdata'] = 'Saving data...';

View file

@ -37,7 +37,7 @@
#foldersubscriptions td.mailbox {
padding-right: 3em;
padding-left: 25px;
padding-left: 30px;
min-width: 12em;
background: url(foldertypes.png) 2px 2px no-repeat;
}