-
Notifications
You must be signed in to change notification settings - Fork 96
Added calendar-user preferences. #288
base: master
Are you sure you want to change the base?
Added calendar-user preferences. #288
Conversation
Thanks
@DeepDiver1975 What do you think about removing this field? |
and "_calendar_user_preferences" should be a key-value store |
Thanks for the feedback @georgehrke! I've shortened the table name to clndr_user_preferences instead of clndr_calendar_user_preferences. I have also refactored clndr_user_preferences to be a key-value store. Would you like me to put the active field back in clndr_calendars now, or should I wait until @DeepDiver1975 has replied? Cheers! |
Let's wait for @DeepDiver1975 's opinion |
Are there any design changes, i.e. is my review necessary? |
@jancborchardt I wouldn't say there are any design changes, other than the addition of the "Delete unused calendar preferences" button in the calendar settings. |
@ben-denham hm, strange button. Do we need that? What does it do? Would a user ever need to click it – and if so, what for? :) |
Those should be deleted automatically. There are sharing hooks for it. |
Yes, that should all be automatic. No additional settings for users or admins for this needed. :) @ben-denham can you change that? |
Ok, calendar-user preferences are now deleted automatically when:
However, preferences are only deleted if the user does not have access to the calendar in some other way (e.g. being the owner or a having a second share) :) |
Cool, so if now there’s no interface change anymore I can at least give my design-:+1: :) |
@butonic What was the limit for table names in oracle? 26 chars? |
@georgehrke 30 chars |
@georgehrke so what’s your call on this? @rysiekpl can you review this as well? |
@ben-denham Sorry for the long delay. Can I get you to rebase to master? |
Shortened table name from clndr_calendar_user_preferences to clndr_user_preferences Initial conversion of calendar-user preferences to use a key-value store. Updated the update hook to work with the key-value stored preferences. Fixed SQL in update hook. Fixed minor bugs with key-value calendar-user preferences implementation. Fixed mainly indentation and comments. Calendar-user preferences are now automatically cleaned when a user loses access to a calendar. Also fixed minor bugs with creating default calendar-user preferences. Removed unused cleanpreferences.php
@tanghus Just rebased to master. |
Thanks @ben-denham :) |
@@ -249,7 +397,7 @@ public static function touchCalendar($id) { | |||
*/ | |||
public static function deleteCalendar($id) { | |||
$calendar = self::find($id); | |||
if ($calendar['userid'] != OCP\User::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the admin check means you'll get an error when admin deletes a user possibly causing other cleanup hooks to fail. Since OC_User::isAdminUser(OC_User::getUser())
is not in the public namespace, this is the only way to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that I used non-public OC_Group
here. Old code ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'll put this back.
Do you know what the public equivalent of OC_Group is? I can't find anything like it in core's lib/public
@ben-denham Generally the code looks good, but the direct manipulation of the share table is a no-go. Instead use something like this: Add a method in lib/hooks.php: public static function calendarDeletion($parameters) {
// Clean up sharing
\OCP\Share::unshareAll('calendar', $parameters['id']);
} And in appinfo/app.php add: OCP\Util::connectHook('OC_Calendar', 'deleteCalendar', 'OC_Calendar_Hooks', 'calendarDeletion'); |
Any updates on this? I really would like to see this on OC7 :) |
@ben-denham yeah, me too. :) Can you rebase this branch? |
@tanghus Ok, I have fixed the typos, and I have stopped using the oc_share table directly. However, when using the public share API, we cannot get a list of calendars that are shared with a particular group, which has caused me to make two key changes:
Also, as you say that OC_Group is private and should not be used, do you know the correct way to check if a user is an admin? It seems that OCP\User::checkAdminUser() would redirect the user to the home page if they were not an admin. |
@georgehrke can you take over from here? |
@@ -52,10 +45,19 @@ public static function allCalendars($uid, $active=false) { | |||
| OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE | |||
| OCP\PERMISSION_DELETE | OCP\PERMISSION_SHARE; | |||
$row['description'] = ''; | |||
$calendars[] = $row; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking at my owncloud files (version 0.6.3) and I don't see a lot of these lines of code anywhere in the files. Is there a reason why I see something different from what you have? Thanks
I am looking in our files and we don't have the same code for a lot of these calendar files. Our owncloud is 6.3, fresh install. Please advise... |
@rwasserstrom This is an unmerged branch. You will be seeing this feature when it is merged. |
Ok, so can we help implement this branch? We would like to help since we need this feature. |
@rwasserstrom You can fork https://github.com/ben-denham/calendar and work on |
These changes allow a user to hide/show and change the display name and colour of a calendar that is shared with them, without affecting how the calendar is displayed to other users.
It does this by storing calendar-user preferences for each calendar a user has access to (whether it is owned by them or shared with them or a group they belong to) in a new "clndr_calendar_user_preferences" database table.
Therefore, the "cldnr_calendars.active" column has been removed, because that setting is now stored per user in "clndr_calendar_user_preferences.active". However, the "cldnr_calendars.calendarcolor" and "cldnr_calendars.displayname" have been retained to serve as default preferences for the calendar.
When a user loses access to a calendar (e.g. it is unshared with them), their preferences are retained in the database. That way, if the user regains access to a calendar that used to be shared with them, their old preferences will still be applied to the calendar.
Because retaining these unused preferences could create a lot of obsolete rows in the database, a new button has also been added in the calendar settings for administrators to "Delete unused calendar preferences", which will delete any preferences where the user no longer has access to the calendar.
This fixes owncloud/calendar#21 and owncloud/calendar#131, and was mentioned in owncloud/calendar#265 (comment).