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
Comment #1
cha0s commentedI 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!
Comment #2
Island Usurper commentedDoing $account->created % 86400 just gives us the number of seconds since midnight of that day. I think we need to do
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.
Comment #3
zmove commentedHi,
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...
Comment #4
cha0s commentedIncorporated the fix proposed by Lyle.
Comment #5
cha0s commentedHmm, spoke too soon :) Reviewing the patch again, I find that there was a similar mistake in the user login time logic. New patch follows.
Comment #6
Island Usurper commentedI'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.
Comment #7
rszrama commentedComment #8
rszrama commentedComment #9
Island Usurper commentedCleaned up a few more of the option descriptions, and fixed the roles conditions so it actually works as advertised.
Committed. Thanks, guys.