本文整理汇总了PHP中ZurmoConfigurationUtil::setForCurrentUserByModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP ZurmoConfigurationUtil::setForCurrentUserByModuleName方法的具体用法?PHP ZurmoConfigurationUtil::setForCurrentUserByModuleName怎么用?PHP ZurmoConfigurationUtil::setForCurrentUserByModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZurmoConfigurationUtil
的用法示例。
在下文中一共展示了ZurmoConfigurationUtil::setForCurrentUserByModuleName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setForCurrentUserByPortletIdAndKey
/**
* Set a persistent config value for current user against portletId and keyName.
* @param $portletId integer Id of the portlet or string representation of the unique id of the portlet to set value against
* @param $keyName string Name of the key that should be set
* @param $value string|integer|boolean Value that should be assigned to keyName config
*/
public static function setForCurrentUserByPortletIdAndKey($portletId, $keyName, $value)
{
assert('is_int($portletId) || is_string($portletId)');
assert('is_string($keyName)');
$moduleName = static::getModuleName();
$keyName = static::resolveKeyNameByPortletId($portletId, $keyName);
ZurmoConfigurationUtil::setForCurrentUserByModuleName($moduleName, $keyName, $value);
Yii::app()->user->setState($keyName, $value);
}
示例2: testGetAndSetByCurrentUserByModuleName
public function testGetAndSetByCurrentUserByModuleName()
{
Yii::app()->user->userModel = User::getByUsername('super');
$this->assertNull(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'aKey', 'aValue');
Yii::app()->user->userModel = User::getByUsername('billy');
$this->assertNull(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'aKey', 'bValue');
Yii::app()->user->userModel = User::getByUsername('sally');
$this->assertNull(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'aKey', 'cValue');
//now retrieve again.
Yii::app()->user->userModel = User::getByUsername('super');
$this->assertEquals('aValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
Yii::app()->user->userModel = User::getByUsername('billy');
$this->assertEquals('bValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
Yii::app()->user->userModel = User::getByUsername('sally');
$this->assertEquals('cValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
//Test retrieving a generic value that is set globally on ZurmoModule. The value returned should be the
//same for all users.
$metadata = ZurmoModule::getMetadata();
$this->assertTrue(!isset($metadata['global']['bKey']));
$metadata['global']['bKey'] = 'GlobalValue';
ZurmoModule::setMetadata($metadata);
Yii::app()->user->userModel = User::getByUsername('super');
$this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
Yii::app()->user->userModel = User::getByUsername('billy');
$this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
Yii::app()->user->userModel = User::getByUsername('sally');
$this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
//Now change the bKey value, just for billy and retrieve again for all users. Only billy's bKey value
//should be different.
ZurmoConfigurationUtil::setByUserAndModuleName(User::getByUsername('billy'), 'ZurmoModule', 'bKey', 'BillyBKey');
Yii::app()->user->userModel = User::getByUsername('super');
$this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
Yii::app()->user->userModel = User::getByUsername('billy');
$this->assertEquals('BillyBKey', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
Yii::app()->user->userModel = User::getByUsername('sally');
$this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
}
示例3: confirmCurrentUsersTimeZone
public function confirmCurrentUsersTimeZone()
{
$keyName = 'timeZoneConfirmed';
ZurmoConfigurationUtil::setForCurrentUserByModuleName('UsersModule', $keyName, true);
}
示例4: deleteModelFromRecentlyViewed
/**
* @param $moduleName
* @param RedBeanModel $model
*/
public static function deleteModelFromRecentlyViewed($moduleName, RedBeanModel $model)
{
if (!isset($model) || !isset($moduleName)) {
return;
}
$newItem = array($moduleName, $model->id, strval($model));
$recentlyViewed = unserialize(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'recentlyViewed'));
if (!is_array($recentlyViewed)) {
return;
}
if (in_array($newItem, $recentlyViewed)) {
$key = array_search($newItem, $recentlyViewed);
unset($recentlyViewed[$key]);
array_keys($recentlyViewed);
}
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'recentlyViewed', serialize($recentlyViewed));
}
示例5: testDeleteModelFromRecentlyViewed
public function testDeleteModelFromRecentlyViewed()
{
Yii::app()->user->userModel = User::getByUsername('super');
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'recentlyViewed', null);
$account1 = new Account();
$account1->name = 'Dooble1';
$this->assertTrue($account1->save());
$account2 = new Account();
$account2->name = 'Dooble2';
$this->assertTrue($account2->save());
$account3 = new Account();
$account3->name = 'Dooble3';
$account3->owner = User::getByUsername('jimmy');
$this->assertTrue($account3->save());
//Now create some audit entries for the Item Viewed event.
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account1), 'AccountsModule'), $account1);
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account2), 'AccountsModule'), $account2);
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account1), 'AccountsModule'), $account3);
$content = AuditEventsRecentlyViewedUtil::getRecentlyViewedAjaxContentByUser(Yii::app()->user->userModel, 5);
$this->assertContains('Dooble1', $content);
$this->assertContains('Dooble2', $content);
$this->assertContains('Dooble3', $content);
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_DELETED, strval($account1), $account1);
$content = AuditEventsRecentlyViewedUtil::getRecentlyViewedAjaxContentByUser(Yii::app()->user->userModel, 5);
$this->assertNotContains('Dooble1', $content);
$this->assertContains('Dooble2', $content);
$this->assertContains('Dooble3', $content);
}
示例6: setForCurrentUserByType
/**
* Set the pagination value for the current user by pagination type.
* Also sets value as active state value by key.
* @param $type - pagination type
* @param $moduleName - optional. Module class name.
*/
public function setForCurrentUserByType($type, $value, $moduleName = null)
{
assert('in_array($type, static::getAvailablePageSizeNames()) == true');
assert('is_int($value) && $value > 0');
assert('$moduleName == null || is_string($moduleName)');
$keyName = $this->getKeyByTypeAndModuleName($type);
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', $keyName, $value);
Yii::app()->user->setState($keyName, $value);
}
示例7: actionToggleDismissIntroView
public function actionToggleDismissIntroView($moduleName, $panelId)
{
$value = (bool) ZurmoConfigurationUtil::getForCurrentUserByModuleName($moduleName, $panelId);
ZurmoConfigurationUtil::setForCurrentUserByModuleName($moduleName, $panelId, !$value);
}
示例8: toggleCollapseMenu
public function toggleCollapseMenu()
{
$value = ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', static::TOGGLE_COLLAPSE_KEY);
ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', static::TOGGLE_COLLAPSE_KEY, !$value);
}