Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend

This commit is contained in:
Taras Machyshyn
2017-12-20 13:51:11 +02:00
2 changed files with 42 additions and 0 deletions

View File

@@ -117,6 +117,32 @@ class Config
return $lastBranch;
}
/**
* Whether parameter is set
*
* @param string $name
* @return bool
*/
public function has($name)
{
$keys = explode('.', $name);
$lastBranch = $this->loadConfig();
foreach ($keys as $keyName) {
if (isset($lastBranch[$keyName]) && (is_array($lastBranch) || is_object($lastBranch))) {
if (is_array($lastBranch)) {
$lastBranch = $lastBranch[$keyName];
} else {
$lastBranch = $lastBranch->$keyName;
}
} else {
return false;
}
}
return true;
}
/**
* Set an option to the config
*

View File

@@ -43,6 +43,7 @@ class App extends \Espo\Core\Services\Base
$this->addDependency('acl');
$this->addDependency('container');
$this->addDependency('entityManager');
$this->addDependency('metadata');
}
protected function getPreferences()
@@ -83,6 +84,21 @@ class App extends \Espo\Core\Services\Base
$settings->$item = $this->getConfig()->get($item);
}
if ($this->getUser()->isAdmin()) {
foreach ($this->getConfig()->get('adminItems') as $item) {
if ($this->getConfig()->has($item)) {
$settings->$item = $this->getConfig()->get($item);
}
}
}
$settingsFieldDefs = $this->getInjection('metadata')->get('entityDefs.Settings.fields', []);
foreach ($settingsFieldDefs as $field => $d) {
if ($d['type'] === 'password') {
unset($settings->$field);
}
}
unset($userData->authTokenId);
unset($userData->password);