Tuesday, May 02, 2006

Modifying the registration component II

Control flows from registration.php to registration.html.php, from the data layer to the presentation layer.

registration.php just has functions, no classes.
registration.html.php has one big class in it called HTML_registration.

The main switch statement in registration.php calls registerForm below.

The data layer function registerForm calls the presentation layer function registerForm: HTML_registration::registerForm($option, $useractivation);

Control then passes to the validation if-statement that I'm modifying.

If I define the function subscriber_exists() and the constant _REGWARN_SUBSCRIBER in registration.php it should be available inside the class HTML_registration?

registration.php:


function registerForm( $option, $useractivation ) {
    global $mainframe;
    
    if (!$mainframe->getCfg( 'allowUserRegistration' )) {
        mosNotAuth();
        return;
    }
    
    $mainframe->SetPageTitle(_REGISTER_TITLE);
    
    HTML_registration::registerForm($option, $useractivation);
}



registration.html.php:


function registerForm($option, $useractivation) {
    ?>
    function submitbutton() {
        var form = document.mosForm;
        var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
        
        // do field validation
        if (subscriber_exists(form.subscriberid.value)) {
            alert( "<?php echo html_entity_decode(_REGWARN_SUBSCRIBER);?>" );
            } else if (form.name.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_NAME);?>" );
            } else if (form.username.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_UNAME);?>" );
            } else if (r.exec(form.username.value) || form.username.value.length < 3) {
            alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_PROMPT_UNAME), 2 );?>" );
            } else if (form.email.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_MAIL);?>" );
            } else if (form.password.value.length < 6) {
            alert( "<?php echo html_entity_decode(_REGWARN_PASS);?>" );
            } else if (form.password2.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_VPASS1);?>" );
            } else if ((form.password.value != "") && (form.password.value != form.password2.value)){
            alert( "<?php echo html_entity_decode(_REGWARN_VPASS2);?>" );
            } else if (r.exec(form.password.value)) {
            alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_REGISTER_PASS), 6 );?>" );
            } else {
            form.submit();
        }
    }

0 Comments:

Post a Comment

<< Home