Changeset View
Changeset View
Standalone View
Standalone View
plugins/kolab_activesync/kolab_activesync_ui.php
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | public function folder_subscriptions($attrib = array()) | ||||
$imei = $this->device['_id']; | $imei = $this->device['_id']; | ||||
$subscribed = array(); | $subscribed = array(); | ||||
if ($imei) { | if ($imei) { | ||||
$folder_meta = $this->plugin->folder_meta(); | $folder_meta = $this->plugin->folder_meta(); | ||||
} | } | ||||
$devicetype = strtolower($this->device['TYPE']); | $devicetype = strtolower($this->device['TYPE']); | ||||
$device_force_subscriptions = $this->force_subscriptions[$devicetype]; | $device_force_subscriptions = $this->force_subscriptions[$devicetype] ?? null; | ||||
foreach ($this->plugin->list_folders() as $folder) { | foreach ($this->plugin->list_folders() as $folder) { | ||||
if ($folder_types[$folder]) { | if ($folder_types[$folder] ?? null) { | ||||
list($type, ) = explode('.', $folder_types[$folder]); | list($type, ) = explode('.', $folder_types[$folder]); | ||||
} | } | ||||
else { | else { | ||||
$type = 'mail'; | $type = 'mail'; | ||||
} | } | ||||
if (is_array($folder_groups[$type])) { | if (is_array($folder_groups[$type] ?? null)) { | ||||
$folder_groups[$type][] = $folder; | $folder_groups[$type][] = $folder; | ||||
if ($device_force_subscriptions && array_key_exists($folder, $device_force_subscriptions)) { | if ($device_force_subscriptions && array_key_exists($folder, $device_force_subscriptions)) { | ||||
$subscribed[$folder] = intval($device_force_subscriptions[$folder]); | $subscribed[$folder] = intval($device_force_subscriptions[$folder] ?? null); | ||||
} else if (!empty($folder_meta) && ($meta = $folder_meta[$folder]) | } else if (!empty($folder_meta) && ($meta = ($folder_meta[$folder] ?? null)) | ||||
&& $meta['FOLDER'] && $meta['FOLDER'][$imei]['S'] | && ($meta['FOLDER'] ?? false) && $meta['FOLDER'][$imei]['S'] | ||||
) { | ) { | ||||
$subscribed[$folder] = intval($meta['FOLDER'][$imei]['S']); | $subscribed[$folder] = intval($meta['FOLDER'][$imei]['S']); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// build block for every folder type | // build block for every folder type | ||||
$html = null; | |||||
foreach ($folder_groups as $type => $group) { | foreach ($folder_groups as $type => $group) { | ||||
if (empty($group)) { | if (empty($group)) { | ||||
continue; | continue; | ||||
} | } | ||||
$attrib['type'] = $type; | $attrib['type'] = $type; | ||||
$table = $this->folder_subscriptions_block($group, $attrib, $subscribed); | $table = $this->folder_subscriptions_block($group, $attrib, $subscribed); | ||||
$label = $this->plugin->gettext($type); | $label = $this->plugin->gettext($type); | ||||
Show All 16 Lines | public function folder_subscriptions_block($a_folders, $attrib, $subscribed) | ||||
$alarms = ($attrib['type'] == 'event' || $attrib['type'] == 'task'); | $alarms = ($attrib['type'] == 'event' || $attrib['type'] == 'task'); | ||||
$table = new html_table(array('cellspacing' => 0, 'class' => 'table-striped')); | $table = new html_table(array('cellspacing' => 0, 'class' => 'table-striped')); | ||||
$table->add_header(array( | $table->add_header(array( | ||||
'class' => 'subscription checkbox-cell', | 'class' => 'subscription checkbox-cell', | ||||
'title' => $this->plugin->gettext('synchronize'), | 'title' => $this->plugin->gettext('synchronize'), | ||||
'tabindex' => 0 | 'tabindex' => 0 | ||||
), | ), | ||||
$attrib['syncicon'] ? html::img(array('src' => $this->skin_path . $attrib['syncicon'])) : | ($attrib['syncicon'] ?? false) ? html::img(array('src' => $this->skin_path . $attrib['syncicon'])) : | ||||
$this->plugin->gettext('synchronize') | $this->plugin->gettext('synchronize') | ||||
); | ); | ||||
if ($alarms) { | if ($alarms) { | ||||
$table->add_header(array( | $table->add_header(array( | ||||
'class' => 'alarm checkbox-cell', | 'class' => 'alarm checkbox-cell', | ||||
'title' => $this->plugin->gettext('withalarms'), | 'title' => $this->plugin->gettext('withalarms'), | ||||
'tabindex' => 0 | 'tabindex' => 0 | ||||
), | ), | ||||
$attrib['alarmicon'] ? html::img(array('src' => $this->skin_path . $attrib['alarmicon'])) : | ($attrib['alarmicon'] ?? null) ? html::img(array('src' => $this->skin_path . $attrib['alarmicon'])) : | ||||
$this->plugin->gettext('withalarms') | $this->plugin->gettext('withalarms') | ||||
); | ); | ||||
} | } | ||||
$table->add_header('foldername', $this->plugin->gettext('folder')); | $table->add_header('foldername', $this->plugin->gettext('folder')); | ||||
$checkbox_sync = new html_checkbox(array('name' => 'subscribed[]', 'class' => 'subscription')); | $checkbox_sync = new html_checkbox(array('name' => 'subscribed[]', 'class' => 'subscription')); | ||||
$checkbox_alarm = new html_checkbox(array('name' => 'alarm[]', 'class' => 'alarm')); | $checkbox_alarm = new html_checkbox(array('name' => 'alarm[]', 'class' => 'alarm')); | ||||
Show All 29 Lines | public function folder_subscriptions_block($a_folders, $attrib, $subscribed) | ||||
$disabled = $this->is_protected($folder, $this->device['TYPE']); | $disabled = $this->is_protected($folder, $this->device['TYPE']); | ||||
$table->add('subscription checkbox-cell', $checkbox_sync->show( | $table->add('subscription checkbox-cell', $checkbox_sync->show( | ||||
!empty($subscribed[$folder]) ? $folder : null, | !empty($subscribed[$folder]) ? $folder : null, | ||||
array('value' => $folder, 'id' => $folder_id, 'disabled' => $disabled))); | array('value' => $folder, 'id' => $folder_id, 'disabled' => $disabled))); | ||||
if ($alarms) { | if ($alarms) { | ||||
$table->add('alarm checkbox-cell', $checkbox_alarm->show( | $table->add('alarm checkbox-cell', $checkbox_alarm->show( | ||||
intval($subscribed[$folder]) > 1 ? $folder : null, | intval($subscribed[$folder] ?? 0) > 1 ? $folder : null, | ||||
array('value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled))); | array('value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled))); | ||||
} | } | ||||
$table->add(join(' ', $classes), html::label($folder_id, $foldername)); | $table->add(join(' ', $classes), html::label($folder_id, $foldername)); | ||||
} | } | ||||
return $table->show(); | return $table->show(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |