Results 1 to 7 of 7

Thread: Help! Help! Email field ????

  1. #1
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default Help! Help! Email field ????

    Hi everybody.

    I have spoken to sugar and they said that it cannot be done from sugar and needs to be customised.
    no i need to find out how?


    next to the email is the opt in button. this should not b seen in edit view, but a custom field must be created that links to this field via workflow. so that only people in that role can edit this button.

    The reason fir this being that when people have opted out, only admins should be able to opt them back in for there could be huge law suits if unauthorised people opts someine back in.

    Regards

    Paul

  2. #2
    collinlee is offline Sugar Team Member
    Join Date
    Sep 2006
    Posts
    187

    Default Re: Help! Help! Email field ????

    Hi Paul,

    This is an interesting situation and as of today there is no easy, upgrade safe customization that I am seeing in the product to support this. With that said, I do think something like having role permission to enable/disable hide/show editable fields would be a nice feature to add in a future release of the produce.

    From what I can see (and I'm sure there may be tweaks needed as I haven't had too much time to look into it in depth) here is a quick solution.

    1) Modify include/SugarEmailAddress/templates/forEditView.tpl

    This is the file that renders the edit view's widgets.

    What I would do to this file is:

    Around line 53 where there is this block of code:

    Code:
    {if $useOptOut == true}
    <td scope="row" NOWRAP>
    {$app_strings.LBL_EMAIL_OPT_OUT}
    </td>
    {/if}
    I wouid take out the if checks and change it to:
    Code:
    <td scope="row" NOWRAP>
    {$app_strings.LBL_EMAIL_OPT_OUT}
    </td>

    Around line 70 or so I'd add ids to the image and href fields

    So change

    Code:
    <a href="javascript:addEmailAddress({literal}'{/literal}{$module}emailAddressesTable{literal}'{/literal},'','');"><img src="themes/Sugar/images/plus_inline.gif" border="0" height="10" width="10" class="img"></a>&nbsp;
    <a href="javascript:addEmailAddress({literal}'{/literal}{$module}emailAddressesTable{literal}'{/literal},'','');">{$app_strings.LBL_EMAIL_ADD}</a>

    to

    Code:
    <a id="add_email_icon" href="javascript:addEmailAddress({literal}'{/literal}{$module}emailAddressesTable{literal}'{/literal},'','');"><img src="themes/Sugar/images/plus_inline.gif" border="0" height="10" width="10" class="img"></a>&nbsp;
    <a id="add_email_link" href="javascript:addEmailAddress({literal}'{/literal}{$module}emailAddressesTable{literal}'{/literal},'','');">{$app_strings.LBL_EMAIL_ADD}</a>


    Then at the end of this file I would add this entire block of code:


    Code:
    {if !$useOptOut}
    {literal}
    <script type="text/javascript" language="javascript">
    function set_opt_out_fields() {
       var els = document.getElementsByTagName("input");
       for(x in els) {
           if(els[x].type && els[x].type == 'checkbox' && /^emailAddressOptOut/.test(els[x].id)) {
              els[x].disabled = true;
           }
       }
    }
    
    function initialize() {
       document.getElementById("add_email_icon").removeAttribute("href");
       document.getElementById("add_email_link").removeAttribute("href");
       document.getElementById("add_email_icon").setAttribute("onclick", "addEmailAddress('{/literal}{$module}emailAddressesTable{literal}','',''); set_opt_out_fields();");
       document.getElementById("add_email_link").setAttribute("onclick", "addEmailAddress('{/literal}{$module}emailAddressesTable{literal}','',''); set_opt_out_fields();");
       set_opt_out_fields();
    }
    
    YAHOO.util.Event.onDOMReady(initialize);
    </script>
    {/literal}
    {/if}


    2) Then I would modify include/SugarEmailAddress/SugarEmailAddress.php

    Change this block of code:


    Code:
    $this->smarty->assign('useOptOut', true);

    to

    Code:
    $this->smarty->assign('useOptOut', $GLOBALS['current_user']->is_admin || $GLOBALS['current_user']->check_role_membership('Marketing Administrator Role'));


    Summary

    What I am doing here is using some javascript to disbale the checkbox fields if the user is not an admin or is not in the "Marketing Administrator Role". I just chose that as an example.

    Notes

    * Only tested this on Firefox
    * If YAHOO.util.Event.onDOMReady is not available for your version of Sugar then I'd scan other .js (javascript) files to find which on ready function to use (it may be Ext instead)
    * Example disable fields, but you could also code around it to remove it (set checkbox visibility to hidden, etc.) up to you...

    Best wishes!
    Last edited by collinlee; 2009-05-29 at 06:20 AM.

  3. #3
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default Re: Help! Help! Email field ????

    hi there

    Thanks so long .

    I have done what you suggested but, it only takes the labe opted out away , the person can still click on the tick box.

    Regards

    Paul

  4. #4
    collinlee is offline Sugar Team Member
    Join Date
    Sep 2006
    Posts
    187

    Default Re: Help! Help! Email field ????

    Is the current user an admin that you're testing on?

    Try to set the PHP so that the optOutField is set to false always and see if it is picking up the value. I only tested it on Firefox so maybe there are some Javascript issues. Also, like I said make sure the functions are being called by the on ready handlers. You can do a simple alert("hello") statement to check this.

  5. #5
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default Re: Help! Help! Email field ????

    hi

    i have cteated 3 users. one admin, onebeling to a role called t
    and the other to the role you specified

  6. #6
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default Re: Help! Help! Email field ????

    Hi the above staement you wrote , to me looks like lghdlkgblesknb;ewnblekbet
    hberhvberjhbvetRbdrjvgbekvner
    berkjbvhekrljhb;drasjbhndtr

    To a programmer it might make more sense. heh heh heh

  7. #7
    Monkeyman is offline Senior Member
    Join Date
    May 2009
    Posts
    55

    Default Re: Help! Help! Email field ????

    Grrr... I'm fighting to get rid of pesky primary, optOut and invalid checkboxes. This is hard to do, since they are being added via JS.

    Is there a way to get rid of them completely? They are of no use for me at all.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2009-05-06, 06:03 AM
  2. Replies: 7
    Last Post: 2009-01-21, 07:04 PM
  3. Replies: 2
    Last Post: 2008-11-18, 02:40 PM
  4. Replies: 0
    Last Post: 2008-06-07, 06:14 PM
  5. Replies: 2
    Last Post: 2008-04-01, 07:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •