X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fprefs%2Fsysprefs.inc;h=cce4769c563fcf3cfc80a58a65090ffe24e8af69;hb=3c1ca6e8e69a5c362ba2423c477c7e8351475563;hp=bf68576823f16072319ffbdb224f34a1d16a7cf4;hpb=5e63c6ace55729bbb5ee3b060035a25a4426eb0a;p=fa-stable.git diff --git a/includes/prefs/sysprefs.inc b/includes/prefs/sysprefs.inc index bf685768..cce4769c 100644 --- a/includes/prefs/sysprefs.inc +++ b/includes/prefs/sysprefs.inc @@ -11,6 +11,11 @@ ***********************************************************************/ include_once($path_to_root . "/admin/db/company_db.inc"); +/* + System and per company prefferences. + Object is created only with site wide preffernces. + After user login refresh method have to be called to re-initialize company specific settings. +*/ class sys_prefs { var $prefs; @@ -20,10 +25,11 @@ class sys_prefs { global $path_to_root; + // retrieve set system wide preferences include $path_to_root.'/config.default.php'; - include $path_to_root.'/config.php'; + if (file_exists($path_to_root.'/config.php')) + include $path_to_root.'/config.php'; - // set system wide preferences foreach(get_defined_vars() as $name => $value) $this->$name = $value; @@ -32,10 +38,34 @@ class sys_prefs if (!$this->time_zone) $this->time_zone = 'Europe/Berlin'; + + if (!isset($this->use_popup_search)) + $this->use_popup_search = false; ini_set('date.timezone', $this->time_zone); } + /* + Re-initialize company preferrencies. + */ + function refresh() + { + global $db_version; + + $sql = "SELECT name, value FROM ".TB_PREF."sys_prefs"; + $result = @db_query($sql); // supress errors before 2.3 db structure upgrade + + if(!$result) + return null; + + while($pref = db_fetch_assoc($result)) { + $this->prefs[$pref['name']] = $pref['value']; + } + + // update current db status for info in log file + $this->db_ok = $this->prefs['version_id'] == $db_version; + } + function allow_negative_stock() { return $this->prefs['allow_negative_stock']; @@ -144,5 +174,16 @@ class sys_prefs { return $this->prefs['suppress_tax_rates']; } + + function backup_dir($comp=null) + { + if (!isset($comp)) + $comp = user_company(); + + if (isset($this->backup_path)) + return sprintf($this->backup_path, $comp); + else + return $this->comp_path.'/'.$comp."/backup/"; + } }