I was curious, is it possible to hide an option for a record dependent on role.
For example I would like to hide the generate letter feature for specific roles.
I was curious, is it possible to hide an option for a record dependent on role.
For example I would like to hide the generate letter feature for specific roles.
Ok i Figured it out thanks to the help from overstack.com
I modified the view for the contacts module under
/custom/modules/Contacts/views/view.detail.php
require_once(âmodules/Contacts/views/view.detail.phpâ);
class CustomContactsViewDetail extends ContactsViewDetail{
public function display(){
global $sugar_config;
$aop_portal_enabled = !empty($sugar_config['aop']['enable_portal']);
$this->ss->assign("AOP_PORTAL_ENABLED", $aop_portal_enabled);
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml('Contacts');
parent::display();
}
}
TO:
require_once(âmodules/Contacts/views/view.detail.phpâ);
class CustomContactsViewDetail extends ContactsViewDetail{
public function display(){
global $sugar_config;
[color=#008800]global $current_user;[/color]
$aop_portal_enabled = !empty($sugar_config[âaopâ][âenable_portalâ]);
$this->ss->assign("AOP_PORTAL_ENABLED", $aop_portal_enabled);
[color=#008800]$isDisabledRole = in_array("Management", ACLRole::getUserRoleNames($current_user->id));
if(!$isDisabledRole){[/color]
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml('Contacts');
[color=#008800]}[/color]
parent::display();
}
}
First we need to load the global variable $current_user.
Then we check the role i would like to block pdfgeneration from.
Then If statememnt to allow all other roles.
If I would like more roles I can check an array against an array, or use a loop to check etcâŚ
i wanted the option to be totally hided and did as above, but not helped. (i tried with the role named âHRâ)
it is still displayed
iâv also quick repared and restarted apache
did i missed something?
this version of commented-out code didnt helped also:
/*
$isDisabledRole = in_array(âHRâ, ACLRole::getUserRoleNames($current_user->id));
if(!$isDisabledRole){
require_once(âmodules/AOS_PDF_Templates/formLetter.phpâ);
formLetter::DVPopupHtml(âContactsâ);
}
*/
Can you post the contents of /custom/modules/Contacts/views/view.detail.php
?
There could be a number of things wrong
Try turning on temporarily error reporting in php.ini and see if you get an error
A few things i would look out for.
make sure global variable current_user is there
global $current_user;
and then make sure you are editing the custom file version that extends modules/Contacts/views/view.detail.php
require_once(âmodules/Contacts/views/view.detail.phpâ);
and make sure the call etc is correct
class CustomContactsViewDetail extends ContactsViewDetail{
âŚ
}
You could also try to do this
$isDisabledRole = in_array(âHRâ, ACLRole::getUserRoleNames($current_user->id));
if($isDisabledRole){
}else {
require_once(âmodules/AOS_PDF_Templates/formLetter.phpâ);
formLetter::DVPopupHtml(âContactsâ);
}
It is more similar to what I a currently using this method for, I block Socials from certain roles with a similar way.
Make sure the role name is matching exactly
I hope i did not confuse you further, post the contents of the file, turn on error reporting and make sure syntax is all well.