Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user