3 * Bacula® - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2014 Marcin Haba
8 * The main author of Baculum is Marcin Haba.
9 * The main author of Bacula is Kern Sibbald, with contributions from many
10 * others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * Bacula® is a registered trademark of Kern Sibbald.
20 Prado::using('Application.Class.Miscellaneous');
22 class ConfigurationManager extends TModule
26 * Location o application configuration file.
28 const CONFIG_FILE = 'Application.Data.settings';
31 * PostgreSQL default params.
33 const PGSQL = 'pgsql';
34 const PGSQL_NAME = 'PostgreSQL';
35 const PGSQL_PORT = 5432;
38 * MySQL default params.
40 const MYSQL = 'mysql';
41 const MYSQL_NAME = 'MySQL';
42 const MYSQL_PORT = 3306;
45 * SQLite default params.
47 const SQLITE = 'sqlite';
48 const SQLITE_NAME = 'SQLite';
49 const SQLITE_PORT = null;
52 * Default language for application.
54 const DEFAULT_LANGUAGE = 'en';
56 public function getDbNameByType($type) {
58 case self::PGSQL: $dbName = self::PGSQL_NAME; break;
59 case self::MYSQL: $dbName = self::MYSQL_NAME; break;
60 case self::SQLITE: $dbName = self::SQLITE_NAME; break;
61 default: $dbName = null; break;
66 public function getPostgreSQLType() {
70 public function getMySQLType() {
74 public function getSQLiteType() {
78 public function isPostgreSQLType($type) {
79 return ($type === self::PGSQL);
82 public function isMySQLType($type) {
83 return ($type === self::MYSQL);
86 public function isSQLiteType($type) {
87 return ($type === self::SQLITE);
90 public function getLanguage() {
91 return $this->Application->Parameters['language'];
94 public function setLanguage($language) {
99 * Saving application configuration.
102 * @param array $config structure of config file params
103 * @return boolean true if config save is successfully, false if config save is failure
105 public function setApplicationConfig(array $config) {
106 $cfgFile = Prado::getPathOfNamespace(self::CONFIG_FILE, '.conf');
107 return ($this->Application->getModule('misc')->writeINIFile($cfgFile, $config) != false);
111 * Getting application configuration.
114 * @return array application configuration
116 public static function getApplicationConfig() {
117 $cfgFile = Prado::getPathOfNamespace(self::CONFIG_FILE, '.conf');
118 return Miscellaneous::parseINIFile($cfgFile);
122 * Checking if application configuration file exists.
125 * @return boolean true if file exists, otherwise false
127 public function isApplicationConfig() {
128 return file_exists(Prado::getPathOfNamespace(self::CONFIG_FILE, '.conf'));