setDatechanged() public method

Set change date.
public setDatechanged ( DateTime | string | null $date )
$date DateTime | string | null
Exemplo n.º 1
0
 /**
  * Do the edit form for a record.
  *
  * @param Content $content     A content record
  * @param array   $contentType The contenttype data
  * @param boolean $duplicate   If TRUE create a duplicate record
  *
  * @return array
  */
 public function action(Content $content, array $contentType, $duplicate)
 {
     $contentTypeSlug = $contentType['slug'];
     $new = $content->getId() === null ?: false;
     $oldStatus = $content->getStatus();
     $allStatuses = ['published', 'held', 'draft', 'timed'];
     $allowedStatuses = [];
     foreach ($allStatuses as $status) {
         if ($this->users->isContentStatusTransitionAllowed($oldStatus, $status, $contentTypeSlug, $content->getId())) {
             $allowedStatuses[] = $status;
         }
     }
     // For duplicating a record, clear base field values.
     if ($duplicate) {
         $content->setId('');
         $content->setSlug('');
         $content->setDatecreated('');
         $content->setDatepublish('');
         $content->setDatedepublish(null);
         $content->setDatechanged('');
         $content->setUsername('');
         $content->setOwnerid('');
         $this->loggerFlash->info(Trans::__('contenttypes.generic.duplicated-finalize', ['%contenttype%' => $contentTypeSlug]));
     }
     // Set the users and the current owner of this content.
     if ($new || $duplicate) {
         // For brand-new and duplicated items, the creator becomes the owner.
         $contentowner = $this->users->getCurrentUser();
     } else {
         // For existing items, we'll just keep the current owner.
         $contentowner = $this->users->getUser($content->getOwnerid());
     }
     // Build list of incoming non inverted related records.
     $incomingNotInverted = [];
     foreach ($content->getRelation()->incoming($content) as $relation) {
         if ($relation->isInverted()) {
             continue;
         }
         $fromContentType = $relation->getFromContenttype();
         $record = $this->em->getContent($fromContentType . '/' . $relation->getFromId());
         if ($record) {
             $incomingNotInverted[$fromContentType][] = $record;
         }
     }
     // Test write access for uploadable fields.
     $contentType['fields'] = $this->setCanUpload($contentType['fields']);
     $templateFields = $content->getTemplatefields();
     if ($templateFields instanceof TemplateFields && ($templateFieldsData = $templateFields->getContenttype()->getFields())) {
         $templateFields->getContenttype()['fields'] = $this->setCanUpload($templateFields->getContenttype()->getFields());
     }
     // Build context for Twig.
     $contextCan = ['upload' => $this->users->isAllowed('files:uploads'), 'publish' => $this->users->isAllowed('contenttype:' . $contentTypeSlug . ':publish:' . $content->getId()), 'depublish' => $this->users->isAllowed('contenttype:' . $contentTypeSlug . ':depublish:' . $content->getId()), 'change_ownership' => $this->users->isAllowed('contenttype:' . $contentTypeSlug . ':change-ownership:' . $content->getId())];
     $contextHas = ['incoming_relations' => count($incomingNotInverted) > 0, 'relations' => isset($contentType['relations']), 'tabs' => $contentType['groups'] !== false, 'taxonomy' => isset($contentType['taxonomy']), 'templatefields' => empty($templateFieldsData) ? false : true];
     $contextValues = ['datepublish' => $this->getPublishingDate($content->getDatepublish(), true), 'datedepublish' => $this->getPublishingDate($content->getDatedepublish())];
     $context = ['incoming_not_inv' => $incomingNotInverted, 'contenttype' => $contentType, 'content' => $content, 'allowed_status' => $allowedStatuses, 'contentowner' => $contentowner, 'fields' => $this->config->fields->fields(), 'fieldtemplates' => $this->getTemplateFieldTemplates($contentType, $content), 'fieldtypes' => $this->getUsedFieldtypes($contentType, $content, $contextHas), 'groups' => $this->createGroupTabs($contentType, $contextHas), 'can' => $contextCan, 'has' => $contextHas, 'values' => $contextValues, 'relations_list' => $this->getRelationsList($contentType)];
     return $context;
 }
