public function getDeActivate($noDependent = false)
{
Yii::app()->getCache()->flush();
Yii::app()->configManager->flushDump();
$fileModule = Yii::app()->moduleManager->getModulesConfigDefault($this->id);
$fileConfig = Yii::app()->moduleManager->getModulesConfig($this->id);
$fileConfigBack = Yii::app()->moduleManager->getModulesConfigBack($this->id);
if (!is_file($fileConfig) && $this->id != 'install') {
throw new CException(Yii::t('YupeModule.yupe', 'Module already disabled!'));
} else {
// Проверка зависимых модулей
if (!$noDependent) {
$dependent = $this->getDependent();
if (!empty($dependent) && is_array($dependent)) {
foreach ($dependent as $dependen) {
$module = Yii::app()->getModule($dependen);
if ($module != null) {
if ($module->getIsNoDisable()) {
continue;
}
$module->getDeActivate();
}
}
}
}
if ($this->getIsNoDisable()) {
throw new CException(Yii::t('YupeModule.yupe', 'This module can\'t be disabled!'));
} elseif (@md5_file($fileModule) != @md5_file($fileConfig) && !@copy($fileConfig, $fileConfigBack)) {
throw new CException(Yii::t('YupeModule.yupe', "Error when coping old configuration file in modulesBack folder!"));
} elseif (!@unlink($fileConfig)) {
throw new CException(Yii::t('YupeModule.yupe', 'Error when disabling module, there is no access to configuration file!'));
} else {
return true;
}
}
return false;
}