BUGFIX: Fixed behaviour of the subsite filter field added to reports. (from r95963)

This commit is contained in:
Tom Rix 2010-03-01 21:56:37 +00:00
parent 5dc4a86f30
commit f511ceb0e4

View File

@ -23,8 +23,15 @@ class SubsiteReportWrapper extends SSReport {
function parameterFields() { function parameterFields() {
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain'); $subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
$options = $subsites->toDropdownMap('ID', 'Title'); $options = $subsites->toDropdownMap('ID', 'Title');
$subsiteField = new TreeMultiselectField('Subsites', 'Sites', $options); $subsiteField = new TreeMultiselectField('Subsites', 'Sites', $options);
$subsiteField->setValue(array_keys($options));
// We don't need to make the field editable if only one subsite is available
if(sizeof($options) <= 1) {
$subsiteField = $subsiteField->performReadonlyTransformation();
}
$fields = $this->baseReport->parameterFields(); $fields = $this->baseReport->parameterFields();
if($fields) { if($fields) {
$fields->insertBefore($subsiteField, $fields->First()->Name()); $fields->insertBefore($subsiteField, $fields->First()->Name());
@ -47,13 +54,15 @@ class SubsiteReportWrapper extends SSReport {
// Querying // Querying
function beforeQuery($params) { function beforeQuery($params) {
// The user has select a few specific sites
if(!empty($params['Subsites'])) { if(!empty($params['Subsites'])) {
// 'any' wasn't selected Subsite::$force_subsite = $params['Subsites'];
$subsiteIds = array();
foreach(explode(',', $params['Subsites']) as $subsite) { // Default: restrict to all accessible sites
if(is_numeric(trim($subsite))) $subsiteIds[] = trim($subsite); } else {
} $subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
Subsite::$force_subsite = join(',', $subsiteIds); $options = $subsites->toDropdownMap('ID', 'Title');
Subsite::$force_subsite = join(',', array_keys($options));
} }
} }
function afterQuery() { function afterQuery() {