/** * Export a Collecticiel. * * @param Workspace $workspace * @param array $files * @param Dropzone $dropzone * * @return array */ public function export(Workspace $workspace, array &$files, Dropzone $dropzone) { $data = []; $uid = uniqid() . '.txt'; $tmpPath = $this->ch->getParameter('tmp_dir') . DIRECTORY_SEPARATOR . $uid; file_put_contents($tmpPath, $dropzone->getInstruction()); $files[$uid] = $tmpPath; $data['instruction'] = $uid; $data['allow_workspace_resource'] = $dropzone->getAllowWorkspaceResource(); $data['allow_upload'] = $dropzone->getAllowUpload(); $data['allow_url'] = $dropzone->getAllowUrl(); $data['allow_rich_text'] = $dropzone->getAllowRichText(); $data['manual_planning'] = $dropzone->getManualPlanning(); $data['manual_state'] = $dropzone->getManualState(); $startDate = $dropzone->getStartAllowDrop(); if (!empty($startDate)) { $data['start_allow_drop'] = $startDate->format('Y-m-d H:i:s'); } $endDate = $dropzone->getEndAllowDrop(); if (!empty($endDate)) { $data['end_allow_drop'] = $endDate->format('Y-m-d H:i:s'); } return $data; }
/** * Test to detect the incorrect input. * * @param Form $form form to control * @param Dropzone $dropzone dropzone to update * * @return form */ public function handleFormErrors($form, Dropzone $dropzone) { if (!$dropzone->getAllowWorkspaceResource() && !$dropzone->getAllowUpload() && !$dropzone->getAllowUrl() && !$dropzone->getAllowRichText()) { $form->get('allowWorkspaceResource')->addError(new FormError('Choose at least one type of document')); $form->get('allowUpload')->addError(new FormError('Choose at least one type of document')); $form->get('allowUrl')->addError(new FormError('Choose at least one type of document')); $form->get('allowRichText')->addError(new FormError('Choose at least one type of document')); } if (!$dropzone->getManualPlanning()) { if ($dropzone->getStartAllowDrop() === null) { $form->get('startAllowDrop')->addError(new FormError('Choose a date')); } if ($dropzone->getEndAllowDrop() === null) { $form->get('endAllowDrop')->addError(new FormError('Choose a date')); } if ($dropzone->getStartAllowDrop() !== null && $dropzone->getEndAllowDrop() !== null) { if ($dropzone->getStartAllowDrop()->getTimestamp() > $dropzone->getEndAllowDrop()->getTimestamp()) { $form->get('startAllowDrop')->addError(new FormError('Must be before end allow drop')); $form->get('endAllowDrop')->addError(new FormError('Must be after start allow drop')); } } } return $form; }
private function createAgendaEventDrop(User $user, Dropzone $dropzone) { $translator = $this->container->get('translator'); $em = $this->container->get('doctrine')->getEntityManager(); $event = new Event(); $event->setStart($dropzone->getStartAllowDrop()); $event->setEnd($dropzone->getEndAllowDrop()); $event->setUser($user); $dropzoneName = $dropzone->getResourceNode()->getName(); $title = $translator->trans('Deposit phase of the %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel'); $desc = $translator->trans('Evaluation %dropzonename% opening', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel'); $event->setTitle($title); $event->setDescription($desc); $em->persist($event); $em->flush(); return $event; }
/** * Check if dropzone options are ok in order to autoclose Drops * @param Dropzone $dropzone * @return bool */ private function isDropzoneDropTimeIsUp(Dropzone $dropzone) { $dropDatePassed = false; if ($dropzone->getAutoCloseOpenedDropsWhenTimeIsUp() && $dropzone->getManualPlanning() == false) { $now = new \DateTime(); $dropDatePassed = $now->getTimestamp() > $dropzone->getEndAllowDrop()->getTimeStamp(); } return $dropDatePassed; }