In Collections under the Children tab is a resource listing, each entry with a series of buttons. I need to remove certain buttons (Unpublish, Delete, Change Parent) for the Member user-group while keeping all the buttons for the Admin group. Is such a thing possible? If so could someone walk me through the steps?
Also, if it matters the site is split into 3 different contexts but I only need to target one of them with the button modifications.
I disabled those settings previously but they don’t seem to have any effect on the Collections buttons. Though they do work on the main Manager menu as expected.
I tested it. I created a new Access Policy without the permissions unpublish_document and delete_document. I created a new User Group with this Access Policy in the “mgr” context. Now when I login as a user that is a member of this new group, I don’t see the buttons “Unpublish” and “Delete” anymore.
When the child resources are loaded in the Collections grid, the permissions are checked here in the processor
These permissions are then used to determine if a button gets added here
@halftrainedharry thanks for taking the time to do this, it has been very helpful. @bobray thanks for the reminder, I always seem to forget to do it.
I started over and was able to make some progress, the Delete and Unpublish buttons have been removed. As for the remaining Duplicate and Change Parent buttons the resource_duplicate option is disabled yet the Duplicate button persists and I don’t see another setting that would control it. And with no default permission for Change Parent I have no idea how to proceed.
Although there exists a permission resource_duplicate in MODX, there is no check for this permission in the Collections code.
Both options (“Duplicate” and “Change Parent”) are always added without checking any permissions:
Maybe in the column, instead of using the renderer Collections.renderer.pagetitleWithButtons, you could create a custom renderer to only show the buttons the user is allowed to see.
Otherwise, you’d have to change the code of the GetList processor (and create a pull request on Github for it, so that the change won’t be overwritten on the next update of the extra).
Set the system setting “collections.user_js” to {assets_url}my_collections_renderer.js
Create the file assets/my_collections_renderer.js with code like this:
var myPagetitleWithButtons = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
// Filter out some of the action buttons
data.actions = data.actions.filter(action => {
if (action.className == 'changeparent' && !MODx.perm.show_collections_changeparent) {
return false;
}
if (action.className == 'duplicate' && !MODx.perm.resource_duplicate) {
return false;
}
return true;
});
data.self = this;
return pagetitleWithButtons.apply(data);
}
It basically uses the same code as “collections.renderer.pagetitleWithButtons”, but filters out some of the action buttons based on the permissions (in MODx.perm).
Under “Extras” → “Collection views” change the renderer of the pagetitle column from “Collections.renderer.pagetitleWithButtons” to myPagetitleWithButtons.
Under → “Access Control Lists” → tab “Policy Templates” → “AdministratorTemplate”, create a new permission show_collections_changeparent.
In the tab “Access Policies”, check the new policy show_collections_changeparent for all the policies that should have this permission.