X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fsecurity_roles.php;h=4b438091f237794d6cfce657ea247aed74b7f2a1;hb=26d7ae434469ae407f209ae3c0d3955b29107d95;hp=ef7e23ed0580217207c492221099be86ea8eee1f;hpb=e933b7e5bcdf8cddd62778abfb373564388c2485;p=fa-stable.git diff --git a/admin/security_roles.php b/admin/security_roles.php index ef7e23ed..4b438091 100644 --- a/admin/security_roles.php +++ b/admin/security_roles.php @@ -15,7 +15,7 @@ include_once($path_to_root . "/includes/session.inc"); add_access_extensions(); -page(_("Access setup")); +page(_($help_context = "Access setup")); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/access_levels.inc"); @@ -26,13 +26,23 @@ $new_role = get_post('role')=='' || get_post('cancel') || get_post('clone'); // Following compare function is used for sorting areas // in such a way that security areas defined by module/plugin // is properly placed under related section regardless of -// unique extension number +// unique extension number, with order inside sections preserved. // function comp_areas($area1, $area2) { - return ($area1[0]&0xffff)-($area2[0]&0xffff); + $sec_comp = ($area1[0]&0xff00)-($area2[0]&0xff00); + return $sec_comp == 0 ? ($area1[2]-$area2[2]) : $sec_comp; } +function sort_areas($areas) +{ + $old_order = 0; + foreach($areas as $key => $area) { + $areas[$key][] = $old_order++; + } + uasort($areas,'comp_areas'); + return $areas; +} //-------------------------------------------------------------------------------------------------- if (list_updated('role')) { $Ajax->activate('details'); @@ -75,20 +85,20 @@ if (get_post('addupdate')) $sections = array(); $areas = array(); foreach($_POST as $p =>$val) { - if (substr($p,0,4) == 'Area') { + if (substr($p,0,4) == 'Area' && $val == 1) { $a = substr($p, 4); if (($a&~0xffff) && (($a&0xff00)<(99<<8))) { $sections[] = $a&~0xff; // add extended section for plugins } - $areas[] = $a; + $areas[] = (int)$a; } - if (substr($p,0,7) == 'Section') - $sections[] = substr($p, 7); + if (substr($p,0,7) == 'Section' && $val == 1) + $sections[] = (int)substr($p, 7); } - uasort($areas, 'comp_areas'); +// $areas = sort_areas($areas); $sections = array_values($sections); - _vd($sections); + if ($new_role) { add_security_role($_POST['name'], $_POST['description'], $sections, $areas); @@ -137,9 +147,6 @@ if (!isset($_POST['role']) || get_post('clone') || list_updated('role')) { $row = get_security_role($id); $_POST['description'] = $row['description']; $_POST['name'] = $row['role']; -// if ($row['inactive'] -// $_POST['inactive'] = 1; - $_POST['inactive'] = $row['inactive']; $access = $row['areas']; $sections = $row['sections']; @@ -163,7 +170,7 @@ if (!isset($_POST['role']) || get_post('clone') || list_updated('role')) { start_form(); -start_table("class='tablestyle_noborder'"); +start_table(TABLESTYLE_NOBORDER); start_row(); security_roles_list_cells(_("Role:"). " ", 'role', null, true, true, check_value('show_inactive')); $new_role = get_post('role')==''; @@ -181,18 +188,18 @@ if (find_submit('_Section')) { } //----------------------------------------------------------------------------------------------- div_start('details'); -start_table($table_style2); +start_table(TABLESTYLE2); text_row(_("Role name:"), 'name', null, 20, 22); text_row(_("Role description:"), 'description', null, 50, 52); record_status_list_row(_("Current status:"), 'inactive'); end_table(1); - start_table("$table_style width=40%"); + start_table(TABLESTYLE, "width='40%'"); $k = $j = 0; //row colour counter $ext = $sec = $m = -1; - uasort($security_areas,'comp_areas'); - foreach($security_areas as $area =>$parms ) { + + foreach(sort_areas($security_areas) as $area =>$parms ) { // system setup areas are accessable only for site admins i.e. // admins of first registered company if (user_company() && (($parms[0]&0xff00) == SS_SADMIN)) continue; @@ -204,8 +211,6 @@ end_table(1); $ext = $newext; $sec = $newsec; $m = $parms[0] & ~0xff; -// if(!isset($security_sections[$m])) -// display_error(sprintf("Bad section %X:", $m)); label_row($security_sections[$m].':', checkbox( null, 'Section'.$m, null, true, _("On/off set of features")), @@ -244,4 +249,3 @@ div_end(); end_form(); end_page(); -?>