protected function GroupRoleUIController::roleTableRow in Group 7
Generates the row for the passed role.
1 call to GroupRoleUIController::roleTableRow()
- GroupRoleUIController::roleTable in classes/
group_role.ui_controller.inc - Generate an overview table for group roles matching the given conditions.
File
- classes/
group_role.ui_controller.inc, line 278 - Defines the Entity API UI class for group roles.
Class
- GroupRoleUIController
- UI class for group roles.
Code
protected function roleTableRow($name, GroupRole $group_role) {
// Check if the group role is ENTITY_FIXED.
$role_fixed = entity_has_status('group_role', $group_role, ENTITY_FIXED);
// Create the row container array.
$row = array(
'data' => array(),
'class' => array(
'draggable',
),
);
if ($this->tabledrag) {
// Cell for the cross drag&drop element.
$row['data']['drag'] = array(
'class' => array(
'entry-cross',
),
);
// Weight item for the tabledrag.
$row['data']['weight'] = array(
'data' => array(
'#type' => 'weight',
'#title' => t('Weight'),
'#title_display' => 'invisible',
'#default_value' => $group_role->weight,
'#parents' => array(
'weights',
$name,
),
'#attributes' => array(
'class' => array(
'group-role-weight',
),
),
'#disabled' => $role_fixed,
),
);
}
// Add the role label.
$row['data']['label'] = $group_role
->label();
// Permissions related links.
$what = $role_fixed || $this->type_fixed ? t('view permissions') : t('edit permissions');
$row['data']['permissions'] = l($what, "{$this->path}/manage/{$name}/permissions");
// Add the actions columns.
if ($ops = $this
->roleOperations()) {
// Add the status column if available.
if (in_array('status', $ops)) {
$row['data']['status'] = array(
'data' => array(
'#theme' => 'entity_status',
'#status' => $group_role->status,
),
);
}
// Add the edit action if available.
if (in_array('edit', $ops)) {
$row['data']['edit'] = $role_fixed ? '' : l(t('edit'), "{$this->path}/manage/{$name}");
}
// Add the translate action if available.
if (in_array('translate', $ops)) {
$row['data']['translate'] = l(t('translate'), "{$this->path}/manage/{$name}/translate");
}
// Add the clone action if available.
if (in_array('clone', $ops)) {
$row['data']['clone'] = l(t('clone'), "{$this->path}/manage/{$name}/clone");
}
// Add the delete/revert action if available.
if (in_array('delete', $ops)) {
$overridden = entity_has_status('group_role', $group_role, ENTITY_OVERRIDDEN);
// Don't show action for fixed or default roles.
if ($role_fixed || $group_role->status == ENTITY_IN_CODE) {
$row['data']['delete'] = '';
}
else {
// Show revert action for overridden roles.
if ($overridden) {
$what = t('revert');
$path = "{$this->path}/manage/{$name}/revert";
}
else {
$what = t('delete');
$path = "{$this->path}/manage/{$name}/delete";
}
$row['data']['delete'] = l($what, $path, array(
'query' => drupal_get_destination(),
));
}
}
// Add the export action if available.
if (in_array('export', $ops)) {
$row['data']['export'] = l(t('export'), "{$this->path}/manage/{$name}/export");
}
}
return $row;
}