Пример #1
0
 $geo = $_POST['geo'];
 $plan = $_POST['plan'];
 $state = $_POST['state'];
 if (isset($_POST['isAdmin'])) {
     $isAdmin = $_POST['isAdmin'];
     $isAdmin = true;
     var_dump($isAdmin);
 } else {
     $isAdmin = false;
     var_dump($isAdmin);
 }
 $userManager = new UserPdoManager();
 $accountManager = new AccountPdoManager();
 $planManager = new RefPlanPdoManager();
 //Verifie la disponibilité de l'adresse mail
 if ($userManager->checkEmailAvailability($email) != FALSE) {
     $accountId = new MongoId();
     $userId = new MongoId();
     //crypte le password
     $password = $userManager->encrypt($password);
     //@link http://www.php.net/manual/en/class.mongodate.php
     $time = time();
     $end = $time + 30 * 24 * 60 * 60;
     // + 30 jours
     //info compte
     $account = array('_id' => $accountId, 'state' => new MongoInt32($state), 'idUser' => $userId, 'idRefPlan' => new MongoId($plan), 'storage' => (int) 0, 'ratio' => (int) 0, 'startDate' => new MongoDate($time), 'endDate' => new MongoDate($end));
     $isAccountAdded = $accountManager->create($account);
     //Si aucun pb apres ajout du compte, ajoute l'user, sinon suppresion de user
     if ($isAccountAdded == TRUE) {
         //infos user
         $user = array('_id' => $userId, 'isAdmin' => $isAdmin, 'state' => new MongoInt32($state), 'idCurrentAccount' => $accountId, 'firstName' => _sanitize($firstname), 'lastName' => _sanitize($lastname), 'password' => $password, 'email' => $email, 'geolocation' => $geo, 'apiKey' => $userManager->generateGUID());