Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Custom Validation on Additional Profile Inputs

Aloittaja utroda, helmikuu 07, 2014, 01:46:04 IP

« edellinen - seuraava »

utroda

I created a new additional profile input, that just an input that can take a text string, but I need the ability to make sure users can only update this field once in 24 hours. I see that i can write regex for string validation but where would i go about writing a validation method to make sure an input can only be updated within x amount of hours?

margarett

That should be something very hard to achieve...

The way the fields are stored is not compatible with any kind of "time-based" checking... I can't really imagine an easy way to do it without substantially change the current codebase...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

utroda

Well, can't i just like loop the array of custom fields on profile save, find the one that matches, then check last updated time, if not return the user to the profile with an error?

I'm sure how the form data is saved currently.

margarett

How it works, you can find explanation here:
http://www.simplemachines.org/community/index.php?topic=518203.msg3666696#msg3666696

And there you can see that there is no real way to get the last modified time...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

utroda

what if i created a new table that stored that information and checked against that?

margarett

Yup, that's a thought.
You need to basically duplicate the "themes" table structure, with an extra column to store the modified time, because it has no single "ID" like others

Lainaus käyttäjältä: margarett - helmikuu 07, 2014, 01:51:42 IP
That should be something very hard to achieve...
See what I mean? :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

utroda

You would think by default that you would have a last updated time for anything that a user can change.

Arantor

You would think that storing that for the hundreds of possible values that a user can update, it would get very inefficient to store the last-updated time as well.
Holder of controversial views, all of which my own.


Advertisement: