Commit 1d9bab25 authored by jonnybradley's avatar jonnybradley

[FIX] socialnetworks: Restore validation on registration form for...

[FIX] socialnetworks: Restore validation on registration form for socialnetworks_firstlogin (lost since Tiki 6 xajax removal i think, required refactoring the validation js into registrationlib) Also removed some bad CSS
parent 5a1b9519
......@@ -544,6 +544,94 @@ class RegistrationLib extends TikiLib
return $result;
}
/**
* Adds jquery validation javascript to the page to validate the registration form inputs
*/
public function addRegistrationFormValidationJs()
{
global $prefs, $user;
if ($prefs['feature_jquery_validation'] === 'y') {
$js_m = '';
$js = '
$("form[name=RegForm]").validate({
rules: {
name: {
required: true,';
if ($prefs['login_is_email'] === 'y') {
$js .= '
email: true,';
}
$js .= '
remote: {
url: "validate-ajax.php",
type: "post",
data: {
validator: "username",
input: function() { return $("#name").val(); }
}
}
},
email: {
required: true,
email: true
},
pass: {
required: true,
remote: {
url: "validate-ajax.php",
type: "post",
data: {
validator: "password",
input: function() { return $("#pass1").val(); }
}
}
},
passAgain: { equalTo: "#pass1" }';
if ($prefs['user_must_choose_group'] === 'y') {
$choosable_groups = $this->merged_prefs['choosable_groups'];
$js .= ',
chosenGroup: {
required: true
}';
$js_m .= ' "chosenGroup": { required: "' . tra('One of these groups is required') . '"}, ';
}
if (extension_loaded('gd') && function_exists('imagepng') && function_exists('imageftbbox') && $prefs['feature_antibot'] == 'y' && empty($user) && $prefs['recaptcha_enabled'] != 'y') {
// antibot validation
$js .= ',
"captcha[input]": {
required: true,
remote: {
url: "validate-ajax.php",
type: "post",
data: {
validator: "captcha",
parameter: function() { return $jq("#captchaId").val(); },
input: function() { return $jq("#antibotcode").val(); }
}
}
}
';
$js_m .= ' "captcha[input]": { required: "' . tra('This field is required') . '"}, ';
}
$js .= '
},
messages: {' . $js_m . '
name: { required: "This field is required"},
email: { email: "Invalid email", required: "This field is required"},
pass: { required: "This field is required"},
passAgain: { equalTo: "Passwords do not match"}
},
submitHandler: function(){process_submit(this.currentForm);}
});
';
TikiLib::lib('header')->add_jq_onready($js);
}
}
private function init_registration_prefs()
{
global $userlib, $prefs;
......
......@@ -158,86 +158,11 @@ function smarty_function_user_registration($params, $smarty)
}
}
if ($needs_validation_js && $prefs['feature_jquery_validation'] === 'y') {
$js_m = '';
$js = '
$("form[name=RegForm]").validate({
rules: {
name: {
required: true,';
if ($prefs['login_is_email'] === 'y') {
$js .= '
email: true,';
}
$js .= '
remote: {
url: "validate-ajax.php",
type: "post",
data: {
validator: "username",
input: function() { return $("#name").val(); }
}
}
},
email: {
required: true,
email: true
},
pass: {
required: true,
remote: {
url: "validate-ajax.php",
type: "post",
data: {
validator: "password",
input: function() { return $("#pass1").val(); }
}
}
},
passAgain: { equalTo: "#pass1" }';
if ($prefs['user_must_choose_group'] === 'y') {
$choosable_groups = $registrationlib->merged_prefs['choosable_groups'];
$js .= ',
chosenGroup: {
required: true
}';
$js_m .= ' "chosenGroup": { required: "' . tra('One of these groups is required') . '"}, ';
}
if (extension_loaded('gd') && function_exists('imagepng') && function_exists('imageftbbox') && $prefs['feature_antibot'] == 'y' && empty($user) && $prefs['recaptcha_enabled'] != 'y') {
// antibot validation
$js .= ',
"captcha[input]": {
required: true,
remote: {
url: "validate-ajax.php",
type: "post",
data: {
validator: "captcha",
parameter: function() { return $jq("#captchaId").val(); },
input: function() { return $jq("#antibotcode").val(); }
}
}
}
';
$js_m .= ' "captcha[input]": { required: "' . tra('This field is required') . '"}, ';
}
$js .= '},
messages: {' . $js_m . '
name: { required: "This field is required"},
email: { email: "Invalid email", required: "This field is required"},
pass: { required: "This field is required"},
passAgain: { equalTo: "Passwords do not match"}
},
submitHandler: function(){process_submit(this.currentForm);}
});
';
TikiLib::lib('header')->add_jq_onready($js);
if ($needs_validation_js) {
$registrationlib->addRegistrationFormValidationJs();
}
$smarty->assign('email_valid', 'y');
return $smarty->fetch('user_registration.tpl');
}
......@@ -48,24 +48,3 @@ $("#email").val("{{$userinfo.email|escape}}");
</form>
{/if}
{literal}
<style type="text/css">
#col1 { width: 580px; }
#col2, #col3, #header, #footer, #header-shadow, #footer-shadow {display: none;}
body {
background: white none;
}
</style>
{/literal}
{jq notonready=true}
function check_name() {
// xajax.config.requestURI = "tiki-socialnetworks_firstlogin.php";
// xajax_chkRegName(xajax.$('name').value);
}
function check_mail() {
// xajax.config.requestURI = "tiki-socialnetworks_firstlogin.php";
// xajax_chkRegEmail(xajax.$('email').value);
}
{/jq}
......@@ -19,13 +19,6 @@ $inputConfiguration = array(
require_once ('tiki-setup.php');
$access->check_user($user);
//if (0 and $prefs['feature_ajax'] == 'y') { // AJAX_TODO
// include_once ('register_ajax.php');
// $ajaxlib->registerFunction('chkRegName');
// $ajaxlib->registerFunction('chkRegEmail');
// $ajaxlib->registerTemplate('tiki-register.tpl');
//}
$smarty->assign('msg', '');
$smarty->assign('alldone', false);
......@@ -80,5 +73,7 @@ if (isset($_REQUEST["linkaccount"])) {
}
}
TikiLib::lib('registration')->addRegistrationFormValidationJs();
$smarty->assign('mid_data', $smarty->fetch('tiki-socialnetworks_firstlogin.tpl'));
$smarty->display('tiki_full.tpl');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment