If you want to change the who is able to see for example the Assigned to Contacts on the Advanced Menus, because maybe you don't want employees to see names of all other users, you have to do an Edit Module by Module.
For example, lets say you have the Assigned to Menu on the Advanced Search of the Leads Module. Everybody with access to the Leads Module will be able to see this Menu which contains all of the users names. If you want only selected users to see it you can do the following:
Go to the following path.
../custom/modules/Leads/metadata/searchdefs.php
This is basically an Array, so you'll want to add a Conditional to the field of the Array you want to add. Adding conditionals on an Array may by tricky. This is the format:
($Condition) ? (IF TRUE) : (IF FALSE)
So I will do something like: If the username is Admin (which username is 1) print the field otherwise return NULL
($user_id == "1") ? (Print Array) : NULL
See Below:
'assigned_user_id' => ($user_id == "1") ?
array (
'name' => 'assigned_user_id',
'type' => 'enum',
'label' => 'LBL_ASSIGNED_TO',
'function' =>
array (
'name' => 'get_user_array',
'params' =>
array (
0 => false,
),
),
'default' => true,
'width' => '10%',
) : NULL,
Now, to get the user ID you have to add before the Array Starts
global $current_user;
$user_id = $current_user->id;
That way the problem is resolved.
Support Information
{php}
global $current_user;
$user_id = $current_user->id;
echo $user_id ;
{/php}
How to Print Smarty Variables!
{php}
print_r(get_defined_vars());
{/php}
{php}
var_dump(get_defined_vars());
{/php}
Code to Get Field Shown or Not Shown
{php}
global $current_user;
$user_id = $current_user->id;
$this->assign('user',$user_id);
{/php}
{if ( $user == 1)}
<td scope="row" nowrap="nowrap" width='8.3333333333333%' >
<label for='assigned_user_id_advanced'>{sugar_translate label='LBL_ASSIGNED_TO' module='A26_Proveedor'}</label>
</td>
<td nowrap="nowrap" width='25%'>
{html_options name='assigned_user_id_advanced[]' options=$fields.assigned_user_id_advanced.options size="6" style="width: 150px" multiple="1" selected=$fields.assigned_user_id_advanced.value}
</td>
{/if}
Where to Add the Codes.
/var/www/html/master/cache/modules/A01_Servicios/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/A100_Distribuidores/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/A1_Ubicaciones/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/A26_Proveedor/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/Accounts/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/Calls/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/Contacts/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/Leads/SearchForm_advanced.tpl
/var/www/html/master/cache/modules/Opportunities/SearchForm_advanced.tpl
This Cache Files are Deleted when you Delete Cache, I believe that the PHP Files will have to be edited.
/var/www/html/master/custom/modules/Leads/metadata/searchdefs.php