App-Request: Busy Calendar

Because I’m not able to develop an app, I post here my Idea. May someone feels inspired. If so - thanks a lot!

Case:
Management of a family. Every Family member has it’s own calendar.
Goal: Family members should know if others are not available.

Design Idea sorted by Priority:

  1. Allow to set a calendar share
    • Choose involved calendars (local, federated and readonly calendar)
    • create a calendar with name of the family member as subject that list all entries of the chosen calendars
    • this shared calendar entries are setup with “available”, that way, it do not interfere with entries of the resceiver of the calendar.
    • This calendar do not appear in the creators calendar
    • this calendar could be shared to internal user and groups, federated and externals as public link.
  2. this calendar should merge all dates that follow each other with a chosen max. gap (e.g. 30min) ==> less cluttered overview
  3. add an edit for the information transfer. That way a member could set-up that a e.g. a subject should appear in the description of a calendar entry.
  4. If a member setup an entry that is set as “available” it should not been listed.
  5. Allow sharing as public calendar where you could setup details of the Public calendar and state of all busy Items.
    1. Overall Subject
    2. Overall available
    3. Overall category
  6. alternated calendar share: share this calendar by mail. every time a date got added an anonymized mail invitation mail is sent to a specific mail address.

If you feel inspired to develop this app. I am ready to test it.

1 Like

Mannshoch,

I’m currently, working around this by leveraging a shared Google Family Calendar, not ideal and yes it takes the weekly sync for updates, and I agree have an internal shared Calendar functionality would be great!

1 Like

I mentioned this idea to a friend of min. He told me that he would really like such a feature because he has two part time jobs and a wife.
On one job his superior would have it more easy to request him for some shifts.

For him I created this request.

I had the same idea and solved the goal with a litte bit of my development skills. Sorry for my english, I am german.

My concept is to download the source calendar, modify every event to anonymize them and give them the title “-=busy=-”. Then upload the modified calendar to nextcloud, where this “busycalendar” is shared to the family memers needed.

Here are my solution steps:

  1. Download the source calendar as .ics file. This can be done easyly with the extension of “?export” after the CalDAV-URL - see link of the “Export-Button” in calendars settings (web-ui).
  2. Modify the downloaded ics-file with a search-and-replace tool. I used the following regular expressions:
  • “SUMMARY:.*[^a]” replaced with “SUMMARY:-=busy=-”
  • “DESCRIPTION:.*[^a]” replaced with “DESCRIPTION:”
  • “LOCATION:.*[^a]” replaced with “LOCATION:”
  1. Uploading the modified ics-file to nexcloud by using a ics2caldav-importer. On github I found a php-solution: https://github.com/stefan-muc/caldav-calendar-import
  2. Automate the process by wrapping the steps above in a shell-script.

I’m not new in programming linux shell scripts and php, but last time I’ve done thomething like this is passing many years. So the code I produced is quick-and-dirty, has room for improvement but works fine for me.
This is the wrapper-script and you will adjust your needs:

#!/bin/sh
# get source .ics
echo "#1 get source .ics"
sudo -u http php82 [/var/www/html]/busycalendar/download_ics-file.php $1

# modify .ics to -=busy=-
echo "#2 modify .ics to -=busy=-"
sed -e "s/SUMMARY:.*[^a]/SUMMARY:-=busy=-/g" /var/tmp/export.ics > /var/tmp/export_1.ics
sed -e "s/DESCRIPTION:.*[^a]/DESCRIPTION:/g" /var/tmp/export_1.ics > /var/tmp/export_2.ics
sed -e "s/LOCATION:.*[^a]/LOCATION:/g" /var/tmp/export_2.ics > /var/tmp/export_busy.ics

# prepare .ics for import
echo "prepare .ics for import"
chmod 777 /var/tmp/export*.ics

# update busy-calendar via ics2caldav-importer
echo "#3 update busy-calendar via ics2caldav-importer"
sudo -u http php82 [/var/www/html]/busycalendar/calendar_import.php $1

# cleanup
echo "#4 cleanup"
rm /var/tmp/export*.ics

The called download_ics-file.php is a basic php-file-downloader script, witch accepts a optional given calendar-name as parameter 1:

<?php
if (isset($argv[1]))
{
    echo "download .ics file from calendar: " . $argv[1];
}

//API KEY AND PASSWORD
$username = '[username]';
$password = '[password]';
$usernamePassword = $username . ':' . $password;
$headers = array('Authorization: Basic ' . base64_encode($usernamePassword), 'Content-Type: application/json');

//URL
$url = 'https://[nextcloud-host]/remote.php/dav/calendars/[username]/[calendar-name]/?export';

if (isset($argv[1]))
{
    if ($argv[1] == '[calendar-name 1]') $url = 'https://[nextcloud-host]/remote.php/dav/calendars/[username]/[calendar-name 1]/?export';
    if ($argv[1] == '[calendar-name 2]') $url = 'https://[nextcloud-host]/remote.php/dav/calendars/[username]/[calendar-name 2]/?export';
}

//FILE NAME
$filename = 'export.ics';

//DOWNLOAD PATH
$path = '/var/tmp/'.$filename;

/FOLDER PATH
$fp = fopen($path, 'w');

//SETTING UP CURL REQUEST
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);

//CONNECTION CLOSE
curl_close($ch);
fclose($fp);
?>

The challenge with the caldav-importer script was, that the url for the ics-file to import is designed for WebDAV on the same nextcloud-host. But you can easy use a url without using WebDAV too. So I created a symbolc link to the modified ics-file, that is reachable directly via the webhost like this “https://[nextcloud-host]/busycalendar/export_busy.ics”.

When I bring all together, I created a cron job to call the wrapper script once a day. WHOOHAA! :slight_smile:

Be ispired of this solution and fork it. For example an only-php solution should be a better way. → The used caldav-importer script stores the events as VEVENT-objects (sabre/vobject) in a list. This list is processed for uploading via CalDAV by looping through this list. Here the anonymization should be done better.