Fix handling of kolab_freebusy_server=false (and other empty values)
- Cleanup code - Hide availability features in the Resources tab
This commit is contained in:
parent
5863bcc947
commit
83d5c9f7f5
6 changed files with 88 additions and 68 deletions
|
@ -342,6 +342,7 @@ class calendar extends rcube_plugin
|
||||||
$this->rc->output->set_env('timezone', $this->timezone->getName());
|
$this->rc->output->set_env('timezone', $this->timezone->getName());
|
||||||
$this->rc->output->set_env('calendar_driver', $this->rc->config->get('calendar_driver'), false);
|
$this->rc->output->set_env('calendar_driver', $this->rc->config->get('calendar_driver'), false);
|
||||||
$this->rc->output->set_env('calendar_resources', (bool)$this->rc->config->get('calendar_resources_driver'));
|
$this->rc->output->set_env('calendar_resources', (bool)$this->rc->config->get('calendar_resources_driver'));
|
||||||
|
$this->rc->output->set_env('calendar_resources_freebusy', !empty($this->rc->config->get('kolab_freebusy_server')));
|
||||||
$this->rc->output->set_env('identities-selector', $this->ui->identity_select([
|
$this->rc->output->set_env('identities-selector', $this->ui->identity_select([
|
||||||
'id' => 'edit-identities-list',
|
'id' => 'edit-identities-list',
|
||||||
'aria-label' => $this->gettext('roleorganizer'),
|
'aria-label' => $this->gettext('roleorganizer'),
|
||||||
|
|
|
@ -924,13 +924,19 @@ function rcube_calendar_ui(settings)
|
||||||
$('#edit-tab-attachments')[(calendar.attachments?'show':'hide')]();
|
$('#edit-tab-attachments')[(calendar.attachments?'show':'hide')]();
|
||||||
$('#eventedit:not([data-notabs])').tabs('option', 'active', 0); // Larry
|
$('#eventedit:not([data-notabs])').tabs('option', 'active', 0); // Larry
|
||||||
|
|
||||||
// show/hide tabs according to calendar's feature support and activate first tab (Ellastic)
|
// show/hide tabs according to calendar's feature support and activate first tab (Elastic)
|
||||||
$('li > a[href="#event-panel-attendees"]').parent()[(calendar.attendees?'show':'hide')]();
|
$('li > a[href="#event-panel-attendees"]').parent()[(calendar.attendees?'show':'hide')]();
|
||||||
$('li > a[href="#event-panel-resources"]').parent()[(rcmail.env.calendar_resources?'show':'hide')]();
|
$('li > a[href="#event-panel-resources"]').parent()[(rcmail.env.calendar_resources?'show':'hide')]();
|
||||||
$('li > a[href="#event-panel-attachments"]').parent()[(calendar.attachments?'show':'hide')]();
|
$('li > a[href="#event-panel-attachments"]').parent()[(calendar.attachments?'show':'hide')]();
|
||||||
if ($('#eventedit').data('notabs'))
|
if ($('#eventedit').data('notabs'))
|
||||||
$('#eventedit li.nav-item:first-child a').tab('show');
|
$('#eventedit li.nav-item:first-child a').tab('show');
|
||||||
|
|
||||||
|
if (!rcmail.env.calendar_resources_freebusy) {
|
||||||
|
// With no freebusy setup, some features needs to be hidden
|
||||||
|
// TODO: Show "Find resources" dialog, but with Availability tab hidden
|
||||||
|
$('#event-panel-resources').find('#edit-resource-find,#edit-attendees-legend,td.availability,th.availability').hide();
|
||||||
|
}
|
||||||
|
|
||||||
// hack: set task to 'calendar' to make all dialog actions work correctly
|
// hack: set task to 'calendar' to make all dialog actions work correctly
|
||||||
var comm_path_before = rcmail.env.comm_path;
|
var comm_path_before = rcmail.env.comm_path;
|
||||||
rcmail.env.comm_path = comm_path_before.replace(/_task=[a-z]+/, '_task=calendar');
|
rcmail.env.comm_path = comm_path_before.replace(/_task=[a-z]+/, '_task=calendar');
|
||||||
|
@ -3381,6 +3387,7 @@ function rcube_calendar_ui(settings)
|
||||||
me.calendars[this.id].url = this.url;
|
me.calendars[this.id].url = this.url;
|
||||||
sources.push(this.id);
|
sources.push(this.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
id += '@'+sources.join(',');
|
id += '@'+sources.join(',');
|
||||||
|
|
||||||
// ignore if query didn't change
|
// ignore if query didn't change
|
||||||
|
|
|
@ -2016,6 +2016,12 @@ class kolab_driver extends calendar_driver
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$url = $this->storage->get_freebusy_url($email);
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// map vcalendar fbtypes to internal values
|
// map vcalendar fbtypes to internal values
|
||||||
$fbtypemap = [
|
$fbtypemap = [
|
||||||
'FREE' => calendar::FREEBUSY_FREE,
|
'FREE' => calendar::FREEBUSY_FREE,
|
||||||
|
@ -2031,7 +2037,7 @@ class kolab_driver extends calendar_driver
|
||||||
'follow_redirects' => true,
|
'follow_redirects' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
$request = libkolab::http_request($this->storage->get_freebusy_url($email), 'GET', $request_config);
|
$request = libkolab::http_request($url, 'GET', $request_config);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
|
|
||||||
// authentication required
|
// authentication required
|
||||||
|
|
|
@ -279,11 +279,12 @@ class kolab_storage
|
||||||
{
|
{
|
||||||
$rcmail = rcube::get_instance();
|
$rcmail = rcube::get_instance();
|
||||||
|
|
||||||
$url = 'https://' . $_SESSION['imap_host'] . '/freebusy';
|
if ($url = $rcmail->config->get('kolab_freebusy_server')) {
|
||||||
$url = $rcmail->config->get('kolab_freebusy_server', $url);
|
|
||||||
$url = rcube_utils::resolve_url($url);
|
$url = rcube_utils::resolve_url($url);
|
||||||
|
$url = unslashify($url);
|
||||||
|
}
|
||||||
|
|
||||||
return unslashify($url);
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,10 +294,16 @@ class kolab_storage
|
||||||
* @param object DateTime Start of the query range (optional)
|
* @param object DateTime Start of the query range (optional)
|
||||||
* @param object DateTime End of the query range (optional)
|
* @param object DateTime End of the query range (optional)
|
||||||
*
|
*
|
||||||
* @return string Fully qualified URL to query free/busy data
|
* @return ?string Fully qualified URL to query free/busy data
|
||||||
*/
|
*/
|
||||||
public static function get_freebusy_url($email, $start = null, $end = null)
|
public static function get_freebusy_url($email, $start = null, $end = null)
|
||||||
{
|
{
|
||||||
|
$url = self::get_freebusy_server();
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$query = '';
|
$query = '';
|
||||||
$param = array();
|
$param = array();
|
||||||
$utc = new \DateTimeZone('UTC');
|
$utc = new \DateTimeZone('UTC');
|
||||||
|
@ -317,8 +324,6 @@ class kolab_storage
|
||||||
$query = '?' . http_build_query($param);
|
$query = '?' . http_build_query($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = self::get_freebusy_server();
|
|
||||||
|
|
||||||
if (strpos($url, '%u')) {
|
if (strpos($url, '%u')) {
|
||||||
// Expected configured full URL, just replace the %u variable
|
// Expected configured full URL, just replace the %u variable
|
||||||
// Note: Cyrus v3 Free-Busy service does not use .ifb extension
|
// Note: Cyrus v3 Free-Busy service does not use .ifb extension
|
||||||
|
|
|
@ -149,7 +149,7 @@ class kolab_storage_dav
|
||||||
* @param object DateTime Start of the query range (optional)
|
* @param object DateTime Start of the query range (optional)
|
||||||
* @param object DateTime End of the query range (optional)
|
* @param object DateTime End of the query range (optional)
|
||||||
*
|
*
|
||||||
* @return string Fully qualified URL to query free/busy data
|
* @return ?string Fully qualified URL to query free/busy data
|
||||||
*/
|
*/
|
||||||
public static function get_freebusy_url($email, $start = null, $end = null)
|
public static function get_freebusy_url($email, $start = null, $end = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1099,13 +1099,14 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
||||||
{
|
{
|
||||||
$owner = $this->get_owner();
|
$owner = $this->get_owner();
|
||||||
$result = false;
|
$result = false;
|
||||||
|
$url = kolab_storage::get_freebusy_server();
|
||||||
|
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case 'event':
|
case 'event':
|
||||||
if ($this->get_namespace() == 'personal') {
|
if ($url && $this->get_namespace() == 'personal') {
|
||||||
$result = $this->trigger_url(
|
$result = $this->trigger_url(
|
||||||
sprintf('%s/trigger/%s/%s.pfb',
|
sprintf('%s/trigger/%s/%s.pfb',
|
||||||
kolab_storage::get_freebusy_server(),
|
$url,
|
||||||
urlencode($owner),
|
urlencode($owner),
|
||||||
urlencode($this->imap->mod_folder($this->name))
|
urlencode($this->imap->mod_folder($this->name))
|
||||||
),
|
),
|
||||||
|
@ -1119,7 +1120,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result && is_object($result) && is_a($result, 'PEAR_Error')) {
|
if ($result instanceof PEAR_Error) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
sprintf("Failed triggering folder %s. Error was: %s", $this->name, $result->getMessage())
|
sprintf("Failed triggering folder %s. Error was: %s", $this->name, $result->getMessage())
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue