1
|
|
|
<?php |
2
|
|
|
namespace core\admin\inscription; |
3
|
|
|
use core\App; |
4
|
|
|
use core\auth\Encrypt; |
5
|
|
|
use core\auth\Inscription; |
6
|
|
|
|
7
|
|
|
class AdminInscription extends Inscription { |
8
|
|
|
protected $acces_administration; |
9
|
|
|
protected $id_liste_droit_acces; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
//-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
13
|
|
|
//-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
17
|
|
|
public function getAccesAdministration() { |
18
|
|
|
return $this->acces_administration; |
19
|
|
|
} |
20
|
|
|
public function getidListeDroitAcces() { |
21
|
|
|
return $this->id_liste_droit_acces; |
22
|
|
|
} |
23
|
|
|
//-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
27
|
|
|
/** |
28
|
|
|
* vient de la partie admin n du site pages gestion-comptes/creer-utilisateur |
29
|
|
|
* @param $value |
30
|
|
|
* @return bool |
31
|
|
|
*/ |
32
|
|
|
protected function setVerifAccesAdministration($value) { |
|
|
|
|
33
|
|
|
//on verifie que la valeur est bien un int |
34
|
|
|
//test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
35
|
|
|
if ($this->getTestInt($value) === true) { |
36
|
|
|
$this->acces_administration = $value; |
37
|
|
|
return true; |
38
|
|
|
} |
39
|
|
|
else if ($this->getTestInt($value) === false) { |
40
|
|
|
$this->erreur .= "<li>Le champs accès administration n'est pas au bon format</li>"; |
41
|
|
|
return false; |
42
|
|
|
} |
43
|
|
|
else { |
44
|
|
|
return true; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* vient de la partie admin du site pages gestion-comptes/creer-utilisateur |
51
|
|
|
* @param $value |
52
|
|
|
* @return bool |
53
|
|
|
*/ |
54
|
|
|
protected function setVerifListeDroitAcces($value) { |
|
|
|
|
55
|
|
|
//on verifie que la valeur est bien un int |
56
|
|
|
//test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
57
|
|
|
if ($this->getTestInt($value) === true) { |
58
|
|
|
$this->id_liste_droit_acces = $value; |
59
|
|
|
return true; |
60
|
|
|
} |
61
|
|
|
else if ($this->getTestInt($value) === false) { |
62
|
|
|
$this->erreur .= "<li>Le champs accès administration n'est pas au bon format</li>"; |
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
else { |
66
|
|
|
return true; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* si tous les test concernant le formulaire sont passés on inscrit le user |
73
|
|
|
*/ |
74
|
|
|
public function setInscrireUtilisateur() { |
75
|
|
|
$dbc = App::getDb(); |
76
|
|
|
|
77
|
|
|
$dbc->insert("pseudo", $this->pseudo) |
78
|
|
|
->insert("nom", $this->nom) |
79
|
|
|
->insert("prenom", $this->prenom) |
80
|
|
|
->insert("mail", $this->mail) |
81
|
|
|
->insert("mdp", Encrypt::setEncryptMdp($this->mdp)) |
82
|
|
|
->insert("mdp_params", Encrypt::getParams()) |
83
|
|
|
->insert("last_change_mdp", date("Y-m-d")) |
84
|
|
|
->insert("img_profil", "profil/defaut.png") |
85
|
|
|
->insert("valide", 1) |
86
|
|
|
->insert("archiver", 0) |
87
|
|
|
->insert("acces_admin", $this->acces_administration) |
88
|
|
|
->insert("liste_droit", $this->id_liste_droit_acces) |
89
|
|
|
->into("identite") |
90
|
|
|
->set(); |
91
|
|
|
} |
92
|
|
|
//-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
93
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.