Support from Acquia helps fund testing for Drupal Acquia logo

Comments

trillex’s picture

I second this request.

Miria’s picture

I would like this very much!
Used this for 6 and loved it; was hard to let go of it when I upgraded to D7.

keltic’s picture

Subscribe

JustMagicMaria’s picture

Subscribe

boran’s picture

+1

ConradFlashback’s picture

sub++

BeaPower’s picture

sub

Spitfire’s picture

/second

graker’s picture

FileSize
20.3 KB

Hey guys.

It seems that I ported User Titles module to D7. No contribs though, but they seem to be easy since they are all less than 1 KB of code (only 1 function in each).

Also I didn't test titles with images because I had no need in images for user titles. But the code which supports images is ported as well, so if any bugs or problems, post it here, I could possibly take a look.

The ported module is attached to this message. It has off course "dev" in its version because it should be tested by community.

boran’s picture

@graker: I had a quick go.
Good: it installed fine. It was on a site upgraded form D7 and I could see the previously defined title.
I only used text titles, so the lack of images does not concern me.
Issues:
Userpoints method not supported?
Move the Config menu under configuration people?
When viewing my profile: Warning: Parameter 1 to user_titles_user_view() expected to be a reference, value given in module_invoke_all() (line 819 of /disk2/www/drupal-7.8/includes/module.inc).

Maybe get the sources into git?

graker’s picture

On userpoints - nope, as I said, I didn't port any contribs and it is a contrib.
On moving to config menu - good point, will do it (when I get to the module again, could be couple of days).
On warning - can't reproduce it on my server, I don't see any warnings. Also I checked the code and parameter 1 to user_titles_user_view() is actually a reference.

On moving to git - it isn't really my intention to be a maintainer for the module. I actually hoped that the actual maintainer could do something with my port, or somebody else. Just wanted to share it with the community.

boran’s picture

FileSize
1.07 KB

a) Git: Understood.

b) I'm attaching a first port of contrib/ut_userpoints, in case it interest others.

c) View profile: Its better without the "&", since presumably one cannot change the user object:
//function user_titles_user_view(&$user) {
function user_titles_user_view($user) {

d) When saving the settings form I get:
Duplicate entry '3' for key 'PRIMARY': INSERT INTO {user_titles_roles} (rid, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 3 [:db_insert_placeholder_1] => 0 ) in user_titles_settings_form_submit() (line 159 of /disk2/www/drupal-7.8/sites/all/modules/custom/user_titles/user_titles.admin.inc

As if there was an error in this code, but I dont see it:
$updated = db_update('user_titles_roles')
->fields(array(
'weight' => $role['weight'],
)
)
->condition('rid', $rid)
->execute();

If I complete un-install and thus wipe the ut tables and recreate, this error does not happen. But of course I'd like to preserve the existing data :-)

graker’s picture

c) Oh, i see now. For some reason I thought that $account should go as a reference, but now I checked with API hook_user_view description and it actually shouldn't :) Will fix this.

d) It's weird, if it points to db_update() call, then it shouldn't generate INSERT query. Gotta look through somehow, though I don't have previous installations of 6.x version of user titles to upgrade from.

graker’s picture

FileSize
21.59 KB

Attaching new version.
Changes:
- fixed reference (&) bug in hook_user_view() implementation;
- module settings moved to configuration->people category;
- added boran's ut_userpoints contrib module to the archive.

Couldn't fix the issue with INSERT query error on line 159. Maybe it could be easier to write some kind of migration script or use a DB save/restore when installing new module.

likewhoa’s picture

Status: Active » Needs work
FileSize
105.83 KB

Attached patch will apply against the 6.x-1x-dev branch from git and will install on drupal 7 but on install I encounter some notices.

Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 250 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 255 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 250 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 255 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 250 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 255 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 250 of sites/all/modules/user_titles/user_titles.module).
    Notice: Use of undefined constant BLOCK_CACHE_PER_USER - assumed 'BLOCK_CACHE_PER_USER' in user_titles_block_info() (line 255 of sites/all/modules/user_titles/user_titles.module).

& then after going to admin/config/people/user-titles this fatal error occurred

Notice: Undefined variable: form_values in user_titles_settings_form_submit() (line 126 of sites/all/modules/user_titles/user_titles.admin.inc).
    Error creating directory
    PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2' for key 'PRIMARY': INSERT INTO {user_titles_roles} (rid, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => -10 ) in user_titles_settings_form_submit() (line 159 of sites/all/modules/user_titles/user_titles.admin.inc).

obviously this patch needs more work. I'll leave this here for now. Anyways, thanks graker for your contribution.

boran’s picture

Er, why apply against the 6.x-1x-dev branch?
Why not create a 7.x-1x-dev, checkin #, an change the version on this issue
... and we can work on it from there, directly pulling from git?

For the BLOCK warnings, found a fix:
http://drupal.org/node/224333#block_cache-constancts

