Skip to content

Commit

Permalink
CalDAV HTML Admin page: show/edit sheduling-enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dilyanpalauzov committed Oct 9, 2024
1 parent 06cb964 commit d173d40
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion changes/next/htmladminpage
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description:

The CalDAV and CardDAV HTML administration pages allow editing
the DAV:displayname and description properties.
For calendars also the color and order properties.
For calendars also the color, CY:calendar-scheduling and order properties.

Config changes:

Expand Down
3 changes: 3 additions & 0 deletions docsrc/imap/download/installation/http/caldav.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ server-side freebusy calculations. The Time Zone on calendars
is used to calculate the freebusy state on events with floating
times. Public toggles the `lrw9` rights for the `anyone` user.

When the property http://cyrusimap.org/ns/:scheduling-enabled has
value `F` on a calendar, then the calendar does not perform scheduling.

The Cyrus web GUI for CalDAV Collection Management is disabled by
default, but can be enabled with the "caldav_allowcalendaradmin" option.

Expand Down
11 changes: 11 additions & 0 deletions imap/http_cal_abook_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const X_CLIENT = 'Cyrus/%s'; // Version filled in by printf() in http_caldav.c/
const XML_CALCARD_NS = 'urn:ietf:params:xml:ns:ca' + (calendar ? 'ldav' : 'rddav');
const DESCRIPTION = (calendar ? 'calendar' : 'addressbook') + '-description';
const XML_APPLE_NS = 'http://apple.com/ns/ical/';
const XML_CYRUS_NS = 'http://cyrusimap.org/ns/';

function n(i) {
const h = window.location.href;
Expand Down Expand Up @@ -255,6 +256,16 @@ function transpCalendar(i, transp) {
pu[2].submit();
}

function scheduling(i, set) {
const pu = propupdate(!set, i);
const scheduling_enabled = pu[0].createElementNS(XML_CYRUS_NS, "scheduling-enabled");
pu[1].appendChild(scheduling_enabled);
if (!set)
scheduling_enabled.appendChild(pu[0].createTextNode("F"));

pu[2].submit();
}


// Adjust supported components on a calendar collection
function compsetCalendar(id, comps) {
Expand Down
21 changes: 19 additions & 2 deletions imap/http_caldav.c
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,8 @@ enum {
CAL_CAN_ADMIN = (1<<2),
CAL_IS_PUBLIC = (1<<3),
CAL_IS_TRANSP = (1<<4),
CAL_CAN_PROPCOL = (1<<5)
CAL_CAN_PROPCOL = (1<<5),
CAL_DOES_SCHEDULE = (1<<6)
};

struct list_cal_rock {
Expand Down Expand Up @@ -2055,6 +2056,9 @@ static int list_cal_cb(const mbentry_t *mbentry, void *rock)
if (rights & DACL_PROPCOL) {
cal->flags |= CAL_CAN_PROPCOL;
}
annotatemore_lookup(mbentry->name, DAV_ANNOT_NS "<" XML_NS_CYRUS ">scheduling-enabled", "", &temp);
if (strcasecmp(buf_cstring(&temp), "F") && strcasecmp(buf_cstring(&temp), "no"))
cal->flags |= CAL_DOES_SCHEDULE;

/* Is this the default calendar? */
if (len == lrock->defaultlen &&
Expand Down Expand Up @@ -2310,7 +2314,7 @@ static int list_calendars(struct transaction_t *txn)
qsort(lrock.cal, lrock.len, sizeof(struct cal_info), &cal_compare);
charset_t utf8 = charset_lookupname("utf-8");
buf_printf_markup(body, level, "<thead>");
buf_printf_markup(body, level, "<tr><th colspan='2'>Name</th><th colspan='2'>Description</th><th>Color</th><th>Order</th><th>Components</th><th>WebCAL link</th><th>HTTPS link</th><th>Actions</th><th>Public</th><th>Transparent</th></tr>");
buf_printf_markup(body, level, "<tr><th colspan='2'>Name</th><th colspan='2'>Description</th><th>Color</th><th>Order</th><th>Components</th><th>WebCAL link</th><th>HTTPS link</th><th>Actions</th><th>Public</th><th>Transparent</th>%s</tr>", namespace_calendar.allow & ALLOW_CAL_SCHED ? "<th>Scheduling</th>" : "");
buf_printf_markup(body, level, "</thead><tbody>");

/* Add available calendars with action items */
Expand Down Expand Up @@ -2415,6 +2419,19 @@ static int list_calendars(struct transaction_t *txn)
(cal->flags & CAL_CAN_ADMIN) ? "" : " disabled",
(cal->flags & CAL_IS_TRANSP) ? " checked" : "", i);

/* Scheduling checkbox */
if (namespace_calendar.allow & ALLOW_CAL_SCHED) {
if (cal->flags & CAL_CAN_PROPCOL)
buf_printf_markup(body, level,
"<td><label><input type=checkbox%s"
" onclick='scheduling(%i, this.checked)'>Enabled</label>"
"</td>",
cal->flags & CAL_DOES_SCHEDULE ? " checked" : "", i);
else
buf_printf_markup(body, level, "<td>%s</td>",
cal->flags & CAL_DOES_SCHEDULE ? "Enabled" : "Disabled");
}

buf_printf_markup(body, --level, "</tr>");
}

Expand Down

0 comments on commit d173d40

Please sign in to comment.