Exemplo n.º 2
0
 /**
  * Do the edit form for a record.
  *
  * @param Content $content     A content record
  * @param array   $contenttype The contenttype data
  * @param boolean $duplicate   If TRUE create a duplicate record
  *
  * @return array
  */
 public function handleEditRequest(Content $content, array $contenttype, $duplicate)
 {
     $contenttypeSlug = $contenttype['slug'];
     $new = $content->getId() === null ?: false;
     $oldStatus = $content->getStatus();
     $allStatuses = ['published', 'held', 'draft', 'timed'];
     $allowedStatuses = [];
     foreach ($allStatuses as $status) {
         if ($this->app['users']->isContentStatusTransitionAllowed($oldStatus, $status, $contenttypeSlug, $content->getId())) {
             $allowedStatuses[] = $status;
         }
     }
     // For duplicating a record, clear base field values.
     if ($duplicate) {
         $content->setId('');
         $content->setSlug('');
         $content->setDatecreated('');
         $content->setDatepublish('');
         $content->setDatedepublish(null);
         $content->setDatechanged('');
         $content->setUsername('');
         $content->setOwnerid('');
         $this->app['logger.flash']->info(Trans::__('contenttypes.generic.duplicated-finalize', ['%contenttype%' => $contenttypeSlug]));
     }
     // Set the users and the current owner of this content.
     if ($new || $duplicate) {
         // For brand-new and duplicated items, the creator becomes the owner.
         $contentowner = $this->app['users']->getCurrentUser();
     } else {
         // For existing items, we'll just keep the current owner.
         $contentowner = $this->app['users']->getUser($content->getOwnerid());
     }
     // Test write access for uploadable fields.
     $contenttype['fields'] = $this->setCanUpload($contenttype['fields']);
     if ($templatefields = $content->getTemplatefields()) {
         $this->setCanUpload($templatefields->getContenttype());
     }
     // Build context for Twig.
     $contextCan = ['upload' => $this->app['users']->isAllowed('files:uploads'), 'publish' => $this->app['users']->isAllowed('contenttype:' . $contenttypeSlug . ':publish:' . $content->getId()), 'depublish' => $this->app['users']->isAllowed('contenttype:' . $contenttypeSlug . ':depublish:' . $content->getId()), 'change_ownership' => $this->app['users']->isAllowed('contenttype:' . $contenttypeSlug . ':change-ownership:' . $content->getId())];
     $contextHas = ['incoming_relations' => is_array($content->relation), 'relations' => isset($contenttype['relations']), 'tabs' => $contenttype['groups'] !== false, 'taxonomy' => isset($contenttype['taxonomy']), 'templatefields' => $templatefields ? true : false];
     $contextValues = ['datepublish' => $this->getPublishingDate($content->getDatepublish(), true), 'datedepublish' => $this->getPublishingDate($content->getDatedepublish())];
     $context = ['contenttype' => $contenttype, 'content' => $content, 'allowed_status' => $allowedStatuses, 'contentowner' => $contentowner, 'fields' => $this->app['config']->fields->fields(), 'fieldtemplates' => $this->getTempateFieldTemplates($contenttype, $content), 'fieldtypes' => $this->getUsedFieldtypes($contenttype, $content, $contextHas), 'groups' => $this->createGroupTabs($contenttype, $contextHas), 'can' => $contextCan, 'has' => $contextHas, 'values' => $contextValues, 'relations_list' => $this->getRelationsList($contenttype)];
     return $context;
 }
Exemplo n.º 3
0
Arquivo: Save.php Projeto: Boorj/bolt
 /**
  * Commit the record to the database.
  *
  * @param Entity\Content      $content
  * @param Entity\Content|null $oldContent
  * @param array               $contentType
  * @param boolean             $new
  * @param string              $comment
  * @param string              $returnTo
  * @param string              $editReferrer
  *
  * @return Response
  */
 private function saveContentRecord(Entity\Content $content, $oldContent, array $contentType, $new, $comment, $returnTo, $editReferrer)
 {
     // Save the record
     $repo = $this->em->getRepository($contentType['slug']);
     // Update the date modified timestamp
     $content->setDatechanged('now');
     $repo->save($content);
     $id = $content->getId();
     // Create the change log entry if configured
     $this->logChange($contentType, $content->getId(), $content, $oldContent, $comment);
     // Log the change
     if ($new) {
         $this->loggerFlash->success(Trans::__('contenttypes.generic.saved-new', ['%contenttype%' => $contentType['slug']]));
         $this->loggerSystem->info('Created: ' . $content->getTitle(), ['event' => 'content']);
     } else {
         $this->loggerFlash->success(Trans::__('contenttypes.generic.saved-changes', ['%contenttype%' => $contentType['slug']]));
         $this->loggerSystem->info('Saved: ' . $content->getTitle(), ['event' => 'content']);
     }
     /*
      * We now only get a returnto parameter if we are saving a new
      * record and staying on the same page, i.e. "Save {contenttype}"
      */
     if ($returnTo) {
         if ($returnTo === 'new') {
             return new RedirectResponse($this->generateUrl('editcontent', ['contenttypeslug' => $contentType['slug'], 'id' => $id, '#' => $returnTo]));
         } elseif ($returnTo === 'saveandnew') {
             return new RedirectResponse($this->generateUrl('editcontent', ['contenttypeslug' => $contentType['slug'], '#' => $returnTo]));
         } elseif ($returnTo === 'ajax') {
             return $this->createJsonUpdate($content, true);
         } elseif ($returnTo === 'test') {
             return $this->createJsonUpdate($content, false);
         }
     }
     // No returnto, so we go back to the 'overview' for this contenttype.
     // check if a pager was set in the referrer - if yes go back there
     if ($editReferrer) {
         return new RedirectResponse($editReferrer);
     } else {
         return new RedirectResponse($this->generateUrl('overview', ['contenttypeslug' => $contentType['slug']]));
     }
 }