/** * @Route("/doc/new", name="doc_new") * @todo $indir validieren */ public function newAction(Request $request) { $indir = $request->query->get('indir'); $storage = $this->get('app.storage_helper'); $document = new Document(); if (null !== $indir) { $document->setPath($indir); } $repo = $this->getDoctrine()->getRepository('AppBundle:Document'); global $allFilingPlaces; $allFilingPlaces = []; foreach ($repo->getAllFilingPlaces() as $value) { $allFilingPlaces[$value['filingPlace']] = $value['filingPlace']; } $form = $this->createForm(DocumentType::class, $document); $form->handleRequest($request); if ($form->isValid()) { $document->setCreated(new \Datetime()); $em = $this->getDoctrine()->getManager(); try { $dir = $this->_handleDirectoryCreation($document->getPath()); $document->setDirectory($dir); $em->persist($document); $em->flush(); return $this->redirectToRoute('doc', ['id' => $document->getId()]); } catch (\Exception $e) { print $e->getMessage(); die; } } return $this->render('document/new.html.twig', ['document' => $document, 'form' => $form->createView()]); }
public function getSharedUsers(Document $document) { $sharedUsers = []; foreach ($document->getShares() as $share) { if (!$share->getUser()->isEqual($document->getOwner())) { $sharedUsers[] = $share->getUser(); } } return $sharedUsers; }
/** * @Route("/uploadPhoto/", name="profile_photo_upload") * @param Request $request * @return string|\Symfony\Component\HttpFoundation\Response */ public function profilePhotoAction(Request $request) { $image = $request->files->get('image'); $document = new Document(); $document->setFile($image); $this->getUser()->setProfileImg($document); $document->setName($this->getUser()->getId() . '_' . $image->getClientOriginalName()); $document->upload(); $em = $this->getDoctrine()->getEntityManager(); $em->persist($document); $em->flush(); return $this->redirect($this->generateUrl('user-profile', array('id' => $this->getUser()->getId()))); }
public function load(ObjectManager $manager) { $newDocument1 = new Document(); $newDocument1->setFilename("Счет.doc"); $newDocument1->setAdministrator($this->getReference('Administrator1')); $newDocument1->setTask($this->getReference('Task1')); $manager->persist($newDocument1); $newDocument2 = new Document(); $newDocument2->setFilename("Акт.doc"); $newDocument2->setAdministrator($this->getReference('Administrator2')); $newDocument2->setClient($this->getReference('Client1')); $manager->persist($newDocument2); $newDocument3 = new Document(); $newDocument3->setFilename("Коммерческое предложение.pdf"); $newDocument3->setAdministrator($this->getReference('Administrator3')); $newDocument3->setClient($this->getReference('Client1')); $manager->persist($newDocument3); $newDocument4 = new Document(); $newDocument4->setFilename("Документ 4.doc"); $newDocument4->setAdministrator($this->getReference('Administrator2')); $newDocument4->setTask($this->getReference('Task1')); $manager->persist($newDocument4); $newDocument5 = new Document(); $newDocument5->setFilename("Документ 5.doc"); $newDocument5->setAdministrator($this->getReference('Administrator3')); $newDocument5->setTask($this->getReference('Task4')); $manager->persist($newDocument5); $newDocument6 = new Document(); $newDocument6->setFilename("Документ 6.doc"); $newDocument6->setAdministrator($this->getReference('Administrator1')); $newDocument6->setClient($this->getReference('Client3')); $manager->persist($newDocument6); $newDocument7 = new Document(); $newDocument7->setFilename("Документ 7.doc"); $newDocument7->setAdministrator($this->getReference('Administrator1')); $newDocument7->setClient($this->getReference('Client5')); $manager->persist($newDocument7); $manager->flush(); $this->addReference('Document1', $newDocument1); $this->addReference('Document2', $newDocument2); $this->addReference('Document3', $newDocument3); $this->addReference('Document4', $newDocument4); $this->addReference('Document5', $newDocument5); $this->addReference('Document6', $newDocument6); $this->addReference('Document7', $newDocument7); }
/** * Stores a document and its isbns in the database * * @param $filename * @param array $isbns * @return boolean */ public function saveDocumentWithIsbns($filename, array $isbns) { if (!is_null($filename && !is_null($isbns))) { $file = new Document(); $file->setName($filename); $bookArray = []; foreach ($isbns as $isbn) { $bookRepo = $this->_em->getRepository('AppBundle:Book'); $book = $bookRepo->findBy(array('isbn13' => $isbn)); if (!is_null($book) && array_key_exists(0, $book)) { $bookArray[] = $book[0]; //$file->addBook($book[0]); } } $bookArray = $this->deleteRepeatedBooksInArray($bookArray); foreach ($bookArray as $book) { $file->addBook($book); } $this->add($file); return true; } return false; }
/** * {@inheritDoc} */ protected function doLoad(ObjectManager $manager) { $doc = new Document(); $doc->setContent("<p>Content is good and cheesy.</p>"); $doc->setPath('test1'); $doc->setSummary("summarized"); $doc->setTitle("title1"); $manager->persist($doc); $this->setReference('doc', $doc); $manager->flush(); }
public function load(ObjectManager $manager) { foreach ($this->getAllDocuments() as $singleDocument) { $document = new Document(); $document->setSiteId($this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('AppBundle:Site')->findOneBy(array('url' => $singleDocument['site_id_id']))); $document->setPath('#'); $document->setUploadDate(new \DateTime()); $document->setDocumentType($singleDocument['document_type']); $manager->persist($document); } $manager->flush(); }
public function load(ObjectManager $manager) { /* $connection = $manager->getConnection(); $dbPlatform = $connection->getDatabasePlatform(); # $connection->query('SET FOREIGN_KEY_CHECKS=0'); $q = $dbPlatform->getTruncateTableSql('documents'); $connection->executeUpdate($q); $q = $dbPlatform->getTruncateTableSql('files'); $connection->executeUpdate($q); # $connection->query('SET FOREIGN_KEY_CHECKS=1'); */ for ($i = 0; $i <= 10; $i++) { $document = new Document(); $document->setTitle('Der Titel Nr. ' . $i); $document->setDocDate(new \Datetime()); $document->setPath('/home/jacek/dir'); $document->setCreated(new \Datetime()); $document->setTags('tag1 tag2 tag3'); $r = mt_rand(1, 2); for ($j = 0; $j <= $r; $j++) { $file = new File(); $file->setTitle('Titel der Datei Nr. ' . $j); $file->setFilename('Dateiname.ext'); $file->setPath('/home/jacek/dir'); $file->setFiletype('ext'); $file->setContent('blablabla'); $file->setCreated(new \Datetime()); $file->setDocument($document); $manager->persist($file); print "File angelegt: {$file->getTitle()} \n"; } $manager->persist($document); print "Doc angelegt: {$document->getTitle()} \n"; } $manager->flush(); }
public function getContent(Document $document, User $requester, $passPhrase) { $share = $document->getShareOf($requester); $encryptionKey = $this->getEncryptionKey($share, $passPhrase); return \Crypto::Decrypt(base64_decode($document->getEncryptedContent()), $encryptionKey); }
public function indexAction(Request $request) { $em = $this->getDoctrine()->getManager(); $um = $this->get('fos_user.user_manager'); $user_id = $this->get('security.context')->getToken()->getUser(); $billing = $this->getDoctrine()->getRepository('AppBundle:Billing')->findAll(); $status = $this->getDoctrine()->getRepository('AppBundle:Status')->findOneById(3); $user = new Userform(); if ($request->isMethod('POST')) { $user->setSellpartner($user_id); $string = ""; $chaine = "0123456789"; srand((double) microtime() * 1000000); for ($i = 0; $i < 12; $i++) { $string .= $chaine[rand() % strlen($chaine)]; } $file = $request->files->get('img'); $valid_filetypes = array('jpg', 'jpeg'); if ($file instanceof UploadedFile) { if ($file->getError() == '0') { $originalName = explode('.', $file->getClientOriginalName()); if (!($file->getSize() < 2000000)) { echo 'taille'; die; return $this->redirectToRoute('app_homepage'); } if (!in_array(strtolower($originalName[sizeof($originalName) - 1]), $valid_filetypes)) { echo 'valid'; die; return $this->redirectToRoute('app_homepage'); } if (!($file->getMimeType() == "image/jpeg" or $file->getMimeType() == "image/png")) { echo 'mimetype'; die; return $this->redirectToRoute('app_homepage'); } } else { return $this->redirectToRoute('app_homepage'); } } else { return $this->redirectToRoute('app_homepage'); } $document = new Document(); $document->setFile($file); $document->setSubDirectory('photos'); $document->processFile(); $uploadedURL = $document->getUploadDirectory() . DIRECTORY_SEPARATOR . $document->getSubDirectory() . DIRECTORY_SEPARATOR . $file->getBasename(); $user->setUsername($string); $user->setStatus($status); $user->setFirstname($request->request->get('firstname')); $user->setLastname($request->request->get('lastname')); $user->setEmail($request->request->get('email')); $user->setMobile($request->request->get('number')); $user->setStudyLevel($request->request->get('level')); $user->setAddress($request->request->get('address')); $user->setZipcode(intval($request->request->get('zipcode'))); $user->setCity($request->request->get('city')); $user->setSchool($user_id->getSchoolId()); $user->setPicture($uploadedURL); $user->setLastBillingPrice($request->request->get('amount')); $type = $this->getDoctrine()->getRepository('AppBundle:Billing')->findOneById($request->request->get('payment')); $user->setLastBillingType($type); $date = DateTime::createFromFormat('m/d/Y', trim($request->request->get('birthdate'))); $date->format('Y-m-d'); $user->setBirthdate($date); $em->persist($user); $em->flush(); return $this->redirectToRoute('app_homepage'); } return $this->render('AppBundle:Default:index.html.twig', array('billing' => $billing)); }
/** * @param Document $document * @return string */ public function getFilename(Document $document) { return $this->directory . '/' . substr($document->getId(), 0, 1) . '/' . $document->getId() . '.' . $document->getExtension(); }