2014-02-19 03:58:19 +01:00
|
|
|
<?php
|
|
|
|
require_once 'Zend/Date.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show all pages that need to be reviewed
|
|
|
|
*
|
|
|
|
* @package contentreview
|
|
|
|
*/
|
|
|
|
class PagesWithoutReviewScheduleReport extends SS_Report {
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function title() {
|
|
|
|
return _t('PagesWithoutReviewScheduleReport.TITLE', 'Pages without a scheduled review.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return \FieldList
|
|
|
|
*/
|
|
|
|
public function parameterFields() {
|
|
|
|
$params = new FieldList();
|
|
|
|
$params->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages'));
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function columns() {
|
2015-08-03 09:30:55 +02:00
|
|
|
$linkBase = singleton('CMSPageEditController')->Link('show');
|
|
|
|
$linkPath = parse_url($linkBase, PHP_URL_PATH);
|
|
|
|
$linkQuery = parse_url($linkBase, PHP_URL_QUERY);
|
|
|
|
|
2014-02-19 03:58:19 +01:00
|
|
|
$fields = array(
|
|
|
|
'Title' => array(
|
|
|
|
'title' => 'Page name',
|
2015-08-03 09:30:55 +02:00
|
|
|
'formatting' => sprintf('<a href=\"%s/$ID?%s\" title=\"Edit page\">$value</a>', $linkPath, $linkQuery)
|
2014-02-19 03:58:19 +01:00
|
|
|
),
|
|
|
|
'NextReviewDate' => array(
|
|
|
|
'title' => 'Review Date',
|
|
|
|
'casting' => 'Date->Full'
|
|
|
|
),
|
|
|
|
'OwnerNames' => array(
|
|
|
|
'title' => 'Owner'
|
|
|
|
),
|
|
|
|
'LastEditedByName' => 'Last edited by',
|
|
|
|
'AbsoluteLink' => array(
|
|
|
|
'title' => 'URL',
|
|
|
|
'formatting' => function($value, $item) {
|
|
|
|
$liveLink = $item->AbsoluteLiveLink;
|
|
|
|
$stageLink = $item->AbsoluteLink();
|
|
|
|
return sprintf('%s <a href="%s">%s</a>',
|
|
|
|
$stageLink,
|
|
|
|
$liveLink ? $liveLink : $stageLink . '?stage=Stage',
|
|
|
|
$liveLink ? '(live)' : '(draft)'
|
|
|
|
);
|
|
|
|
}
|
2014-02-25 08:37:43 +01:00
|
|
|
),
|
|
|
|
'ContentReviewType' => array(
|
|
|
|
'title' => 'Settings are',
|
2015-08-03 09:30:55 +02:00
|
|
|
'formatting' => function($value, $item) use($linkPath, $linkQuery) {
|
2014-02-25 08:37:43 +01:00
|
|
|
if($item->ContentReviewType == 'Inherit') {
|
|
|
|
$options = $item->getOptions();
|
|
|
|
if($options && $options instanceof SiteConfig) {
|
|
|
|
return 'Inherited from <a href="admin/settings">Settings</a>';
|
|
|
|
} elseif($options) {
|
2015-08-03 09:30:55 +02:00
|
|
|
return sprintf(
|
|
|
|
'Inherited from <a href="%s/%d?%s">%s</a>',
|
|
|
|
$linkPath,
|
|
|
|
$options->ID,
|
|
|
|
$linkQuery,
|
|
|
|
$options->Title
|
|
|
|
);
|
2014-02-25 08:37:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $value;
|
|
|
|
}
|
2014-02-19 03:58:19 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param array $params
|
|
|
|
* @param string $sort
|
|
|
|
* @param array $limit
|
2015-09-15 07:28:28 +02:00
|
|
|
* @return SS_List
|
2014-02-19 03:58:19 +01:00
|
|
|
*/
|
|
|
|
public function sourceRecords($params, $sort, $limit) {
|
2014-02-25 08:37:43 +01:00
|
|
|
Versioned::reading_stage('Stage');
|
2014-02-19 03:58:19 +01:00
|
|
|
$records = SiteTree::get();
|
|
|
|
|
|
|
|
// If there's no review dates set, default to all pages due for review now
|
2014-02-25 08:37:43 +01:00
|
|
|
// $records = $records->where('"NextReviewDate" IS NULL OR "OwnerNames" IS NULL OR "OwnerNames" = \'\'');
|
2014-02-19 03:58:19 +01:00
|
|
|
|
|
|
|
// Show virtual pages?
|
|
|
|
if(empty($params['ShowVirtualPages'])) {
|
|
|
|
$virtualPageClasses = ClassInfo::subclassesFor('VirtualPage');
|
|
|
|
$records = $records->where(sprintf(
|
|
|
|
'"SiteTree"."ClassName" NOT IN (\'%s\')',
|
|
|
|
implode("','", array_values($virtualPageClasses))
|
|
|
|
));
|
|
|
|
}
|
2014-02-25 08:37:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
$records->sort('ParentID');
|
2015-09-15 07:28:28 +02:00
|
|
|
|
|
|
|
// Make sure we get results from all subsites, because only the main site has the Reports section
|
|
|
|
$subsiteFilterBefore = null;
|
|
|
|
if(class_exists('Subsite')){
|
|
|
|
$subsiteFilterBefore = Subsite::disable_subsite_filter(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$records = $records->toArray();
|
|
|
|
|
|
|
|
if(class_exists('Subsite')){
|
|
|
|
Subsite::disable_subsite_filter($subsiteFilterBefore);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-25 08:37:43 +01:00
|
|
|
// Trim out calculated values
|
|
|
|
$list = new ArrayList();
|
|
|
|
foreach($records as $record) {
|
|
|
|
if(!$this->hasReviewSchedule($record)) {
|
|
|
|
$list->push($record);
|
2014-02-19 03:58:19 +01:00
|
|
|
}
|
2014-02-25 08:37:43 +01:00
|
|
|
}
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param DataObject $record
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
protected function hasReviewSchedule(DataObject $record) {
|
|
|
|
if(!$record->obj('NextReviewDate')->exists()) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-19 03:58:19 +01:00
|
|
|
|
2014-02-25 08:37:43 +01:00
|
|
|
$options = $record->getOptions();
|
|
|
|
if($options->OwnerGroups()->count() == 0 && $options->OwnerUsers()->count() == 0) {
|
|
|
|
return false;
|
2014-02-19 03:58:19 +01:00
|
|
|
}
|
|
|
|
|
2014-02-25 08:37:43 +01:00
|
|
|
return true;
|
2014-02-19 03:58:19 +01:00
|
|
|
}
|
|
|
|
}
|