public function testCanSetRollUpForNewAccountLatestActivitiesForPortletView() { LatestActivitiesPortletPersistentConfigUtil::setForCurrentUserByPortletIdAndKey(static::$accountLatestActivitiesPortletId, static::CONFIG_KEY, ''); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey(static::$accountLatestActivitiesPortletId, static::CONFIG_KEY) === ''); LatestActivitiesPortletPersistentConfigUtil::setForCurrentUserByPortletIdAndKey(static::$accountLatestActivitiesPortletId, static::CONFIG_KEY, '1'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey(static::$accountLatestActivitiesPortletId, static::CONFIG_KEY) === '1'); }
/** * @param $portletId - unique id * @return bool */ public static function resolveShouldSlideToSecondPanel($portletId) { return !LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($portletId, static::SHOULD_SLIDE_TO_FIRST_PANEL_KEY_NAME, true); }
protected function restoreUserSettingsToConfigFrom(&$latestActivitiesConfigurationForm, $excludeFromRestore) { foreach (static::$persistantUserPortletConfigs as $persistantUserConfigItem) { if (in_array($persistantUserConfigItem, $excludeFromRestore)) { continue; } $persistantUserConfigItemValue = LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($this->params['portletId'], $persistantUserConfigItem); if (isset($persistantUserConfigItemValue)) { $latestActivitiesConfigurationForm->{$persistantUserConfigItem} = $persistantUserConfigItemValue; } } return $latestActivitiesConfigurationForm; }
public function testSuperUserAllDefaultControllerActions() { // key used to test persistance of user settings $configKey = 'rollup'; //Set the current user as the super user. $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $accounts = Account::getAll(); $this->assertEquals(1, count($accounts)); $superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount'); //Load Details view to generate the portlets. $this->setGetArray(array('id' => $superAccountId)); $this->resetPostArray(); $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details'); //Find the LatestActivity portlet. $portletToUse = null; $portlets = Portlet::getAll(); foreach ($portlets as $portlet) { if ($portlet->viewType == 'AccountLatestActivitiesForPortlet') { $portletToUse = $portlet; break; } } $this->assertNotNull($portletToUse); $this->assertEquals('AccountLatestActivitiesForPortletView', get_class($portletToUse->getView())); //Load the portlet details for latest activity $getData = array('id' => $superAccountId, 'portletId' => $portletToUse->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portletToUse->id, 'LatestActivitiesConfigurationForm' => array('filteredByModelName' => 'all', 'rollup' => '')); $this->setGetArray($getData); $this->resetPostArray(); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($getData['portletId'], $configKey) === ''); //Now add roll up $getData['LatestActivitiesConfigurationForm']['rollup'] = '1'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($getData['portletId'], $configKey) === '1'); //Now filter by meeting, task, and note $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Meeting'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Note'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Task'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); //Now do the same thing with filtering but turn off rollup. $getData['LatestActivitiesConfigurationForm']['rollup'] = ''; $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Meeting'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($getData['portletId'], $configKey) === ''); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Note'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Task'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); }