} else { echo '<span class="success">' . sprintf(_("%s enabled successfully"), $modulename) . '</span>'; } break; case 'disable': if (is_array($errors = module_disable($modulename))) { echo '<span class="error">' . sprintf(_("Error(s) disabling %s"), $modulename) . ': '; echo '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'; echo '</span>'; } else { echo '<span class="success">' . sprintf(_("%s disabled successfully"), $modulename) . '</span>'; } break; case 'uninstall': if (!EXTERNAL_PACKAGE_MANAGEMENT) { if (is_array($errors = module_uninstall($modulename))) { echo '<span class="error">' . sprintf(_("Error(s) uninstalling %s"), $modulename) . ': '; echo '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'; echo '</span>'; } else { echo '<span class="success">' . sprintf(_("%s uninstalled successfully"), $modulename) . '</span>'; } } break; default: // just so we don't send an <hr> and flush() $didsomething = false; } if ($didsomething) { echo "<hr /><br />"; flush();
/** Totally deletes a module * @param string The name of the module to install * @param bool If true, skips status and dependency checks * @return mixed True if succesful, array of error messages if not succesful */ function module_delete($modulename, $force = false) { global $amp_conf; $modules = module_getinfo($modulename); if (!isset($modules[$modulename])) { return array(_("Specified module not found")); } if ($modules[$modulename]['status'] != MODULE_STATUS_NOTINSTALLED) { if (is_array($errors = module_uninstall($modulename, $force))) { return $errors; } } // delete module directory //TODO : do this in pure php $dir = $amp_conf['AMPWEBROOT'] . '/admin/modules/' . $modulename; if (!is_dir($dir)) { return array(sprintf(_("Cannot delete directory %s"), $dir)); } if (strpos($dir, "..") !== false) { die_freepbx("Security problem, denying delete"); } exec("rm -r " . escapeshellarg($dir), $output, $exitcode); if ($exitcode != 0) { return array(sprintf(_("Error deleting directory %s (code %d)"), $dir, $exitcode)); } // uninstall will have called needreload() if necessary return true; }