I want users belonging to the "Editors" group to be able to edit, re-arrange, and delete pages that they've been assigned to based on "Additional Editors" setting on each page.
So, I granted the "Editors" group the following permissions:
- Add Pages
- Remove Pages
- Modify Page Structure
I didn't want to grant "Modify all Pages" because there are certain pages that only I want to be able to edit or delete.
The problem with the above rights is that by granting 'Modify Page Structure', all users were able to delete any page, even if they weren't assigned access through the "Additional Editors" setting on that particular page. Granted, the CMSMS was smart enough to not display the "Edit" icon on those pages, but the "Delete" icon was still there and functional.
I saw this as dangerous, but yet I didn't want to sacrifice the ability of my editors to reorder pages, so I went ahead and patched the code for my specific purpose. I'm sharing this with you, but note that it's hacky and not thoroughly tested, so back your stuff up first if you want to use it. This will allow you to grant 'Modify Page Structure' permissions while not always granting the ability to delete all pages (they'll only be able to delete pages that they can also edit).
---------------------------------------------------
Core changes for Security. This will allow users with 'Remove Pages' and 'Modify Page Structure' permissions to be able to delete pages that only they have 'Edit' rights to. The original functionality allowed users with 'Modify Page Structure' to delete all pages, even if they were not listed on that item's security.
File: /admin/listcontent.php
Change method "deleteContent" (line 338). Change the start of the function down to the following:
Code: Select all
function deletecontent($contentid)
{
$userid = get_userid();
global $gCms;
$hierManager =& $gCms->GetHierarchyManager();
$node = &$hierManager->getNodeById($contentid);
$access = ( check_permission($userid, 'Remove Pages') || check_permission($userid, 'Modify Page Structure')
) || ( check_modify_all($userid) || check_ownership($userid, $node->Id()) || check_authorship($userid, $node->Id()) );
if ($access)
{
if ($node)
...
Add the following to line 776 to display an empty table cell if no "edit" icon is displayed:
Code: Select all
else
{
$thelist .= '<td> </td>' . "\n";
}
Code: Select all
if ($root->getChildrenCount() == 0 && (check_permission($userid, 'Modify Page Structure') || check_permission($userid, 'Remove Pages')))
Code: Select all
if ($root->getChildrenCount() == 0 && ($display == 'edit' && check_permission($userid, 'Remove Pages')))
Code: Select all
// if (check_modify_all($userid) && check_permission($userid, 'Modify Page Structure'))
// {
$headoflist .= "<th class=\"move\">".lang('move')."</th>\n";
$headoflist .= "<th class=\"pagepos invisible\">".lang('order')."</th>\n";
// }
File: /admin/multicontent.php
Change the following from like 221 down:
Code: Select all
foreach ($nodelist as $node)
{
$contentid = $node->Id();
if( !(check_permission($userid, 'Modify Any Page') || check_ownership($userid, $contentid) || check_authorship($userid, $contentid)) )
{
redirect('listcontent.php?error=error_delete_no_access');
}
if ($node->DefaultContent())
...
File: /admin/lang/en_US/admin.inc.php
Add the following to line 41 (or really anywhere in the file):
Code: Select all
$lang['admin']['error_delete_no_access'] = 'You cannot delete a page unless you have a minimum of edit rights on that page.';