Example #1
0
 public function Install()
 {
     // Module file name
     $file = Kit::GetParam('module', _GET, _STRING);
     if ($file == '') {
         trigger_error(__('Unable to install module'), E_USER_ERROR);
     }
     Debug::LogEntry('audit', 'Request to install Module: ' . $file, 'module', 'Install');
     // Check that the file exists
     if (!file_exists($file)) {
         trigger_error(__('File does not exist'), E_USER_ERROR);
     }
     // Make sure the file is in our list of expected module files
     $files = glob('modules/*.module.php');
     if (!in_array($file, $files)) {
         trigger_error(__('Not a module file'), E_USER_ERROR);
     }
     // Load the file
     include_once $file;
     $type = str_replace('modules/', '', $file);
     $type = str_replace('.module.php', '', $type);
     // Load the module object inside the file
     if (!class_exists($type)) {
         trigger_error(__('Module file does not contain a class of the correct name'), E_USER_ERROR);
     }
     try {
         Debug::LogEntry('audit', 'Validation passed, installing module.', 'module', 'Install');
         $moduleObject = ModuleFactory::create($type, $this->db, $this->user);
         $moduleObject->InstallOrUpdate();
     } catch (Exception $e) {
         trigger_error(__('Unable to install module'), E_USER_ERROR);
     }
     Debug::LogEntry('audit', 'Module Installed: ' . $file, 'module', 'Install');
     // Excellent... capital... success
     $response = new ResponseManager();
     $response->refresh = true;
     $response->refreshLocation = 'index.php?p=module';
     $response->Respond();
 }
Example #2
0
 /**
  * Installs all files related to the enabled modules
  */
 public static function installAllModuleFiles()
 {
     $media = new Media();
     // Do this for all enabled modules
     foreach ($media->ModuleList() as $module) {
         // Install Files for this module
         $moduleObject = ModuleFactory::create($module['module']);
         $moduleObject->InstallFiles();
     }
 }