protected function getDataProvider(Report $report, $stickyKey, $runReport) { assert('is_string($stickyKey) || is_int($stickyKey)'); assert('is_bool($runReport)'); $getData = GetUtil::getData(); if (isset($getData['clearRuntimeFilters']) && $getData['clearRuntimeFilters']) { StickyReportUtil::clearDataByKey($stickyKey); } if (null != ($stickyData = StickyReportUtil::getDataByKey($stickyKey))) { StickyReportUtil::resolveStickyDataToReport($report, $stickyData); } $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('reportResultsListPageSize', get_class($this->getModule())); $dataProvider = ReportDataProviderFactory::makeByReport($report, $pageSize); if ($runReport) { $dataProvider->setRunReport($runReport); } return $dataProvider; }
public function actionResetRuntimeFilters($id) { $savedReport = SavedReport::getById((int) $id); ControllerSecurityUtil::resolveCanCurrentUserAccessModule($savedReport->moduleClassName); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($savedReport); $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport); StickyReportUtil::clearDataByKey($report->getId()); }
/** * @depends testSuperUserAllDefaultControllerActions */ public function testSuperUserListSearchAction() { StickyReportUtil::clearDataByKey('MarketingListsSearchForm'); $this->setGetArray(array('MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'xyz'))); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list'); $this->assertContains('No results found', $content); StickyReportUtil::clearDataByKey('MarketingListsSearchForm'); $this->setGetArray(array('MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'Marketing'))); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list'); $this->assertContains('2 result(s)', $content); $this->assertEquals(2, substr_count($content, 'MarketingListName')); $this->assertContains('Clark Kent', $content); StickyReportUtil::clearDataByKey('MarketingListsSearchForm'); $this->setGetArray(array('MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'Marketing', 'selectedListAttributes' => array('name', 'createdByUser', 'fromAddress', 'fromName')))); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list'); $this->assertContains('2 result(s)', $content); $this->assertEquals(2, substr_count($content, 'MarketingListName')); $this->assertContains('Clark Kent', $content); $this->assertEquals(3, substr_count($content, 'Clark Kent')); $this->assertContains('@zurmo.com', $content); $this->assertEquals(4, substr_count($content, '@zurmo.com')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); StickyReportUtil::clearDataByKey('MarketingListsSearchForm'); $this->setGetArray(array('clearingSearch' => 1, 'MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromAddress', 'structurePosition' => 1, 'fromAddress' => '*****@*****.**')), 'dynamicStructure' => '1'))); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list'); $this->assertContains('1 result(s)', $content); $this->assertEquals(1, substr_count($content, 'MarketingListName2')); $this->assertContains('Clark Kent', $content); $this->assertEquals(2, substr_count($content, 'Clark Kent')); $this->assertContains('@zurmo.com', $content); $this->assertEquals(2, substr_count($content, '@zurmo.com')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); StickyReportUtil::clearDataByKey('MarketingListsSearchForm'); $this->setGetArray(array('clearingSearch' => 1, 'MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromName', 'structurePosition' => 1, 'fromName' => 'first')), 'dynamicStructure' => '1'))); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list'); $this->assertContains('1 result(s)', $content); $this->assertEquals(1, substr_count($content, 'MarketingListName')); $this->assertContains('Clark Kent', $content); $this->assertEquals(2, substr_count($content, 'Clark Kent')); $this->assertContains('@zurmo.com', $content); $this->assertEquals(2, substr_count($content, '@zurmo.com')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); }
/** * @depends testSuperUserAllDefaultControllerActions */ public function testSuperUserListSearchAction() { StickyReportUtil::clearDataByKey('CampaignsSearchForm'); $this->setGetArray(array('CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'xyz'))); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list'); $this->assertContains('No results found', $content); StickyReportUtil::clearDataByKey('CampaignsSearchForm'); $this->setGetArray(array('CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'camp'))); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list'); $this->assertContains('2 result(s)', $content); $this->assertContains('<th id="list-view_c2">Status</th>', $content); $this->assertEquals(1, substr_count($content, 'campaign01')); $this->assertEquals(1, substr_count($content, 'campaign02')); $this->assertEquals(2, substr_count($content, 'Active')); StickyReportUtil::clearDataByKey('CampaignsSearchForm'); $this->setGetArray(array('CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'campaign', 'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName')))); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list'); $this->assertContains('2 result(s)', $content); $this->assertContains('<th id="list-view_c2">Status</th>', $content); $this->assertEquals(1, substr_count($content, 'campaign01')); $this->assertEquals(1, substr_count($content, 'campaign02')); $this->assertEquals(2, substr_count($content, 'Active')); $this->assertEquals(3, substr_count($content, 'Clark Kent')); $this->assertEquals(4, substr_count($content, '@zurmo.com')); $this->assertEquals(6, substr_count($content, 'fromCampaign')); $this->assertEquals(3, substr_count($content, 'fromCampaign2')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); StickyReportUtil::clearDataByKey('CampaignsSearchForm'); $this->setGetArray(array('clearingSearch' => 1, 'CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromAddress', 'structurePosition' => 1, 'fromAddress' => '*****@*****.**')), 'dynamicStructure' => '1'))); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list'); $this->assertContains('1 result(s)', $content); $this->assertContains('<th id="list-view_c2">Status</th>', $content); $this->assertEquals(1, substr_count($content, 'campaign02')); $this->assertEquals(1, substr_count($content, 'Active')); $this->assertEquals(2, substr_count($content, 'Clark Kent')); $this->assertEquals(2, substr_count($content, '@zurmo.com')); $this->assertEquals(7, substr_count($content, 'fromCampaign2')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); StickyReportUtil::clearDataByKey('CampaignsSearchForm'); $this->setGetArray(array('clearingSearch' => 1, 'CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromName', 'structurePosition' => 1, 'fromName' => 'fromCampaign2')), 'dynamicStructure' => '1'))); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list'); $this->assertContains('1 result(s)', $content); $this->assertContains('<th id="list-view_c2">Status</th>', $content); $this->assertEquals(1, substr_count($content, 'campaign02')); $this->assertEquals(1, substr_count($content, 'Active')); $this->assertEquals(2, substr_count($content, 'Clark Kent')); $this->assertEquals(2, substr_count($content, '@zurmo.com')); $this->assertEquals(7, substr_count($content, 'fromCampaign2')); $this->assertEquals(2, substr_count($content, '*****@*****.**')); }