I currently have not learned Git yet, so I will post the changes required for D7 here. These are cumulative and to be applied on top of the current -dev release. I will also include a zip of the current complete module.
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | Screen shot 2012-05-11 at 9.37.32 PM.png | 123.69 KB | cherrysuede |
| #59 | Screen shot 2012-05-11 at 9.39.16 PM.png | 52.55 KB | cherrysuede |
| #51 | rkimmons-adminupdate2.patch | 10.17 KB | Royce Kimmons |
| #50 | rkimmons-adminupdate.patch | 9.44 KB | Royce Kimmons |
| #20 | user_badges_7x.patch | 96.96 KB | nancydru |
Comments
Comment #1
nancydruThis contains:
Remaining known issues:
Comment #2
Refineo commentedI tested these patches with the following test scenario.
User Badges test scenario
Environment
Drupal 7.8
User Badges 7.x-1.x-dev + patches in #1306032: Cumulative D7 Changes
Summary
Error when trying to delete user badges.
Test steps
1. Go to Configuration>People>Badges>List (admin/config/people/user_badges)
At the beginning screen loads, you should see no badges at all ...................OK
2. Go to Configuration>People>Badges>Add (admin/config/people/user_badges/add)
Screen loads ....OK
3. Enter the following data into the form
Name = blank, Image Url = blank, Weight = 0, Description URL = blank
[X] Cannot be hidden
[X] Fixed Weight
[X] Does Not Cound to Limit
4. Click Save badge
You should get error message
"Name field is required.
You need to either enter an image URL or select an image from the library. Your badge needs an image." ... OK
5. Enter the following data into the form
Enter Name = Test Badge 1, Image Url = blank, Weight = 0, Description URL = blank
[X] Cannot be hidden
[X] Fixed Weight
[X] Does Not Cound to Limit
You should get error message
"You need to either enter an image URL or select an image from the library. Your badge needs an image." ... OK
6. Enter the following data into the form
Enter Name = Test Badge 1, Image Url = http://www.centralscrutinizer.it/wp-content/uploads/2006/09/sergey.gif
, Weight = 0, Description URL = blank
[X] Cannot be hidden
[X] Fixed Weight
[X] Does Not Cound to Limit
You should get message "Badge Test Badge 1 saved."
7. Go to List again
YOu should see the new Test Badge 1 and the badge image on the list.
8. Go to Configuration>People>Badges>Images (admin/config/people/user_badges/images)
You should not see the Test Badge 1 image here because it was not added to the library first. ... OK
9. Upload the new badge image
Click the button under Upload image and select a badge.jpg file from your local folder.
Click Open
Click Upload
You should see the badge.jpg image on the list below. ... OK
10. Go to Configuration>People>Badges>Roles
Assign the badge to blocked user
Save Role Badges
You should see badge images next to the blocked user ... OK
11.Assign the badge to your roles
Save Role Badges
You should see badge images next to the role name ... OK
12. Go to Configuration>People>Badges>Settings
Number of badges to display = 0
Only show blocked user badge = Yes
Allow users to reorder badges = No
Image style to size badges =
"No badges" message = leave it blank
Default badge link URL = leave it blank
Vocabulary =
Click Save configuration
You should see Configuration saved. ...........OK
13. Go to Configuration>People>Badges>Images (admin/config/people/user_badges/images)
14. Check the checkbox [X] next to the badge.jpg image.
15. Click Delete ...
ERROR
Error:
Trying to delete 2 badges at once (I had one more badge added before) results in error:
Trying to delete 1 badge results in error:
Trying to delete 1 badge again results in error:
Comment #3
Refineo commentedI found one more warning message on a frontpage:
Comment #4
nancydruHmm, 6 and 7 fail for me - no image.
Interesting, I have no problems deleting badges (even two at a time). I'll have to check for which code I have uploaded.
On both Add and Images, there is an image scaling issue.
Blocked users: "There was a problem saving roles to the database"
Comment #5
nancydruI think there are some major problems with the way role badges are handled that are pervasive throughout the module. That may be why there are so many issues open here. For now, I would say, let's pretend that feature is not present and just make sure everything else works okay.
This may result in significant rewrite needs.
Comment #6
nancydruThis contains:
Remaining known issues:
Comment #7
nancydruThis contains:
Remaining known issues:
To be tested: Does Private file system now work?
Comment #8
boran commentedI've done some testing.. I am calling user_badges_for_user(array('uid'=>123)) from a module of mine. But this resulted in the error:
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 374 of /disk2/www/drupal-7.8/includes/entity.inc).
Fix: In user_badges_for_user() replace:
//$account = user_load($load);
$account = user_load($load[uid]);
user_load does not expect an array in D7, see also http://api.drupal.org/api/drupal/modules--user--user.module/function/use...
If you want I can create the D7 branch in git and do the initial commit, but I'd need (provisional) maintainer status for that. Or I can guide you through it, but you'll need to install git.
Sean.
Comment #9
Satori42 commentedUsing this most recent patch (in Comment #7), Token support is still having some difficulties. It's not crucial to me, but I thought you'd like more data on it.
For the following lines near the end of the module:
Drupal can't find the dsm function. I've done a personal workaround by commenting the lines out.
Additionally, when you go to work on #5, Role Badges, here's more info:
I associated a sample badge with a Role. I used Rules to give the Role - not the Badge - to a user. The user had the Role, but not the Badge. When I went to manually remove the Role from the User, Drupal gave this:
Warning: key_exists() [function.key-exists]: The first argument should be either a string or an integer in user_badges_user_presave() (line 295 of C:\xampplite\htdocs\drupal\modules\user_badges\user_badges.module).If we're still pretending the Role Badges issue's not there, we can pretend I didn't give you that info. =)
Comment #10
nancydruDsm is a Devel module debugging statement. It should always be safe to remove them - or turn on Devel to see what I was looking at.
Actually, I wondered why that function was there, but hadn't looked hard at it yet, so now I know. I suspect it will go away when I figure out what to do with role badges. I write a summary on that (#1319230: D7 Role badges, User weighting, Limit count (6.x users take note)), because there are complications with doing what I'd like to do. Role badges are really bad right now - even in the 6.x branch.
I can also tell you to pretend user weighting of badges isn't there either. That's part of the role badge related problems.
Comment #11
nancydruThis contains:
A new version of the documentation page is included in the zip file.
Remaining known issues:
To be tested: Does Private file system now work?
Comment #12
spaceknight commentedHello NancyDru, I hope that you can deliver a D7 compatible release asap. Did you by change forget to attach the zip file in #11?
Comment #13
spaceknight commentedTesting the zip from #7,
I get following notice when
Configuration >> People >> Badges >> ADD
Notice: Undefined variable: userpoints_goal in userpoints_badges_form_alter() (line 14 of C:\xampp\htdocs\drupal\sites\all\modules\userpoints_contrib\userpoints_badges\userpoints_badges.module).however this is a notice from userpoints_badges.module.
Comment #14
nancydruA full D7 version is going to require resolving the role badge issue and I need user feedback on that (#1319230: D7 Role badges, User weighting, Limit count (6.x users take note)).
I guess I should break down and test out Userpoints.
This contains:
A new version of the documentation page is included in the zip file, as is the code that has been moved to separate files.
Remaining known issues:
To be tested: Does Private file system now work?
Comment #15
spaceknight commentedAnd this is what I get after submitting the ADD form:
Fatal error: Call to undefined function db_result() in C:\xampp\htdocs\drupal\sites\all\modules\userpoints_contrib\userpoints_badges\userpoints_badges.module on line 75Comment #16
nancydruIt looks like the Userpoints_Badges module has not been converted to 7.x yet.
Comment #17
nancydru@spaceknight: Since you are already set up, you can test this better. #1321082: Userpoints_badges for 7.x
Please post issues there.
Comment #18
berdirQuick at your changes, not very detailed but a few hints.
module_exists() outside of any functions is not reliably, just like any other functions. Drupal is only partially initialized at this point. Better do it in hook_init().
For tokens, any call of an token hook should automatically include the yourmodule.tokens.inc file, thanks to http://api.drupal.org/api/drupal/modules--system--system.module/function....
You should uppercase the first character of permission titles, to be in line with others.
As said before, I suggest admin/config/people/user_badges for the admin path, I think this is more a configuration/setup task, unlike managing users.
You might also want to add a description, so that it shows up in the configuration overview.
Maybe this function can be replaced completely with http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ht... ?
This doesn't look like valid orderBy() syntax to me.
This doesn't make sense, why not simply use user_load()? You're doing exactly what user_load() does. That's not what the comment was about...
Also, this code results in an E_STRICT notice, because array_shift() expectes a variable.
Also, if possible, this should be cleaned up so that always a user object is passed in.
Doesn't this require class to be an array as well?
Should use format_plural() instead of that badge(s) thing.
As mentioned in my userpoints_badges review, a module_invoke('user_badges_delete', $bid) would be awesome here (including documentation in a .api.php file), so that modules like userpoints_badages can act when badges are deleted.
Another improvement would be API functions which are just called by the submit callback, so that modules can create/delete badges through code.
Interestingly, here where we actually have a reason for a dynamic query (different conditions based on arguments), you replaced it with hardcoded queries? just wondering why?
I don't think this is a valid condition() usage. not sure what you're trying to do here.
Comment #19
nancydruThanks, I'll go through these in detail in a little while (got a customer call just now). The last one is the beginning of trying to clean up the whole role badge stuff, which is, IMHO, all wrong (there is an issue about that).
Comment #20
nancydruThis contains:
A new version of the documentation page is included in the zip file, as is the code that has been moved to separate files.
Remaining known issues:
To be tested: Does Private file system now work?
Comment #21
boran commentedI tried the above zip and had to do one fix, when viewing the user profile.
at the top of the function user_badges_for_user()
1261,1264c1261
< // @todo: hang on, uid array received.
< if (is_array($uid)) {
< $uid=$uid['uid'];
< }
---
>
to solve errors like:
Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in user_badges_for_user() (line 1267 of /disk2/www/drupal-7.8/sites/all/
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 184 of /disk2/www/drupal-7.8/includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 375 of /disk2/www/drupal-7.8/includes/entity.inc).
Warning: Illegal offset type in user_badges_for_user() (line 1285 of /disk2/www/drupal-7.8/sites/all/modules/custom/user_badges/user_badges.module).
Warning: Illegal offset type in user_badges_for_user() (line 1300 of /disk2/www/drupal-7.8/sites/all/modules/custom/user_badges/user_badges.module).
Comment #22
nancydruIs this the zip from #20? I got this long ago, but not now.
Comment #23
boran commentedYes I pulled:
wget http://drupal.org/files/user_badges_3.zip
unzip user_badges_3.zip
The CHANGELOG.html in there is basically the post from #20
Comment #24
nancydruI don't have that code in my version:
Comment #25
boran commentedYes, I had to add in:
if (is_array($uid)) {
$uid=$uid['uid'];
}
after:
static $save = array(0 => FALSE);
to fix the log messages noted above.
uid was coming in as an array.
Comment #26
nancydruReally? How did you get there? I cannot recreate this.
Comment #27
boran commentedWhen I view my user profile page.
Comment #28
spaceknight commentedI got this error when I tried to uninstall User Badges:
Fatal error: Call to undefined function file_create_path() in C:\xampp\htdocs\drupal7\sites\all\modules\user_badges\user_badges.install on line 170That happens when I select the module, click the Uninstall button, and the page with error is
http://localhost/drupal7/admin/modules/uninstall/confirm
And the module is not being uninstalled, is still there.
Comment #29
nancydruYes, the .install file needs work. That's why I say this should not be used to upgrade from D6 yet.
Uninstall never removes a module, only its data; it will continue to show up on the module admin page.
Comment #30
spaceknight commentedI am posting my findings here:
EDIT:
- When trying to edit a badge, the link takes me to People page. I guess the link is generated as (program/admin/people/user_badges/edit/2), and it should be (program/admin/config/people/user_badges/edit/2)
ADD:
- There are two form buttons named (Save Badge) at the bottom (you already are aware of this).
LIST:
- Can we put Userpoints Goal as a new column (if userpoints_badges is enabled) ?
Comment #31
berdirAnother review. Also applied the patch, some general issues:
- All the new files (token, actions, ..) are missing in the patch.
- See below, I don't have a doc_page.html, just a README.txt ?
- The usual issues with your patch being against the snapshot and containing windows line endings :)
- Image styles don't seem to be working for me, but that part needs work anyway, see below.
- This is a mix of required bugfixes and new features. This results in a huge patch and the new features which need more discussion/work are stopping the smaller bugfixes from being commited. I can see that you're doing this because the single, simple patches aren't commited either but this is still a problem :) I usually do this kind of thing by having a separate branch for every thing I work on in my local git repository.
Where is doc_page.html coming from? That is not in Git nor in the -dev snapshot? Both just have a README.txt.
The path should not contain the module name, this currently requires -p2 so that it can be applied.
The order of the weight thing looks wrong, should have #value first.
I would also recommend using #header then you don't need the additional nesting within #value.
Not too sure about this part, it should at least use real sentences with dots and stuff. Is this really necessary?
According to UX guidelines, tables shouldn't contain too much information...
Same here, wondering if there is a better way to do this, but it's disabled by default so what... :)
Why did you remove this? This is IMHO correct and is for rendering additional stuff like hidden form fields.
Also, this change looks wrong to me, this seemed to be correctly indented? The closing ) needs to be on the same level as the $form... line.
The preferred way to have links in translated text is to embed the directly in the text just embed the url with url(). This allows to see the context of the link when translating it.
Trailing spaces.
The redirect should not point to main menu link, not the deafault local task. Meaning, without /list
Use managed_file instead of file. Then you can drop 90% of the code. The file will be automatically saved and you can work with the resulting $file object in your form submit functions. Consequently, you should work with the file id (fid) instead of the path in the image selection form. See http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html#managed_file
Should be a MENU_LOCAL_ACTION.
The path should be old/doc_page.html, without the module name. Same for everything else.
This applies but requires -p2 which is very uncommon.
Also very uncommon is having a html page for the documentation.
I assume that this sub-module does not exist anymore.
You can probably drop this part..
This should use MENU_VISIBLE_IN_BREADRUMB or maybe actually MENU_LOCAL_TASK so that you still see the other local tasks and the breadcrumb to navigate back if you want to. Same for delete.
A space too much after implements.
Also, there should be an empty line between those too.
Comment #32
nancydruI am using the diff program from Gnuwin32. If I need to use other parameters, I'll be happy to change. Currently I use "-up" because that used to be the standard. My code has Unix line endings, so the Win stuff must be coming in the diff process. The extra "module name" in the diff lines is an artifact of trying to produce a consolidated patch. I cannot keep doing a diff for each file.
And, until I learn Git, I will keep working with the -dev download (which someone else created).
The "new features" are either to solve issues in this queue, or are a result of having problems during testing and I think may be nice for adopters of the module.
The "doc_page.html" is a copy of what the "Documentation" link on the project page points to. It will not be part of the project when I can commit again.
"#header" is apparently new in D7, but I guess the Coder upgrade didn't suggest it to the guy who originally ported this code. Have you got an example of how to use it? The API doc is skimpy. Same with "#managed_file," which looks much better than hand coding that stuff.
The "Cannot be hidden" and "Does not count to limit" stuff helped me debug some issues in testing and I think can be useful to adopters. The text is the same as the form "#title" so that a single translate string can handle both instances. If I add a period, then it will take two strings, which may not be translated the same way. I don't think this is "too much information." I added the user name list also because of debugging and found it to be useful. It is disabled by default because it could result in a very large page on some sites.
"MENU_LOCAL_ACTION" - the API docs read almost the same as "MENU_LOCAL_TASK." What is the distinction? If I change it, the "Add" tab goes away - definitely not what I want.
I have no idea what the status of "User Product Badges" is. I'll worry about it when I get the core functionality stabilized.
You're the one who said that "Implements" should have two spaces. I didn't look up the standard, but it seemed awfully arbitrary. Coder doesn't seem to care either way.
Comment #33
berdirTry -N so that newly added files show up in the diff for a start :)
#header is nothing special. It's simply relying on the fact that the form API does basically ignore it due to the leading # and you can just write $form['#header'] to access it instead of having to use $form['header']['#value'].
I don't have an example at hand for file_managed, but it's not that complex. Just use that type, set the desired properties like allowed file extensions, upload directory and in the submit callback, just use file_usage_add() like you already do.
MENU_LOCAL_ACTION results in a "+ link" on top of the page and is the default for all links which add something. Have a look at admin/content or admin/people for example. And yes, this removes the tab and that's ok :)
Regarding Implements, I think that was a misunderstanding. One of your patches had two spaces already in some cases and I meant that they should be removed. Coder.module never even looks at documentation AFAIK.
Comment #34
nancydruThanks. I looked at the diff --help and missed that parameter.
Comment #35
Refineo commentedHello,
After installing the patch using the wget http://drupal.org/files/user_badges_3.zip as in comment #23
I am still getting this warning:
Notice: Undefined index: roles in user_badges_user_presave() (line 307 of /sites/all/modules/contrib/user_badges/user_badges.module).Comment #36
nancydruI know role support is a mess right now. I've been fighting with managed_file and am about to dump it and go back to not using it. Then I can get back to tackling either Git or roles.
Comment #37
berdirFeel free to post what you have and what you're stuck with. I'll try to help if I find the time.
Comment #38
nancydruThe first issue is that when it uploads the new image, it doesn't display it, but the link will. Then the other images all show "upload" rather than "remove."
Comment #39
fasdalf@fasdalf.ru commentedCould someone roll up an archive and post here current version, so i could join tests and try to fix bugs?
Comment #40
seanrRe #39, that'd be pretty helpful for me too. I'm trying to figure out exactly where this is at right now as we're going to need something like this for an upcoming D7 (from scratch) project, and this thread has gotten a tad unwieldy. ;-)
We're really just looking for basic badges based on userpoints - no roles stuff etc. Simpler the better. If there are some good alternatives, that'd be helpful as well.
Comment #41
boran commented"If there are some good alternatives, that'd be helpful as well."
I switched to the achievements module myself for D7. Its well maintained and has an interesting approach.
Comment #42
RogueM commentedfor those looking for badges assigned to roles, it is indeed not working properly currently. What I have found is that you can only assign badges to one role, with any subsequent attempt overwriting the previous, or failing altogether, with net result that only 1 role can be tagged wit ha badge.
That said it is better than nothing and in my case I was able to make use of the current code state with a combination of role and manual assignment (for the lesser roles, in manageable numbers in my case). So while not perfect, depending on your requirement 'user_badges_3.zip' is useful nonetheless in that respect.
Comment #43
computerology commentedI took a look at Achievements, however the developer has purposely made the module require coding and hooking into an API. While it's a neat module and I may use it for special things like MVP or passing qualification tests, it does not really replace the role badges as a combo of userpoints_role and user_badges.
If you are looking for something that will allow you to award images that are never taken away and have no link to continuous activity, Acheivements may work.
In the meantime, we must wait with bated breath for the role badges in user_badges to get working in D7.
Comment #44
Osuryn commentedI try to add a badge to my website, and it gives this error:
how can i solve this?
Notice: Undefined property: stdClass::$bid in user_badges_edit_form_submit() (line 367 of /home/brokendi/public_html/sites/all/modules/user_badges/user_badges.admin.inc).
PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1: INSERT INTO {user_badges_badges} (bid, name) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1_0, :db_insert_placeholder_1_image, :db_insert_placeholder_1_weight, :db_insert_placeholder_1_href, :db_insert_placeholder_1_unhideable, :db_insert_placeholder_1_fixedweight, :db_insert_placeholder_1_doesnotcounttolimit, :db_insert_placeholder_1_tid); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1_0] => test badge [:db_insert_placeholder_1_image] => public://th_Admin_badge[1].png [:db_insert_placeholder_1_weight] => 0 [:db_insert_placeholder_1_href] => [:db_insert_placeholder_1_unhideable] => 0 [:db_insert_placeholder_1_fixedweight] => 0 [:db_insert_placeholder_1_doesnotcounttolimit] => 0 [:db_insert_placeholder_1_tid] => ) in user_badges_edit_form_submit() (line 378 of /home/brokendi/public_html/sites/all/modules/user_badges/user_badges.admin.inc).
The website encountered an unexpected error. Please try again later.
Comment #45
SheilaRuth commentedIs this D7 port still being worked on? It doesn't look like there has been much activity recently, and I'm just wondering if this is still an active project. Thanks.
Comment #46
nancydruWith some luck, there will be a new -dev this evening.
Comment #47
Refineo commented@NancyDru, please let us know when we could expect the new dev release for D7 ?
Comment #48
nancydruWell, the project page shows it having been generated on 2012-Mar-18. It should include all the patches above.
Comment #49
Refineo commentedI tested the 2012-Mar-18 version of 7.x-1.x-dev today and I got this on frontpage:
on Pressflow 7 (Drupal 7.12) with apc + boost (fresh install without content)
Comment #50
Royce Kimmons commentedCreated a patch that corrects several errors in the administrative area and image displays including the following:
Cheers!
Comment #51
Royce Kimmons commentedThis patch includes the previous and also gives a header to the table on the user badge page.
Comment #52
berdirpatch (to be ported) means a patch has been commited to one major version and needs to be updated to work with another one. needs review is what you're looking for.
That said, I strongly recommend to mark this issue fixed asap (e.g. after your patch has been commited) and create separate new issues for the things you're working on. That makes it easier to write useful commit messages and you're not sending 28 notification mails every time someone comments in here ;)
Comment #53
Royce Kimmons commentedWill do, and thanks for the advice!
Comment #54
computerology commentedAny idea how much work is left for the D7 port with role badges?
Would money help to prioritize this project? I can toss some bones but I'm not rich. I need this module esp with role badges working and the ability to only show the highest ranking badge.
I have been waiting for this to be D7 ported for a year. I am fully understanding that the devs are volunteering their time so I dont intend to be brash at all, please dont take this the wrong way.
I replaced standard forum software with Drupal, and virtually every forum board software has the ability to show a "rank" badge. On my site especially being a paramilitary site everyone chomps at the bit to show off their rank. The only thing I'm missing is user badges with role badges to complete the picture.
Perhaps some flat rate price quotes, if it's above my pay grade maybe a bunch of the admins in here chomping at the bit could chip in together so we can get this puppy to a stable release?
Comment #55
cherrysuede commentedI would also donate some $$ to help move this port across the finish line :)
Comment #56
delty commentedAs would I...
Comment #57
halloffame commentedJust start testing out the dev version guys. Report problems and we deal this thing on a per-bug basis and speed up the process.
Comment #58
delty commentedFYI the patches in #50 and #51 break the application of Media > Image Styles to badges.
Comment #59
cherrysuede commentedHey guys - using latest dev and even with patch in #51
unable to save a badge assignment to a role - i get these errors (attached a screenshot)
Any suggestions?
Thanks guys!
Comment #60
cherrysuede commentedsorry attached the wrong screenshot - it's this one
Comment #61
cherrysuede commentedSorry guys - found the patch in a different - saving is now working.
And I apologize if i'm not in the right thread - finding my way around.
Comment #62
SebCorbin commentedWilling to help on this, but the patch from #51 is to apply against which version/commit?
Comment #63
SebCorbin commentedClosing this issue as it gets a bit messy. Please open another issue for each problem you may encounter.
Thanks to you all for porting the module to D7!