silverstripe-blog/extensions/BlogPostFilter.php

18 lines
368 B
PHP
Raw Normal View History

2013-07-21 12:23:35 +02:00
<?php
2013-08-04 18:38:26 +02:00
class BlogPostFilter extends DataExtension {
2013-07-21 12:23:35 +02:00
/**
2013-08-04 18:38:26 +02:00
* Augment queries so that we don't fetch unpublished articles.
2013-07-21 12:23:35 +02:00
**/
2013-08-04 18:38:26 +02:00
public function augmentSQL(SQLQuery &$query) {
2013-07-21 12:23:35 +02:00
2013-08-04 18:38:26 +02:00
$stage = Versioned::current_stage();
if($stage == "Stage") $stage = "";
else $stage = "_" . Convert::raw2sql($stage);
2013-07-21 12:23:35 +02:00
2013-08-04 18:38:26 +02:00
$query->addWhere("PublishDate < NOW()");
2013-07-21 12:23:35 +02:00
}
}