Difference between revisions of "Removal of users"

From Davical
Jump to navigationJump to search
(Recommended approach)
Line 24: Line 24:
  
 
  SELECT * FROM caldav_data WHERE logged_user = (SELECT user_no FROM usr WHERE username='someuser');
 
  SELECT * FROM caldav_data WHERE logged_user = (SELECT user_no FROM usr WHERE username='someuser');
 +
 +
== Emptying a Calendar with SQL ==
 +
To delete just the events in a particular calendar:
 +
 +
DELETE FROM caldav_data WHERE dav_name = '/username/calendar/';
 +
 +
A database trigger will remove the related entries from the calendar_item table.
  
 
== Deleting a Calendar with SQL ==
 
== Deleting a Calendar with SQL ==

Revision as of 11:21, 22 March 2009

At present there is no functionality in the administrative interface to delete users or calendars.

The recommended approach is to mark users as inactive, rather than delete them.

Deleting Calendars with a DAV Client

It is possible to use a DAV client like cadaver to delete a calendar. I don't know of any CalDAV client which implements deletion of remote calendars (delete usually only removes the connection information), but the functionality is implemented in DAViCal.

Deleting Users with SQL

While there is no functionality to delete a user or a calendar through the admin user interface in DAViCal, the tasks can be done through SQL.

BEGIN;
DELETE FROM relationship WHERE to_user = (SELECT user_no FROM usr WHERE username='someuser');
DELETE FROM relationship WHERE from_user = (SELECT user_no FROM usr WHERE username='someuser');
DELETE FROM collection WHERE user_no = (SELECT user_no FROM usr WHERE username='someuser');
DELETE FROM property WHERE dav_name LIKE '/someuser/%';
DELETE FROM usr WHERE username = 'someuser';
COMMIT;

In some circumstances this won't work completely, because the user will have modified appointments in other calendars. A decision will need to be made to modify or delete those appointments in order to pass the relational integrity check.

To list the entries changed by a particular user, something like the following:

SELECT * FROM caldav_data WHERE logged_user = (SELECT user_no FROM usr WHERE username='someuser');

Emptying a Calendar with SQL

To delete just the events in a particular calendar:

DELETE FROM caldav_data WHERE dav_name = '/username/calendar/';

A database trigger will remove the related entries from the calendar_item table.

Deleting a Calendar with SQL

To delete a calendar:

DELETE FROM collection WHERE dav_name = '/username/calendar/';