public function doSave($con = null)
 {
     parent::doSave($con);
     $enabled_ids = $this->getValue('enabled_modules');
     $all_dependencies = sfConfig::get('app_pm_module_enabler_dependencies', array());
     foreach ($this->getObject()->getpmModules() as $pm_module) {
         $pm_module->setIsEnabled(in_array($pm_module->getId(), $enabled_ids) || $pm_module->getName() == 'pmconfiguration' ? true : false);
         $pm_module->save();
     }
     foreach ($all_dependencies as $pm_module_name => $dependency) {
         $pm_module = pmModulePeer::retrieveByName($pm_module_name);
         if ($pm_module->getIsEnabled()) {
             $dependencies = isset($all_dependencies[$pm_module_name]) ? $all_dependencies[$pm_module_name] : array();
             // save all module dependencies
             foreach ($dependencies as $dependency) {
                 $dependency = pmModulePeer::retrieveByName($dependency);
                 $dependency->setIsEnabled(true);
                 $dependency->save();
             }
         }
     }
     // clear cache
     $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir')));
     $cache->clean();
 }
Example #2
0
 public function isEnabled($module_name)
 {
     $ret = false;
     $always_enabled = sfConfig::get('app_pm_module_enabler_always_enabled', array());
     if ($module_name == 'pmconfiguration') {
         $ret = true;
     } else {
         if (!in_array($module_name, sfConfig::get('sf_enabled_modules')) || in_array($module_name, $always_enabled)) {
             $ret = true;
         } else {
             $c = new Criteria();
             $c->add(pmModulePeer::NAME, $module_name);
             $pm_module = pmModulePeer::doSelectOne($c);
             $ret = $pm_module ? $pm_module->getIsEnabled() : false;
         }
     }
     return $ret;
 }