Support forcing a subscription state
Summary: States can be: * 0 => not subscribed * 1 => subscribed, no alarms * 2 => subscribed with alarms The primary usecase is to disallow unsubscribing folders that Outlook does not allow to be unsubscribed. Differential Revision: https://git.kolab.org/D2173
This commit is contained in:
parent
a313f260a2
commit
7203e49484
3 changed files with 32 additions and 6 deletions
|
@ -2,3 +2,6 @@
|
|||
|
||||
// The page with Activesync clients configuration manual
|
||||
$config['activesync_setup_url'] = 'https://kb.kolabenterprise.com/documentation/setting-up-an-activesync-client';
|
||||
// Force a subscription state per devicetype (lowercase) and folder
|
||||
// States can be: 0 => not subscribed, 1 => subscribed, 2 => subscribed with alarm
|
||||
$config['activesync_force_subscriptions'] = array('windowsoutlook15' => array('INBOX' => 1, 'Sent' => 1, 'Trash' => 1));
|
||||
|
|
|
@ -65,7 +65,7 @@ function kolab_activesync_config()
|
|||
|
||||
var fn = function(elem) {
|
||||
var classname = elem.className.split(' ')[0],
|
||||
list = $(elem).closest('table').find('input.' + classname),
|
||||
list = $(elem).closest('table').find('input.' + classname).not('[disabled]'),
|
||||
check = list.not(':checked').length > 0;
|
||||
|
||||
list.prop('checked', check).change();
|
||||
|
|
|
@ -27,6 +27,7 @@ class kolab_activesync_ui
|
|||
{
|
||||
private $rc;
|
||||
private $plugin;
|
||||
private $force_subscriptions = array();
|
||||
public $device = array();
|
||||
|
||||
const SETUP_URL = 'https://kb.kolabenterprise.com/documentation/setting-up-an-activesync-client';
|
||||
|
@ -39,6 +40,9 @@ class kolab_activesync_ui
|
|||
$skin_path = $this->plugin->local_skin_path() . '/';
|
||||
$this->skin_path = 'plugins/kolab_activesync/' . $skin_path;
|
||||
|
||||
$this->plugin->load_config();
|
||||
$this->force_subscriptions = $this->rc->config->get('activesync_force_subscriptions', array());
|
||||
|
||||
$this->plugin->include_stylesheet($skin_path . 'config.css');
|
||||
}
|
||||
|
||||
|
@ -94,6 +98,15 @@ class kolab_activesync_ui
|
|||
}
|
||||
|
||||
|
||||
private function is_protected($folder, $devicetype)
|
||||
{
|
||||
$devicetype = strtolower($devicetype);
|
||||
if (array_key_exists($devicetype, $this->force_subscriptions)) {
|
||||
return array_key_exists($folder, $this->force_subscriptions[$devicetype]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function folder_subscriptions($attrib = array())
|
||||
{
|
||||
if (!$attrib['id']) {
|
||||
|
@ -111,6 +124,9 @@ class kolab_activesync_ui
|
|||
$folder_meta = $this->plugin->folder_meta();
|
||||
}
|
||||
|
||||
$devicetype = strtolower($this->device['TYPE']);
|
||||
$device_force_subscriptions = $this->force_subscriptions[$devicetype];
|
||||
|
||||
foreach ($this->plugin->list_folders() as $folder) {
|
||||
if ($folder_types[$folder]) {
|
||||
list($type, ) = explode('.', $folder_types[$folder]);
|
||||
|
@ -122,7 +138,9 @@ class kolab_activesync_ui
|
|||
if (is_array($folder_groups[$type])) {
|
||||
$folder_groups[$type][] = $folder;
|
||||
|
||||
if (!empty($folder_meta) && ($meta = $folder_meta[$folder])
|
||||
if ($device_force_subscriptions && array_key_exists($folder, $device_force_subscriptions)) {
|
||||
$subscribed[$folder] = intval($device_force_subscriptions[$folder]);
|
||||
} else if (!empty($folder_meta) && ($meta = $folder_meta[$folder])
|
||||
&& $meta['FOLDER'] && $meta['FOLDER'][$imei]['S']
|
||||
) {
|
||||
$subscribed[$folder] = intval($meta['FOLDER'][$imei]['S']);
|
||||
|
@ -210,14 +228,17 @@ class kolab_activesync_ui
|
|||
}
|
||||
|
||||
$table->add_row();
|
||||
|
||||
$disabled = $this->is_protected($folder, $this->device['TYPE']);
|
||||
|
||||
$table->add('subscription checkbox-cell', $checkbox_sync->show(
|
||||
!empty($subscribed[$folder]) ? $folder : null,
|
||||
array('value' => $folder, 'id' => $folder_id)));
|
||||
array('value' => $folder, 'id' => $folder_id, 'disabled' => $disabled)));
|
||||
|
||||
if ($alarms) {
|
||||
$table->add('alarm checkbox-cell', $checkbox_alarm->show(
|
||||
intval($subscribed[$folder]) > 1 ? $folder : null,
|
||||
array('value' => $folder, 'id' => $folder_id.'_alarm')));
|
||||
array('value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled)));
|
||||
}
|
||||
|
||||
$table->add(join(' ', $classes), html::label($folder_id, $foldername));
|
||||
|
@ -258,15 +279,17 @@ class kolab_activesync_ui
|
|||
}
|
||||
}
|
||||
|
||||
$disabled = $this->is_protected($folder_name, $device['TYPE']);
|
||||
|
||||
$table->add_row();
|
||||
$table->add(array('class' => 'device', 'title' => $title), $name);
|
||||
$table->add('subscription checkbox-cell', $checkbox->show(!empty($folder_data[$id]['S']) ? 1 : 0));
|
||||
$table->add('subscription checkbox-cell', $checkbox->show(!empty($folder_data[$id]['S']) ? 1 : 0, array('disabled' => $disabled)));
|
||||
|
||||
if ($alarms) {
|
||||
$checkbox_alarm = new html_checkbox(array('name' => "_alarms[$id]", 'value' => 1,
|
||||
'onchange' => 'return activesync_object.update_sync_data(this)'));
|
||||
|
||||
$table->add('alarm checkbox-cell', $checkbox_alarm->show($folder_data[$id]['S'] > 1 ? 1 : 0));
|
||||
$table->add('alarm checkbox-cell', $checkbox_alarm->show($folder_data[$id]['S'] > 1 ? 1 : 0, array('disabled' => $disabled)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue