diff --git a/includes/theme.inc b/includes/theme.inc
index 83c528d..82e67c7 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1607,6 +1607,29 @@ function theme_submenu($variables) {
* )
* );
* @endverbatim
+ * - groups: An array of row groups. Each group will be enclosed in a
+ * tag. Use this instead of of the 'rows' attribute if you need multiple
+ * table bodies. This can either be an array of row arrays or an array of
+ * complex row arrays. The data key of a row group is used for the actual
+ * row data and all other keys will become attributes of the tag.
+ * @verbatim
+ * $groups = array(
+ * // Simple row group
+ * array(
+ * array('Cell 1', 'Cell 2', 'Cell 3'),
+ * array('Cell 4', 'Cell 5', 'Cell 6'),
+ * ),
+ * // Row with attributes on the row and some of its cells.
+ * array(
+ * 'data' => array(
+ * array('Cell 1', 'Cell 2', 'Cell 3'),
+ * array('Cell 4', 'Cell 5', 'Cell 6'),
+ * ),
+ * 'class' => 'instasearch-group',
+ * 'title' => t('Cell group'),
+ * )
+ * );
+ * @endverbatim
* - attributes: An array of HTML attributes to apply to the table tag.
* - caption: A localized string to use for the tag.
* - colgroups: An array of column groups. Each element of the array can be
@@ -1647,10 +1670,10 @@ function theme_submenu($variables) {
*/
function theme_table($variables) {
$header = $variables['header'];
- $rows = $variables['rows'];
$attributes = $variables['attributes'];
$caption = $variables['caption'];
$colgroups = $variables['colgroups'];
+ $rowgroups = $variables['groups'];
$sticky = $variables['sticky'];
// Add sticky headers, if applicable.
@@ -1661,6 +1684,10 @@ function theme_table($variables) {
$attributes['class'][] = 'sticky-enabled';
}
+ if (empty($rowgroups) && isset($variables['rows'])) {
+ $rowgroups = array($variables['rows']);
+ }
+
$output = '\n";
if (isset($caption)) {
@@ -1707,59 +1734,72 @@ function theme_table($variables) {
$ts = tablesort_init($header);
// HTML requires that the thead tag has tr tags in it followed by tbody
// tags. Using ternary operator to check and see if we have any rows.
- $output .= (count($rows) ? ' ' : '
');
+ $output .= (count($rowgroups) ? ' ' : '
');
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
// Using ternary operator to close the tags based on whether or not there are rows
- $output .= (count($rows) ? "
\n" : "
\n");
+ $output .= (count($rowgroups) ? " \n" : "\n");
}
else {
$ts = array();
}
// Format the table rows:
- if (count($rows)) {
- $output .= "\n";
- $flip = array('even' => 'odd', 'odd' => 'even');
- $class = 'even';
- foreach ($rows as $number => $row) {
- $attributes = array();
+ foreach ($rowgroups as $group_number => $group) {
+ // Check if we're dealing with a simple or complex group
+ if (isset($group['data'])) {
+ $attributes = $group;
+ unset($attributes['data']);
+ $output .= theme_table_tbody($group['data'], $header, $ts, $attributes);
+ }
+ else {
+ $output .= theme_table_tbody($group, $header, $ts);
+ }
+ }
- // Check if we're dealing with a simple or complex row
- if (isset($row['data'])) {
- foreach ($row as $key => $value) {
- if ($key == 'data') {
- $cells = $value;
- }
- else {
- $attributes[$key] = $value;
- }
- }
- }
- else {
- $cells = $row;
- }
- if (count($cells)) {
- // Add odd/even class
- $class = $flip[$class];
- $attributes['class'][] = $class;
+ $output .= "
\n";
+ return $output;
+}
- // Build row
- $output .= ' ';
- $i = 0;
- foreach ($cells as $cell) {
- $cell = tablesort_cell($cell, $header, $ts, $i++);
- $output .= _theme_table_cell($cell);
+function theme_table_tbody($rows, $header, $ts, $attributes = array()) {
+ $output = '
\n";
+ $flip = array('even' => 'odd', 'odd' => 'even');
+ $class = 'even';
+ foreach ($rows as $number => $row) {
+ $attributes = array();
+
+ // Check if we're dealing with a simple or complex row
+ if (isset($row['data'])) {
+ foreach ($row as $key => $value) {
+ if ($key == 'data') {
+ $cells = $value;
+ }
+ else {
+ $attributes[$key] = $value;
}
- $output .= " \n";
}
}
- $output .= "\n";
+ else {
+ $cells = $row;
+ }
+ if (count($cells)) {
+ // Add odd/even class
+ $class = $flip[$class];
+ $attributes['class'][] = $class;
+
+ // Build row
+ $output .= ' ';
+ $i = 0;
+ foreach ($cells as $cell) {
+ $cell = tablesort_cell($cell, $header, $ts, $i++);
+ $output .= _theme_table_cell($cell);
+ }
+ $output .= "
\n";
+ }
}
-
- $output .= "\n";
+ $output .= "\n";
return $output;
}
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index 958e02f..10b61ea 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -634,7 +634,6 @@ function user_admin_settings() {
* @see theme_user_admin_permissions()
*/
function user_admin_permissions($form, $form_state, $rid = NULL) {
-
// Retrieve role names for columns.
$role_names = user_roles();
if (is_numeric($rid)) {
@@ -654,13 +653,13 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
$hide_descriptions = !system_admin_compact_mode();
foreach (module_implements('permission') as $module) {
if ($permissions = module_invoke($module, 'permission')) {
- $form['permission'][] = array(
- '#markup' => $module_info[$module]['name'],
+ $form['permission'][$module] = array(
+ '#title' => $module_info[$module]['name'],
'#id' => $module,
);
foreach ($permissions as $perm => $perm_item) {
$options[$perm] = '';
- $form['permission'][$perm] = array(
+ $form['permission'][$module][$perm] = array(
'#type' => 'item',
'#markup' => $perm_item['title'],
'#description' => $hide_descriptions && isset($perm_item['description']) ? $perm_item['description'] : NULL,
@@ -684,6 +683,23 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
$form['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.permissions.js';
+ $form['#attributes']['class'] = 'instasearch-container instasearch-group';
+ $form['instasearch'] = array(
+ '#type' => 'textfield',
+ '#weight' => -5,
+ '#input' => FALSE,
+ '#title' => t('Filter permissions'),
+ '#name' => 'instasearch',
+ '#size' => 30,
+ '#value' => '',
+ '#description' => t('Enter part of a permission name.'),
+ '#attributes' => array('class' => array('instasearch-textfield')),
+ '#attached' => array(
+ 'js' => array('misc/instasearch.js'),
+ 'css' => array('misc/instasearch.css'),
+ ),
+ );
+
return $form;
}
@@ -712,30 +728,52 @@ function theme_user_admin_permissions($variables) {
$form = $variables['form'];
$roles = user_roles();
- foreach (element_children($form['permission']) as $key) {
- $row = array();
- // Module name
- if (is_numeric($key)) {
- $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => array('module'), 'id' => 'module-' . $form['permission'][$key]['#id'], 'colspan' => count($form['role_names']['#value']) + 1);
- }
- else {
- // Permission row.
+ $groups = array();
+ foreach (element_children($form['permission']) as $module) {
+ $group = array();
+
+ $group[] = array(
+ // Module name
+ array(
+ 'data' => $form['permission'][$module]['#title'],
+ 'class' => array('module'),
+ 'id' => 'module-' . $form['permission'][$module]['#id'],
+ 'colspan' => count($form['role_names']['#value']) + 1
+ )
+ );
+
+ // Permission rows.
+ foreach (element_children($form['permission'][$module]) as $key) {
+ $row = array();
$row[] = array(
- 'data' => drupal_render($form['permission'][$key]),
+ 'data' => drupal_render($form['permission'][$module][$key]),
'class' => array('permission'),
);
foreach (element_children($form['checkboxes']) as $rid) {
- $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => array('checkbox'), 'title' => $roles[$rid] . ' : ' . t($key));
+ $row[] = array(
+ 'data' => drupal_render($form['checkboxes'][$rid][$key]),
+ 'class' => array('checkbox'),
+ 'title' => $roles[$rid] . ' : ' . t($key)
+ );
}
+ $group[] = array(
+ 'data' => $row,
+ 'class' => array('instasearch-item')
+ );
}
- $rows[] = $row;
+ $groups[] = array(
+ 'data' => $group,
+ 'class' => array('instasearch-group')
+ );
}
+
$header[] = (t('Permission'));
foreach (element_children($form['role_names']) as $rid) {
$header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox'));
}
$output = theme('system_compact_link');
- $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
+ $output .= drupal_render($form['instasearch']);
+ $output .= theme('table', array('header' => $header, 'groups' => $groups, 'attributes' => array('id' => 'permissions')));
$output .= drupal_render_children($form);
return $output;
}