mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
NEW report for pages without a review schedule
This commit is contained in:
parent
8c5e91addc
commit
3b752be238
@ -22,11 +22,6 @@ class PagesWithoutReviewScheduleReport extends SS_Report {
|
|||||||
*/
|
*/
|
||||||
public function parameterFields() {
|
public function parameterFields() {
|
||||||
$params = new FieldList();
|
$params = new FieldList();
|
||||||
|
|
||||||
// We need to be a bit fancier when subsites is enabled
|
|
||||||
if(class_exists('Subsite') && Subsite::get()->count()) {
|
|
||||||
die('No subsite support yet!');
|
|
||||||
}
|
|
||||||
$params->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages'));
|
$params->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages'));
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
@ -61,6 +56,20 @@ class PagesWithoutReviewScheduleReport extends SS_Report {
|
|||||||
$liveLink ? '(live)' : '(draft)'
|
$liveLink ? '(live)' : '(draft)'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
),
|
||||||
|
'ContentReviewType' => array(
|
||||||
|
'title' => 'Settings are',
|
||||||
|
'formatting' => function($value, $item) use($linkBase) {
|
||||||
|
if($item->ContentReviewType == 'Inherit') {
|
||||||
|
$options = $item->getOptions();
|
||||||
|
if($options && $options instanceof SiteConfig) {
|
||||||
|
return 'Inherited from <a href="admin/settings">Settings</a>';
|
||||||
|
} elseif($options) {
|
||||||
|
return 'Inherited from <a href="'.$linkBase.$options->ID.'">'.$options->Title.'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -75,10 +84,11 @@ class PagesWithoutReviewScheduleReport extends SS_Report {
|
|||||||
* @return DataList
|
* @return DataList
|
||||||
*/
|
*/
|
||||||
public function sourceRecords($params, $sort, $limit) {
|
public function sourceRecords($params, $sort, $limit) {
|
||||||
|
Versioned::reading_stage('Stage');
|
||||||
$records = SiteTree::get();
|
$records = SiteTree::get();
|
||||||
|
|
||||||
// If there's no review dates set, default to all pages due for review now
|
// If there's no review dates set, default to all pages due for review now
|
||||||
$records = $records->where('"NextReviewDate" IS NULL OR "OwnerNames" IS NULL OR "OwnerNames" = \'\'');
|
// $records = $records->where('"NextReviewDate" IS NULL OR "OwnerNames" IS NULL OR "OwnerNames" = \'\'');
|
||||||
|
|
||||||
// Show virtual pages?
|
// Show virtual pages?
|
||||||
if(empty($params['ShowVirtualPages'])) {
|
if(empty($params['ShowVirtualPages'])) {
|
||||||
@ -88,26 +98,34 @@ class PagesWithoutReviewScheduleReport extends SS_Report {
|
|||||||
implode("','", array_values($virtualPageClasses))
|
implode("','", array_values($virtualPageClasses))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn a query into records
|
|
||||||
if($sort) {
|
$records->sort('ParentID');
|
||||||
$parts = explode(' ', $sort);
|
// Trim out calculated values
|
||||||
$field = $parts[0];
|
$list = new ArrayList();
|
||||||
$direction = $parts[1];
|
foreach($records as $record) {
|
||||||
|
if(!$this->hasReviewSchedule($record)) {
|
||||||
if($field == 'AbsoluteLink') {
|
$list->push($record);
|
||||||
$sort = '"URLSegment" ' . $direction;
|
|
||||||
} elseif($field == 'Subsite.Title') {
|
|
||||||
$records = $records->leftJoin("Subsite", '"Subsite"."ID" = "SiteTree"."SubsiteID"');
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($field != "LastEditedByName") {
|
return $list;
|
||||||
$records = $records->sort($sort);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
if($limit) $records = $records->limit($limit['limit'], $limit['start']);
|
*
|
||||||
|
* @param DataObject $record
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected function hasReviewSchedule(DataObject $record) {
|
||||||
|
if(!$record->obj('NextReviewDate')->exists()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $records;
|
$options = $record->getOptions();
|
||||||
|
if($options->OwnerGroups()->count() == 0 && $options->OwnerUsers()->count() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user