本文整理汇总了PHP中ModuleInstaller::uninstall方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleInstaller::uninstall方法的具体用法?PHP ModuleInstaller::uninstall怎么用?PHP ModuleInstaller::uninstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleInstaller
的用法示例。
在下文中一共展示了ModuleInstaller::uninstall方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performUninstall
function performUninstall($name)
{
$uh = new UpgradeHistory();
$uh->name = $name;
$uh->id_name = $name;
$found = $uh->checkForExisting($uh);
if ($found != null) {
global $sugar_config;
global $mod_strings;
global $current_language;
$base_upgrade_dir = sugar_cached("/upgrades");
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
if (!isset($GLOBALS['mi_remove_tables'])) {
$GLOBALS['mi_remove_tables'] = true;
}
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip($found->filename, $unzip_dir);
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->uninstall("{$unzip_dir}");
$found->delete();
unlink(remove_file_extension($found->filename) . '-manifest.php');
unlink($found->filename);
}
}
示例2: switch
switch ($mode) {
case "Install":
//here we can determine if this is an upgrade or a new version
if (!empty($previous_version)) {
$mi->install("{$unzip_dir}", true, $previous_version);
} else {
$mi->install("{$unzip_dir}");
}
break;
case "Uninstall":
if ($remove_tables == 'false') {
$GLOBALS['mi_remove_tables'] = false;
} else {
$GLOBALS['mi_remove_tables'] = true;
}
$mi->uninstall("{$unzip_dir}");
break;
case "Disable":
if (!$overwrite_files) {
$GLOBALS['mi_overwrite_files'] = false;
} else {
$GLOBALS['mi_overwrite_files'] = true;
}
$mi->disable("{$unzip_dir}");
break;
case "Enable":
if (!$overwrite_files) {
$GLOBALS['mi_overwrite_files'] = false;
} else {
$GLOBALS['mi_overwrite_files'] = true;
}
示例3: Item
/**
* 系统模块管理功能,用于从商店自动部署模块、移除模块
*/
public function Item()
{
$this->rest(["model" => "System/ModuleItem", "post" => function ($res) {
$zip = "{$res["request"]["module"]}.zip";
$path = APP_PATH . $res["request"]["module"];
if (!APP_DEBUG) {
/*从服务器下载模块压缩包*/
\Org\Util\Downloader::transfer(C("ENTERTILE") . C("ENTERTILE_STORE_PATH") . $zip, TEMP_PATH . $zip);
/*创建模块目录*/
\Org\Util\Directory::create($path);
/*解压ZIP文件*/
\Org\Util\Zip::extract(TEMP_PATH . $zip, $path);
}
/*加载模块配置类并初始化*/
include "{$path}/install.php";
$moduleInstaller = new \ModuleInstaller();
$config = $moduleInstaller->config;
/*准备配置数据(格式化处理)*/
$rules = [];
for ($i = 0, $l = count($config["menus"]); $i < $l; $i++) {
$menu = $config["menus"][$i];
$menu["rules"] = [];
for ($j = 0, $m = count($menu["permits"]); $j < $m; $j++) {
$permit = $menu["permits"][$j];
for ($k = 0, $n = count($permit["methods"]); $k < $n; $k++) {
$rule = strtolower("{$permit["methods"][$k]}{$permit["path"]}");
$rules[] = $menu["rules"][] = $rule;
}
}
$config["menus"][$i] = $menu;
}
/*增加模块信息*/
$config["id"] = D("System/ModuleItem")->add(["name" => $config["name"], "title" => $config["title"], "abstract" => $config["abstract"]]);
/*增加相关权限规则(如果已存在,则不添加)*/
//读取当前规则信息
$modelPermits = D("System/AuthenticationPermit")->select();
//移除已经存在的权限规则
$rules = join($rules, ";");
for ($i = 0, $l = count($modelPermits); $i < $l; $i++) {
$rules = str_replace($modelPermits[$i]["name"], "", $rules);
}
$rules = preg_replace("/^;|;\$/", "", preg_replace("/;{2,}/", ";", $rules));
//解析新增RULE并保存到数据库
if ($rules !== "") {
$rules = '[{"name":"' . str_replace(";", '"},{"name":"', $rules) . '"}]';
}
D("System/AuthenticationPermit")->addAll(json_decode($rules, true));
/*将规则信息与菜单相关联*/
//读取最新规则信息
$rules = [];
$modelPermits = D("System/AuthenticationPermit")->select();
for ($i = 0, $l = count($modelPermits); $i < $l; $i++) {
$rules[$modelPermits[$i]["name"]] = $modelPermits[$i]["id"];
}
//关联菜单权限
for ($i = 0, $l = count($config["menus"]); $i < $l; $i++) {
$tPermits = [];
$menu = $config["menus"][$i];
//添加菜单页面可访问权限
$menu["rules"][] = ["path" => $menu["page"], "methods" => ["GET"]];
for ($j = 0, $m = count($menu["rules"]); $j < $m; $j++) {
$tPermits[] = $rules[$menu["rules"][$j]];
}
//创建菜单记录
unset($config["menus"][$i]["permits"]);
unset($config["menus"][$i]["rules"]);
$config["menus"][$i]["title"] = $menu["menu"];
$config["menus"][$i]["module_id"] = $config["id"];
$config["menus"][$i]["rule_ids"] = join($tPermits, ",");
}
D("SystemModuleMenu")->addAll($config["menus"]);
/*运行自定义安装脚本*/
$moduleInstaller->install();
/*返回输出*/
$res["response"] = $config;
return $res;
}, "delete" => function ($res) {
$path = APP_PATH . $res["request"]["module"];
//执行自定义卸载脚本
include "{$path}/install.php";
$moduleInstaller = new \ModuleInstaller();
$moduleInstaller->uninstall();
/*移除模块相关文件及记录*/
$mod = new \Think\Model();
//移除对应菜单项
$mod->execute("delete from think_system_module_menu where module_id in(select id from think_system_module_item where name='%s')", [$res["request"]["module"]]);
//移除模块主体
$mod->execute("delete from think_system_module_item where name='%s'", [$res["request"]["module"]]);
if (!APP_DEBUG) {
//移除代码
\Org\Util\Directory::unlink($path);
}
/*返回输出*/
return $res;
}]);
}
示例4: performUninstall
function performUninstall($name)
{
$uh = new UpgradeHistory();
$uh->name = $name;
$uh->id_name = $name;
$found = $uh->checkForExisting($uh);
if ($found != null) {
global $sugar_config;
global $mod_strings;
global $current_language;
$base_upgrade_dir = $this->upload_dir . '/upgrades';
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
if (is_file($found->filename)) {
if (!isset($GLOBALS['mi_remove_tables'])) {
$GLOBALS['mi_remove_tables'] = true;
}
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip($found->filename, $unzip_dir);
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->uninstall("{$unzip_dir}");
$found->delete();
unlink(remove_file_extension($found->filename) . '-manifest.php');
unlink($found->filename);
} else {
//file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem
$found->delete();
}
}
}