/** * @param array $filters * @return array */ protected function makeVariableStatesAttributeIndexes(array $filters) { $moduleClassName = $this->report->getModuleClassName(); $attributeIndexes = array(); VariableStatesForReportUtil::resolveAttributeIndexes($moduleClassName::getPrimaryModelName(), $attributeIndexes); VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $this->resolveDisplayAttributes()); VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $filters); VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $this->report->getOrderBys()); VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $this->resolveGroupBys()); return $attributeIndexes; }
public function testInferredRelationModelAttributeWithYetAnotherRelation() { Yii::app()->user->userModel = User::getByUsername('sally'); $stateAdapter = new ContactsStateMetadataAdapter(array('clauses' => array(), 'structure' => '')); $this->assertTrue(count($stateAdapter->getStateIds()) > 0); $filter = new FilterForReportForm('MeetingsModule', 'Meeting', Report::TYPE_ROWS_AND_COLUMNS); $filter->attributeIndexOrDerivedType = 'Account__activityItems__Inferred___contacts___officePhone'; $indexes = array(); VariableStatesForReportUtil::resolveAttributeIndexesByComponents($indexes, array($filter)); $this->assertEquals(array('Account__activityItems__Inferred___contacts___' => array('state', $stateAdapter->getStateIds())), $indexes); //Test with the super user. There shouldn't be any variable state data Yii::app()->user->userModel = User::getByUsername('super'); $filter = new FilterForReportForm('MeetingsModule', 'Meeting', Report::TYPE_ROWS_AND_COLUMNS); $filter->attributeIndexOrDerivedType = 'Account__activityItems__Inferred___contacts___name'; $indexes = array(); VariableStatesForReportUtil::resolveAttributeIndexesByComponents($indexes, array($filter)); $this->assertEquals(array(), $indexes); }