$entityManager = initDoctrine(); date_default_timezone_set('Europe/Paris'); $invitation = $entityManager->getRepository('Entities\\Invitation')->findOneBy(array('token' => $_GET['key'])); if ($invitation == NULL) { error_log('RTA::This invitation is not valid!', 0); die; } $tester = $invitation->getTester(); if ($tester == NULL) { error_log('RTA::This user does not exist!', 0); die; } //Verify if the device does not already exist (Update data for this device if it exists) $device = $invitation->getDevice(); if ($device == NULL) { $device = new Device(); } $device->setName($plistData['DEVICE_NAME']); $device->setDateCreation(new \DateTime("now")); $device->setSystemVersion($plistData['VERSION']); $device->setModel($plistData['PRODUCT']); $device->setUdid($plistData['UDID']); $device->addInvitation($invitation); $device->setTester($tester); $invitation->setStatus(Invitation::STATUS_UDID); $entityManager->persist($device); $entityManager->persist($invitation); $entityManager->flush(); //Send the confirmation email $smtp = Swift_SmtpTransport::newInstance($CRED_SMTP, $CRED_SMTP_PORT, 'ssl')->setUsername($CRED_SMTP_USR)->setPassword($CRED_SMTP_PWD); $mailer = Swift_Mailer::newInstance($smtp);
$invitation->setVersion($version); $entityManager->persist($device); $entityManager->persist($invitation); $entityManager->flush(); } else { $sendMailError += 'The invitation was not sent to: ' . $email . '</br>'; } } if ($_POST['selected_device_new']) { if ($_POST['selected_tester'] == 'new_tester') { //create new tester : new_tester_email //create new empty device : new_tester_email(mail) } else { //create new empty device : value(mail) $tester = $entityManager->getRepository('Entities\\Tester')->findOneBy(array('email' => $_POST['selected_tester'])); $device = new Device(); $device->setTester($tester); $entityManager->persist($device); $entityManager->flush(); sendInvitationForDevice($device, $mailer, $url, $version, $msg, $nbInvitations, $entityManager); } } if (isset($_POST['selected_devices'])) { foreach ($_POST['selected_devices'] as $deviceId) { $device = $entityManager->getRepository('Entities\\Device')->find($deviceId); //echo var_dump($device); sendInvitationForDevice($device, $mailer, $url, $version, $msg, $nbInvitations, $entityManager); } } $entityManager->flush(); ?>