[whups] Using form information for validation

Alex Leverington admin@networkessence.net
Sun, 28 Oct 2001 23:25:47 -0600



I retract my question and query. I got it figured out. It's all good. A few more
changes and I will be posting a diff that will complete the backend stuff for
the Assignee form. Then I'll get some stuff for the assignment backend (user
databases, whether it uses horde, auth stuff, etc.)

-Alex


Quoting Alex Leverington <admin@networkessence.net>:

> 
> Ok...I'm trying to setup the ticket mdify page in whups so that when you
> input a
> user, there is a drop down menu that lets you select whether you are picking
> a
> username or a user email address. I have _that_ part done. Now, what I'm
> having
> a problem with is that I need the validation of the information to have
> access
> to the value of the usertype selected from the dropdown box.
> 
> Search.php:Line 121 (I think, i've changed stuff) says:
> 
> $var3 = new Variable('Assignee', 'assignee', getUserType(), true);
> 
> This means that the Assignee is verifified via getUserType().
> 
> Eventually, that leads to the UserType class defined in Forms.php. The
> validation is as below:
> 
>     function isValid(&$vars, $value, &$message) {
>         $uid = $this->backend->getUserFromEmail($value);
> 
>         if (!isset($uid)) {
>             $message = "no such user " . htmlspecialchars($value);
>             return false;
>         }
> 
> Which is ok if the person enters an email address. It's not ok if a person
> enters a username. So, now I want to change that to something like:
> 
>     function isValid(&$vars, $values, &$message) {
>         if($values['usertype']=='1')
>         $uid = $this->backend->getUserFromEmail($values['input']);
>         if($values['usertype']=='2')
>         $uid = $this->backend->getUserFromName($values['input']);
> 
>         if (!isset($uid)) {
>             $message = "no such user " . htmlspecialchars($value);
>             return false;
>         }
> 
> In essence, the problem is that I don't know how to get the $backend (up
> above)
> to use other information from the form for validation. Any ideas?
> 
> Attached is a diff of where I'm at.
> 
> -Alex
>