ソースを参照

Espace de démonstration (masquage profils + empecher create user)

Masquage des profils utilisateurs des clients du Chat des Noisettes.
Ajout d'une limitation pour empêcher les visiteur de créer des utilisateurs.
master
keun 7年前
コミット
21e903f311
4個のファイルの変更87行の追加11行の削除
  1. +70
    -1
      backend/controllers/CronController.php
  2. +1
    -1
      backend/controllers/UserController.php
  3. +8
    -7
      backend/views/user/create.php
  4. +8
    -2
      frontend/views/site/index.php

+ 70
- 1
backend/controllers/CronController.php ファイルの表示

@@ -42,9 +42,78 @@ class CronController extends BackendController
public function actionInitBddDemo($key = '')
{
if($key == '45432df6e842ac71aa0b5bb6b9f25d44')
if($key == '45432df6e842ac71aa0b5bb6b9f25d44' && YII_ENV == 'demo')
{
$arr_noms = [
'Martin', 'Bernard', 'Thomas','Petit','Robert', 'Richard','Durand','Dubois',
'Moreau', 'Laurent', 'Simon', 'Michel', 'Lefebvre', 'Leroy', 'Roux', 'David',
'Bertrand', 'Morel', 'Fournier', 'Girard', 'Bonnet', 'Dupont','Lambert', 'Fontaine',
'Rousseau', 'Vincent', 'Muller','Lefevre', 'Faure', 'Andre', 'Mercier', 'Blanc', 'Guerin',
'Boyer', 'Garnier', 'Chevalier', 'François','Legrand','Gauthier','Garcia','Perrin',
'Robin','Clement','Morin','Nicolas','Henry','Roussel','Mathieu','Gautier','Masson',
'Marchand','Duval','Denis','Dumont','Marie','Lemaire','Noël','Meyer','Dufour',
'Meunier','Brun','Blanchard','Giraud','Joly','Rivière','Lucas','Brunet','Gaillard','Barbier',
'Arnaud','Martinez','Gerard','Roche','Renard','Schmitt','Roy','Leroux','Colin','Vidal',
'Caron','Picard','Roger','Fabre','Aubert','Lemoine','Renaud','Dumas','Lacroix','Olivier',
'Philippe','Bourgeois','Pierre','Benoit','Rey','Leclerc','Payet','Rolland','Lecomte','Lopez',
'Jean','Dupuis','Guillot','Hubert','Berger','Carpentier','Sanchez','Dupuis','Moulin',
'Louis','Deschamps','Huet','Vasseur','Perez','Trouillot','Fusillier','Massenot','Boucher','Fleury',
'Royer','Klein','Jacquet','Jaquin','Adam','Paris','Poirier','Aubry','Guyot','Carré','Charles',
'Charpentier','Menard','Bailly','Bertin','Le Gall','Collet','Leger','Bouvier','Millet','Daniel',
'Langlois','Pelletier','Perrier','Leblanc','Lebrun','Monnier','Michaud','Laporte','Carlier',
'Pasquier','Delaunay','Lamy','Gilbert','Lejeune','Pichon','Cordier','Barthelemy','Perret','Reynaud',
'Humbert','Marechal','Bernard','Lemaitre','Gay','Bouchet','Da Silva','Chauvin','Chevalier','Tessier',
'Poulain','Girondin','Gillet','Guichard'
];
$arr_prenoms = [
'Adel','Antonin','Armand','Arnaud','Aymeric','Baptiste','Barnabé','Bernard','Brice','Baudouin',
'Camille','Cassandre','Célestin','Christian','Clément','Cyril','Claude','Damien','Daniel','David',
'Delphin','Denis','Didier','Dimitri','Dorothée','Désiré','Edgard','Etienne','Eugène','Eudes','Eric',
'Fabien','Fabrice','Flavien','Florent','Francois','Frédéric','Gabin','Gabriel','Gautier','Gilles','Guy',
'Hervé','Huvert','Hugues','Hector','Jacques','Jason','Jean','Jeannot','Johan','Julien','Léon','Lionel','Loïc',
'Lucas','Luc','Lucien','Maurice','Maxence','Maxime','Michel','Morgan','Nicolas','Normand','Norbert','Olivier,',
'Pascal','Patrice','Pierrick','Raphael','Roland','Stéphane','Sylvain','Sylvestre','Timothée','Thomas','Tristan',
'Ulysse','Vincent','Victor','Vivien',
'Adeline','Albane','Alix','Amélie','Arielle','Aurelle','Blandine','Blanche','Brigitte','Berthe','Camille','Capucine',
'Catherine','Cécile','Charlotte','Chloé','Claudine','Clémenence','Constance','Cyrielle','Corinne','Danielle',
'Delphine','Denise','Dominique','Diane','Édith','Éliane','Éléonore','Émilie','Emmanuelle','Ève','Évelyne',
'Fanny','Flavie','Flore','Françoise', 'Gabrielle','Gaëlle','Geneviève','Georgette','Germaine','Gertrude','Gisèle',
'Gwenaëlle','Hélène','Héloïse','Henriette','Huguette','Inès','Isabelle','Jacqueline','Jeanne','Joëlle','Joséphine',
'Juliette','Justine','Julie','Laura','Laure','Léa','Léonie','Lucie','Lucienne','Lorraine','Lucille','Ludivine','Lydie',
'Margot','Marion','Marlène','Marthe','Mélodie','Monique','Noémie','Nadine','Nadège','Océane','Odette','Odile','Paulette',
'Rose','Roseline','Renée','Sabine','Sophie','Suzanne','Sylvie','Thérèse',
];
$arr_noms_checked = [] ;
$arr_prenoms_checked = [] ;
$users = User::find()
->joinWith('userEtablissement')
->where('user_etablissement.id_etablissement = 1')
->all() ;
foreach($users as $u)
{
do {
$i_nom = rand(0, count($arr_noms)-1) ;
$i_prenom = rand(0, count($arr_prenoms)-1) ;
} while(isset($arr_noms_checked[$i_nom]) || isset($arr_prenoms_checked[$i_prenom])) ;
$arr_noms_checked[$i_nom] = true ;
$arr_prenoms_checked[$i_prenom] = true ;
$nom = $arr_noms[$i_nom] ;
$prenom = $arr_prenoms[$i_prenom] ;
$u->nom = $nom ;
$u->prenom = $prenom ;
$u->email = strtolower($prenom).'.'.strtolower($nom).'@yopmail.com' ;
$u->telephone = '0600000000' ;
$u->save() ;
}
}
}

