Within Drupal 7 I am trying to modify the page myserver.com/admin/people/permissions/roles so that a custom role which I have added cannot be edited. In other words, I'd like it to be locked like the anonymous and administrator roles.
I have found one possible solution at http://drupal.org/node/397480 but I think it is a Drupal 6 fix.
I've tried modifying the render array for the content directly, but also can't figure that out quite right.
Here is the closest I've been able to get it. Any suggestions or solutions will be much appreciated.
function access_group_preprocess_page(&$variables) {
//check to see if the current page matches the path specified
$match_path = explode('/', 'admin/people/permissions/roles');
$match = TRUE;
for ($i = 0; $i < count($match_path); $i++) {
if ($match_path[$i] != arg($i)) {
$match = FALSE;
break;
}
}
//if there is a match, modify the page
if($match){
//define the locked roles
$locked_roles = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID,);
$access_group_role = user_role_load_by_name(ACCESS_GROUP_ROLE);
if ($access_group_role) $locked_roles[] = $access_group_role->rid;
kpr($locked_roles);
kpr($variables);
//recreate the render array for the table
$header = array(
t('Name'),
array(
'data' => t('Operations'),
'colspan' => 2
)
);
foreach (user_roles() as $rid => $name) {
$edit_permissions = l(t('edit permissions'), 'admin/user/permissions/'. $rid);
if (!in_array($rid, $locked_roles)) {
$rows[] = array($name, l(t('edit role'), 'admin/user/roles/edit/'. $rid), $edit_permissions);
}else{
$rows[] = array($name . " <em>(locked)</em>", '', $edit_permissions);
}
}
//$form = user_admin_role(array(), array(), );
//$rows[] = array(drupal_render($form['name']), array('data' => drupal_render($form['submit']), 'colspan' => 2));
$form = $variables['page']['content']['system_main'];
$rows[] = array(
array(
'data' => drupal_render($form['name']) . drupal_render($form['add]']),
'colspan' => 3,
),
);
$output = drupal_render_children($form);
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
$variables['page']['content'] = $output;
}
}