[9.1.07] Vérification de saisie création d'un user
This commit is contained in:
parent
b72f18efe7
commit
285d830ca3
|
@ -32,36 +32,44 @@ class user extends common {
|
||||||
public function add() {
|
public function add() {
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
|
$check=true;
|
||||||
// L'identifiant d'utilisateur est indisponible
|
// L'identifiant d'utilisateur est indisponible
|
||||||
$userId = $this->getInput('userAddId', helper::FILTER_ID, true);
|
$userId = $this->getInput('userAddId', helper::FILTER_ID, true);
|
||||||
if($this->getData(['user', $userId])) {
|
if($this->getData(['user', $userId])) {
|
||||||
self::$inputNotices['userAddId'] = 'Identifiant déjà utilisé';
|
self::$inputNotices['userAddId'] = 'Identifiant déjà utilisé';
|
||||||
|
$check=false;
|
||||||
}
|
}
|
||||||
// Double vérification pour le mot de passe
|
// Double vérification pour le mot de passe
|
||||||
$mail = true;
|
|
||||||
if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
|
if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
|
||||||
self::$inputNotices['userAddConfirmPassword'] = 'Incorrect';
|
self::$inputNotices['userAddConfirmPassword'] = 'Incorrect';
|
||||||
$mail = false;
|
$check = false;
|
||||||
}
|
}
|
||||||
// Crée l'utilisateur
|
// Crée l'utilisateur
|
||||||
$userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true);
|
$userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true);
|
||||||
$userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true);
|
$userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true);
|
||||||
$userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true);
|
$userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true);
|
||||||
$this->setData([
|
// Pas de nom saisi
|
||||||
'user',
|
if (empty($userFirstname) || empty($userLastname)) {
|
||||||
$userId,
|
$check=false;
|
||||||
[
|
}
|
||||||
'firstname' => $userFirstname,
|
// Si tout est ok création effective
|
||||||
'forgot' => 0,
|
if ($check === true) {
|
||||||
'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true),
|
$this->setData([
|
||||||
'lastname' => $userLastname,
|
'user',
|
||||||
'mail' => $userMail,
|
$userId,
|
||||||
'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true)
|
[
|
||||||
]
|
'firstname' => $userFirstname,
|
||||||
]);
|
'forgot' => 0,
|
||||||
// Envoi le mail
|
'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true),
|
||||||
|
'lastname' => $userLastname,
|
||||||
|
'mail' => $userMail,
|
||||||
|
'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true)
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Envoie le mail
|
||||||
$sent = true;
|
$sent = true;
|
||||||
if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $mail === true) {
|
if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) {
|
||||||
$sent = $this->sendMail(
|
$sent = $this->sendMail(
|
||||||
$userMail,
|
$userMail,
|
||||||
'Compte créé sur ' . $this->getData(['config', 'title']),
|
'Compte créé sur ' . $this->getData(['config', 'title']),
|
||||||
|
|
Loading…
Reference in New Issue