Download & Extend

Expiration display on user profile not obeying setting

Project:Ubercart
Version:6.x-2.0
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

I'm using uc role assignment, and after setting "Show expirations on user page" to TRUE on product features setting page and then setting it to FALSE (i.e., unchecking the box), the role expirations are still showing up on the user profile page. I checked the database and it looks like the variable is being recorded to the variable table correctly, so then I checked the code and discovered what I believe is a conditional logic error. Around line 448 is this code:

if (!user_access('view all role expirations') && ($user->uid != $account->uid || !$show_expiration)) {

This seems to be making it so the role expirations show up on the user profile page regardless of what the setting is. To correct it, I just added an extra condition after this line of:

if ($show_expiration) {

And that fixed it. That may not be the best solution, though, and the logic could probably just be incorporated into the first conditional statement.

Comments

#1

Status:active» closed (works as designed)

That conditional is awkward, but it does exactly what the comment says it does. If the user has 'view all role expirations' permission, then the user will always see the role expiration. Otherwise, the user will see the role expiration if and only if $user->uid == $account->uid and $show_expiration == TRUE.

This:

  $show_expiration = variable_get('uc_roles_default_show_expiration', TRUE);
  if (!user_access('view all role expirations') && ($user->uid != $account->uid || !$show_expiration)) {
    return;
  }

Is exactly the same as this:
  $show_expiration = variable_get('uc_roles_default_show_expiration', TRUE);
  if (user_access('view all role expirations') ||
      ($user->uid == $account->uid && $show_expiration) ) {
    // Continue on with this function and show the expiration.
  }
  else {
    // Don't show the expiration, return instead.
    return;
  }

#3

spam clean-up (excuse the noise)