Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Confirm Email Address Field *MOD /w CODE*

OK, so I have had some instances where a client submits a ticket with a misspelled email address and never gets the email with the ticket ID. They then submit another ticket saying the ticket system is broken.

To fix this I have created a mod to add a confirm email address field to the open.php page and have created validation rules for it.

/* Confirm Email Address Modification
* Author: James Williams
* osTicket v1.6 RC4
* Date: 06-30-08
*/

Process for Error Checking Email Confirm Field

------- New form field -------
+ ADD Line 41 open.inc.php:
(Copy the row with the Email Address and change the names from email to confirm_email)

[HTML]


Confirm Email Address:

<?if ($thisclient && ($confirm_email=$thisclient->getEmail())) {
?>
"><?=$confirm_email?>
<?}else {?>
">
<?}?>
 * <?=$errors['confirm_email']?>


[/HTML]

------- New array_element -------
+ ADD Line 30 class.ticket.php
var $confirm_email;


+ ADD Line 820 class.ticket.php:
(This array defines which validation type rule to use when validating, if it's a required field, and what the error message should be. Just copy the email line and change email to confirm_email and edit the error message.)

$fields['confirm_email']    = array('type'=>'confirm_email',    'required'=>1, 'error'=>'Email addresses must match');


------- Add Validation Rules -------
+ ADD Line 23 class.validator.php
(This var will store the string that was entered in the Email field so that on the next loop it will be compared with the confirm_email field)

var $chk_same;


+ ADD Line 94 class.validator.php
(Copy and comment out the original case'email': All I have added is setting the $chk_same to the value of the email field. Then I created a new case statement for confirm_email that actually does the check and errors.)

case 'email':
if(!$this->is_email($this->input[$k])){ // IF NOT email format then...
$this->errors[$k]=$field['error'];
}
$chk_same = $this->input[$k];
break;
case 'confirm_email':
if(strtolower($chk_same) !== strtolower($this->input[$k])){ //Confirm EMAIL CODE & ERROR
$this->errors['confirm_email']=$field['error'];
}
break;


+ADD Line 29 include\staff\newticket.inc.php
(Staff Side error fix)
[HTML]
Confirm Email Address:

">
 * <?=$errors['confirm_email']?>

[/HTML]

There you go, you are all done! This does not do anything with the data base, merely passes along a new field for validation. If the emails match, the Email field is the only field that is recorded in the DB.

;)

