85 Posts
kromoadv
11 years ago
10
Topic

Hi everibody,

i have a field (text) in user content type in wich the new users, while registering, have to put a promotional code.

Now the problem is... i have 10.000 codes in a separate table and i need a double validation on this field:

1) if the code is in the separate table is valid... else not.

2) if the code is already stored in the user table cannot longer be used.


How can i achive this?

Thx in advance.

Get a Book for SEBLOD
85 Posts
kromoadv
11 years ago
0
Level 1

Hi,

any suggestion, please?

Thanks in advance.

Regards,

Luca

11 years ago
0
Level 1

Hi kromoadv,

Thank you for your post.

You have natively with seblod, a validation plugin for your second need. This plugin is called "Ajax Availability".

I don't understand well your first need.

In any case, if you want to have two simultaneous checks, we must develop a new validation plugin.

If you're a developer, we can help you. Otherwise, we can do that for you. We propose several options to address this type of need.

Regards,
Mehdi.

85 Posts
kromoadv
11 years ago
3
Level 1

Hi Mehdi,

thanks for your answer.

Yes i saw the Ajax availability plugin and it's perfect for my second need.

My first need is very simple. I just want the user to not enter an invalid code in the field.

As i said i have to store 10.000 promotional codes in a table and the code submitted by the user must match one of the stored ones.

It's kinda strange, but it seems i need a "non availability" plugin...

So maybe i'll try to modify the Ajax Availability plugin and apply it on a second field.

Any suggestion would be very appreciated.

Thank you.

Regards,

Luca

10 years ago
2
Level 2
Hi kromoadv,

Can you tell me please if you founded a solution for your problem?
I just looking for same validation tips that you asked before. Did you solve your first need?


Thank you!
85 Posts
kromoadv
10 years ago
1
Level 3
Hello Soft M,
we decided to create a component from scratch.
There were other issues that made us decide for this solution.

Regards
Luca
10 years ago
0
Level 4
Hi kromodav,

Thanks for your reply.


Regards
Sofia
10 years ago
3
Level 1
if you need a mask - you can try this http://www.seblod.pro/downloads/212-input-mask

maybe also you can create hack for plugin in ajax_availability.php, somewhere in this function...
	// _check
	protected static function _check( $validation, $value, $config, $and = '' )
	{
		if ( $config['pk'] > 0 ) {
			$count	=	(int)JCckDatabase::loadResult( 'SELECT '.$validation->key.' FROM '.$validation->table
					.	' WHERE '.$validation->column.' = "'.JCckDatabase::escape( $value ).'"'.$and );
			if ( $count > 0 && $count != $config['pk'] ) {
				$error	=	true;
			}
		} else {
			$count	=	(int)JCckDatabase::loadResult( 'SELECT COUNT('.$validation->column.') FROM '.$validation->table
					.	' WHERE '.$validation->column.' = "'.JCckDatabase::escape( $value ).'"'.$and );
			if ( $count > 0 ) {
				$error	=	true;
			}
		}


		return $error;
	}
10 years ago
2
Level 2
and change language file....
if ( $count == 0 && $count != $config['pk'] )
.....
if ( $count == 0 )
9 years ago
1
Level 3

Hello friends. I have found file ajax_availabilty.php and have changed parameteres, as You wrote, but nothing works. It still shows availability, if it can't find coincidence. I also need feature, when Availabilty should check, if there is entered id, login or anything else in database, and if it exists, then allow to use it. 

Can someone help with that? Thank you.

9 years ago
0
Level 4

I have found solution. I just needed to do the same fix in file script.php witch is located in ajax_avalability/assets/ajax

Kind regards

Get a Book for SEBLOD