PHP7 compatibility fixes.
[fa-stable.git] / admin / includes / fa_patch.class.inc
index 1275898d08b4f76a9b4bc1955969ff58ade3115a..d16664053fcd835987e4363e9f8b5b519b97906f 100644 (file)
@@ -26,7 +26,7 @@ class fa_patch {
        var $errors = array();
        var     $max_upgrade_time = 300;
 
-       function fa_patch()
+       function __construct()
        {
                global $path_to_root;
 
@@ -48,6 +48,38 @@ class fa_patch {
                return false;
        }
 
+       /*
+               Selectively extends access to selected security areas/sections.
+       */
+       function update_security_roles($sec_updates)
+       {
+               global $security_areas, $security_sections;
+
+               $roles = db_query("SELECT * FROM ".TB_PREF."security_roles");
+
+               while($role = db_fetch($roles))
+               {
+                       $role['areas'] = explode(';', $role['areas']);
+                       $role['sections'] = explode(';', $role['sections']);
+                       foreach($sec_updates as $has => $add)
+                       {
+                               if (in_array($security_areas[$has][0], $role['areas']))
+                               {
+                                       $sections = array();
+                                       foreach($add as $area)
+                                       {
+                                               $role['areas'][] = $security_areas[$area][0];
+                                               $role['sections'][] = $security_areas[$area][0]&~0xff;
+                                       }
+                                       sort($role['areas']);
+                                       update_security_role($role['id'], $role['role'], $role['description'], 
+                                               array_values($role['sections']), array_values($role['areas']));
+                               }
+                       }
+               }
+               return true;
+       }
+
        /*
                Check and disable incompatible extensions.
        */
@@ -163,7 +195,7 @@ class fa_patch {
                                if ($result)
                                        $this->log_error(_("Upgrade failed. Original database content restored successfully."), 'Info');
                                else
-                                       $thi->log_error(sprintf(_("Database restore operation failed. Original database content is in %s file."), $this->backup));
+                                       $this->log_error(sprintf(_("Database restore operation failed. Original database content is in %s file."), $this->backup));
                                $this->post_fail($this->cur_company);
                        }
                } else {