Comments

  • Good idea

    Estimado,

    Cambie y agregue el codigo segun tus intrucciones pero no me funciona el verificador.
    Siempre me dice que el email "no coincide".

    he revisado varias veces el código y no encuentro el error.
    me puedes ayudar?

    Best regard

    Saludos
    BAGG
  • Using google I translated the above message to this

    Dear,

    Change and add the code according to your instructions but I do not run the verifier.
    I always said that the email "mismatch".

    I have revised the code several times and can not find the mistake.
    I can help?
    Let me look into the problem, Ill report back soon.
  • Can you tell me what version you are running. This mod is for 1.6 RC4
    Can you post your code in your class.validator.php?

    Only thing I can think of is the $chk_same var isn't getting set or compared properly. See if you can echo out the value of that var.
  • Hi
    The version using is 1.6 rc4.

    Cod:


    class Validator {

    var $input=array();
    var $fields=array();
    var $errors=array();
    var $chksame;
    .
    .
    .

    case 'fax':
    if(!$this->is_phone($this->input[$k]))
    $this->errors[$k]=$field['error'];
    break;
    case 'email':
    if(!$this->is_email($this->input[$k])){ // IF NOT email format then...
    $this->errors[$k]=$field['error'];
    }
    $chksame = $this->input[$k];
    break;
    case 'confirm':
    if(strtolower($chksame) !== strtolower($this->input[$k])){ //Confirm EMAIL CODE & ERROR
    $this->errors['confirm']=$field['error'];
    echo '$chksame';
    }
    break;
    case 'url':
    if(!$this->is_url($this->input[$k]))
    $this->errors[$k]=$field['error'];
    break;
  • sorry, now send php code.

    Code class.validator.php

    class Validator {

    var $input=array();
    var $fields=array();
    var $errors=array();
    var $chksame;





    case 'fax':
    if(!$this->is_phone($this->input[$k]))
    $this->errors[$k]=$field['error'];
    break;
    case 'email':
    if(!$this->is_email($this->input[$k])){ // IF NOT email format then...
    $this->errors[$k]=$field['error'];
    }
    $chksame = $this->input[$k];
    break;
    case 'confirm':
    if(strtolower($chksame) !== strtolower($this->input[$k])){ //Confirm EMAIL CODE & ERROR
    $this->errors['confirm']=$field['error'];
    }
    break;
    case 'url':
    if(!$this->is_url($this->input[$k]))
    $this->errors[$k]=$field['error'];
    break;

  • That looks good.

    Can you attach or email me micro3d [AT] gmail [DOT] com your open.inc.php and class.ticket.php

    Just so I can look at the full mod.

    Thank you!
  • Upon looking at your class.ticket.php file that you emailed to me:

    Line 833 is incorrect
     $fields['confirm']  = array('type'=>'email',    'required'=>1, 'error'=>'E-Mail no coincide'); 


    The type should be 'confirm'
     $fields['confirm']  = array('type'=>'confirm',    'required'=>1, 'error'=>'E-Mail no coincide'); 


    This will use the new validation rule we made in class.validator.php

    Try that, then get back to me.
  • Also

    on lines 830 to 838 of class.ticket.php

    $id=0;
    $fields=array();
    $fields['name'] = array('type'=>'string', 'required'=>1, 'error'=>'Nombre requerido');
    $fields['confirm'] = array('type'=>'confirm', 'required'=>1, 'error'=>'E-Mail no coincide');
    $fields['newvar'] = array('type'=>'string', 'required'=>1, 'error'=>'Nombre de Empresa requerido');
    $fields['numclien'] = array('type'=>'string', 'required'=>1, 'error'=>'Numero de cliente es requerido');
    $fields['email'] = array('type'=>'email', 'required'=>1, 'error'=>'E-mail requerido');
    $fields['subject'] = array('type'=>'string', 'required'=>1, 'error'=>'Asunto requerido');
    $fields['message'] = array('type'=>'text', 'required'=>1, 'error'=>'Mensaje requerido');


    Switch the places of the
    $fields['confirm']  = array('type'=>'confirm',    'required'=>1, 'error'=>'E-Mail no coincide');

    and
    $fields['email']    = array('type'=>'email',    'required'=>1, 'error'=>'E-mail requerido');



    So it should look like this:

    $id=0;
    $fields=array();
    $fields['name'] = array('type'=>'string', 'required'=>1, 'error'=>'Nombre requerido');
    $fields['email'] = array('type'=>'email', 'required'=>1, 'error'=>'E-mail requerido');
    $fields['newvar'] = array('type'=>'string', 'required'=>1, 'error'=>'Nombre de Empresa requerido');
    $fields['numclien'] = array('type'=>'string', 'required'=>1, 'error'=>'Numero de cliente es requerido');
    $fields['confirm'] = array('type'=>'confirm', 'required'=>1, 'error'=>'E-Mail no coincide');
    $fields['subject'] = array('type'=>'string', 'required'=>1, 'error'=>'Asunto requerido');
    $fields['message'] = array('type'=>'text', 'required'=>1, 'error'=>'Mensaje requerido');

    I think it is trying to validate the confirm field first, which will cause an error as $chksame will not be set until $fields['email'] is validated.
  • I have tried this MOD but the email is not validated, I am using RC5, is there somewhere else I need add some code to ensure the email field is checked?

    Kind regards
  • Maybe I should ask the question a different way..

    Did this mod ever work correctly with RC4?
    If yes, has anybody upgrade to RC5 and managed to get this MOD to work?

    Kind regards

    Sean
  • Sorted

    I have resolved this issue
  • Minor Bug Fix

    There is one other change that needs to be done for this MOD to work 100% OK.

    If you are "sucking" emails from a POP/IMAP account, they will all fail the validation for the confirm_email since the field is never populated for new emails being turned into tickets. To fix this:

    In class.mailfetch.php:

    Look for (around line 230 in 1.6ST):

    $var['email']=$mailinfo['from']['email'];


    Under that line add:

            // set confirm email to the same thing since we are getting this from email anyway
    $var['confirm_email']=$mailinfo['from']['email'];


    This will fill in the confirm_email address with the same email and so it passes validation.

    Mark
  • I just installed this 1.6 and this is not showing an error. Has anyone have this working for the latest version and is there a better solution?
  • Is it possible to use this feature without the mod on 1.9.6 using custom fields?
  • Not that I know of, but then this was written for 1.6 which is like 5 years old?
This discussion has been closed.