Allow to add ics calendars when no CalDAV sources exist

This commit is contained in:
JodliDev 2021-08-26 16:26:17 +02:00
parent 3df123b0b8
commit 71c4d7aba9
5 changed files with 19 additions and 14 deletions

View file

@ -193,7 +193,6 @@ class caldav_driver extends calendar_driver
'active' => !in_array($id, $hidden), 'active' => !in_array($id, $hidden),
'group' => 'x-birthdays', 'group' => 'x-birthdays',
'editable' => false, 'editable' => false,
'editable_name' => true,
'default' => false, 'default' => false,
'children' => false, 'children' => false,
); );
@ -1898,11 +1897,11 @@ class caldav_driver extends calendar_driver
'SELECT source_id, caldav_url FROM '.$this->db_sources .' WHERE user_id = ?', 'SELECT source_id, caldav_url FROM '.$this->db_sources .' WHERE user_id = ?',
$this->rc->user->ID $this->rc->user->ID
); );
$sources_exist = $this->rc->db->num_rows($result);
if($this->rc->db->num_rows($result)) { if($this->rc->db->num_rows($result)) {
$is_ical = new html_checkbox( array( $is_ical = new html_checkbox( array(
'name' => "is_ical", 'name' => "is_ical",
'value' => 1, 'value' => 1,
'onload' => 'alert(123)',
'onclick' => ' 'onclick' => '
if(this.checked) { if(this.checked) {
$("#ical_url").removeClass("hidden"); $("#ical_url").removeClass("hidden");
@ -1914,7 +1913,7 @@ else {
}' }'
)); ));
$formfields['is_ical'] = array( $formfields['is_ical'] = array(
'label' => $this->cal->gettext('calendar_is_ical'), 'label' => $this->cal->gettext('calendar_ical_file'),
'value' => $is_ical->show(null), 'value' => $is_ical->show(null),
'class' => 'hidden' 'class' => 'hidden'
); );
@ -1925,7 +1924,6 @@ else {
'class' => 'hidden' 'class' => 'hidden'
)); ));
$caldav_url = new html_select([ $caldav_url = new html_select([
'name' => 'source_id', 'name' => 'source_id',
'id' => 'caldav_url' 'id' => 'caldav_url'
@ -1939,8 +1937,19 @@ else {
); );
} }
else { else {
$this->rc->output->show_message($this->cal->gettext('nosources_error'), 'error'); $ical_url = new html_inputfield( array(
return null; 'name' => 'ical_url',
'size' => 20,
));
$formfields['url'] = array(
'label' => $this->cal->gettext('calendar_ical_file'),
'value' => $ical_url->show(null),
);
$enable_ics = new html_hiddenfield(['name' => 'is_ical', 'value' => 1]);
$formfields['hidden'] = array(
'label' => ' ',
'value' =>$enable_ics->show(null),
);
} }
} }

View file

@ -8,9 +8,8 @@
*/ */
$labels['addsources'] = 'CalDAV Quellen hinzufügen'; $labels['addsources'] = 'CalDAV Quellen hinzufügen';
$labels['deletesources'] = 'CalDAV Quellen löschen'; $labels['deletesources'] = 'CalDAV Quellen löschen';
$labels['nosources_error'] = 'Keine CalDAV Quellen vorhanden.';
$labels['source_notadded_error'] = 'CalDAV Quelle konnte nicht hinzugefügt werden.'; $labels['source_notadded_error'] = 'CalDAV Quelle konnte nicht hinzugefügt werden.';
$labels['calendar_is_ical'] = 'Ist ics-Datei'; $labels['calendar_ical_file'] = 'ics-Datei';
$labels['default_view'] = 'Standardansicht'; $labels['default_view'] = 'Standardansicht';
$labels['time_format'] = 'Zeitformatierung'; $labels['time_format'] = 'Zeitformatierung';

View file

@ -8,9 +8,8 @@
*/ */
$labels['addsources'] = 'CalDAV Quellen hinzufügen'; $labels['addsources'] = 'CalDAV Quellen hinzufügen';
$labels['deletesources'] = 'CalDAV Quellen löschen'; $labels['deletesources'] = 'CalDAV Quellen löschen';
$labels['nosources_error'] = 'Keine CalDAV Quellen vorhanden.';
$labels['source_notadded_error'] = 'CalDAV Quelle konnte nicht hinzugefügt werden.'; $labels['source_notadded_error'] = 'CalDAV Quelle konnte nicht hinzugefügt werden.';
$labels['calendar_is_ical'] = 'Ist ics-Datei'; $labels['calendar_ical_file'] = 'ics-Datei';
$labels['default_view'] = 'Standardansicht'; $labels['default_view'] = 'Standardansicht';
$labels['time_format'] = 'Zeitformatierung'; $labels['time_format'] = 'Zeitformatierung';

View file

@ -8,9 +8,8 @@
*/ */
$labels['addsources'] = 'CalDAV Quellen hinzufügen'; $labels['addsources'] = 'CalDAV Quellen hinzufügen';
$labels['deletesources'] = 'CalDAV Quellen löschen'; $labels['deletesources'] = 'CalDAV Quellen löschen';
$labels['nosources_error'] = 'Keine CalDAV Quellen vorhanden.';
$labels['source_notadded_error'] = 'CalDAV Quelle konnte nicht hinzugefügt werden.'; $labels['source_notadded_error'] = 'CalDAV Quelle konnte nicht hinzugefügt werden.';
$labels['calendar_is_ical'] = 'Ist ics-Datei'; $labels['calendar_ical_file'] = 'ics-Datei';
$labels['default_view'] = 'Standardansicht'; $labels['default_view'] = 'Standardansicht';
$labels['time_format'] = 'Zeitformatierung'; $labels['time_format'] = 'Zeitformatierung';

View file

@ -13,9 +13,8 @@ $labels = array();
//caldav driver //caldav driver
$labels['addsources'] = 'Add CalDAV sources'; $labels['addsources'] = 'Add CalDAV sources';
$labels['deletesources'] = 'Delete CalDAV sources'; $labels['deletesources'] = 'Delete CalDAV sources';
$labels['nosources_error'] = 'No CalDAV sources available.';
$labels['source_notadded_error'] = 'CalDAV source could not be added.'; $labels['source_notadded_error'] = 'CalDAV source could not be added.';
$labels['calendar_is_ical'] = 'Is ics file'; $labels['calendar_ical_file'] = 'ics file';
// preferences // preferences
$labels['default_view'] = 'Default view'; $labels['default_view'] = 'Default view';