You are here

function tinybrowser_admin_theme in TinyBrowser 7

1 string reference to 'tinybrowser_admin_theme'
tinybrowser_theme in ./tinybrowser.module
Implements hook_theme

File

./tinybrowser.module, line 608

Code

function tinybrowser_admin_theme($variables) {
  $form = $variables['form'];

  /*
    $adminp = tinybrowser_admin_profile();
    $header = array(t('User role'));
    $rows = array(array(t('Site maintenance account')));
    $keys = array('name');
    // add 'id' attribute to make table draggable
    $attributes = array('style' => 'width:100%', 'id' => 'tinybrowser-table');

    // add each stream wrapper as a column
    $swrappers = file_get_stream_wrappers();
    foreach ($swrappers as $scheme => $info) {
      $header[] = $info['name'];
      $rows[0][] = $adminp['name'];
      $keys[] = $scheme . '_pid';
    }

    // in case we need profile weight
    $weight_info = '';
    if ($form['#weighted']) {
      $header[] = t('Weight');
      $rows[0][] = t('n/a');
      $keys[] = 'weight';
      $weight_info = t('For users who have <strong>multiple roles</strong>, the higher role with assigned profile in the list will take the precedence. Amin user role is always the top of the list and authenticated user role is the bottom of the list. The role that does not have any profile assigned can not use the TinyBrowser.');
    }
  */
  $rows = array();
  $header = array(
    t('User role'),
    t('Assigned profile'),
  );

  // add 'id' attribute to make table draggable
  $attributes = array(
    'style' => 'width:100%',
    'id' => 'tinybrowser-table',
  );
  $adminp = tinybrowser_admin_profile();
  $keys = array(
    'name',
    'pid',
  );
  $rows[0] = array(
    t('Admin'),
    $adminp['name'],
  );
  $info = '';
  if ($form['#weighted']) {
    $header[] = t('Weight');
    $keys[] = 'weight';
    $rows[0][] = t('n/a');
    $info = t('For users who have <strong>multiple roles</strong>, the higher role with assigned profile in the list will take the precedence. Amin user role is always the top of the list and authenticated user role is the bottom of the list. The role that does not have any profile assigned can not use the TinyBrowser.');
  }
  foreach (element_children($form['roles']) as $rid) {
    $cells = array();
    $draggable = 1;
    foreach ($keys as $key) {
      $cells[] = drupal_render($form['roles'][$rid][$key]);

      // exclude authenticated user role
      if ($key == 'weight' && $form['roles'][$rid][$key]['#value'] == 11) {
        $draggable = 0;
      }
    }
    $rows[] = $draggable ? array(
      'data' => $cells,
      'class' => array(
        'draggable',
      ),
    ) : $cells;
  }
  $output = '<h2 class="title">' . t('Role-profile assignments') . '</h2>';
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => $attributes,
  ));

  // make the table row draggable for weight
  drupal_add_tabledrag('tinybrowser-table', 'order', 'sibling', 'tinybrowser-weight');
  $output .= '<div class="form-item"><div class="description">' . t('Assign profiles to user roles.') . ' ' . $info . '</div></div>';
  $output .= drupal_render($form['common']);
  $output .= drupal_render_children($form);
  return $output;
}