Remove a checkbox from user profile preferences

I want to remove the Email all invitees checkbox from the User Profile Advanced settings.

I know the Users module is legacy BWC, but the Meetings module isn't and contains data for this, yet uses Smarty templates.

I've been searching around but cannot seem to find any information on how to do this or override the template. I also could not find any logic for how the checkbox is displayed in the template anywhere in the SugarCRM filesystem - no variable that determines it.

  • Hi Artis Plocins 

    You just need to copy the file modules/Meetings/tpls/reminders.tpl into custom/modules/Meetings/tpls/reminders.tpl and modify it accordingly. Actually you need to remove the "div" containing the field "email_reminder_checked".

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi,

    So this is the file modules/Meetings/tpls/reminders.tpl:

    {*
    /*
    * Your installation or use of this SugarCRM file is subject to the applicable
    * terms available at
    * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
    * If you do not agree to all of the applicable terms or do not have the
    * authority to bind the entity as an authorized representative, then do not
    * install or use this SugarCRM file.
    *
    * Copyright (C) SugarCRM Inc. All rights reserved.
    */

    *}

         {if $fields.reminder_time}                 
                     
                     {assign var="REMINDER_TIME_OPTIONS" value=$fields.reminder_time.options}
                     {assign var="EMAIL_REMINDER_TIME_OPTIONS" value=$fields.reminder_time.options}     
                     
                     {if !$fields.reminder_checked.value}                      
                          {assign var="REMINDER_TIME" value=-1}
                     {else}
                          {assign var="REMINDER_TIME" value=$fields.reminder_time.value}
                     {/if}
                     {if !$fields.email_reminder_checked.value}                      
                          {assign var="EMAIL_REMINDER_TIME" value=-1}
                     {else}
                          {assign var="EMAIL_REMINDER_TIME" value=$fields.email_reminder_time.value}
                     {/if}
         {/if}
         
         {assign var="REMINDER_TIME_DISPLAY" value="none"}
         {assign var="EMAIL_REMINDER_TIME_DISPLAY" value="none"}
         {if $REMINDER_TIME != -1}
                     {assign var="REMINDER_CHECKED" value="checked"}
                     {assign var="REMINDER_TIME_DISPLAY" value="inline"}     
         {/if}
            {if $EMAIL_REMINDER_TIME != -1}
                     {assign var="EMAIL_REMINDER_CHECKED" value="checked"}
                     {assign var="EMAIL_REMINDER_TIME_DISPLAY" value="inline"}
            {/if}

    {if $view == "EditView" || $view == "QuickCreate" || $view == "QuickEdit" || $view == "wirelessedit"}


              <div>
                               
                       <input name="reminder_checked" type="hidden" value="0">
                       <input name="reminder_checked" id="reminder_checked" onclick="toggleReminder(this,'reminder');" type="checkbox" class="checkbox" value="1" {$REMINDER_CHECKED}>
                       <div style="display: inline-block; width: 111px;">{$MOD.LBL_REMINDER_POPUP}</div>
                       <div id="reminder_list" style="display: {$REMINDER_TIME_DISPLAY}">
                            <select tabindex="{$REMINDER_TABINDEX}" name="reminder_time">
                             {html_options options=$REMINDER_TIME_OPTIONS selected=$REMINDER_TIME}
                        </select>
                       </div>
                     </div>
                     <div>
                       
                      <input name="email_reminder_checked" type="hidden" value="0">
                       <input name="email_reminder_checked" id="email_reminder_checked" onclick="toggleReminder(this,'email_reminder');" type="checkbox" class="checkbox" value="1" {$EMAIL_REMINDER_CHECKED}>
                       <div style="display: inline-block; width: 111px;">{$MOD.LBL_REMINDER_EMAIL_ALL_INVITEES}</div>
                       <div id="email_reminder_list" style="display: {$EMAIL_REMINDER_TIME_DISPLAY}">
                            <select tabindex="{$REMINDER_TABINDEX}" name="email_reminder_time">
                             {html_options options=$EMAIL_REMINDER_TIME_OPTIONS selected=$EMAIL_REMINDER_TIME}
                        </select>
                       </div>
              </div>
                     <script type="text/javascript">
                          {literal}
                   function toggleReminder(el,field){
                        if(el.checked){
                             document.getElementById(field + "_list").style.display = "inline";
                        }else{
                             document.getElementById(field + "_list").style.display = "none";
                        }
                   }
                   {/literal}
                     </script>
         {else}
              <div>               
                   <input type="checkbox" disabled  {$REMINDER_CHECKED}>
                   {$MOD.LBL_REMINDER_POPUP}
                   {if $REMINDER_TIME != -1}
                        {$REMINDER_TIME_OPTIONS[$REMINDER_TIME]}
                   {/if}               
              </div>
              <div>               
                   <input type="checkbox" disabled  {$EMAIL_REMINDER_CHECKED}>
                   {$MOD.LBL_REMINDER_EMAIL_ALL_INVITEES}
                   {if $EMAIL_REMINDER_TIME != -1}
                        {$EMAIL_REMINDER_TIME_OPTIONS[$EMAIL_REMINDER_TIME]}
                   {/if}               
              </div>
         {/if}     

    And here is my modified version where I have removed two divs for the email reminder, lines 56-66 and 86-92 from the file above - custom/modules/Meetings/tpls/reminders.tpl:

    {*
    /*
    * Your installation or use of this SugarCRM file is subject to the applicable
    * terms available at
    * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
    * If you do not agree to all of the applicable terms or do not have the
    * authority to bind the entity as an authorized representative, then do not
    * install or use this SugarCRM file.
    *
    * Copyright (C) SugarCRM Inc. All rights reserved.
    */

    *}

         {if $fields.reminder_time}

                     {assign var="REMINDER_TIME_OPTIONS" value=$fields.reminder_time.options}
                     {assign var="EMAIL_REMINDER_TIME_OPTIONS" value=$fields.reminder_time.options}

                     {if !$fields.reminder_checked.value}
                          {assign var="REMINDER_TIME" value=-1}
                     {else}
                          {assign var="REMINDER_TIME" value=$fields.reminder_time.value}
                     {/if}
                     {if !$fields.email_reminder_checked.value}
                          {assign var="EMAIL_REMINDER_TIME" value=-1}
                     {else}
                          {assign var="EMAIL_REMINDER_TIME" value=$fields.email_reminder_time.value}
                     {/if}
         {/if}

         {assign var="REMINDER_TIME_DISPLAY" value="none"}
         {assign var="EMAIL_REMINDER_TIME_DISPLAY" value="none"}
         {if $REMINDER_TIME != -1}
                     {assign var="REMINDER_CHECKED" value="checked"}
                     {assign var="REMINDER_TIME_DISPLAY" value="inline"}
         {/if}
            {if $EMAIL_REMINDER_TIME != -1}
                     {assign var="EMAIL_REMINDER_CHECKED" value="checked"}
                     {assign var="EMAIL_REMINDER_TIME_DISPLAY" value="inline"}
            {/if}

    {if $view == "EditView" || $view == "QuickCreate" || $view == "QuickEdit" || $view == "wirelessedit"}


              <div>

                       <input name="reminder_checked" type="hidden" value="0">
                       <input name="reminder_checked" id="reminder_checked" onclick="toggleReminder(this,'reminder');" type="checkbox" class="checkbox" value="1" {$REMINDER_CHECKED}>
                       <div style="display: inline-block; width: 111px;">{$MOD.LBL_REMINDER_POPUP}</div>
                       <div id="reminder_list" style="display: {$REMINDER_TIME_DISPLAY}">
                            <select tabindex="{$REMINDER_TABINDEX}" name="reminder_time">
                             {html_options options=$REMINDER_TIME_OPTIONS selected=$REMINDER_TIME}
                        </select>
                       </div>
                     </div>
                     <script type="text/javascript">
                          {literal}
                   function toggleReminder(el,field){
                        if(el.checked){
                             document.getElementById(field + "_list").style.display = "inline";
                        }else{
                             document.getElementById(field + "_list").style.display = "none";
                        }
                   }
                   {/literal}
                     </script>
         {else}
              <div>
                   <input type="checkbox" disabled  {$REMINDER_CHECKED}>
                   {$MOD.LBL_REMINDER_POPUP}
                   {if $REMINDER_TIME != -1}
                        {$REMINDER_TIME_OPTIONS[$REMINDER_TIME]}
                   {/if}
              </div>
         {/if}

    After a quick repair, there is no change to be seen.

    Why does this not work, what should I do to make this change and why is there no documentation on something like this?

  • Hi Artis Plocins 

    It seems SugarCRM no longer automatically load custom template file, so you need to do the following tasks:

    • Create/edit the file custom/modules/Users/metadata/editivewdefs.php and modify the attribute $viewdefs['Users']['EditView']['templateMeta']['form']['footerTpl'], set it to 'custom/modules/Users/tpls/EditViewFooter.tpl';
    • Create the file custom/modules/Users/tpls/EditViewFooter.tpl and modify the path for Meetings tpl, set it to the custom one you previously create.

    Run the Quick Repair and Rebuild and then test again.

    Good luck!

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi, I did that and changed the following line as you can see below on both files editvewdefs.php and editviewdefs.php.suback.php:

    'customCode' => '{include file="custom/modules/Meetings/tpls/reminders.tpl"}',

    This is the directory structure of those files now:

  • It is not requied to setup a customCode.

    You just need to follow these steps:

    • modify custom/modules/Users/metadata/editviewdefs.php in order to define the custom footerTpl
    • copy modules/Users/tpls/EditViewFooter.tpl into custom/modules/Users/tpls/EditViewFooter.tpl and replace modules/Meetings/tpls/reminders.tpl by custom/modules/Meetings/tpls/reminders.tpl
    • copy modules/Meetings/tpls/reminders.tpl into custom/modules/Meetings/tpls/reminders.tpl and remove the div containing the field email_reminder_checked

    Execute Quick Repair and Rebuild

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Thank you very much, my change works now and I was able to install it as a module!

    Can you please explain where you found the way to do this and if it is the most correct way of changing BWC templates in SugarCRM 7?

  • I'm glad to know it worked!

    Yes, this is the most correct and upgrade safe way to do that.

    I just tracked the code from rendered Users layout until Meetings tpl.

    Kind regards

    André Lopes
    Lampada Global
    Skype: andre.lampada