function user_titles_block_info() {
..
//'cache' => BLOCK_CACHE_PER_USER,
'cache' => DRUPAL_CACHE_PER_USER,
...
//'cache' => BLOCK_CACHE_PER_USER,
'cache' => DRUPAL_CACHE_PER_USER,

likewhoa’s picture

@boran the maintainers need to do this new branch in order for us to pull straight from git instead of applying a difference on 6.x-1.x-dev ;) Once we get the community to test this patch and fix all bugs then we can request or a maintainer can go ahead and create this 7.x-1.x-dev branch ;)

gcybill’s picture

Are there maintainer around? -subscribe-

ssace’s picture

subscribing

Michelle’s picture

@ssace: No need to announce to us that you are subscribing. Just click the button.

jramby’s picture

++

likewhoa’s picture

@maintainers I like to have commit access so I can push this D7 code into a -dev release so we can finally move forward and not have to patch from D6 version.

andypost’s picture

@likewhoa Pleasee follow this to take over maintainership http://drupal.org/node/251466

andypost’s picture

I think this module should join forces with http://drupal.org/project/user_badges

Michelle’s picture

User Titles and User Badges do two different things. Many sites only want titles, not badges. They should only merge if there is a good reason for it.

Killpill’s picture

Component: Miscellaneous » Code
Issue tags: -d7 ports ++patch
FileSize
19.83 KB

I don't know where this went but I fixed the variable and duplicate entry error. The patch also has the constant fix mentioned below. I'm new to this, so I don't know what to do, but it seems the code works.

Notice: Undefined variable: form_values in user_titles_settings_form_submit() (line 126 of sites/all/modules/user_titles/user_titles.admin.inc).

I changed $form_values to $form_status['values']. This I am not sure on.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2' for key 'PRIMARY': INSERT INTO {user_titles_roles} (rid, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => -10 ) in user_titles_settings_form_submit() (line 159 of sites/all/modules/user_titles/user_titles.admin.inc).

This was caused because the db_update would return false if there was nothing to update. I fixed this by doing this instead:

// Role orders
  foreach ($form_state['values']['roles'] as $rid => $role) {
  	
		$select = db_select('user_titles_roles', 'weight')
			->fields('weight')
			->condition('rid', $rid)
			->execute();
		
		if ($select) {
			if ($select->fetchAssoc() != $role['weight']) { //check if we even need to update
				db_update('user_titles_roles')
					->fields(array('weight' => $role['weight'],))
					->condition('rid', $rid)
					->execute();
			}
		}else{
			db_insert('user_titles_roles')
        ->fields(array(
          'rid' => $rid,
          'weight' => $role['weight'],
        )
      )
      ->execute();
		}
  }

Edit: I, of course, removed a tag by mistake. New to this.

Killpill’s picture

Issue tags: +D7 port patch
Killpill’s picture

Status: Needs work » Patch (to be ported)
FileSize
19.91 KB

Updated again.

Changed a lot. Images work now. I had to add 'public://' in front of the variable_get('user_titles_image_dir', DEFAULT_IMAGE_DIR) stuff. It was creating the directory in the base path of the site before then, which was invalid.

The add title form works now. The validator code assumed the $title variable was an object. It is an array, so I fixed that.

I also added this:

if ((!isset($form['values']['tid'])) || ($title['tid'] != $form_state['values']['tid'])) {

The isset stops the error about $form['values']['tid'] not existing and makes sure the validation of role names and post numbers is down for new titles.

/config/people/user-titles/titles looks REALLY funky to me. It gets better as you add titles though.

I don't know how to really create a patch or anything but I uploaded my changes.

Can someone who knows what to do create a branch for 7.x and get this moving again?

Killpill’s picture

My if statement for the validator was messed up and caused you to not be able to edit existing titles.

if ((!isset($form['tid']['#value'])) || ($title['tid'] != $form['tid']['#value'])) {

I feel like I'm cheating when I do "$form['tid']['#value']" but it works, it seems.

andypost’s picture

Status: Patch (to be ported) » Needs work
Issue tags: -D7 port patch, -+patch +D7 porting

@Killpill please provide a patch not a single file

// $Id: user_titles.admin.inc,v 1.1.2.1 2010/02/02 11:20:15 agileware Exp $

Is there any other files?
$Id$ placeholder should be removed, git does not use it

Oleksa-1’s picture

up

shane1090’s picture

Just recently came across a problem with this D7 port that is causing issues when trying to delete posts. It seems to ignore the fact that there is already an entry in the {user_titles_posts} table and try to insert a new record, causing the following error for when trying to delete a comment:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '16' for key 'PRIMARY': INSERT INTO {user_titles_posts} (uid, posts) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 16 [:db_insert_placeholder_1] => 438 ) in user_titles_comment_delete() (line 443 of \sites\all\modules\user_titles\user_titles.module).

and the following when trying to delete nodes:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9' for key 'PRIMARY': INSERT INTO {user_titles_posts} (uid, posts) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 9 [:db_insert_placeholder_1] => 353 ) in user_titles_node_delete() (line 205 of \sites\all\modules\user_titles\user_titles.module).

It seems very strange - I tried adding a watchdog command before the $updated check, and for some reason its never run. Sometimes this error occurs, and sometimes it works fine. Seems very strange!

svarco’s picture

Could still no one take maintainership of the project? :-(

OFF’s picture

Issue summary: View changes

Project is died!