User Badges for Drupal 6?

Fayna - March 16, 2008 - 03:12
Project:User Badges
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Nuno Veloso
Status:closed
Description

I'd love to see this module updated for Drupal 6. Is there any chance of this happening?

Thank you for such a wonderful module~

#1

Heine - March 19, 2008 - 19:54

Early April is all I can commit to. Patches are always appreciated.

#2

Fayna - March 19, 2008 - 20:13

Lovely!! It doesn't matter how long it takes :)

I'm not much of a programmer so I wish I could help more.

#3

BTMash - April 2, 2008 - 20:17

I may be using user badges on our site so I'll post up the patches if I get through it. There was one question I had.

I see some functions in there that looks like they extend other APIs. Could you please let me know which ones those are (I'll place them in a separate file since it might be better to split core functionality from optional).

#4

BTMash - April 3, 2008 - 15:18

An update re: the user badges module...I have the forms working at this stage. Granted, I don't have the product or ecommerce module so I haven't tested that (are they the same thing??). But everything else seems to be working so far. Should I put it up in a patch format?

#5

BTMash - April 3, 2008 - 16:19

I'm attaching in patch format - it should hopefully patch correctly. Please take a look through to see if I've missed anything.

AttachmentSize
user_badges_all_drupal6x_btmash_0001.patch 31.35 KB

#6

BTMash - April 4, 2008 - 15:56

Ok, there were a few mistakes that I had made (in the values for the fields) - I cleaned up some parts where I could as well. Please take a look at this patch instead.

AttachmentSize
user_badges_all_drupal6x_btmash_0002.patch 31.63 KB

#7

Fayna - June 8, 2008 - 23:23

Hi BTMash,

I don't know if I'm doing something wrong or what but this is what I get when trying to apply your latest patch.

Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file README.txt.rej
patching file user_badges.info
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file user_badges.info.rej
patching file user_badges.install
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file user_badges.install.rej
patching file user_badges.module
Hunk #1 FAILED at 1.
Hunk #8 FAILED at 283.
Hunk #9 FAILED at 291.
Hunk #10 FAILED at 320.
Hunk #11 succeeded at 378 (offset 1 line).
Hunk #12 succeeded at 466 (offset 1 line).
Hunk #13 FAILED at 483.
Hunk #14 succeeded at 511 (offset 1 line).
Hunk #15 FAILED at 527.
Hunk #16 FAILED at 538.
Hunk #17 succeeded at 551 (offset 1 line).
Hunk #18 succeeded at 564 (offset 1 line).
Hunk #19 FAILED at 591.
Hunk #20 FAILED at 720.
Hunk #21 succeeded at 731 (offset 1 line).
9 out of 21 hunks FAILED -- saving rejects to file user_badges.module.rej
patching file user_badges_products.info
patching file user_badges_products.install
patching file user_badges_products.module

#8

BTMash - June 11, 2008 - 15:31

Fayna, were you trying to patch it against the Drupal 5 version of user badges or against the first patch that was above?

#9

Fayna - June 11, 2008 - 15:32

The Drupal 5 version of User Badges.

#10

BTMash - June 20, 2008 - 15:31

I'm going to attach the user_badges 6.x version - I'm confused on the patches myself now (it **should** have worked) >_<

AttachmentSize
user_badges.zip 10.53 KB

#11

Fayna - June 25, 2008 - 01:37

That worked great!! I was able to upload an image for one of the badges, save it, but wasn't sure how to assign a role to it. Both roles I have created only have one drop-down option of "Inactive." So far I haven't noticed any errors or problems. Thanks!!

#12

Flying Drupalist - July 30, 2008 - 02:37

Are we going to see an official development snapshot soon?

#13

BTMash - July 31, 2008 - 19:08

The images getting deleted was a mistake on my part - I didn't realize the files uploaded temporarily unless verified - so I perform the verification that the files are valid and it seems to work properly now.

The zipped format is the new version.

AttachmentSize
user_badges.zip 12.81 KB

#14

scotese - August 2, 2008 - 22:05
Category:feature request» bug report

Thanks,

I did update to the new code above but still have the exact same problem -- will not let me have more than 7 badges -- the image appears fine -- but when I go to assign the image to a badge name it never appears.

#15

Heine - August 2, 2008 - 22:17
Category:bug report» feature request
Status:active» needs work

#16

Heine - August 14, 2008 - 16:48

#13 seems largely functional except for
- no display of assigned badges on the user profile 'view' page (unless I missed something).
- a large amount of NOTICEs

It is best to develop Drupal 6 modules against Drupal 6.x-dev or when using a release, modify common.inc:

change if ($errno & (E_ALL ^ E_NOTICE)) {
to  if ($errno & (E_ALL)) {

#17

scotese - August 19, 2008 - 17:33

My problem was solved by uploading the badges directly to my server rather than using the upload command within the Badges Module. Now working like a charm.

#18

Rosamunda - September 10, 2008 - 22:47

+1!
I really need this [excellent!] module for my Drupal 6 site!

#19

flobruit - September 16, 2008 - 16:31
Status:needs work» needs review

Here's an updated version of the zip file from #13, and a patch since that's the recommended way of doing (against the DRUPAL-5 branch, that's where the latest code seems to be).

Fixed the bug with the badges not showing up on the profile page (hook_user($op = 'view') now uses drupal_render()).

Passes the coder module test, and E_ALL compliant. Also fixed some minor coding style issues.

BTMash already did most of the work, so I would say that this is ready.

Edit: note that I haven't touched the user_badges_product module, only user_badges.

AttachmentSize
user_badges-D6.patch 43.13 KB
user_badges.tar_.gz 9.21 KB

#20

Rosamunda - September 24, 2008 - 20:41

THANKS for the archives!!
I´m sorry for this [probably silly] question, but could this patched version be tagged as 6.x dev version? I mean, isn´t it safe enough? I don´t quite understand how Drupal CVS works, and applying patches is [still] quite an issue for me. And it´s probably a difficult task for some people here aswell :)

#21

Heine - September 19, 2008 - 20:44
Status:needs review» reviewed & tested by the community

Excellent; I'll add this to CVS asap.

#22

aaron - September 26, 2008 - 19:33

I've begun work on the views handlers for this. Currently, this just creates a 'User Badges' field handler, which works after a fashion, although not in the most optimal way for views. (Plus, it returns a row per badge per user, which is not really what is needed.)

Still, I figure this is a good start if someone wants to figure out what I'm doing wrong here.

Requires the following in the module too:

<?php
/**
*  Implementation of hook_views_api().
*/
function user_badges_views_api() {
  return array(
   
'api' => 2.0,
  );
}
?>

(Not doing a patch, because I'm not sure what to patch against here, since HEAD doesn't seem to be updated with the previous patch yet. Just rename the two included files as .inc)

AttachmentSize
user_badges.views_.inc_.txt 1.71 KB
views_handler_field_user_badges_user_uid.inc_.txt 433 bytes

#23

aaron - September 26, 2008 - 20:56

And here are actions. Again, nothing to patch against. Just add this to user_badges.module:

<?php
/**
* Implementation of hook_action_info().
*/
function user_badges_action_info() {
  return array(
   
'user_badges_add_badge_action' => array(
     
'description' => t('Add badge'),
     
'type' => 'user',
     
'configurable' => TRUE,
     
'hooks' => array(
       
'any' => TRUE,
       ),
      ),
   
'user_badges_remove_badge_action' => array(
     
'description' => t('Remove badge'),
     
'type' => 'user',
     
'configurable' => TRUE,
     
'hooks' => array(
       
'any' => TRUE,
       ),
    ),
  );
}

/**
* Implementation of a Drupal action.
* Adds a badge to the current user.
*/
function user_badges_add_badge_action(&$account, $context = array()) {
  if (isset(
$account->uid)) {
   
$uid = $account->uid;
  }
  elseif (isset(
$context['uid'])) {
   
$uid = $context['uid'];
  }
  else {
    global
$user;
   
$uid = $user->uid;
  }
 
$success = TRUE;
 
$badges = user_badges_get_badges('all');

  foreach (
$context['badges'] as $bid) {
   
$success = (boolean) user_badges_user_add_badge($uid, $bid, 'uid');
    if (
$success) {
     
watchdog('action', 'Added user badge %badge to user %name.', array('%name' => check_plain($user->name), '%badge' => check_plain($badges[$bid]->name)));
    }
    else {
     
watchdog('action', 'Unable to add user badge %badge to user %name.', array('%name' => check_plain($user->name), '%badge' => check_plain($badges[$bid]->name)), WATCHDOG_WARNING);
    }
  }
}

function
user_badges_add_badge_action_form($context) {
 
$form['badges'] = array('#tree' => TRUE);

 
$badges = user_badges_get_badges('all');
 
$context['badges'] = is_array($context['badges']) ? $context['badges'] : array();

  foreach (
$badges as $badge) {
   
$form['badges'][$badge->bid] = array(
     
'#type' => 'checkbox',
     
'#title' => theme('user_badge', $badge),
     
'#return_value' => 1,
     
'#default_value' => $context['badges'][$badge->bid],
     
'#description' => check_plain($badge->name),
    );
  }

  return
$form;
}

function
user_badges_add_badge_action_submit($form, $form_state) {
 
$badges = array();
  foreach (
$form_state['values']['badges'] as $badge => $set) {
    if (
$set) {
     
$badges[$badge] = $badge;
    }
  }
  return array(
'badges' => $badges);
}

/**
* Implementation of a Drupal action.
* Removes a badge to the current user.
*/
function user_badges_remove_badge_action(&$account, $context = array()) {
  if (isset(
$account->uid)) {
   
$uid = $account->uid;
  }
  elseif (isset(
$context['uid'])) {
   
$uid = $context['uid'];
  }
  else {
    global
$user;
   
$uid = $user->uid;
  }
 
$success = TRUE;
 
$badges = user_badges_get_badges('all');

  foreach (
$context['badges'] as $bid) {
   
$success = (boolean) user_badges_user_remove_badge($uid, $bid, 'uid');
    if (
$success) {
     
watchdog('action', 'Removed user badge %badge to user %name.', array('%name' => check_plain($user->name), '%badge' => check_plain($badges[$bid]->name)));
    }
    else {
     
watchdog('action', 'Unable to remove user badge %badge to user %name.', array('%name' => check_plain($user->name), '%badge' => check_plain($badges[$bid]->name)), WATCHDOG_WARNING);
    }
  }
}

function
user_badges_remove_badge_action_form($context) {
 
$form['badges'] = array('#tree' => TRUE);

 
$badges = user_badges_get_badges('all');
 
$context['badges'] = is_array($context['badges']) ? $context['badges'] : array();

  foreach (
$badges as $badge) {
   
$form['badges'][$badge->bid] = array(
     
'#type' => 'checkbox',
     
'#title' => theme('user_badge', $badge),
     
'#return_value' => 1,
     
'#default_value' => $context['badges'][$badge->bid],
     
'#description' => check_plain($badge->name),
    );
  }

  return
$form;
}

function
user_badges_remove_badge_action_submit($form, $form_state) {
 
$badges = array();
  foreach (
$form_state['values']['badges'] as $badge => $set) {
    if (
$set) {
     
$badges[$badge] = $badge;
    }
  }
  return array(
'badges' => $badges);
}
?>

#24

aaron - September 26, 2008 - 21:04
Status:reviewed & tested by the community» needs review

duh, I forgot I can just diff the whole thing...

here's the latest, against HEAD. incorporates 19, 22, and 23.

AttachmentSize
user_badges.d6_plus_actions.patch 50.99 KB

#25

aaron - October 2, 2008 - 16:27
Status:needs review» needs work

I'm getting an error when using this d6 patch:

user warning: Duplicate entry '3-1-uid' for key 1 query: INSERT INTO user_badges_user (uid, bid, type) VALUES (1, 3, 'uid') in /home/www/sites/all/modules/user_badges/user_badges.module on line 302.

#26

aaron - October 2, 2008 - 16:28

That's when creating any node.

#27

aaron - October 6, 2008 - 14:23

would be nice to create a dev release so we can file issues against this 6.x patch.

the latest bug i found with this patch is that when an admin creates a new user of a role, role-assigned badges are not assigned.

#28

chasz - October 6, 2008 - 14:32

+1

#29

aaron - October 6, 2008 - 20:33

this fixes the bug at #25, and rolls all other functionality, patched against current HEAD. the bug at #27 still needs attention. could we roll a dev release to make the patches a little more manageable?

AttachmentSize
userbadges.d6.234780.patch 55.94 KB

#30

nikitac - October 17, 2008 - 17:38

Ever since I upgraded Advanced Forum to the lastest version, badges dont show up anymore, please let me know how to fix it. I'm using version created on June. Thanks in advance.

#31

andypost - October 20, 2008 - 22:44

subscribe

#32

zilla - October 22, 2008 - 00:34

per #19 above, could this be rolled into a downloadable zip again for folks like me who know nada about patching??? or alternatively, could it be rolled up and moved to the project page as a dev release or alpha??

#33

Rosamunda - October 23, 2008 - 14:38

+ 1 to your idea zilla!
:)

#34

Lucretia9 - October 26, 2008 - 20:53

Could a new zip be provided for D6? I just tried the nightly head branch and patched it, but there are quite a few failures. It seems that some of these patches have been included. I dunno.

Thanks,
Luke.

#35

krisvannest - November 13, 2008 - 12:04

Ditto & subscribe... I've started to read up on patching, but have a long way to go before I'm versed enough to actually do it on my site so a standalone dev/alpha v6 release would be super. BTW this is one of my most used mods, so great job on it so far and really looking forward to working with v6 support when available.

#36

Shyin - November 14, 2008 - 15:31

I would love to see this also.

Shyin

#37

andypost - November 14, 2008 - 17:55

Suppose it's good to make 6.x-dev to make more people test this module

#38

Rosamunda - November 14, 2008 - 21:41

DNDV!

(desperately needing dev. version :)

#39

hankpalan.com - November 19, 2008 - 22:08

+1 for a Dev. I would love to start testing this.

#40

Heine - November 20, 2008 - 17:23
Status:needs work» fixed

I've committed #24. A dev tarball should appear within 12 hours. Problems can be worked out in additional, separate issues.

Thanks a lot folks.

#41

nilocd - November 27, 2008 - 15:38

subscribing...

#42

pjb - November 27, 2008 - 16:08

Was this checked in fully? I'm still not seeing any dev tarballs on the project page for D6.

#43

Heine - November 27, 2008 - 16:28

http://drupal.org/node/24411/release

The release is not for consumption.

#44

Hilal - December 3, 2008 - 16:26

waiting for 6.X version as well. Love the module.

#45

Nuno Veloso - December 5, 2008 - 20:40
Assigned to:Anonymous» Nuno Veloso

Dear Drupalers,

As you may have noticed, Heine handed me the reins of this module so I'll do my best. However, for now I just intend to support and fix bugs and don't plan any extra features development (besides description URL).

I had a different version (customised for personal use) from the current ones in dev. I tried to merge those to versions, did some code improvements and added/modified some features. So I will now release the first "stable" versions (D5 & D6). Here is a list of what has been added/modified:

I hope it will be useful for all of you. Thank you for your feedback! Don't forget there are some todo's like

  • query optimisation (I am thinking on it)
  • support for private file upload
  • etc.

Enjoy!

#46

Hilal - December 6, 2008 - 05:17

Thank you so much!

#47

Lucretia9 - December 6, 2008 - 16:20

Excellent!

#48

Shyin - December 8, 2008 - 04:52

I should have time soon to set this up on my testbed and give it a good workout. Great to see one of the modules I have been waiting for updated to D-6. Thank you so much.

#49

System Message - December 22, 2008 - 05:02
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.