The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    Warning button help

    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Warning button help

    Post by _Twisted_Mods_ October 24th 2014, 12:57 am

    ok ange how do i setup your code so only users of that lvl can see the buttons

    like admin can only see admin button,mods only see mod button?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Warning button help

    Post by Ange Tuteur October 24th 2014, 1:19 am

    Hello,

    You're referring to this tuto ?
    https://help.forumotion.com/t136169-warning-button-for-administrators-and-moderators

    If so, by default Admins can see the admin/mod buttons, and users with moderation rights can only see the mod button.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Warning button help

    Post by _Twisted_Mods_ October 24th 2014, 1:33 am

    yes....


    i know but i wanna add more groups and only have each group see theres including admin
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Warning button help

    Post by Ange Tuteur October 24th 2014, 2:22 am

    Okay, see if this works :

    I've made some modifications for making buttons for groups.


    Administration Panel > Modules > JavaScript codes management > Create a new script

    Title : Your choice
    Placement : In all the pages
    Code:
    $(function() {
     Â // custom buttons
     Â groupButton([1, 2, 3], 'test', 'http://i39.servimg.com/u/f39/18/21/41/30/bouton10.png');
     Â 
     Â function groupButton(users, tagname, image) {
     Â   for (i=0; i<users.length; i++) {
     Â     if (users[i] === _userdata.user_id) {
     Â       $("#text_editor_textarea").before("<img src='"+image+"' title='Warning' id='"+tagname+"-b'/>");
     Â       $('#'+tagname+'-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('['+tagname+']','[/'+tagname+']')});
     Â     }
     Â   }
     Â   var reg = new RegExp('\\['+tagname+'\\](.+?)\\[/'+tagname+'\\]','ig');
     Â   $('div.postbody div').each(function () {if ($(this).text().indexOf('['+tagname+']') != -1) $(this).html($(this).html().replace(reg, '<div class="'+tagname+'_mess"><div class="titl">Warning</div><div>$1 </div></div>'))});
     Â }
    });

    Under the comment // custom buttons, you can write the following function to create new buttons : groupButton(users, tagname, image);

    users : Takes an array. In the array insert the user ID of the users you want to view the button.
    Example groupButton([1, 23, 6, 188], tagname, image);

    tagname : Takes a string value. Insert the name of the tag.
    Example groupButton([1, 23, 6, 188], 'tag', image);
    [tag] ... [/tag]

    image : Takes a string value. Insert the image that will be used as the button.
    Example groupButton([1, 23, 6, 188], 'tag', '/myimage.gif');
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Warning button help

    Post by _Twisted_Mods_ October 24th 2014, 4:00 am

    no seems to be some kinda bug when i add more then the 2 groups

    none of the buttons show up for the other groups unless i change the # to 2 even tho they are not in group 2
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Warning button help

    Post by Ange Tuteur October 24th 2014, 4:22 am

    In the first argument (users), are you inserting the user ID of that group member ?

    Example :
    I am 88576 https://help.forumotion.com/u88576

    So I would write my ID, plus others separated by a comma.
    Code:
    groupButton([88576], 'test', 'http://i39.servimg.com/u/f39/18/21/41/30/bouton10.png');
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Warning button help

    Post by _Twisted_Mods_ October 24th 2014, 4:24 am

    oh thought it was doing it by group # not member #
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Warning button help

    Post by Ange Tuteur October 24th 2014, 4:30 am

    Yep, you must create an array of UIDs. There's no way to check groups that I know of, so this is the next best way. Smile
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Warning button help

    Post by _Twisted_Mods_ October 24th 2014, 4:31 am

    what about doing it by rank_title
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Warning button help

    Post by Ange Tuteur October 24th 2014, 4:36 am

    You could use _lang.rank_title however, that data requires the toolbar to be active. Also if it contains HTML you need to compare it with the HTML.

    ex :
    Code:
    if (_lang.rank_title === '<span style="color:#f00">my</span> rank') console.log(true);
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Warning button help

    Post by _Twisted_Mods_ October 24th 2014, 4:37 am

    dang ok ill use the way with the usernames ....ty


    Solved
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Warning button help

    Post by Ange Tuteur October 24th 2014, 4:39 am

    You're welcome ^^

    Topic archived

      Current date/time is September 22nd 2024, 2:33 pm