Allow drafted pages to show up in the report

This commit is contained in:
Stig Lindqvist 2014-02-25 18:23:18 +13:00
parent 6b337496cf
commit 5376c3a248

View File

@ -24,43 +24,43 @@ class PagesDueForReviewReport extends SS_Report {
$params = new FieldList(); $params = new FieldList();
// We need to be a bit fancier when subsites is enabled // We need to be a bit fancier when subsites is enabled
if(class_exists('Subsite') && $subsites = DataObject::get('Subsite')) { // if(class_exists('Subsite') && $subsites = DataObject::get('Subsite')) {
//
throw new Exception('feature missing, check with subsites'); // throw new Exception('feature missing, check with subsites');
// javascript for subsite specific owner dropdown // // javascript for subsite specific owner dropdown
Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js'); // Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
Requirements::javascript('contentreview/javascript/PagesDueForReview.js'); // Requirements::javascript('contentreview/javascript/PagesDueForReview.js');
//
// Remember current subsite // // Remember current subsite
$existingSubsite = Subsite::currentSubsiteID(); // $existingSubsite = Subsite::currentSubsiteID();
//
$map = array(); // $map = array();
//
// Create a map of all potential owners from all applicable sites // // Create a map of all potential owners from all applicable sites
$sites = Subsite::accessible_sites('CMS_ACCESS_CMSMain'); // $sites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
foreach($sites as $site) { // foreach($sites as $site) {
Subsite::changeSubsite($site); // Subsite::changeSubsite($site);
//
$cmsUsers = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN")); // $cmsUsers = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
// Key-preserving merge // // Key-preserving merge
foreach($cmsUsers->map('ID', 'Title') as $k => $v) { // foreach($cmsUsers->map('ID', 'Title') as $k => $v) {
$map[$k] = $v; // $map[$k] = $v;
} // }
} // }
//
$map = $map + array('' => 'Any', '-1' => '(no owner)'); // $map = $map + array('' => 'Any', '-1' => '(no owner)');
//
$params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map)); // $params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map));
//
// Restore current subsite // // Restore current subsite
Subsite::changeSubsite($existingSubsite); // Subsite::changeSubsite($existingSubsite);
} else { // } else {
$cmsUsers = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN")); $cmsUsers = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
$map = $cmsUsers->map('ID', 'Title', '(no owner)')->toArray(); $map = $cmsUsers->map('ID', 'Title', '(no owner)')->toArray();
unset($map['']); unset($map['']);
$map = array('' => 'Any', '-1' => '(no owner)') + $map; $map = array('' => 'Any', '-1' => '(no owner)') + $map;
$params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map)); $params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map));
} // }
$params->push( $params->push(
DateField::create('ReviewDateAfter', 'Review date after or on') DateField::create('ReviewDateAfter', 'Review date after or on')
@ -68,7 +68,7 @@ class PagesDueForReviewReport extends SS_Report {
); );
$params->push( $params->push(
DateField::create('ReviewDateBefore', 'Review date before or on', date('d/m/Y', strtotime('midnight'))) DateField::create('ReviewDateBefore', 'Review date before or on', date('d/m/Y', strtotime('midnight')))
->setConfig('showcalendar', true) ->setConfig('showcalendar', true)
); );
$params->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages')); $params->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages'));
@ -81,18 +81,16 @@ class PagesDueForReviewReport extends SS_Report {
* @return array * @return array
*/ */
public function columns() { public function columns() {
Versioned::reading_stage('Stage');
$linkBase = singleton('CMSPageEditController')->Link('show') . '/'; $linkBase = singleton('CMSPageEditController')->Link('show') . '/';
$fields = array( $fields = array(
'Title' => array( 'Title' => array(
'title' => 'Page name', 'title' => 'Page name',
'formatting' => '<a href=\"' . $linkBase . '/$ID\" title=\"Edit page\">$value</a>' 'formatting' => '<a href=\"' . $linkBase . '/$ID\" title=\"Edit page\">$value</a>'
), ),
'ContentReviewType' => array(
'title' => 'Settings are',
'formatting' => function($value, $item) {
return $value;
}
),
'NextReviewDate' => array( 'NextReviewDate' => array(
'title' => 'Review Date', 'title' => 'Review Date',
'casting' => 'Date->Full', 'casting' => 'Date->Full',
@ -101,11 +99,11 @@ class PagesDueForReviewReport extends SS_Report {
return 'disabled'; return 'disabled';
} }
if($item->ContentReviewType == 'Inherit') { if($item->ContentReviewType == 'Inherit') {
$setting = SiteTreeContentReview::getOptions($item); $setting = $item->getOptions();
if(!$setting) { if(!$setting) {
return 'disabled'; return 'disabled';
} }
return $item->get_next_review_date($setting, $item)->Full(); return $item->obj('NextReviewDate')->Full();
} }
return $value; return $value;
} }
@ -117,7 +115,7 @@ class PagesDueForReviewReport extends SS_Report {
return 'disabled'; return 'disabled';
} }
if($item->ContentReviewType == 'Inherit') { if($item->ContentReviewType == 'Inherit') {
$setting = SiteTreeContentReview::getOptions($item); $setting = $item->getOptions();
if(!$setting) { if(!$setting) {
return 'disabled'; return 'disabled';
} }
@ -138,7 +136,21 @@ class PagesDueForReviewReport 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;
}
),
); );
return $fields; return $fields;
@ -194,24 +206,23 @@ class PagesDueForReviewReport extends SS_Report {
} }
// Turn a query into records // Turn a query into records
if($sort) { // if($sort) {
$parts = explode(' ', $sort); // $parts = explode(' ', $sort);
$field = $parts[0]; // $field = $parts[0];
$direction = $parts[1]; // $direction = $parts[1];
//
if($field == 'AbsoluteLink') { // if($field == 'AbsoluteLink') {
$sort = '"URLSegment" ' . $direction; // $sort = '"URLSegment" ' . $direction;
} elseif($field == 'Subsite.Title') { // } elseif($field == 'Subsite.Title') {
$records = $records->leftJoin("Subsite", '"Subsite"."ID" = "SiteTree"."SubsiteID"'); // $records = $records->leftJoin("Subsite", '"Subsite"."ID" = "SiteTree"."SubsiteID"');
} // }
//
if($field != "LastEditedByName") { // if($field != "LastEditedByName") {
$records = $records->sort($sort); // $records = $records->sort($sort);
} // }
//
if($limit) $records = $records->limit($limit['limit'], $limit['start']); // if($limit) $records = $records->limit($limit['limit'], $limit['start']);
} // }
return $records->sort('NextReviewDate', 'DESC');
return $records;
} }
} }