本文整理汇总了PHP中HSetting::model方法的典型用法代码示例。如果您正苦于以下问题:PHP HSetting::model方法的具体用法?PHP HSetting::model怎么用?PHP HSetting::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HSetting
的用法示例。
在下文中一共展示了HSetting::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: disable
/**
* Disables a module
*
* Which means delete all (user-) data created by the module.
*
*/
public function disable()
{
if (!$this->isEnabled() || $this->isCoreModule) {
return false;
}
// Check this module is a SpaceModule
if ($this->isSpaceModule()) {
foreach ($this->getSpaceModuleSpaces() as $space) {
$space->disableModule($this->getId());
}
}
// Check this module is a UserModule
if ($this->isUserModule()) {
foreach ($this->getUserModuleUsers() as $user) {
$user->disableModule($this->getId());
}
}
// Disable module in database
$moduleEnabled = ModuleEnabled::model()->findByPk($this->getId());
if ($moduleEnabled != null) {
$moduleEnabled->delete();
}
HSetting::model()->deleteAllByAttributes(array('module_id' => $this->getId()));
SpaceSetting::model()->deleteAllByAttributes(array('module_id' => $this->getId()));
UserSetting::model()->deleteAllByAttributes(array('module_id' => $this->getId()));
// Delete also records with disabled state from SpaceApplicationModule Table
foreach (SpaceApplicationModule::model()->findAllByAttributes(array('module_id' => $this->getId())) as $sam) {
$sam->delete();
}
// Delete also records with disabled state from UserApplicationModule Table
foreach (UserApplicationModule::model()->findAllByAttributes(array('module_id' => $this->getId())) as $uam) {
$uam->delete();
}
ModuleManager::flushCache();
return true;
}
示例2: GetRecord
/**
* Returns a registry record by Name and Module Id
* The result is cached.
*
* @param type $name
* @param type $moduleId
* @return \HSetting
*/
private static function GetRecord($name, $moduleId = "")
{
$cacheId = 'HSetting_' . $name . '_' . $moduleId;
// Check if stored in Runtime Cache
if (RuntimeCache::Get($cacheId) !== false) {
return RuntimeCache::Get($cacheId);
}
// Check if stored in Cache
$cacheValue = Yii::app()->cache->get($cacheId);
if ($cacheValue !== false) {
return $cacheValue;
}
$condition = "";
$params = array('name' => $name);
if ($moduleId != "") {
$params['module_id'] = $moduleId;
} else {
$condition = "module_id IS NULL or module_id = ''";
}
$record = HSetting::model()->findByAttributes($params, $condition);
if ($record == null) {
$record = new HSetting();
$record->name = $name;
$record->module_id = $moduleId;
}
$expireTime = 3600;
if ($record->name != 'expireTime' && $record->module_id != "cache") {
$expireTime = HSetting::Get('expireTime', 'cache');
}
Yii::app()->cache->set($cacheId, $record, $expireTime);
RuntimeCache::Set($cacheId, $record);
return $record;
}