public function addV6($fname, $lname, $email, $role, $gender, $password) { APP::import('Model', 'User'); $this->User = new User(); // Includes App::import('Lib', 'Strings'); App::import('Lib', 'Mailing'); App::uses('Folder', 'Utility'); App::uses('File', 'Utility'); $strings = new Strings(); // Check if the username already exists $user = $this->User->findByEmail($email); if (count($user) > 0) { $this->Session->setFlash(__('Prière de vous authentifier afin de continuer votre candidature.'), 'custom-flash-danger-go-back'); $this->redirect(array('controller' => 'login', 'action' => 'login')); return; } $encrypted_password = $strings->Encript($password); // Create user $this->User->create(); $this->User->set('fname', $fname); $this->User->set('lname', $lname); $this->User->set('password', $encrypted_password); $this->User->set('email', $email); $this->User->set('role_id', $role); $this->User->set('gender_id', $gender); $this->User->save(); // Send E-mail $mailer = new Mailing(); $mailer->UserAccountCreation($email, '', $fname, $lname, $email, $password, $role); return $this->User->getLastInsertID(); }