Simplified the Pages due for review report #12

This commit is contained in:
Stig Lindqvist 2014-02-25 20:36:26 +13:00
parent 21b6b05fb7
commit 8c5e91addc

View File

@ -21,59 +21,20 @@ class PagesDueForReviewReport extends SS_Report {
* @return \FieldList
*/
public function parameterFields() {
$params = new FieldList();
$filtersList = new FieldList();
// We need to be a bit fancier when subsites is enabled
// if(class_exists('Subsite') && $subsites = DataObject::get('Subsite')) {
//
// throw new Exception('feature missing, check with subsites');
// // javascript for subsite specific owner dropdown
// Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
// Requirements::javascript('contentreview/javascript/PagesDueForReview.js');
//
// // Remember current subsite
// $existingSubsite = Subsite::currentSubsiteID();
//
// $map = array();
//
// // Create a map of all potential owners from all applicable sites
// $sites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
// foreach($sites as $site) {
// Subsite::changeSubsite($site);
//
// $cmsUsers = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
// // Key-preserving merge
// foreach($cmsUsers->map('ID', 'Title') as $k => $v) {
// $map[$k] = $v;
// }
// }
//
// $map = $map + array('' => 'Any', '-1' => '(no owner)');
//
// $params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map));
//
// // Restore current subsite
// Subsite::changeSubsite($existingSubsite);
// } else {
$cmsUsers = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
$map = $cmsUsers->map('ID', 'Title', '(no owner)')->toArray();
unset($map['']);
$map = array('' => 'Any', '-1' => '(no owner)') + $map;
$params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map));
// }
$params->push(
$filtersList->push(
DateField::create('ReviewDateAfter', 'Review date after or on')
->setConfig('showcalendar', true)
);
$params->push(
$filtersList->push(
DateField::create('ReviewDateBefore', 'Review date before or on', date('d/m/Y', strtotime('midnight')))
->setConfig('showcalendar', true)
);
$params->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages'));
$filtersList->push(new CheckboxField('ShowVirtualPages', 'Show Virtual Pages'));
return $params;
return $filtersList;
}
/**
@ -82,8 +43,6 @@ class PagesDueForReviewReport extends SS_Report {
*/
public function columns() {
Versioned::reading_stage('Stage');
$linkBase = singleton('CMSPageEditController')->Link('show') . '/';
$fields = array(
@ -109,20 +68,7 @@ class PagesDueForReviewReport extends SS_Report {
}
),
'OwnerNames' => array(
'title' => 'Owner',
'formatting' => function($value, $item) {
if($item->ContentReviewType == 'Disabled') {
return 'disabled';
}
if($item->ContentReviewType == 'Inherit') {
$setting = $item->getOptions();
if(!$setting) {
return 'disabled';
}
return $setting->getOwnerNames();
}
return $value;
}
'title' => 'Owner'
),
'LastEditedByName' => 'Last edited by',
'AbsoluteLink' => array(
@ -164,6 +110,7 @@ class PagesDueForReviewReport extends SS_Report {
* @return DataList
*/
public function sourceRecords($params, $sort, $limit) {
Versioned::reading_stage('Stage');
$records = SiteTree::get();
if(empty($params['ReviewDateBefore']) && empty($params['ReviewDateAfter'])) {
@ -198,31 +145,11 @@ class PagesDueForReviewReport extends SS_Report {
}
// Owner dropdown
if(!empty($params['ContentReviewOwnerID'])) {
$ownerID = (int)$params['ContentReviewOwnerID'];
// We use -1 here to distinguish between No Owner and Any
if($ownerID == -1) $ownerID = 0;
$records = $records->filter('ContentReviewOwnerID', $ownerID);
if(!empty($params['ContentReviewOwner'])) {
$ownerNames = Convert::raw2sql($params['ContentReviewOwner']);
$records = $records->filter('OwnerNames:PartialMatch', $ownerNames);
}
// Turn a query into records
// if($sort) {
// $parts = explode(' ', $sort);
// $field = $parts[0];
// $direction = $parts[1];
//
// if($field == 'AbsoluteLink') {
// $sort = '"URLSegment" ' . $direction;
// } elseif($field == 'Subsite.Title') {
// $records = $records->leftJoin("Subsite", '"Subsite"."ID" = "SiteTree"."SubsiteID"');
// }
//
// if($field != "LastEditedByName") {
// $records = $records->sort($sort);
// }
//
// if($limit) $records = $records->limit($limit['limit'], $limit['start']);
// }
return $records->sort('NextReviewDate', 'DESC');
}
}