Skip to content

Commit

Permalink
feat: add conditions when registering
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcoo authored and Eywek committed Jun 18, 2018
1 parent 7f51608 commit 27e89d0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function after($event = array(), $install = false, $updateContent = array
'server_cache' => 0,
'server_secretkey' => '',
'server_timeout' => 1,
'condition' => null,
'skype' => 'http://mineweb.org',
'youtube' => 'http://mineweb.org',
'twitter' => 'http://mineweb.org',
Expand Down Expand Up @@ -203,6 +204,7 @@ public function after($event = array(), $install = false, $updateContent = array
'server_cache' => array('type' => 'integer', 'null' => false, 'default' => 0, 'length' => 1, 'unsigned' => false),
'server_secretkey' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'server_timeout' => array('type' => 'float', 'null' => false, 'default' => null, 'unsigned' => false),
'condition' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 250, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'skype' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'youtube' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'twitter' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
Expand Down
2 changes: 2 additions & 0 deletions app/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function __initConfiguration()
// Variables
$google_analytics = $this->Configuration->getKey('google_analytics');
$configuration_end_code = $this->Configuration->getKey('end_layout_code');
$condition = $this->Configuration->getKey('condition');

$this->loadModel('SocialButton');
$findSocialButtons = $this->SocialButton->find('all');
Expand All @@ -133,6 +134,7 @@ public function __initConfiguration()

$this->set(compact(
'reCaptcha',
'condition',
'website_name',
'theme_config',
'facebook_link',
Expand Down
4 changes: 2 additions & 2 deletions app/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function ajax_register()
$this->autoRender = false;
$this->response->type('json');
if ($this->request->is('Post')) { // si la requête est bien un post
if (!empty($this->request->data['pseudo']) && !empty($this->request->data['password']) && !empty($this->request->data['password_confirmation']) && !empty($this->request->data['email'])) { // si tout les champs sont bien remplis
$conditionsChecked = !empty($this->request->data['condition']) || !$this->Configuration->getKey('condition');
if (!empty($this->request->data['pseudo']) && !empty($this->request->data['password']) && $conditionsChecked && !empty($this->request->data['password_confirmation']) && !empty($this->request->data['email'])) { // si tout les champs sont bien remplis

// Captcha
if ($this->Configuration->getKey('captcha_type') == "2") { // ReCaptcha
Expand All @@ -51,7 +52,6 @@ function ajax_register()

}
//

if ($validCaptcha) { // on check le captcha déjà
$this->loadModel('User');
$isValid = $this->User->validRegister($this->request->data, $this->Util);
Expand Down
15 changes: 15 additions & 0 deletions app/View/Configuration/admin_index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@
<small class="text-danger"><?= $Lang->get('CONFIG__KEY_PASSWORDS_ADVERTISSEMENT') ?></small>
</div>

<hr>
<div class="form-group">
<label><?= $Lang->get('CONFIG__CONDITION_TITLE') ?></label>
<div class="form-group">
<?= $this->Form->input(false, array(
'div' => false,
'type' => 'text',
'name' => 'condition',
'class' => 'form-control',
'value' => $config['condition']
)); ?>
</div>
<small class="text-danger"><?= $Lang->get('CONFIG__CONDITION') ?></small>
</div>

<hr>

<div class="form-group">
Expand Down
10 changes: 10 additions & 0 deletions app/View/Elements/modals.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
<input type="text" class="form-control" name="captcha" id="inputPassword3" placeholder="<?= $Lang->get('FORM__CAPTCHA_LABEL') ?>">
</div>
<?php } ?>
<?php if (!empty($condition)) { ?>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="condition">
<?=$Lang->get('USER__CONDITION_1')?> <a href="<?= $condition ?>"> <?= $Lang->get('USER__CONDITION_2')?></a>
</label>
</div>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-block"><?= $Lang->get('USER__REGISTER') ?></button>
Expand Down
4 changes: 4 additions & 0 deletions lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
"PLUGIN__ERROR_UNINSTALLED": "The plugin is uninstalled",

"CONFIG__GENERAL_PREFERENCES": "General Preferences",
"CONFIG__CONDITION_TITLE": "Conditions of use",
"CONFIG__CONDITION": "Put the link of the general conditions of use to activate this option. ! Please note, not all themes are compatible and may prevent registration.",
"CONFIG__SOCIAL_PREFERENCES": "Social preferences",
"CONFIG__OTHER_PREFERENCES": "Preferences other",
"CONFIG__EDIT_SUCCESS": "Configuration successfully changed!",
Expand Down Expand Up @@ -346,6 +348,8 @@
"USER__LOGIN": "Login",
"USER__REGISTER": "Register",
"USER__USERNAME": "Nickname",
"USER__CONDITION_1":"Accept the",
"USER__CONDITION_2":"conditions",
"USER__USERNAME_LABEL": "Enter your username",
"USER__PASSWORD": "Password",
"USER__PASSWORD_LABEL": "Enter your password",
Expand Down
4 changes: 4 additions & 0 deletions lang/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
"PLUGIN__ERROR_UNINSTALLED":"Le plugin est désinstallé",

"CONFIG__GENERAL_PREFERENCES": "Préférences générales",
"CONFIG__CONDITION_TITLE": "Conditions d'utilisations",
"CONFIG__CONDITION": "Mettez le lien des conditions générales d'utilisations pour activer cette option. ! Attention, tous les thèmes ne sont pas compatibles et peuvent empêcher l'inscription",
"CONFIG__SOCIAL_PREFERENCES": "Préférences sociales",
"CONFIG__OTHER_PREFERENCES": "Préférences autres",
"CONFIG__EDIT_SUCCESS":"Configuration modifié avec succès !",
Expand Down Expand Up @@ -344,6 +346,8 @@
"USER__LOGIN":"Connexion",
"USER__REGISTER":"S'inscrire",
"USER__USERNAME":"Pseudo",
"USER__CONDITION_1":"Accepter les",
"USER__CONDITION_2":"conditions",
"USER__USERNAME_LABEL":"Entrez votre pseudo",
"USER__PASSWORD":"Mot de passe",
"USER__PASSWORD_LABEL":"Entrez votre mot de passe",
Expand Down

0 comments on commit 27e89d0

Please sign in to comment.