public function installModule($file)
{
@ini_set('max_execution_time', 0);
// Temporarily increase maximum execution time
if (is_file($file)) {
$filename = $this->uploadModule($file);
$canonical = str_replace('.zip', '', $filename);
$unzipSuccess = $this->Unzip("{$this->temp_path}{$filename}", "{$this->temp_path}{$canonical}");
if (!$unzipSuccess) {
throw new Exception("The module file {$filename} couldn\\'t be extracted.");
}
$temp_module_dir = "{$this->temp_path}{$canonical}/";
$replace_existing = (bool) Input::get('replace_existing');
} else {
$temp_module_dir = $file;
$replace_existing = true;
}
$config_file = $temp_module_dir . 'module.json';
if (!File::exists($config_file)) {
throw new Exception('module.json doesn\'t exist in the module');
}
$this->config = json_decode(file_get_contents($config_file), true);
if (Module::where('alias', '=', $this->config['info']['alias'])->first() && !$replace_existing) {
throw new Exception('Another module with the same name already exists');
}
$this->checkIfRequiredModulesExist();
// Copy modules from temporary folder to modules folder
$this->copyModule($temp_module_dir);
File::delete($file);
$this->manageTables();
$form_ids = $this->addToBuiltForms();
if ($form_ids) {
$this->addToBuiltModules($form_ids);
}
$input = $this->fixInput();
return $input;
}