Recurrent Invoices: fixed buggy call to non existing function and payment terms type...
[fa-stable.git] / admin / security_roles.php
index 2727af4c3eabe5f97196b88baad0ce7196b502c3..7e68d3734854b6c45f647f021bfce8f9c1fec8cb 100644 (file)
@@ -85,33 +85,25 @@ 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);
                }
 //             $areas = sort_areas($areas);
 
-               $sections = array_values($sections);
+       write_security_role($_POST['role'], $_POST['name'], $_POST['description'], 
+               $sections, $areas, get_post('inactive'));
 
-       if ($new_role) 
-               {
-                       add_security_role($_POST['name'], $_POST['description'], $sections, $areas); 
-                       display_notification(_("New security role has been added."));
-               } else
-               {
-                       update_security_role($_POST['role'], $_POST['name'], $_POST['description'], 
-                               $sections, $areas); 
-                       update_record_status($_POST['role'], get_post('inactive'),
-                               'security_roles', 'id');
-
-                       display_notification(_("Security role has been updated."));
-               }
+       if ($new_role) 
+               display_notification(_("New security role has been added."));
+       else
+               display_notification(_("Security role has been updated."));
        $new_role = true;
        clear_data();
        $Ajax->activate('_page_body');
@@ -147,9 +139,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'];
@@ -197,7 +186,7 @@ start_table(TABLESTYLE2);
        record_status_list_row(_("Current status:"), 'inactive');
 end_table(1);
 
-       start_table(TABLESTYLE, "width=40%");
+       start_table(TABLESTYLE, "width='40%'");
 
        $k = $j = 0; //row colour counter
        $ext = $sec = $m = -1;
@@ -214,8 +203,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")),
@@ -254,4 +241,3 @@ div_end();
 end_form();
 end_page();
 
-?>