commit 1a8a8eb523a7de1a5f7ef680bd0e3153f06fec33
Author: Daniel Neis Araujo <daniel@npd.ufsc.br>
Date:   Mon Dec 21 13:47:40 2009 -0200

    Partindo o array ao invés de utilizar um contador para repetir o header.

diff --git a/index.php b/index.php
index 256e1ca..47cb2c4 100644
--- a/index.php
+++ b/index.php
@@ -71,27 +71,25 @@ if (empty($roles_ids)) {
     }
     $th .= '<th class="action">'.get_string('capability','role').'</th></tr>';
 
-    echo $th;
-
-    $i = 1;
-    $capabilities = get_moodle_capabilities($roles);
-    foreach ($capabilities as $capability) {
-        if ($i % $repeat_each == 0) {
-            echo $th;
+    $capabilities = array_chunk(get_moodle_capabilities($roles), $repeat_each);
+    foreach ($capabilities as $chunk) {
+
+        echo $th;
+
+        foreach ($chunk as $capability) {
+
+            $cap_string = get_cap_string($capability);
+            echo '<tr>', $cap_string;
+            foreach ($roles as $role) {
+                if (isset($capability[$role->shortname])) {
+                    echo '<td class="role cap_', $capability[$role->shortname] , '">';
+                } else {
+                    echo '<td class="role cap_not_set">';
+                }
+                echo '</td>';
+            }   
+            echo $cap_string, '</tr>';
         }
-
-        $cap_string = get_cap_string($capability);
-        echo '<tr>', $cap_string;
-        foreach ($roles as $role) {
-            if (isset($capability[$role->shortname])) {
-                echo '<td class="role cap_', $capability[$role->shortname] , '">';
-            } else {
-                echo '<td class="role cap_not_set">';
-            }
-            echo '</td>';
-        }   
-        echo $cap_string, '</tr>';
-        $i++;
     }
     echo '</table>';
 }
