User Badges v1.0.3

Release Notes

This plugin allows users to be automatically awarded a badge based on a configurable number of user points (requires the User Points plugin). Additionally, badges can be manually assigned by an administrator and locked so that the badge will not change as points are gained or lost.

 

The badges are displayed on the lower right hand corner of the users icon (see screenshots). This is done by overriding the default profile/icon view and adding a css overlay on the fly. For the best results you should use 16x16 icons. IconArchive has a good collection of 16x16 icons.

 

Update 1.0.3:

  • Fixes bug where a space or special characterin a users name would break the css for badge overlay.

 

Update 1.0.2:

  • Added option to lock badge at highest level i.e. badges go up but now down.
  • Added option to display the badge description along with the badge on the users profile page.

 

 

 

 

 

 

  • Last night I located a conflict with badges and online plugins.  I noticed online was not working.  Started looking around enable/disable. nothing, check the logs and find badges is looping some command.  The log had over 4000 enteries from NO user. with in a 2 hour period.

  • Only after reordering online, disabling badges, and forcing a cron.  Was I able to stop the loop.

  • I suspect that with extending views plugin conflicts will be inevitable. I will grab online and see if I can figure out whats up.

  • Ok, so like Badges, Online overrides the profile/icon view. Unlike extending the view where code can be either added just before or just after the view, overriding completely replaces the view. 2 plugins can't replace the same view 1 will win and 1 will lose in that situation.

     

    The easiest way to add an overlay to the profile icon is to override the view because then you have complete control over it. There are a couple otherways it could be done. 1 is to hook on the view action, intercept the html that is about to be displayed to the user and loop through the html injecting code where you need it. For that approach you would need some really solid pattern matching to make sure your code gets injected in the right place. Another aproach is use javascript to post process and update the dom as needed.

     

    Not sure how I feel about either of those approaches at the moment. Will need to look into it and see.

     

     

  • yeah, I know but neither appeals to at this time.  How about this tell my if it will damage anything, just remove the reference to display the badges on anything other then the profile ie no icons at all just the badge under the points?

  • Sure, to do that disable badges, delete the directory mod/badges/views/default/profile, and re-enable badges.

     

    ~Billy

  • You R a god amongst men.  I will check it out later today on the loop and conflict.  I will post back either way for others.

  • Billy, I've been testing the Badge widget for a few days now on 1.6 and it looks like the Badges don't read the total points that a user has. It could also be a "userpoints" or "user points standard" issue since the total points shown there do not match the same points mentioned in the user's "settings->Account Statistics"...hmmmm

  • oops forgot to expound on that. What I meant by "the Badges don't read the total points" is that the users can only get the first badge and then never progress to the higher badges. When I automatically assigned a higher badge to someone it reset, after their next log-in, back down to the lowest badge. I think that it may have to do with the userpoints or userpoints_standard because in the users' account statistics, the total points shown are extremely lower than what they say in Userpoints. For example, I have 10 points set as needed for a "n00b" badge and then 1,500 points required for "notta noob." When a user gets to 1,505 points, for example, they are still stuck with the "n00b" badge. I checked each user's "account statistics" and it shows each user as having like 100 to 200 points. So is this is a userpoints or userpoints_standard issue? I'm using the latest plugins for all three and elgg 1.6.

  • Ok, so settings->Account Statistics is an elgg thing. It is not actually displaying the amount of points a user has it is displaying the number of various entities i.e. records. So that number next to user points is the number of userpoint entities (records) they have. Don't look here to see points.

     

    The actual number of points a user has can be seen in 3 places by default.

     

    • On the users profile page just under their icon when you have the option 'Display points on users profile?' set to Yes. 
    • On the top points widget if they are in the top.
    • In the admin list view at Administration -> Userpoints -> List

    All 3 of those methods get a users total points from the userpoints_points metadata attached to the user entity so they could never be different. When in the admin list view you can click on a user and now you are seeing each individual userpoint record.

     

    Given the information above, let me know if you still believe a user with 1505 user points is not being awarded a badge set at 1500 points.

     

    Cheers,

    Billy

  • I figured it out. DUH. It looks like the point-requirements in the Badge settings must NOT have any commas (e.g. 1,500 must be entered as 1500). Otherwise, the userpoints won't recognize the requirements. =)

  • Oh good catch :) Yup, that field requires an integer only. I will add a note for it.

  • image

    DEAR Friend, please explein me, how can i set diferent color in the text (Badges and Points:340), because is my backgroun is black color. So I need white or other color...thx..

  • You will want to add your styling to the .badges_profile section in mod/badges/views/default/badges/css.php

  • Oh and for the userpoints styling update the .userpoints_profile section in mod/userpoints/views/default/userpoints/css.php

  • whata I must change in this code if i wont white color for text???

    <?php
        /**
         * Badges CSS
         */
        /* margin: 5px 0 0; */
    ?>

    .badges_profile{
        font-weight: bold;
    }

    .badges_profile_description {
        font-family: sans-serif;
        font-style: normal;
        font-variant: normal;
        font-weight: lighter;
        font-size: smaller;
        line-height: 100%;
        text-decoration: none;
        text-transform: none;
        text-align: left;
        text-indent: 0ex;
    }

    .badges_settings_info {
        font-family: sans-serif;
        font-style: normal;
        font-variant: normal;
        font-weight: lighter;
        font-size: smaller;
        line-height: 100%;
        text-decoration: none;
        text-transform: none;
        text-align: left;
        text-indent: 0ex;
    }

    .river_object_badge_update {
        background: url(<?php echo $vars['url']; ?>_graphics/river_icons/river_icon_profile.gif) no-repeat left -1px;
    }

  • Its just css so you will need to google for all the different css parameters that you may want to change. If you just want to change the color then:

     

    .badges_profile{

        font-weight: bold;

        color: #E8E8E8

    }

     

    So I just added the color attribute. Add the color attribute to the other sections that you want to change color in also like badges_profile_description and badges_settings_info. Look here for some color codes to use.

  • I insert the code color: #E8E8E8 below font-weight: bold;   in my css.php but the color remains the same. Nothing change....whyyyy???

  • after a change in css type yoursite.com/upgrade.php and you will see the change

  • thank you very much....now everthing is OK....thx...

  • Can anyone tell me where the badge icons are uploaded to when you first create your badges, I can't seem to find them anywhere on my system... weird!

  • Badges extends ElggFile which ultimatley controls the file location. Its nice for elgg developers cuz we don't gotta worry about it :) So it will be under whatever you set in your site administration properties for uploaded files and from there it should be under the username that uploaded the file followed by image/badges/. So on my site, badges I uploaded are under /data/d/i/v/a/g/divagater/image/badges/.

     

    Cheers,

  • doh. forgot to ask if there is a way to enlarge the ico on the users profile page, as it still shows quite small... cheers.

  • I don't do anything with the icon size meaning the size is dependent on whatever you upload. So a 16x16 badge icon will be 16x16 when its applied to a profile picture. So try uploading a 20x20 version or 24x24 etc. I think much larger and the badge may start to get in he way.

Billy Gunn

Developer @ Arck Interactive

Stats

  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 5474
  • Recommendations: 9

Other Projects

View Billy Gunn's plugins