diff --git a/application/Espo/Controllers/Settings.php b/application/Espo/Controllers/Settings.php index 6be955a312..a856092709 100644 --- a/application/Espo/Controllers/Settings.php +++ b/application/Espo/Controllers/Settings.php @@ -37,7 +37,11 @@ class Settings extends \Espo\Core\Controllers\Base { protected function getConfigData() { - $data = $this->getConfig()->getData($this->getUser()->isAdmin()); + if ($this->getUser()->id == 'system') { + $data = $this->getConfig()->getData(); + } else { + $data = $this->getConfig()->getData($this->getUser()->isAdmin()); + } $fieldDefs = $this->getMetadata()->get('entityDefs.Settings.fields'); diff --git a/application/Espo/Core/Utils/Config.php b/application/Espo/Core/Utils/Config.php index 84f1d83e2c..026f7f2183 100644 --- a/application/Espo/Core/Utils/Config.php +++ b/application/Espo/Core/Utils/Config.php @@ -226,7 +226,7 @@ class Config * @param $isAdmin * @return array */ - public function getData($isAdmin = false) + public function getData($isAdmin = null) { $data = $this->loadConfig(); @@ -247,7 +247,7 @@ class Config * @param $isAdmin * @return bool */ - public function setData($data, $isAdmin = false) + public function setData($data, $isAdmin = null) { $restrictItems = $this->getRestrictItems($isAdmin); @@ -285,7 +285,7 @@ class Config * * @return object */ - protected function getRestrictItems($onlySystemItems = false) + protected function getRestrictItems($onlySystemItems = null) { $data = $this->loadConfig(); @@ -297,7 +297,11 @@ class Config $this->adminItems = array_merge($data['systemItems'], $data['adminItems']); } - return $this->adminItems; + if ($onlySystemItems === false) { + return $this->adminItems; + } + + return array_merge($this->adminItems, $data['userItems']); } diff --git a/application/Espo/Core/defaults/systemConfig.php b/application/Espo/Core/defaults/systemConfig.php index 58e1f1f3e3..eedcb85722 100644 --- a/application/Espo/Core/defaults/systemConfig.php +++ b/application/Espo/Core/defaults/systemConfig.php @@ -94,7 +94,8 @@ return array ( 'defaultPermissions' => 'restrictedMode', 'userLimit', 'portalUserLimit', - 'stylesheet' + 'stylesheet', + 'userItems' ), 'adminItems' => array ( @@ -137,7 +138,14 @@ return array ( 'defaultPermissions' => 'personalEmailMaxPortionSize', 'inboundEmailMaxPortionSize', 'authTokenLifetime', - 'authTokenMaxIdleTime' + 'authTokenMaxIdleTime', + 'ldapUserDefaultTeamId', + 'ldapUserDefaultTeamName', + 'ldapUserTeamsIds', + 'ldapUserTeamsNames' + ), + 'userItems' => + array ( ), 'isInstalled' => false, 'ldapUserNameAttribute' => 'sAMAccountName', diff --git a/tests/unit/Espo/Core/Utils/ConfigTest.php b/tests/unit/Espo/Core/Utils/ConfigTest.php index 13747122bc..6f118ae642 100644 --- a/tests/unit/Espo/Core/Utils/ConfigTest.php +++ b/tests/unit/Espo/Core/Utils/ConfigTest.php @@ -166,6 +166,51 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertArrayHasKey('adminItems', $configData); } + public function testUnauthorizedGetData() + { + $data = $this->object->getData(); + $this->assertArrayNotHasKey('quickCreateList', $data); + $this->assertArrayNotHasKey('tabList', $data); + $this->assertArrayNotHasKey('timeFormat', $data); + $this->assertArrayNotHasKey('smtpSecurity', $data); + $this->assertArrayNotHasKey('cron', $data); + $this->assertArrayNotHasKey('smtpServer', $data); + + $this->assertArrayNotHasKey('database', $data); + $this->assertArrayNotHasKey('isInstalled', $data); + } + + public function testUserGetData() + { + $data = $this->object->getData(false); + + $this->assertArrayHasKey('quickCreateList', $data); + $this->assertArrayHasKey('tabList', $data); + $this->assertArrayHasKey('timeFormat', $data); + + $this->assertArrayNotHasKey('smtpSecurity', $data); + $this->assertArrayNotHasKey('cron', $data); + $this->assertArrayNotHasKey('smtpServer', $data); + + $this->assertArrayNotHasKey('database', $data); + $this->assertArrayNotHasKey('isInstalled', $data); + } + + public function testAdminGetData() + { + $data = $this->object->getData(true); + + $this->assertArrayHasKey('quickCreateList', $data); + $this->assertArrayHasKey('tabList', $data); + $this->assertArrayHasKey('timeFormat', $data); + + $this->assertArrayHasKey('smtpSecurity', $data); + $this->assertArrayHasKey('cron', $data); + $this->assertArrayHasKey('smtpServer', $data); + + $this->assertArrayNotHasKey('database', $data); + $this->assertArrayNotHasKey('isInstalled', $data); + } } \ No newline at end of file diff --git a/tests/unit/testData/Utils/Config/systemConfig.php b/tests/unit/testData/Utils/Config/systemConfig.php index 1ac2c0c88c..106e1b16b8 100644 --- a/tests/unit/testData/Utils/Config/systemConfig.php +++ b/tests/unit/testData/Utils/Config/systemConfig.php @@ -58,6 +58,7 @@ return array ( 'isInstalled', 'defaultPermissions', 'systemUser', + 'userItems', ), 'adminItems' => array ( @@ -73,6 +74,19 @@ return array ( 'smtpPassword', 'cron', ), + 'userItems' => + array ( + 'currencyList', + 'addressFormat', + 'quickCreateList', + 'recordsPerPage', + 'recordsPerPageSmall', + 'tabList', + 'thousandSeparator', + 'timeFormat', + 'timeZone', + 'weekStart' + ), 'isInstalled' => false, );