<h1><?php echo __('Group %1%', array('%1%' => render_title($group))) ?></h1>

<?php echo get_component('aclGroup', 'tabs') ?>

<?php if (0 < count($acl)): ?>
  <table class="table table-bordered sticky-enabled">
    <thead>
      <tr>
        <th colspan="2">&nbsp;</th>
        <?php foreach ($roles as $roleId): ?>
          <th><?php echo QubitAclGroup::getById($roleId)->__toString() ?></th>
        <?php endforeach; ?>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($acl as $objectId => $actions): ?>
        <tr>
          <td colspan="<?php echo $tableCols - 1 ?>">
            <strong>
              <?php if (1 < $objectId): ?>
                <?php echo render_title(QubitActor::getById($objectId)) ?>
              <?php else: ?>
                <em><?php echo __('All %1%', array('%1%' => lcfirst(sfConfig::get('app_ui_label_actor')))) ?></em>
              <?php endif; ?>
            </strong>
          </td>
        </tr>
        <?php foreach ($actions as $action => $groupPermission): ?>
          <tr>
            <td>&nbsp;</td>
            <td>
              <?php if ('' != $action): ?>
                <?php echo QubitAcl::$ACTIONS[$action] ?>
              <?php else: ?>
                <em><?php echo __('All privileges') ?></em>
              <?php endif; ?>
            </td>
            <?php foreach ($roles as $roleId): ?>
              <td>
                <?php if (isset($groupPermission[$roleId]) && $permission = $groupPermission[$roleId]): ?>
                  <?php echo __($permission->renderAccess()) ?>
                <?php else: ?>
                  <?php echo '-' ?>
                <?php endif; ?>
              </td>
            <?php endforeach; ?>
          </tr>
        <?php endforeach; ?>
      <?php endforeach; ?>
    </tbody>
  </table>
<?php endif; ?>

<?php echo get_partial('showActions', array('group' => $group)) ?>
