/** * Function: disable * Disables a module or feather. */ public function disable() { $config = Config::current(); $visitor = Visitor::current(); $type = isset($_GET['module']) ? "module" : "feather"; if (!$visitor->group->can("toggle_extensions")) { if ($type == "module") { show_403(__("Access Denied"), __("You do not have sufficient privileges to enable/disable modules.")); } else { show_403(__("Access Denied"), __("You do not have sufficient privileges to enable/disable feathers.")); } } if ($type == "module" and !module_enabled($_GET[$type])) { Flash::warning(__("Module already disabled."), "/admin/?action=modules"); } if ($type == "feather" and !feather_enabled($_GET[$type])) { Flash::warning(__("Feather already disabled."), "/admin/?action=feathers"); } $enabled_array = $type == "module" ? "enabled_modules" : "enabled_feathers"; $folder = $type == "module" ? MODULES_DIR : FEATHERS_DIR; $class_name = camelize($_GET[$type]); if (method_exists($class_name, "__uninstall")) { call_user_func(array($class_name, "__uninstall"), false); } $config->set($type == "module" ? "enabled_modules" : "enabled_feathers", array_diff($config->{$enabled_array}, array($_GET[$type]))); $info = YAML::load($folder . "/" . $_GET[$type] . "/info.yaml"); if ($type == "module") { Flash::notice(_f("“%s” module disabled.", array($info["name"])), "/admin/?action=" . pluralize($type)); } elseif ($type == "feather") { Flash::notice(_f("“%s” feather disabled.", array($info["name"])), "/admin/?action=" . pluralize($type)); } }
$new = $config->{$enabled_array}; array_push($new, $_POST["extension"]); $config->set($enabled_array, $new); exit('{ notifications: [' . (!empty($info["notifications"]) ? '"' . implode('", "', $info["notifications"]) . '"' : "") . '] }'); break; case "disable_module": case "disable_feather": $type = $_POST['action'] == "disable_module" ? "module" : "feather"; if (!$visitor->group->can("change_settings")) { if ($type == "module") { exit("{ notifications: ['" . __("You do not have sufficient privileges to enable/disable modules.") . "'] }"); } else { exit("{ notifications: ['" . __("You do not have sufficient privileges to enable/disable feathers.") . "'] }"); } } if ($type == "module" and !module_enabled($_POST['extension']) or $type == "feather" and !feather_enabled($_POST['extension'])) { exit("{ notifications: [] }"); } $class_name = camelize($_POST["extension"]); if (method_exists($class_name, "__uninstall")) { call_user_func(array($class_name, "__uninstall"), $_POST['confirm'] == "1"); } $enabled_array = $type == "module" ? "enabled_modules" : "enabled_feathers"; $config->set($enabled_array, array_diff($config->{$enabled_array}, array($_POST['extension']))); exit('{ notifications: [] }'); break; case "reorder_feathers": $reorder = oneof(@$_POST['list'], $config->enabled_feathers); foreach ($reorder as &$value) { $value = preg_replace("/feathers\\[([^\\]]+)\\]/", "\\1", $value); }