Пример #1
0
/*     | | \ \  __/ (__| |_| |_| \__ \  / /_   / /     */
/*     |_|  \_\___|\___|\__|\__,_|___/ |____| /_/      */
/*                                                     */
/*                Date: 15/10/2015 23:55               */
/*                 All right reserved                  */
/*-----------------------------------------------------*/
use MealBooker\manager\SecurityManager;
use MealBooker\model\User;
use MealBooker\models\dao\CompanyDao;
use MealBooker\models\dao\RoleDao;
use MealBooker\models\dao\UserDao;
if (!SecurityManager::get()->getCurrentUser($_SESSION)->isAdmin()) {
    header('Location:' . WEB_PATH);
}
$userDao = new UserDao($em);
$roleDao = new RoleDao($em);
$error = null;
$info = null;
//save mode
if (isset($_POST['lastname']) && isset($_POST['firstname']) && isset($_POST['mail']) && isset($_POST['phone']) && isset($_POST['role']) && isset($_POST['company']) && isset($_POST['id']) && isset($_POST['state'])) {
    try {
        $user = $userDao->getByPrimaryKey($_POST['id']);
        if ($user == null) {
            $user = new User();
        }
        $user->setFirstName($_POST['firstname']);
        $user->setLastName($_POST['lastname']);
        $user->setMail($_POST['mail']);
        $user->setPhoneNumber($_POST['phone']);
        $user->setOptIn(isset($_POST['optin']) ? true : false);
        $user->setStatus($_POST['state']);
Пример #2
0
/*                Date: 23/09/2015                     */
/*                 All right reserved                  */
/*-----------------------------------------------------*/
use MealBooker\manager\MailManager;
use MealBooker\manager\SecurityManager;
use MealBooker\model\User;
use MealBooker\models\dao\CompanyDao;
use MealBooker\models\dao\RoleDao;
use MealBooker\models\dao\UserDao;
use MealBooker\utils\Utils;
$error = null;
$info = null;
if (isset($_POST) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['firstName']) && isset($_POST['lastName']) && isset($_POST['idEntreprise']) && isset($_POST['password']) && isset($_POST['passwordCheck'])) {
    $companyDao = new CompanyDao($em);
    $userDao = new UserDao($em);
    $roleDao = new RoleDao($em);
    try {
        if ($userDao->getUserByMail($_POST['email']) != null) {
            throw new Exception("Ce mail est déjà utilisé par un compte existant");
        }
        //set user data
        $user = new User();
        $user->setLastName($_POST['lastName']);
        $user->setFirstName($_POST['firstName']);
        $user->setMail($_POST['email']);
        $user->setPhoneNumber($_POST['phone']);
        //check password validation
        if ($_POST['password'] != $_POST['passwordCheck']) {
            throw new Exception("Le champs mot de passe et confirmation mot de passe doivent étre identiques");
        }
        $user->setPassword(password_hash($_POST['password'], PASSWORD_BCRYPT, ['salt' => $user->getSalt()]));