mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
Merge pull request #32 from flashbackzoo/pulls/add-user-filter
Add report filter for only the pages a user is assigned to
This commit is contained in:
commit
97adaee9a5
@ -112,10 +112,7 @@ class ContentReviewDefaultSettings extends DataExtension
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function ContentReviewOwners()
|
||||
{
|
||||
return new ArrayList();
|
||||
|
||||
public function ContentReviewOwners() {
|
||||
return SiteTreeContentReview::merge_owners($this->OwnerGroups(), $this->OwnerUsers());
|
||||
}
|
||||
}
|
||||
|
@ -23,16 +23,18 @@ class PagesDueForReviewReport extends SS_Report
|
||||
$filtersList = new FieldList();
|
||||
|
||||
$filtersList->push(
|
||||
DateField::create("ReviewDateAfter", "Review date after or on")
|
||||
DateField::create("ReviewDateAfter", _t("PagesDueForReviewReport.REVIEWDATEAFTER", "Review date after or on"))
|
||||
->setConfig("showcalendar", true)
|
||||
);
|
||||
|
||||
$filtersList->push(
|
||||
DateField::create("ReviewDateBefore", "Review date before or on", date("d/m/Y", strtotime("midnight")))
|
||||
DateField::create("ReviewDateBefore", _t("PagesDueForReviewReport.REVIEWDATEBEFORE", "Review date before or on"), date("d/m/Y", strtotime("midnight")))
|
||||
->setConfig("showcalendar", true)
|
||||
);
|
||||
|
||||
$filtersList->push(new CheckboxField("ShowVirtualPages", "Show Virtual Pages"));
|
||||
$filtersList->push(new CheckboxField("ShowVirtualPages", _t("PagesDueForReviewReport.SHOWVIRTUALPAGES", "Show Virtual Pages")));
|
||||
|
||||
$filtersList->push(new CheckboxField("OnlyMyPages", _t("PagesDueForReviewReport.ONLYMYPAGES", "Only Show pages assigned to me")));
|
||||
|
||||
return $filtersList;
|
||||
}
|
||||
@ -159,7 +161,23 @@ class PagesDueForReviewReport extends SS_Report
|
||||
$records = $records->filter("OwnerNames:PartialMatch", $ownerNames);
|
||||
}
|
||||
|
||||
$records = new ArrayList($records->sort("NextReviewDate", "DESC")->toArray());
|
||||
// Only show pages assigned to the current user?
|
||||
// This come last because it transforms $records to an ArrayList.
|
||||
if (!empty($params["OnlyMyPages"])) {
|
||||
$currentUser = Member::currentUser();
|
||||
|
||||
$records = $records->filterByCallback(function($page) use ($currentUser) {
|
||||
$options = $page->getOptions();
|
||||
|
||||
foreach ($options->ContentReviewOwners() as $owner) {
|
||||
if ($currentUser->ID == $owner->ID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
ContentReviewCompatability::done($compatibility);
|
||||
|
||||
|
@ -43,7 +43,7 @@ You'll also need to run `dev/build`.
|
||||
|
||||
## Documentation
|
||||
|
||||
See the [docs/en](docs/en/introduction.md) folder.
|
||||
See the [docs/en](docs/en/index.md) folder.
|
||||
|
||||
## Versioning
|
||||
|
||||
|
@ -37,11 +37,11 @@ class ContentReviewReportTest extends FunctionalTest
|
||||
));
|
||||
|
||||
$this->assertEquals(array(
|
||||
"Contact Us",
|
||||
"Contact Us Child",
|
||||
"Staff",
|
||||
"About Us",
|
||||
"Home",
|
||||
"About Us",
|
||||
"Staff",
|
||||
"Contact Us",
|
||||
), $results->column("Title"));
|
||||
|
||||
SS_Datetime::set_mock_now("2010-02-13 00:00:00");
|
||||
@ -49,8 +49,8 @@ class ContentReviewReportTest extends FunctionalTest
|
||||
$results = $report->sourceRecords(array());
|
||||
|
||||
$this->assertEquals(array(
|
||||
"About Us",
|
||||
"Home",
|
||||
"About Us",
|
||||
), $results->column("Title"));
|
||||
|
||||
SS_Datetime::clear_mock_now();
|
||||
|
Loading…
Reference in New Issue
Block a user