예제 #1
0
 /**
  * Delete plugin from table_plugins, pluginhooks and pluginsettings
  *
  * @param int $upgrade flag to disable message
  */
 public function uninstall($h, $upgrade = 0, $clearCache = true)
 {
     if ($clearCache) {
         // Clear the database cache to ensure plugins and hooks are up-to-date.
         $h->deleteFiles(CACHE . 'db_cache');
         // Clear the css/js cache to ensure this plugin's files are removed
         $h->deleteFiles(CACHE . 'css_js_cache');
         // Clear the language cache to ensure any new language files get included
         $h->clearCache('lang_cache', false);
         $h->messages['db, css, language caches cleared'] = 'alert-info';
     }
     if ($upgrade == 0) {
         // don't delete plugin when we're upgrading
         $h->db->query($h->db->prepare("DELETE FROM " . TABLE_PLUGINS . " WHERE plugin_folder = %s", $h->plugin->folder));
     }
     \Hotaru\Models2\Pluginhook::removeHook($h, $h->plugin->folder);
     //$h->db->query($h->db->prepare("DELETE FROM " . TABLE_PLUGINHOOKS . " WHERE plugin_folder = %s", $h->plugin->folder));
     // Settings aren't deleted anymore, but a user can do so manually from Admin->Maintenance
     //$h->db->query($h->db->prepare("DELETE FROM " . TABLE_PLUGINSETTINGS . " WHERE plugin_folder = %s", $h->plugin->folder));
     $h->pluginHook('uninstall_plugin', $h->plugin->folder);
     if ($upgrade == 0) {
         $h->messages[$h->lang("admin_plugins_uninstall_done")] = 'green';
     }
     // Re-sort all orders and remove any accidental gaps
     $this->refreshPluginOrder($h);
     $this->sortPluginHooks($h);
 }