Skip to content

Commit

Permalink
Fixed issue #153
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasKovacs committed Nov 4, 2016
1 parent bc69428 commit ea8cb8b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
26 changes: 26 additions & 0 deletions src/xgp3.0.0/upload/application/controllers/home/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@ private function buildPage()
$parse['css_path'] = CSS_PATH . 'home/';
$parse['img_path'] = IMG_PATH . 'home/';
$parse['base_path'] = BASE_PATH;
$parse['extra_js_error']= '';
$parse['user_name'] = isset($_GET['character']) ? $_GET['character'] : '';
$parse['user_email'] = isset($_GET['email']) ? $_GET['email'] : '';

if (isset($_GET['error']) && $_GET['error'] > 0) {

switch($_GET['error']) {

case 1:
$div_id = '#username';
$message = $this->langs['hm_username_not_available'];
break;

case 2:
$div_id = '#email';
$message = $this->langs['hm_email_not_available'];
break;

default:
$div_id = '';
$message = '';
break;
}

$parse['extra_js_error'] = '$.validationEngine.buildPrompt("' . $div_id . '", "' . $message . '", "error");';
}

parent::$page->display(
parent::$page->parseTemplate(parent::$page->getTemplate('home/index_body'), $parse),
Expand Down
25 changes: 21 additions & 4 deletions src/xgp3.0.0/upload/application/controllers/home/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class Register extends XGPCore
private $creator;
private $langs;
private $current_user;

/**
* Contains the error
*
* @var int
*/
private $error_id;

/**
* __construct()
Expand Down Expand Up @@ -76,7 +83,15 @@ private function buildPage()

if (!$this->runValidations()) {

FunctionsLib::redirect('index.php');
if ($this->error_id != '') {

$url = 'index.php?character=' . $_POST['character'] . '&email=' . $_POST['email'] . '&error=' . $this->error_id;
} else {

$url = 'index.php';
}

FunctionsLib::redirect($url);
} else {

$user_password = $_POST['password'];
Expand Down Expand Up @@ -179,9 +194,9 @@ private function buildPage()
WHERE `user_id` = '" . $user_id . "' LIMIT 1;"
);

$from = $this->langs['re_welcome_message_from'];
$subject = $this->langs['re_welcome_message_subject'];
$message = str_replace('%s', $user_name, $this->langs['re_welcome_message_content']);
$from = $this->langs['re_welcome_message_from'];
$subject = $this->langs['re_welcome_message_subject'];
$message = str_replace('%s', $user_name, $this->langs['re_welcome_message_content']);

// Send Welcome Message to the user if the feature is enabled
if (FunctionsLib::readConfig('reg_welcome_message')) {
Expand Down Expand Up @@ -270,10 +285,12 @@ private function runValidations()

if ($this->checkUser()) {
$errors++;
$this->error_id = 1;
}

if ($this->checkEmail()) {
$errors++;
$this->error_id = 2;
}

if ($errors > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/xgp3.0.0/upload/application/lang/english/HOME.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$lang['hm_username_available'] = 'This username is available.';
$lang['hm_username_loading'] = 'Please wait, loading...';
$lang['hm_username_not_available'] = 'This username is not available anymore';
$lang['hm_email_not_available'] = 'The E-mail address is already in use!';
$lang['hm_only_characters'] = 'Use characters only.';
$lang['hm_hidden_title'] = 'XGProyect - Conquer the universe';
$lang['hm_login_button'] = 'Login';
Expand Down
1 change: 1 addition & 0 deletions src/xgp3.0.0/upload/application/lang/spanish/HOME.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$lang['hm_username_available'] = 'Este nombre de usuario est\u00e1 disponible.';
$lang['hm_username_loading'] = 'Cargando... Por favor, espera';
$lang['hm_username_not_available'] = 'Este nombre de usuario ya no est\u00e1 disponible.';
$lang['hm_email_not_available'] = '¡La dirección de E-mail ya está en uso!';
$lang['hm_only_characters'] = 'Utilizar s\u00f3lo caracteres.';
$lang['hm_hidden_title'] = 'XGProyect - Conquista el universo';
$lang['hm_login_button'] = 'Entrar';
Expand Down
8 changes: 5 additions & 3 deletions src/xgp3.0.0/upload/application/views/home/index_body.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@
}
}
})(jQuery);
var universeDistinctions = [];
$(document).ready(function() {
$(".zebra tr:odd").addClass("alt");
$.validationEngineLanguage.newLang()
});
{extra_js_error}
});
// ]]>
</script>
Expand Down Expand Up @@ -210,7 +212,7 @@
<div class="black-border">
<!-- validate options dürfen nicht umgebrochen werden, da das plugin sonst nicht mehr funktioniert -->
<input id="username" class="js_userName validate[required,custom[noSpecialCharacters],custom[noBeginOrEndUnderscore],custom[noBeginOrEndWhitespace],custom[noBeginOrEndHyphen],custom[notMoreThanThreeUnderscores],custom[notMoreThanThreeWhitespaces],custom[notMoreThanThreeHyphen],custom[noCollocateUnderscores],custom[noCollocateWhitespaces],custom[noCollocateHyphen],length[3,20]]" type="text" name="character" value="">
<input id="username" class="js_userName validate[required,custom[noSpecialCharacters],custom[noBeginOrEndUnderscore],custom[noBeginOrEndWhitespace],custom[noBeginOrEndHyphen],custom[notMoreThanThreeUnderscores],custom[notMoreThanThreeWhitespaces],custom[notMoreThanThreeHyphen],custom[noCollocateUnderscores],custom[noCollocateWhitespaces],custom[noCollocateHyphen],length[3,20]]" type="text" name="character" value="{user_name}">
</div>
</div>
<div class="input-wrap">
Expand All @@ -222,7 +224,7 @@
<div class="input-wrap">
<label for="email">{hm_mail_address}</label>
<div class="black-border">
<input class="validate[required,custom[email],length[0,255]]" type="text" id="email" name="email" value="">
<input class="validate[required,custom[email],length[0,255]]" type="text" id="email" name="email" value="{user_email}">
</div>
</div>
<div class="input-wrap">
Expand Down

0 comments on commit ea8cb8b

Please sign in to comment.