Hi,

I worked on uc_order.ca.inc to add some conditions about the user. Here is the list of added conditions :

  • Conditions on user UID
  • Conditions on user name
  • Conditions on user email
  • Conditions on user creation date
  • Conditions on user login date
  • Conditions on user prefered language settings
  • Conditions on user roles

The user I'm talking about is the user associated to an order. If $order->uid exists, it load this user, if not, it load the current user. (As the user is not known on the checkout page, this is the current user to load).

Here is the patch, applied on the latest 6.x dev found on drupal.org

Comments

cha0s’s picture

StatusFileSize
new10.62 KB

I cleaned up your patch a little bit... mostly coding standards stuff, but I also added some of the $user security stuff.

Thanks for the patch!

Island Usurper’s picture

Status: Needs review » Needs work

Doing $account->created % 86400 just gives us the number of seconds since midnight of that day. I think we need to do

  $user_created = $account->created - ($account->created % 86400);

Otherwise, we're only going to be comparing against different times during Jan. 1, 1970. I think we also need to use gmmktime() on the settings data since the timestamp above is zeroed to midnight GMT.

For the uid condition, is it actually useful to check that someone's uid is greater than a particular number? The equality checks are good, but I don't see why someone would use the inequality checks.

Looks good otherwise.

zmove’s picture

Hi,

We don't have to be so limitative about the functionnalities. Even if you don't see what could be the interest to allow greater than option to the uid, it's an integer, we can easily add a greater than, lesser than condition on an integer, so this should be available.

For example to create a discount for 1000 first created account...

cha0s’s picture

Assigned: Unassigned » cha0s
Status: Needs work » Needs review
StatusFileSize
new10.7 KB

Incorporated the fix proposed by Lyle.

cha0s’s picture

StatusFileSize
new10.78 KB

Hmm, spoke too soon :) Reviewing the patch again, I find that there was a similar mistake in the user login time logic. New patch follows.

Island Usurper’s picture

Status: Needs review » Needs work
StatusFileSize
new9.72 KB

I've cleaned up the descriptions on the conditions so that they're more descriptive and better English. I also saw that the creation and login conditions were mixing up the month and day.

Even with those fixes, I think there are improvements to be made. Instead of checking a single name, I think that condition could use an autocomplete field like the user search page. This lets you have more than one name in the condition, and you don't need to figure out the uids, either. That would take care of the need for the uid condition, then.

rszrama’s picture

Issue tags: +CA
rszrama’s picture

Issue tags: +VAT
Island Usurper’s picture

Status: Needs work » Fixed
StatusFileSize
new9.96 KB

Cleaned up a few more of the option descriptions, and fixed the roles conditions so it actually works as advertised.

Committed. Thanks, guys.

Status: Fixed » Closed (fixed)
Issue tags: -CA, -VAT

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