Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Automatic Role Award

meshugymeshugy Musician/Hacker ✭✭

I set up Yaga to award users new roles when they level up. The Yaga plugin performs this task perfectly. However, it leaves the previous role intact. So if someone had been at Level 1, and then earned enough points for Yaga to promote them to Level 2, the Level 1 role is left intact. So the result is the user has roles for both Level 1 and Level 2.

I'd like Yaga to simultaneously promote the user to the designated new roll while also removing the previous one. Is it possible to do that?

thanks!

Comments

  • Options
    hgtonighthgtonight ∞ · New MVP

    Anything is possible :)

    The ranks system is probably the worst designed system in Yaga atm. I am still looking for better ways to accomplish this. I to explain why it works the way it works right now. It might shed some light as to why I think removing roles on rank progression is a bad idea.

    A higher level rank should always contains the benefits of a previous rank and something else. Roles are really just a group of permissions, and the permissions of a user is just the union of all the roles' permissions. In this way, it makes sense to never remove a role via rank progression. You add the next rank's role and now you can do everything you could before plus a little more.

    The flipside is that you can defined your roles in such a way as to maintain the progressive permission reward. Now it seems silly to not remove the role with the current associated rank. You are ending up with a bunch of different roles where one overlaps all the previous roles.

    The real reason rank progression doesn't remove lower associated roles is to keep the logic as simple and to prevent gotchas with complex set ups.

    I am still looking for a better solution.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    meshugymeshugy Musician/Hacker ✭✭

    @hgtonight thanks for the explanation. The only reason I'm considering removing previously attained roles was so that I could get a cleaner display with the Role Titles plugin. I'd like to use the Role Titles plugin to display the name of the user's highest ranked role next to their name when commenting (just like in this support forum.) Currently, the Role Titles plugin displays ALL the roles assigned to a user, which makes quite a mess in the AuthorInfo area. Is there a way to mod the Role Titles plugin to just display only the highest ranked role?

    thanks!

  • Options
    peregrineperegrine MVP
    edited January 2014

    Yes. in roletitles look for this. but the question would be better asked in a different discussion perhaps under the roletitles plugin and state your version number of roletitle when asking question. :)

               if (is_array($Sender->Discussion->Roles)) {
                    if (count($Sender->Discussion->Roles)) {
                       $CssRoles = GetValue('Roles', $Sender->Discussion);
                       foreach ($CssRoles as &$RawRole)
                          $RawRole = $this->_FormatRoleCss($RawRole);
    
                       $Sender->Discussion->_CssClass = GetValue('_CssClass', $Sender->Discussion, '').' '.implode(' ',$CssRoles);
                    }
                 }
                }
    
    
    add a check
    
       if (is_array($Sender->Discussion->Roles)) {
                    if (count($Sender->Discussion->Roles)) {
                       $CssRoles = GetValue('Roles', $Sender->Discussion);
    // you could either preg replace unwanted roles here...                add your code here
    
                  foreach ($CssRoles as &$RawRole)
    
    // or skip the here.  add your code here
    
    
                          $RawRole = $this->_FormatRoleCss($RawRole);
                       $Sender->Discussion->_CssClass = GetValue('_CssClass', $Sender->Discussion, '').' '.implode(' ',$CssRoles);
                    }
                 }
                }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    meshugymeshugy Musician/Hacker ✭✭

    @peregrine I found my answer here: http://vanillaforums.org/discussion/15064/roletitle-addon-change-of-role#latest

    I'm using v 0.4 of RoleTitles so I made the following change:

    echo '<span class="MItem RoleTitle">'.implode(', ', $Roles).'</span> ';
    

    to

    echo '<span class="MItem RoleTitle">'.array_pop($Roles).'</span> ';
    

    Does exactly what I want!

  • Options
    hgtonighthgtonight ∞ · New MVP

    I could see making a yaga plugin called rank title that just displays rank names much like role title does roles.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    peregrineperegrine MVP
    edited January 2014

    @meshugy

    cool. but it has flaws. If the last role added is not the last role you want. e.g. if a moderator has a level role added, and you would want moderator to show. it will not show moderator because moderator was presumable prior to the level role. but whatever works for you is most important.

    and you would want to change CssRoles as well if you want css to go with your displayed role.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    peregrineperegrine MVP
    edited January 2014

    hg,

    it might be better to replace level roles but leave standard roles alone.

    so you could be member, level1
    or member, level5

    otherwise there is potential for each user to have many,many roles instead of an optimal 1 or 2 roles.

    speaking from not looking at the code.

    Additive is great until it becomes role-intensive. In the school or thought "less roles the better". vs chool of thought "the additive increasing number of roles. Although addivitve roles give you alot more flexibility. I suppose it depends on which sshool you belong to.

    perhaps this could be solved by a config.

    select level preference
    additive leveling
    replacement leveling.

    another several days of coding :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    meshugymeshugy Musician/Hacker ✭✭

    @peregrine thanks for the comments. In most cases my users will be progressively moving up the order of roles so I don't think I'll have a problem with a lesser role displaying. I think this simple solution will work for now...

  • Options
    hgtonighthgtonight ∞ · New MVP
    edited January 2014

    The issue with not using roles is that I didn't want to create a new thing (rank) that does the same thing as an existing one (role).

    You can mark roles as personal info, right? Or is that an alpha feature?

    Like I said, I am happy to discuss solutions because the current method feels hacky.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    edited January 2014

    @hgtonight Not an expert of coding myself, but maybe you can add some code to add a text box during Rank Creation that will say something like: "Delete Role" and that might work to delete a role, while adding a role as well. As I said, I'm not an expert of coding myself, but I'll dig through the Yaga files to see if I can add some code to it to make that happen

    EDIT: Alongside making a text box for Delete Role, we have to have the application do a $SQL command or something to write to the role section of the user in GDN_User

Sign In or Register to comment.