function autoassignrole_list_pages in Auto Assign Role 7
Same name and namespace in other branches
- 7.2 autoassignrole.admin.inc \autoassignrole_list_pages()
Function to display list of role-specific pages.
Return value
array Returns a build array.
1 string reference to 'autoassignrole_list_pages'
- autoassignrole_menu in ./
autoassignrole.module - Implements hook_menu().
File
- ./
autoassignrole.admin.inc, line 484 - Administrative functionality for auto assign role.
Code
function autoassignrole_list_pages() {
$header = array(
array(
'data' => 'Title',
'field' => 'title',
'sort' => 'asc',
),
array(
'data' => 'Roles',
'field' => 'rids',
),
array(
'data' => 'Path',
'field' => 'path',
),
array(
'data' => 'Operations',
),
);
$query = db_select('autoassignrole_page', 'p')
->extend('PagerDefault')
->limit(10)
->extend('TableSort')
->orderByHeader($header)
->fields('p', array(
'rid_page_id',
'rids',
'title',
'path',
));
$results = $query
->execute();
$user_roles = user_roles(TRUE);
$rows = array();
foreach ($results as $page) {
$rids = unserialize($page->rids);
$roles = '';
$count = 0;
foreach ($rids as $rid) {
if (!empty($rid) && array_key_exists($rid, $user_roles)) {
if ($count != 0) {
$roles .= ', ';
}
$roles .= $user_roles[$rid];
$count++;
}
}
$edit = l(t('Edit'), 'admin/config/people/autoassignrole/pages/edit/' . $page->rid_page_id);
$delete = l(t('Delete'), 'admin/config/people/autoassignrole/pages/delete/' . $page->rid_page_id);
$links = $edit . ' | ' . $delete;
$rows[] = array(
'data' => array(
$page->title,
$roles,
$page->path,
$links,
),
);
}
$html = theme('table', array(
'header' => $header,
'rows' => $rows,
'sticky' => TRUE,
'empty' => 'No Auto Assign pages created...',
));
$html .= theme('pager', array(
'tags' => array(),
));
return $html;
}