I'm watching a demo of the Commerce File module, and we noticed that the license duration options are quite limited by the available options in the dropdown. What I'd recommend instead is to keep your unlimited option as the default, but instead of using the select list to choose a specific duration (0 seconds, for example ; ), use it to select a unit of time measurement (e.g. seconds, minutes, hours, weeks, days, and years). Then either show or enable a disabled textfield where you put in the actual number of that unit (defaulted to 1).
You're then not limited in any selection, able to specify any possible duration instead of just the options that you put in the list or alter in there. I'm assuming the data is ultimately stored as the number of seconds (I haven't looked, maybe you're just using strtotime() with relative time strings when you create the license... that's probably smarter, so I'll actually assume you do this : ), so it should be easy enough to translate the values of those two fields into the saved value. Depending on the way you're storing this data, it may not even need an update path. : )
Does the end goal make sense? It's the approach I took for time limited product features in Ubercart and gives much greater flexibility if we can get the UI right. May have to run that by Allison. : P
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | commerce_file-access-limit-duration.png | 19.63 KB | recrit |
Comments
Comment #1
recrit commentedit's stored as seconds and then used to calculate the expiration of the license on creation.
The 2 step approach makes sense to me. The only real reason that I did not do it initially was to keep the UI simple so I could focus on the rest of the module.
Comment #2
rszrama commentedYep, no worries! And either seconds or stringtotime() work fine - so you'd just have to do the seconds math when setting the dropdown value.
Comment #3
recrit commentedCommit duration updates per http://drupalcode.org/project/commerce_file.git/commit/6562af0.
See attached image for new duration input.