/**
  * Finds newly available configuration files and stores them in the magic data.
  * @param mixed  $modules a string or array of strings:  
  * the shortnames of modules we wish to look for sub-modules.  If null (default), we check all enabled modules.
  * @return array of string the shortname of any modules we found (old and new)
  */
 public function checkForNewModules($modules = null)
 {
     if ($modules !== null) {
         if (!is_array($modules)) {
             $modules = array($modules);
         }
         $fileSearch = new I2CE_FileSearch();
         $this->loadPaths($modules, array('CLASSES', 'MODULES'), true, $fileSearch);
         //add in the class path and module paths for the new modules
     } else {
         $fileSearch = I2CE::getFileSearch();
     }
     require_once 'I2CE_Configurator.php';
     //need to explicitly put this in here b/c the system may  not be enabled
     $configurator = new I2CE_Configurator(I2CE::getConfig());
     return $configurator->findAvailableConfigs($fileSearch, false, '', true);
 }
Example #2
0
 protected static function reinstall($site_module_file, $restart)
 {
     I2CE::raiseError("Beginning re-intiaizliation of site to new file {$site_module_file}");
     //we have at one point installed the system, however we changed
     //the config file that we are using or the name of the module we are using
     // we need to update the system starting with the site module
     $config = I2CE::getConfig();
     $site_module = '';
     $config->setIfIsSet($site_module, '/config/site/module');
     $mod_factory = I2CE_ModuleFactory::instance();
     $previous_site_file = '';
     $config->setIfIsSet($previous_site_file, '/config/data/' . $site_module . '/file');
     $installed = '';
     I2CE::longExecution();
     $mod_factory = I2CE_ModuleFactory::instance();
     $tmp_config = I2CE_MagicData::instance("temp_ReInit");
     I2CE::getFileSearch()->addPath('MODULES', dirname(dirname(__FILE__)), 'EVEN_HIGHER');
     $configurator = new I2CE_Configurator($tmp_config, false);
     $site_module_config_file_path = '/config/data/' . $site_module . '/file';
     unset($config->{$site_module_config_file_path});
     $new_site_module = $configurator->processConfigFile($site_module_file, true, false, true);
     I2CE::raiseError("Reinitializing: " . $new_site_module);
     if (!(is_string($new_site_module) && strlen($new_site_module) > 0)) {
         I2CE::raiseError("Installation Failed for site.  Invalid configuration file {$site_module_file}.  No name given.");
         return false;
     }
     if ($site_module !== $new_site_module) {
         I2CE::raiseError("You are not permitted to change the site from {$site_module} to {$new_site_module}");
         return false;
     }
     I2CE::raiseError("Begining re-initializiation of site {$site_module} -- moving config file from {$previous_site_file} to {$site_module_file}");
     if ($config->is_parent("/config/data")) {
         I2CE::raiseError("Erasing all previously found config file locations");
         foreach ($config->traverse("/config/data") as $module => $mod_config) {
             if ($module == $site_module || !$mod_config instanceof I2CE_MagicDataNode) {
                 continue;
             }
             $mod_config->__unset("file");
         }
     }
     $config->{$site_module_config_file_path} = I2CE_FileSearch::relativePath($site_module_file);
     //make sure we are looking at the correct config file for the site module
     I2CE::setupFileSearch(array("CLASSES" => "./", 'MODULES' => array(dirname(dirname(__FILE__)), dirname($site_module_file))), true);
     $mod_factory->resetStoredLoadedPaths();
     $configurator->findAvailableConfigs(I2CE::getFileSearch(), true);
     if (!self::updateOutOfDateConfigFiles()) {
         //maybe something that wasn't in the site module was changed
         I2CE::raiseError("Re-installation failed for {$site_module} ");
         return false;
     }
     I2CE::setupFileSearch();
     $mod_factory->resetStoredLoadedPaths();
     $mod_factory->loadPaths(null, 'CLASSES');
     //make sure all of our classes are loaded.
     $mod_factory->updateHooks();
     return true;
 }