Hi. I'd like to use the real name of a person assigned to a task, instead of uid in links and views.

I am trying to use the http://drupal.org/project/token_profile module, which can pick up any profile fields that are setup via admin/user/profile.

Please has anyone done anything similar, or has advice on the best way to do this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zeezhao’s picture

By the way, I also tried editing the casetracker_assignee_options view to return the fullname instead of username, but for some reason did not seem to work even after clearing cache...

zeezhao’s picture

For now, decided to override the user link with my own based on real name, in template.php via phptemplate_casetracker_case_summary().

Then in views, used http://drupal.org/project/views_customfield module which allows a custom php field to be added to views.

dagmar’s picture

Status: Active » Fixed

Case Tracker 6.x-1.0-beta8 includes the user assigned to as a view relationship. So, you can load the user profile by including this relationship in the view.

Even more, the view provided by casetracker is now using this method, so, you just have to revert the view from the views ui and the relationship will be automatically added. Views customfield is not necessary in this case.

zeezhao’s picture

Thanks for the info. Had to do it that way for now, as i have some additional complications. Will come back to it again.

In any case, just found this: http://drupal.org/project/realname

edit:
Tried this out. If setup properly, will automatically replace name with real name.

For token, will need to overide in casetracker.token.inc:
$values['case_assign_to'] = theme('username', $assignedUser, array('plain' => TRUE));

zeezhao’s picture

The only oustanding thing is the dropdown userlist which still shows username even though I changed the casetracker_assignee_options view.

In summary, the realname module works very well, except for this.

Status: Fixed » Closed (fixed)

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

SophieG’s picture

Status: Closed (fixed) » Active

Hi,

i am using casetracker beta8 and i don't see this working with realnames ?
Could you tell me how you managed to do this ?

Thanks !!

zeezhao’s picture

- make sure you have a field setup via admin/user/profile for holding the fullname

- install the realname module & associate that field via: admin/user/realname

- make fix for token, will need to overide in casetracker.token.inc:
$values['case_assign_to'] = theme('username', $assignedUser, array('plain' => TRUE));

- "recalculate names" using the menu via: admin/user/realname

As per my comments above in #5, realname will display in all views etc. The only oustanding thing is the username drop-down menu when editing a case. Not sure why that piece did not work and ran out of time...

SophieG’s picture

Thanks !

One last question : to overide casetracker.tocken.inc how do you proceed ?

Thanks

zeezhao’s picture

For now, simply replace line in casetracker.token.inc.

Eventually, the line should be replaced in dev code in CVS. Or else change will be lost...

i.e.

    //$values['case_assign_to'] = $assignedUser->name; //old line commented out and replaced by one below
    $values['case_assign_to'] = theme('username', $assignedUser, array('plain' => TRUE));
Grayside’s picture

If you generate a patch for the token override and set this issue to Needs Review, I will review it for you. That's the kind of thing that should simply be how the token integration works.

charles.holtzkampf’s picture

FileSize
23.7 KB

Hi All,

Ive done all the above and I still only get the username. Not sure what im doing wrong, if anyone can offer advice, I would be really greatfull.

I've attached a screenshot of my realname setup.

SophieG’s picture

Hi again,

i have made the change in the token inc file, but nothing is changing...
Any idea why ?

Thanks

i have cleared the cache....

zeezhao’s picture

If you've done all in #8, the only other thing I did is to override in template.php in your theme directory:

/**
 * Theme the case summary shown at the beginning of a case's node.
 *
 * @param $case
 *   The node object of the case being viewed.
 * @param $project
 *   The node object of the project this case belongs to.
 */
function phptemplate_casetracker_case_summary($case, $project) {
  $last_comment = db_result(db_query('SELECT last_comment_timestamp FROM {node_comment_statistics} WHERE nid = %d', $case->nid));
  $rows = array();

  // On node preview the form logic can't translate assign_to back to a uid for
  // us so we need to be able handle it either way.
  if (is_numeric($case->casetracker->assign_to)) {
    $assign_to = user_load(array('uid' => $case->casetracker->assign_to));
  }
  else {
    $assign_to = user_load(array('name' => $case->casetracker->assign_to));
  }

  if (empty($assign_to) || $assign_to->uid == 0) {
    $rows[] = array(
      t('Assigned to:'),
      '<em>' . t('Unassigned')  . '</em>',
    );
  }
  else {
    $rows[] = array(
      t('Assigned to:'),
      theme('username', $assign_to),
    );
  }
  $rows[] = array(
    t('Created:'),
    t('!username at !date', array('!username' => theme('username', $case), '!date' => format_date($case->created, 'medium'))),
  );
  $rows[] = array(
    t('Status:'),
    t('<strong>@status</strong>', array(
      '@status' => casetracker_case_state_load($case->casetracker->case_status_id, 'status'),
    )),
  );

  // On node preview a case may not have a nid, so we use some placeholder text.
  $case_id = isset($case->nid) ? $case->nid : t("NEW");
  $rows[] = array(
    t('Case ID:'),
    $case_id,
  );
  if ($last_comment != $case->created) {
    $rows[] = array(
      t('Last modified:'),
      format_date($last_comment, 'medium')
    );
  }

  $output  = '<div class="case">';
  $output .= theme('table', NULL, $rows, array('class' => 'summary'));
  $output .= '</div>';
  return $output;
}

You can amend to suit your preference. This will enable realname on summary of case.

As mentioned, I could not get the dropdown to work. But I do not use it anyway, as I hide it from users since allocation of cases in my system is rules driven. So I have another dropdown using a view, and real names works for that.

charles.holtzkampf’s picture

thanks zeezhao, its really appreciated that you help us non php folk like this :)

If you have the time, would you mind pointing me in the right direction to for the following:

I would like to remove the Group Selection List, as I use organic groups and I dont want users to be able to choose which OG node to set as the project.

I assume that I can somehow remove some elements from casetracker.module so that its not displayed ?

thanks again

zeezhao’s picture

Did my suggestion work for you?

Ideally, for your new question you should open another support request... I've not used OG myself so can't really say. But in general, you can try using:

http://drupal.org/project/formfilter [can be used to hide fields when in edit mode]

or

you'll have to write a hook_form_alter() -- find details on: http://api.drupal.org/

charles.holtzkampf’s picture

Hi Zeehao,

thanks I will give that go, im afraid it still doesn;t work. But Let me get back to you, as I was not on the latest OG. I will confirm later.

thanks again

SophieG’s picture

yes i can confirm it is not working for me either...
And i don't know why now i have the title of my projects remplaced by the name of the author, but only when i am on the project page, not when it is displayed using views in tables...

Any idea why ?

Thanks

aaron1234nz’s picture

FileSize
1.47 KB

I couldn't get this to work but I did find that I could patch the casetracker.module with a few simple change to enable it to work fully with the realname module.
The one caveat with this is that if two people exist in the database with the same realname, its possible that cases can be assigned to the wrong person. This is unavoidable unless further changes are made to casetracker so that users are always identified by their uid rather than username.

Grayside’s picture

You should assign cases to uid or username, but show realname in the forms and case info. Differentiating users could be done ala Node Reference/Book references, changing the assignment form to read options like Bob Villa [uid: 31].

Dimas_’s picture

The patch doesn't work for me. The select of users doesn't work: it shows the names instead the usernames (that's ok) but when I save the task is Unassigned.