+ 1
- 1
backend/controllers/UserController.php ファイルの表示

@@ -119,7 +119,7 @@ class UserController extends BackendController
{
$model = new User();

if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->load(Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') {
// save use
$password = Password::generate() ;

+ 8
- 7
backend/views/user/create.php ファイルの表示

@@ -11,11 +11,12 @@ $this->params['breadcrumbs'][] = ['label' => 'Utilisateurs', 'url' => ['index']]
$this->params['breadcrumbs'][] = 'Ajouter' ;
?>
<div class="user-create">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

<?php if(YII_ENV == 'demo'): ?>
<div class="alert alert-warning">Vous ne pouvez pas ajouter d'utilisateur dans l'espace Démo.</div>
<?php else: ?>
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
<?php endif; ?>
</div>

+ 8
- 2
frontend/views/site/index.php ファイルの表示

@@ -10,6 +10,8 @@ use dosamigos\leaflet\layers\TileLayer;
use dosamigos\leaflet\LeafLet;
use dosamigos\leaflet\widgets\Map;

use common\helpers\Url ;

/* @var $this yii\web\View */
$this->title = 'Plateforme de réservation de pain';
?>
@@ -70,8 +72,12 @@ $this->title = 'Plateforme de réservation de pain';
</div>
<?php if(Yii::$app->user->isGuest): ?>
<div class="row" id="row-signup">
<a class="btn btn-primary btn-lg" href="<?= Yii::$app->urlManager->createUrl('site/signup'); ?>"><span class="glyphicon glyphicon-circle-arrow-right"></span> Je m'inscris</a>
<a class="btn btn-default btn-lg" id="btn-demo" href="http://demo.laboiteapain.net/"><span class="glyphicon glyphicon-eye-open"></span> Espace de démo</a>;
<?php if(YII_ENV == 'demo'): ?>
<a class="btn btn-primary btn-lg" href="<?= Url::env('prod','frontend'); ?>"><span class="glyphicon glyphicon-circle-arrow-left"></span> Retour sur le site</a>
<?php else: ?>
<a class="btn btn-primary btn-lg" href="<?= Yii::$app->urlManager->createUrl('site/signup'); ?>"><span class="glyphicon glyphicon-circle-arrow-right"></span> Je m'inscris</a>
<a class="btn btn-default btn-lg" id="btn-demo" href="http://demo.laboiteapain.net/"><span class="glyphicon glyphicon-eye-open"></span> Espace de démo</a>;
<?php endif; ?>
</div>
<?php endif; ?>
</div>

読み込み中…
キャンセル
保存