當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ModuleInstaller::uninstall方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:netconstructor,項目名稱:sugarcrm_dev,代碼行數:25,代碼來源:PackageManager.php

示例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;
         }
開發者ID:klr2003,項目名稱:sourceread,代碼行數:31,代碼來源:UpgradeWizard_commit.php

示例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;
     }]);
 }
開發者ID:sayi21cn,項目名稱:Atomu,代碼行數:99,代碼來源:ModuleController.class.php

示例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();
         }
     }
 }
開發者ID:omusico,項目名稱:sugar_work,代碼行數:30,代碼來源:PackageManager.php


注:本文中的ModuleInstaller::uninstall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。