1 reply [Last post]
hinrichsislcocom's picture
Offline
Bug Finder
Joined: 05/28/2008
Juice: 92
Was this information Helpful?

The message should be adjusted on role grant upon purchase. If the role is set to never expire, the message appears as:

"counselor-bob has been granted the assessment access role. It will expire on 12/31/1969 - 17:00."

Perhaps a conditional should be put in there to make a more appropriate message for non-expiring roles.

The code in question is line 1204 of uc_roles.module, in function uc_roles_grant.

Suggested change:

Index: /ubercart/uc_roles/uc_roles.module
===================================================================

diff -u -r1.2 uc_roles.module
--- ubercart/uc_roles/uc_roles.module 29 Oct 2008 18:42:06 -0000 1.2
+++ ubercart/uc_roles/uc_roles.module 31 Oct 2008 21:11:28 -0000
@@ -1195,13 +1195,14 @@
// If the role expires, keep a record.
if (!is_null($timestamp)) {
db_query("INSERT INTO {uc_roles_expirations} (uid, rid, expiration) VALUES (%d, %d, %d)", $user->uid, $rid, $timestamp);
+ $expiration_message = t('It will expire on %date.', array('%date' => format_date($timestamp, 'small')));
}

// Flush visible menu items, since our permissions could've changed.
_uc_roles_flush_menu_cache($user);

$role_name = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $rid));
- drupal_set_message(t('%user has been granted the %role role. It will expire on %date.', array('%user' => $user->name, '%role' => $role_name, '%date' => format_date($timestamp, 'small'))));
+ drupal_set_message(t('%user has been granted the %role role.', array('%user' => $user->name, '%role' => $role_name, '%date' => format_date($timestamp, 'small'))).' '.$expiration_message);
}

/**

Bob Hinrichs
ISL Consulting
http://www.islco.com

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: 6.x-2.x-dev: Role assignment on purchase; inappropriate mess

I'll make sure cha0s sees this one... he's actually reworked that module for the 2.x version, so I wouldn't be surprised if he fixed it. For future bug reports for the 2.x-dev, please use the Ubercart issue tracker on drupal.org. Smiling

Somewhat related... I'm sure he'd appreciate an extra set of eyes on the code: http://www.ubercart.org/contrib/6994