Is there anyway to NOT ALLOW a user from changing their preferences ?
Collapse
X
-
Hey shalmaxb
Yes that was my first solution which was to remove the preference from the menu on the top right. and below what i have done to achieve it (Remember this will only hide it from the UI) however if a user know the url for preference they would still be able to access. Also this was done on previous version not sure it is impacted with the new version, anyway try it out and see how it goes.
1 - Create App.json under custom\Espo\Custom\Resources\metadata\clientDefs
PHP Code:{
"navbarView" : "custom:views/site/navbar"
}
2 - Create the new custom view navbar.js under client\custom\src\views\site
PHP Code:define('custom:views/site/navbar', ['views/site/navbar'], function (Dep) {
return Dep.extend({
getMenuDataList: function () {
var list = Dep.prototype.getMenuDataList.call(this);
if (!this.getUser().isAdmin()) {
list = list.filter(item => item.link !== '#Preferences');
}
return list;
},
});
});
I hope this helps
-
rabii, hello,
I currently have that same problem. Your solution in the following thread already helped, thank you.
In this comment, you mention, that you customized the navbar to get rid of the preferences link. How did you do that. I tried a solution from another thread, which did not work.
Perhaps you still have that code on hand, I thank you in advance. -
Maybe define a custom API route for PUT Preferences/:id that will throw Forbidden exception if logged not by admin. Otherwise, call service->update.Leave a comment:
-
Hey all,
Thanks for your help and support, my use case was to hide notifications from the preference view to not allow regular user to disable them, after tinkering around i found a way around which does exactly what i want, below is what i did :
1 - created a custom Preferences.json under custom directory (clientDefs) and defined a new custom edit view as below:
PHP Code:{
"recordViews":{
"edit": "custom:views/preferences/record/edit"
}
}
2 - Create the custom view under client\custom\src\views\preferences\record\edit.js
PHP Code:define('custom:views/preferences/record/edit', ['views/preferences/record/edit'], function (Dep) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
if (!this.getUser().isAdmin()) {
this.layoutName = 'detailRegular';
}
},
});
});
3 - As you can see in the code above i have simple condition to check if current user is not admin (means regular) then apply a detailRegular layout which i created as below:
PHP Code:[
{
"rows": [
[{"name": "dateFormat"}, {"name": "timeFormat"}],
[{"name": "defaultCurrency"}, {"name": "thousandSeparator"}],
[false, {"name": "decimalMark"}]
],
"tabBreak": true,
"tabLabel": "$label:Locale"
},
{
"rows": [
[{"name": "exportDelimiter"}, {"name":"autoFollowEntityTypeList"}],
[
{
"name": "signature"
},
{
"name": "defaultReminders"
}
],
[
{
"name": "emailReplyToAllByDefault"
},
{
"name": "doNotFillAssignedUserIfNotRequired"
}
],
[
{
"name": "emailReplyForceHtml"
},
{
"name": "followEntityOnStreamPost"
}
],
[
{
"name": "emailUseExternalClient"
},
{
"name": "followCreatedEntities"
}
],
[
{
"name": "textSearchStoringDisabled"
},
{
"name": "followCreatedEntityTypeList"
}
]
],
"tabBreak": true,
"tabLabel": "$label:Misc"
},
{
"rows": [
[
{"name":"theme"},
false
],
[
{"name":"useCustomTabList"},
{"name":"tabList"}
],
[
{"name":"dashboardLayout", "fullWidth": true}
]
],
"tabBreak": true,
"tabLabel": "$label:User Interface"
}
]
That is it and it worked as i wanted, the good thing about this approach is its simplicity and also i get to design a whole layout which i can control what the regular user should see and not see.
Hope this help someone when needed.
Thanks again
Last edited by rabii; 07-06-2023, 08:00 AM.Leave a comment:
-
Hi Rabii,
of course if i have understand your request.
custom record/edit i do if understand do the trick.
of course you can check if user is admin or regular.
PHP Code:define('custom:views/preferences/record/edit', ['views/preferences/record/edit'], function (Dep) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
hideNotificationPanel = true;
if (hideNotificationPanel) {
//this.hidePanel('notifications');
}
this.setFieldReadOnly('assignmentNotificationsIgnoreEntityTypeList');
},
afterRender: function () {
Dep.prototype.afterRender.call(this);
},
});
});
Leave a comment:
-
I already tried that before didn't work, my purpose is to Not Allow user to disable notifications (all sort) the preferences entity doesn't have any ACL applied to it so therefore there is no way to disable a specific field for a user. I also tried customising the layout so i could hide only the preferences tab but no success hence there is way to check fi the user type is admin or regular. -
Hi,
Maybe :
application/Espo/Resources/metadata/scopes/Preferences.json
go to admin/entityManager/Preferences.. set field read only and default value.PHP Code:
{
"entity": true,
"layouts": false,
"tab": false,
"acl": false,
"customizable": true <= change from false to true
}
To test.
Leave a comment:
-
For interest I tried to get rid of these configurations. I copied the folder Preferences from application/Espo/Resources/layouts to the custom folder and in the file detail.json I deleted the lines on the bottom "name": "notifications", which hides that tab completely for everybody.
I know, it is a bit a hard hack, but works.Last edited by shalmaxb; 07-04-2023, 03:12 PM.Leave a comment:

Leave a comment: