Ejemplo n.º 1
0
 public function __construct(Revision $revision)
 {
     $this->revision = $revision;
     if ($revision->getContentType()) {
         $message = "Not enough privilege the manipulate the object " . $revision->getContentType()->getName() . ":" . $revision->getOuuid();
     } else {
         throw new \Exception("Not enough privilege the manipulate the object");
     }
     parent::__construct($message, 0, null);
 }
Ejemplo n.º 2
0
 /**
  * @Route("/data/revisions/revert/{id}", name="revision.revert"))
  * @Method({"POST"})
  */
 public function revertRevisionAction(Revision $revision, Request $request)
 {
     $type = $revision->getContentType()->getName();
     $ouuid = $revision->getOuuid();
     $newestRevision = $this->getNewestRevision($type, $ouuid);
     if ($newestRevision->getDraft()) {
         //TODO: ????
     }
     $revertedRevsision = $this->initNewDraft($type, $ouuid, $revision);
     $this->addFlash('notice', 'Revision ' . $revision->getId() . ' reverted as draft');
     return $this->redirectToRoute('revision.edit', ['revisionId' => $revertedRevsision->getId()]);
 }
Ejemplo n.º 3
0
 public function __construct(Revision $revision)
 {
     $this->revision = $revision;
     $message = "Revision " . $revision->getStartTime()->format("c") . " of the object " . $revision->getContentType()->getName() . ":" . $revision->getOuuid() . " is locked by " . $revision->getLockBy() . " until " . $revision->getLockUntil()->format("c");
     parent::__construct($message, 0, null);
 }
Ejemplo n.º 4
0
 public function unpublish(Revision $revision, Environment $environment)
 {
     if (!$this->authorizationChecker->isGranted($revision->getContentType()->getEditRole())) {
         $this->session->getFlashBag()->add('warning', 'You are not allowed to unpublish the object ' . $revision);
         return;
     }
     $user = $this->userService->getCurrentUser();
     if (!empty($environment->getCircles() && !$this->authorizationChecker->isGranted('ROLE_ADMIN') && empty(array_intersect($environment->getCircles(), $user->getCircles())))) {
         $this->session->getFlashBag()->add('warning', 'You are not allowed to unpublish from the environment ' . $environment);
         return;
     }
     if ($revision->getContentType()->getEnvironment() == $environment) {
         $this->session->getFlashBag()->add('warning', 'You can\'t unpublish from the default environment of the content type ' . $revision->getContentType());
         return;
     }
     $this->dataService->lockRevision($revision, $environment);
     $revision->removeEnvironment($environment);
     try {
         $status = $this->client->delete(['id' => $revision->getOuuid(), 'index' => $environment->getAlias(), 'type' => $revision->getContentType()->getName()]);
         $this->session->getFlashBag()->add('notice', 'The object ' . $revision . ' has been unpublished from environment ' . $environment->getName());
     } catch (\Exception $e) {
         if (!$revision->getDeleted()) {
             $this->session->getFlashBag()->add('warning', 'The object ' . $revision . ' was already unpublished from environment ' . $environment->getName());
         }
     }
     $em = $this->doctrine->getManager();
     $em->persist($revision);
     $em->flush();
     $this->auditService->auditLog('PublishService:unpublish', $revision->getRawData(), $environment->getName());
 }
Ejemplo n.º 5
0
 public function findByOuuidContentTypeAndEnvironnement(Revision $revision, Environment $env = null)
 {
     if (!isset($env)) {
         $env = $revision->getContentType()->getEnvironment();
     }
     return $this->findByOuuidAndContentTypeAndEnvironnement($revision->getContentType(), $revision->getOuuid(), $env);
 }
Ejemplo n.º 6
0
 public function __construct(Revision $revision)
 {
     $this->revision = $revision;
     $message = "Update on a not locked object " . $revision->getContentType()->getName() . ":" . $revision->getOuuid() . ' #' . $revision->getId();
     parent::__construct($message, 0, null);
 }
Ejemplo n.º 7
0
 public function removeCriteria($filters, Revision $revision, $criteriaField)
 {
     $rawData = $revision->getRawData();
     if (!isset($rawData[$criteriaField])) {
         $rawData[$criteriaField] = [];
     }
     $criteriaFieldType = $revision->getContentType()->getFieldType()->__get('ems_' . $criteriaField);
     $multipleField = $this->getMultipleField($criteriaFieldType);
     $found = false;
     foreach ($rawData[$criteriaField] as $index => $criteriaSet) {
         $found = true;
         foreach ($filters as $criterion => $value) {
             if ($criterion != $multipleField && $value != $criteriaSet[$criterion]) {
                 $found = false;
                 break;
             }
         }
         if ($found) {
             if ($multipleField) {
                 $indexKey = array_search($filters[$multipleField], $criteriaSet[$multipleField]);
                 if ($indexKey === FALSE) {
                     $this->addFlash('notice', 'Criteria not found in multiple key');
                 } else {
                     unset($rawData[$criteriaField][$index][$multipleField][$indexKey]);
                     $rawData[$criteriaField][$index][$multipleField] = array_values($rawData[$criteriaField][$index][$multipleField]);
                     if (count($rawData[$criteriaField][$index][$multipleField]) == 0) {
                         unset($rawData[$criteriaField][$index]);
                         $rawData[$criteriaField] = array_values($rawData[$criteriaField]);
                     }
                     if (!$revision->getDraft()) {
                         $revision = $this->dataService->initNewDraft($revision->getContentType()->getName(), $revision->getOuuid(), $revision);
                     }
                     $revision->setRawData($rawData);
                     $this->addFlash('notice', '<b>Remove</b> ' . $multipleField . ' with value ' . $filters[$multipleField] . ' from ' . $revision);
                     return $revision;
                 }
             } else {
                 unset($rawData[$criteriaField][$index]);
                 $rawData[$criteriaField][$index] = array_values($rawData[$criteriaField][$index]);
                 if (!$revision->getDraft()) {
                     $revision = $this->dataService->initNewDraft($revision->getContentType()->getName(), $revision->getOuuid(), $revision);
                 }
                 $revision->setRawData($rawData);
                 $this->addFlash('notice', '<b>Remove</b> from ' . $revision);
                 return $revision;
             }
             break;
         }
     }
     if (!$found) {
         $this->addFlash('notice', 'Criteria not found for ' . $revision);
     }
     return false;
 }
Ejemplo n.º 8
0
 public function loadDataStructure(Revision $revision)
 {
     $data = new DataField();
     $data->setFieldType($revision->getContentType()->getFieldType());
     $data->setOrderKey($revision->getContentType()->getFieldType()->getOrderKey());
     $revision->setDataField($data);
     $revision->getDataField()->updateDataStructure($revision->getContentType()->getFieldType());
     $object = $revision->getRawData();
     $data->updateDataValue($object);
     if (count($object) > 0) {
         $html = DataService::arrayToHtml($object);
         $this->session->getFlashBag()->add('warning', "Some data of this revision were not consumed by the content type:" . $html);
     }
 }