/** * {@inheritdoc} */ public function stageChildren($showAll = false) { $staged = parent::stageChildren($showAll); if (!$this->shouldFilter() && $this->subclassForBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) { $stage = Versioned::current_stage(); if ($stage == 'Stage') { $stage = ''; } elseif ($stage) { $stage = '_' . $stage; } $dataQuery = $staged->dataQuery()->innerJoin('BlogPost', sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage))->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now()))); $staged = $staged->setDataQuery($dataQuery); } return $staged; }
/** * Augments (@link Hierarchy::stageChildren()} * * @param $staged DataList * @param $showAll boolean **/ public function stageChildren($showAll = false) { $staged = parent::stageChildren($showAll); if (!$this->shouldFilter() && in_array(get_class($this->owner), ClassInfo::subClassesFor("Blog")) && !Permission::check("VIEW_DRAFT_CONTENT")) { // Get the current stage. $stage = Versioned::current_stage(); if ($stage == "Stage") { $stage = ""; } else { $stage = "_" . Convert::raw2sql($stage); } // Filter published posts $dataQuery = $staged->dataQuery()->innerJoin("BlogPost", '"BlogPost' . $stage . '"."ID" = "SiteTree' . $stage . '"."ID"')->where('"PublishDate" < \'' . Convert::raw2sql(SS_Datetime::now()) . '\''); $staged = $staged->setDataQuery($dataQuery); } return $staged; }