本文整理汇总了PHP中Portlet::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Portlet::save方法的具体用法?PHP Portlet::save怎么用?PHP Portlet::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portlet
的用法示例。
在下文中一共展示了Portlet::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveAndRetrievePortlet
public function testSaveAndRetrievePortlet()
{
$user = UserTestHelper::createBasicUser('Billy');
$contracts = Contract::getByName('superOpp');
$portlet = new Portlet();
$portlet->column = 2;
$portlet->position = 5;
$portlet->layoutId = 'Test';
$portlet->collapsed = true;
$portlet->viewType = 'ContractsForContactRelatedList';
$portlet->serializedViewData = serialize(array('title' => 'Testing Title'));
$portlet->user = $user;
$this->assertTrue($portlet->save());
$portlet = Portlet::getById($portlet->id);
$params = array('controllerId' => 'test', 'relationModuleId' => 'test', 'relationModel' => $contracts[0], 'redirectUrl' => 'someRedirect');
$portlet->params = $params;
$unserializedViewData = unserialize($portlet->serializedViewData);
$this->assertEquals(2, $portlet->column);
$this->assertEquals(5, $portlet->position);
$this->assertEquals('Testing Title', $portlet->getTitle());
$this->assertEquals(false, $portlet->isEditable());
$this->assertEquals('Test', $portlet->layoutId);
//$this->assertEquals(true, $portlet->collapsed); //reenable once working
$this->assertEquals('ContractsForContactRelatedList', $portlet->viewType);
$this->assertEquals($user->id, $portlet->user->id);
$view = $portlet->getView();
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$super = User::getByUsername('super');
$portlet = new Portlet();
$portlet->column = 2;
$portlet->position = 5;
$portlet->layoutId = 'Test';
$portlet->collapsed = true;
$portlet->viewType = 'AccountLatestActivitiesForPortlet';
$portlet->user = $super;
$portlet->save();
static::$accountLatestActivitiesPortletId = $portlet->id;
}
示例3: testRegularUserProductPortletAccess
public function testRegularUserProductPortletAccess()
{
$benny = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
$account = AccountTestHelper::createAccountByNameForOwner('superAccount', Yii::app()->user->userModel);
$superAccountId = $account->id;
$benny->setRight('ProductTemplatesModule', ProductTemplatesModule::getAccessRight(), Right::DENY);
$this->assertTrue($benny->save());
$this->assertFalse(RightsUtil::canUserAccessModule('ProductTemplatesModule', $benny));
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = 1;
$portlet->layoutId = 'Test';
$portlet->collapsed = true;
$portlet->viewType = 'RssReader';
$portlet->user = $benny;
$this->assertTrue($portlet->save());
$this->setGetArray(array('uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id, 'portletId' => $portlet->id, 'relationAttributeName' => 'account', 'relationModelId' => $superAccountId, 'relationModuleId' => 'accounts', 'relationModelClassName' => 'Account'));
$this->runControllerWithNoExceptionsAndGetContent('productTemplates/default/selectFromRelatedList');
}
示例4: pushDetailsAndRelationsViewPortlets
public static function pushDetailsAndRelationsViewPortlets(User $user, $model)
{
$layoutIdPrefix = get_class($model);
$layoutId = $layoutIdPrefix . self::DETAILS_AND_RELATIONS_VIEW;
$userLayoutPortlets = Portlet::getByLayoutIdAndUserSortedById($layoutId, $user->id);
$pushedLayoutPortlets = Portlet::getByLayoutIdAndUserSortedById($layoutId, Yii::app()->user->userModel->id);
foreach ($userLayoutPortlets as $portlet) {
$portlet->delete();
unset($portlet);
}
foreach ($pushedLayoutPortlets as $pushedLayoutPortlet) {
$portlet = new Portlet();
$portlet->column = $pushedLayoutPortlet->column;
$portlet->position = $pushedLayoutPortlet->position;
$portlet->layoutId = $layoutId;
$portlet->collapsed = $pushedLayoutPortlet->collapsed;
$portlet->viewType = $pushedLayoutPortlet->viewType;
$portlet->serializedViewData = $pushedLayoutPortlet->serializedViewData;
$portlet->user = $user;
$portlet->save();
}
}
示例5: testFilteredResultsByStageForProductPortlet
public function testFilteredResultsByStageForProductPortlet()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
Yii::app()->user->userModel = $super;
//Setup test data owned by the super user.
$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
ProductTestHelper::createProductStagesIfDoesNotExist();
$superProductId = self::getModelIdByModelNameAndName('Product', 'My Product 1');
$product = Product::getById($superProductId);
$product->account = $account;
$product->stage->value = 'Open';
$this->assertTrue($product->save());
ProductTestHelper::createProductByNameForOwner("My Product 2", $super);
$superProductId2 = self::getModelIdByModelNameAndName('Product', 'My Product 2');
$product = Product::getById($superProductId2);
$product->account = $account;
$product->stage->value = 'Won';
$this->assertTrue($product->save());
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = 1;
$portlet->layoutId = 'AccountDetailsAndRelationsView';
$portlet->user = $super;
$portlet->viewType = 'ProductsForAccountRelatedList';
$this->assertTrue($portlet->save());
$this->setGetArray(array('id' => $account->id, 'portletParams' => array('relationModuleId' => 'accounts', 'relationModelId' => $account->id), 'ProductsConfigurationForm' => array('filteredByStage' => 'Open'), 'redirectUrl' => Yii::app()->createUrl('accounts/default/details', array('id' => $account->id)), 'portletId' => $portlet->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id));
$content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/modalRefresh');
$this->assertContains('My Product 1', $content);
$this->assertNotContains('My Product 2', $content);
$this->setGetArray(array('id' => $account->id, 'portletParams' => array('relationModuleId' => 'accounts', 'relationModelId' => $account->id), 'ProductsConfigurationForm' => array('filteredByStage' => 'All'), 'redirectUrl' => Yii::app()->createUrl('accounts/default/details', array('id' => $account->id)), 'portletId' => $portlet->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id));
$content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/modalRefresh');
$this->assertContains('My Product 1', $content);
$this->assertContains('My Product 2', $content);
$this->setGetArray(array('id' => $account->id, 'portletParams' => array('relationModuleId' => 'accounts', 'relationModelId' => $account->id), 'ProductsConfigurationForm' => array('filteredByStage' => 'Won'), 'redirectUrl' => Yii::app()->createUrl('accounts/default/details', array('id' => $account->id)), 'portletId' => $portlet->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id));
$content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/modalRefresh');
$this->assertNotContains('My Product 1', $content);
$this->assertContains('My Product 2', $content);
}
示例6: makePortletUsingViewType
/**
* Make a portlet with default values.
*/
public static function makePortletUsingViewType($viewType, $uniqueLayoutId, $user)
{
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = 1;
$portlet->layoutId = $uniqueLayoutId;
$portlet->collapsed = false;
$portlet->viewType = $viewType;
$portlet->user = $user;
$portlet->save();
}
示例7: testBooleanSaveValueMatchesBooleanRetrieveValue
/**
* @depends testSavePortlet
*/
public function testBooleanSaveValueMatchesBooleanRetrieveValue()
{
$user = User::getByUserName('billy');
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = 1;
$portlet->layoutId = 'Test';
$portlet->collapsed = true;
$portlet->viewType = 'RssReader';
$portlet->user = $user;
$this->assertTrue($portlet->save());
$portlet = Portlet::getById($portlet->id);
$this->assertEquals(1, $portlet->collapsed);
}
示例8: testDeleteDashboardAndRelatedPortlets
/**
* testGetRowsByUserId
*/
public function testDeleteDashboardAndRelatedPortlets()
{
Yii::app()->user->userModel = User::getByUsername('billy');
$dashboardCount = Dashboard::getCount();
$this->assertTrue($dashboardCount > 0);
$user = User::getByUserName('billy');
Yii::app()->user->userModel = $user;
$dashboard = new Dashboard();
$dashboard->name = "Dashboard TESTING";
$dashboard->layoutId = 3;
$dashboard->owner = $user;
$dashboard->layoutType = '100';
$dashboard->isDefault = false;
$this->assertTrue($dashboard->save());
$this->assertEquals(Portlet::getCount(), 0);
$this->assertEquals(Dashboard::getCount(), $dashboardCount + 1);
for ($i = 1; $i <= 3; $i++) {
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = 1 + $i;
$portlet->layoutId = 'TEST' . $dashboard->layoutId;
$portlet->collapsed = false;
$portlet->viewType = 'TasksMyList';
$portlet->user = $user;
$this->assertTrue($portlet->save());
}
$this->assertEquals(Portlet::getCount(), 3);
$portlets = Portlet::getByLayoutIdAndUserSortedById('TEST' . $dashboard->layoutId, $user->id);
foreach ($portlets as $portlet) {
$portlet->delete();
}
$dashboard->delete();
$this->assertEquals(Portlet::getCount(), 0);
$this->assertEquals(Dashboard::getCount(), $dashboardCount);
}
示例9: testRegularUserAllControllerActions
public function testRegularUserAllControllerActions()
{
$aUser = $this->logoutCurrentUserLoginNewUserAndGetByUsername('aUser');
$this->runControllerWithNoExceptionsAndGetContent('users/default/profile');
$bUser = User::getByUsername('bUser');
//Access to admin configuration should fail.
$this->runControllerShouldResultInAccessFailureAndGetContent('configuration');
//Access to users list to modify users should fail.
$this->runControllerShouldResultInAccessFailureAndGetContent('users/default');
$this->setGetArray(array('id' => $bUser->id));
//Access to view other users Audit Trail should fail.
$this->runControllerShouldResultInAccessFailureAndGetContent('users/default/auditEventsModalList');
//Access to edit other User and Role should fail.
$this->runControllerShouldResultInAccessFailureAndGetContent('users/default/edit');
$this->setGetArray(array('id' => $aUser->id));
//Access to allowed to view Audit Trail.
$this->runControllerWithNoExceptionsAndGetContent('users/default/auditEventsModalList');
//Access to User Role edit link and control not available.
$content = $this->runControllerWithNoExceptionsAndGetContent('users/default/edit');
$this->assertFalse(strpos($content, 'User_role_SelectLink') !== false);
$this->assertFalse(strpos($content, 'User_role_name') !== false);
//Check if the user who has right access for users can access any users audit trail.
$bUser = $this->logoutCurrentUserLoginNewUserAndGetByUsername('bUser');
$this->setGetArray(array('id' => $bUser->id));
//Access to audit Trail should not fail.
$this->runControllerWithNoExceptionsAndGetContent('users/default/auditEventsModalList');
$this->setGetArray(array('id' => $aUser->id));
//Access to other user audit Trail should not fail.
$this->runControllerWithNoExceptionsAndGetContent('users/default/auditEventsModalList');
//Now test all portlet controller actions
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = 1;
$portlet->layoutId = 'xyz';
$portlet->collapsed = false;
$portlet->viewType = 'UserLatestActivitiesForPortlet';
$portlet->user = $bUser;
$portlet->save();
$this->setGetArray(array('id' => $aUser->id, 'portletId' => $portlet->id));
//Using dummy portlet id
//Access to details of a portlet for self user should be fine.
$this->runControllerWithNoExceptionsAndGetContent('users/defaultPortlet/details');
//Now test peon with elevated rights to tabs /other available rights
//such as convert lead
//Now test peon with elevated permissions to models.
//actionModalList
//Autocomplete for User
}