Mailing List Archive

Proposed patch to show android PRIVATE events as CONFIDENTIAL like "thunderbird show only busy" events
It seems that all (or at least all calendar that I've found on android) are unable to create CONFIDENTIAL events.

You have to choose between PUBLIC (that is, all guys that you've shared the calendar will see all the event info) or PRIVATE (that means that they will not see the event at all).

Thunderbird has a nice solution: show the event as busy (show date time only), that saves your pryvacy but nevertheless allow other people to see your plans.

This is a patch to convert the PRIVATE events sent by android calendars to CONFIDENTIAL, so allowing the same behavior of thunderbird.

I don't know how to set this in PHP code, so I've implemented it as a trigger.
Here is the code:

<pre>
=================================================================
-- Trigger: caldav_data_modified on caldav_data
CREATE OR REPLACE FUNCTION caldav_data_set_private_as_busy()
RETURNS trigger AS
$BODY$
BEGIN
if (position('CLASS:PRIVATE' in NEW.caldav_data) > 0) then
-- private event, convert it to confidential
if (position('TRANSP:' in NEW.caldav_data) > 0) then
-- transparency already set, leave it unchanged and set only the class
NEW.caldav_data = replace(NEW.caldav_data, 'CLASS:PRIVATE', 'CLASS:CONFIDENTIAL');
else
-- transparency NOT set, set the class and insert transparency it as opaque
NEW.caldav_data = replace(NEW.caldav_data, 'CLASS:PRIVATE', 'CLASS:CONFIDENTIAL\nTRASP:OPAQUE');
end if;
end if;


RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;

ALTER FUNCTION caldav_data_set_private_as_busy() OWNER TO davical_dba;

CREATE TRIGGER caldav_data_set_private_as_busy
BEFORE INSERT OR UPDATE
ON caldav_data
FOR EACH ROW
EXECUTE PROCEDURE caldav_data_set_private_as_busy();


-- Trigger: caldav_data_modified on caldav_data
CREATE OR REPLACE FUNCTION calendar_item_set_private_as_busy()
RETURNS trigger AS
$BODY$
BEGIN
if (NEW.class = 'PRIVATE') then
-- private event, convert it to confidential
NEW.class = 'CONFIDENTIAL';

if (NEW.transp is null) then
-- transparency NOT set, set it as opaque
NEW.transp = 'OPAQUE';
end if;
end if;

RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;

ALTER FUNCTION calendar_item_set_private_as_busy() OWNER TO davical_dba;

CREATE TRIGGER calendar_item_set_private_as_busy
BEFORE INSERT OR UPDATE
ON calendar_item
FOR EACH ROW
EXECUTE PROCEDURE calendar_item_set_private_as_busy();
=================================================================
</pre>

Regards,
larzeni

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general