/** * Validates the model. * * @return boolean True if passed validators otherwise false */ private function _validate() { require_once 'Validations.php'; $validator = new Validations($this); $validationOn = 'ValidationOn' . ($this->isNewRecord() ? 'Create' : 'Update'); foreach (array('beforeValidation', "before{$validationOn}") as $callback) { if (!$this->invokeCallback($callback, false)) { return false; } } // need to store reference b4 validating so that custom validators have access to add errors $this->errors = $validator->getRecord(); $validator->validate(); foreach (array('afterValidation', "after{$validationOn}") as $callback) { $this->invokeCallback($callback, false); } if (!$this->errors->isEmpty()) { return false; } return true; }
break; case "inscription": $controle = new Errors(); if (empty($_POST['codeClientSignIn'])) { $controle->add('Veuillez saisir votre code client', 'codeClientSignIn'); } if (empty($_POST['emailSignIn'])) { $controle->add('Veuillez saisir votre adresse email', 'emailSignIn'); } if (empty($_POST['emailSignIn2'])) { $controle->add('Veuillez confirmez votre adresse email', 'emailSignIn2'); } if ($_POST['emailSignIn'] != $_POST['emailSignIn2']) { $controle->add('Les adresses email ne sont pas identiques', 'emailNotSame'); } if ($controle->isEmpty()) { $codeClientSignIn = $_POST['codeClientSignIn']; $emailSignIn = $_POST['emailSignIn']; $customer = UtilisateursManager::getUtilisateurByCodeClientAndEmail($codeClientSignIn, $emailSignIn); if ($customer) { # fonction d'envoie de mot de passe par mail. $password = Utils::random(); $customer->setMotDePasse(sha1($password)); UtilisateursManager::updateUtilisateurs($customer); $mail = Mail::inscription($customer, $password); if ($mail) { Utils::json(array('result' => 'success', 'email' => $emailSignIn)); } else { tils::json(array('result' => 'errorSendMail')); } } else {
break; } } } } // section backoffice if (isset($_POST['submit-backoffice'])) { if (isset($_POST)) { $error = new Errors(); if (empty($_POST['PATH_CLASS'])) { $error->add('Veuilliez sassir le nom de la base de donnés. ', 'DBNAME'); } if (empty($_POST['PATH'])) { $error->add('Veuilliez sassir le chemi des fichers ', 'PATH'); } if ($error->isEmpty()) { $dir = $_POST['PATH_CLASS']; $files = scandir($dir); $menu = array(); foreach ($files as $file) { if (count(explode('.php', $file)) > 1) { $name = explode('.php', $file); array_push($menu, $name[0]); $content = file_get_contents($dir . $file); explode($content); // creation controller ; } } } } }