MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
-include($path_to_root."/includes/packages.inc");
+include_once($path_to_root."/includes/packages.inc");
//
// Utility class contains basic database upgrade routines.
//
var $errors = array();
var $max_upgrade_time = 300;
- function fa_patch()
+ function __construct()
{
global $path_to_root;
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.
*/
$this->errors = array();
$this->backup = null;
- $this->save_log = ini_set('error_log', dirname(__FILE__).'/../../tmp/upgrade.'.$this->cur_company.'.log');
+ $this->save_log = ini_set('error_log', VARLOG_PATH.'/upgrade.'.$this->cur_company.'.log');
$this->log_error(sprintf(_("Upgrade started for company %s."), $this->cur_company), 'Info');
if (!set_global_connection($this->cur_company))
{
foreach($result as $err)
$this->log_error($err[1] . ':'. $err[0]);
- } else
- {
+ } else {
$this->log_error($result);
unset($this->backup); // prevent restore (database was not touched due to other errors)
}
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 {
}
/*
- Present upgrade parameters to administrator
- This function presents upgrade choices, after selection company to be upgraded.
+ Present upgrade parameters to administrator.
+ This function is run after successfull switching to target database connection
+ and presents upgrade choices, later fetched in prepare() method.
*/
function show_params($comp)
{
/*
Fetch & check upgrade parameters, check additional upgrade pre-conditions.
- This function is run after successfull switching to target database connection.
+ This function is run after successfull switching to target database connection, before sql upgrade script is run.
*/
function prepare()
{