Added sorting back in and fixed rows being displayed oddly when there is an odd number of permissions

This commit is contained in:
jengo 2000-12-27 02:10:21 +00:00
parent 78ec4589dd
commit fa169cd79f
2 changed files with 42 additions and 14 deletions

View File

@ -19,6 +19,16 @@
include("../header.inc.php"); include("../header.inc.php");
include($phpgw_info["server"]["app_inc"]."/accounts_".$phpgw_info["server"]["account_repository"].".inc.php"); include($phpgw_info["server"]["app_inc"]."/accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
function is_odd($n)
{
$ln = substr($n,-1);
if ($ln == 1 || $ln == 3 || $ln == 5 || $ln == 7 || $ln == 9) {
return True;
} else {
return False;
}
}
if (! $account_id) { if (! $account_id) {
Header("Location: " . $phpgw->link("accounts.php")); Header("Location: " . $phpgw->link("accounts.php"));
} }
@ -193,8 +203,8 @@
$i = 0; $i = 0;
$sorted_apps = $phpgw_info["apps"]; $sorted_apps = $phpgw_info["apps"];
// @asort($sorted_apps); @asort($sorted_apps);
// @reset($sorted_apps); @reset($sorted_apps);
while ($permission = each($phpgw_info["apps"])) { while ($permission = each($phpgw_info["apps"])) {
if ($permission[1]["enabled"]) { if ($permission[1]["enabled"]) {
$perm_display[$i][0] = $permission[0]; $perm_display[$i][0] = $permission[0];
@ -214,6 +224,10 @@
$perm_html .= "></td>"; $perm_html .= "></td>";
$i++; $i++;
if ($i == count($perm_display) && is_odd(count($perm_display))) {
$perm_html .= '<td colspan="2">&nbsp;</td></tr>';
}
if (! $perm_display[$i][1]) break; if (! $perm_display[$i][1]) break;
$perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>' $perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="new_permissions[' . '<td><input type="checkbox" name="new_permissions['
@ -221,7 +235,7 @@
if ($new_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) { if ($new_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
$perm_html .= " checked"; $perm_html .= " checked";
} }
$perm_html .= "></td></tr>"; $perm_html .= "></td></tr>\n";
$i++; $i++;
} }

View File

@ -17,6 +17,16 @@
include("../header.inc.php"); include("../header.inc.php");
include($phpgw_info["server"]["app_inc"]."/accounts_".$phpgw_info["server"]["account_repository"].".inc.php"); include($phpgw_info["server"]["app_inc"]."/accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
function is_odd($n)
{
$ln = substr($n,-1);
if ($ln == 1 || $ln == 3 || $ln == 5 || $ln == 7 || $ln == 9) {
return True;
} else {
return False;
}
}
if ($submit) { if ($submit) {
$totalerrors = 0; $totalerrors = 0;
@ -140,17 +150,21 @@
$i++; $i++;
if (! $perm_display[$i][1]) break; if ($i == count($perm_display) && is_odd(count($perm_display))) {
$perms_html .= '<td colspan="2">&nbsp;</td></tr>';
$perms_html .= '<td>' . lang($perm_display[$i][1]) . '</td>' }
. '<td><input type="checkbox" name="new_permissions['
. $perm_display[$i][0] . ']" value="True"'; if (! $perm_display[$i][1]) break;
if ($new_permissions[$perm_display[$i][0]]) {
$perms_html .= " checked"; $perms_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
} . '<td><input type="checkbox" name="new_permissions['
$perms_html .= "></td></tr>"; . $perm_display[$i][0] . ']" value="True"';
if ($new_permissions[$perm_display[$i][0]]) {
$i++; $perms_html .= " checked";
}
$perms_html .= "></td></tr>";
$i++;
} }
$phpgw->template->set_var("permissions_list",$perms_html); $phpgw->template->set_var("permissions_list",$perms_html);