Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#1966 closed enhancement (fixed)

The user that delete an item should see the item in the trashcan

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: BASE 3.7
Component: core Version:
Keywords: Cc:

Description

The current trashcan functionality can only display items that the currently logged in user is the owner of.

If a user that is not the owner delete an item it will not show up in that user's trashcan. This is a bit annoying in a large project where different items are owned by different users but once in a while an administrator need to clean up something. The administrator typically has DELETE permission but then has to ask other users (or use the impersonate functionality) to empty the trashcans.

A workaround is to enable the 'removed' option in the 'view/presets' list and use the trashcan icon for each item. This may be okay for a few items, but not when deleting lots of items at the same time.

It would be nice if the user that deleted an item actually could see that item in the own trashcan.

A possible solution to this issue is to replace the boolean isRemoved property of items with a nullable integer removedBy property. Null values are the same as 'not removed' and non-null values is the id of the user that removed the item. When listing items in the trashcan we could simply include items which has owner=<id-of-current-user> OR removedBy=<id-of-current-user>.

For existing items with the removed flag set we simply set removedBy=owner.

Change History (6)

comment:1 Changed 6 years ago by Nicklas Nordborg

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:2 Changed 6 years ago by Nicklas Nordborg

(In [7015]) References #1966: The user that delete an item should see the item in the trashcan

Replaced RemovableData.isRemoved() with RemovableData.getRemovedBy(). Existing classes has been updated to implement the new methods.

The schema update will fix existing items that has been flagged for removal by setting the removedBy property to the owner or to the root user and then removed the removed column from all tables.

Existing code that query the database has been updated to use removedBy instead of removed.

The trashcan still has the old functionality since we only check for NULL/NOT NULL.

comment:3 Changed 6 years ago by Nicklas Nordborg

(In [7016]) References #1966: The user that delete an item should see the item in the trashcan

Added getRemovedBy() method to the Removable interface and all implementing classes. Added two columns in the trashcan which display the owner and the user that removed the item.

comment:4 Changed 6 years ago by Nicklas Nordborg

(In [7017]) References #1966: The user that delete an item should see the item in the trashcan

Defined filter ownedOrRemovedBy that is used by the traschcan instead of the ownedBy filter. This filter should return items that are either owner or removed by the current user.

Items that are ChildItem:s or not Ownable still require special handling. For child items we check the owner of the parent item. For items that are not ownable we only check if the user has delete permission or not (as before).

comment:5 Changed 6 years ago by Nicklas Nordborg

Resolution: fixed
Status: assignedclosed

Seems like this is working now.

comment:6 Changed 6 years ago by Nicklas Nordborg

(In [7035]) References #1966: The user that delete an item should see the item in the trashcan

The database schema update need to happen in a different order. The installation will for example create new item subtypes and plug-ins for Kits. This will fail if the 'removed' column exists in the tables since it is defined as 'not null' and the new mapping doesn't include this column. The update that transfers the owner/root to the 'removed_by' column and then drops the 'removed' column must be done in the adjustExistingItems() method so that the database is good to go for inserting new items after that.

Note: See TracTickets for help on using tickets.