Nextcloud App to hide shared nextcloud calendars on user login
Find a file
2025-09-02 11:52:42 +02:00
calhider Added version dependencies 2025-09-02 11:52:42 +02:00
LICENSE Initial commit 2025-09-01 15:41:35 +02:00
README.md Inital commit: Calhider app 2025-09-01 15:39:53 +02:00

Nextcloud CalHider App

A lightweight Nextcloud app that automatically hides all shared calendars for new users on their first login.
This ensures that every user starts with a clean calendar view and can selectively enable only the calendars they actually need.

Features

  • Automatically hides all shared calendars on the first login of a new user.
  • Uses a guard flag (initial-hide-done) so the operation only runs once per user.
  • OCC command to show, set, or unset the guard flag.
  • Optional one-time rollout command (seed-guard) to initialize the guard flag for existing users.

Installation

  1. Place the app into the Nextcloud apps/ directory, e.g. apps/calhider.
  2. Set the owner to www-data:
    chown -R www-data:www-data apps/calhider
    
  3. Enable the app:
    php occ app:enable calhider
    

OCC Commands

Guard Flag Control

# Show the guard flag status for a user
php occ org:calendar:guard --show <userId>

# Set the guard flag (user will no longer be auto-processed)
php occ org:calendar:guard --set <userId>

# Unset the guard flag (user will be processed again at next login)
php occ org:calendar:guard --unset <userId>

Optional: Rollout for Existing Users

If you want to prevent all existing users from being processed on their next login:

# Dry run (shows which users would be marked)
php occ org:calendar:seed-guard --dry-run

# Mark all existing users as "done"
php occ org:calendar:seed-guard

After running this once, you can remove the SeedGuard command from appinfo/info.xml and delete the file SeedGuard.php.

How It Works

  1. A new user is created via OIDC/LDAP/provisioning.
  2. At the first login, the event listener (UserLoggedInListener) triggers.
  3. If the guard flag is not set:
    • CalDavHider hides all shared calendars for that user.
    • The guard flag is then set.
  4. Subsequent logins are unaffected.

Debugging

  • Debug logs are written to data/calhider-debug.log.
  • You can check a users guard status with:
    php occ org:calendar:guard --show <uid>
    

License

AGPLv3 (as required for Nextcloud apps)