function Confirm_Uninstall() { global $config, $langmessage, $dataDir, $gp_titles, $gp_menu, $gp_index; $addon =& $_POST['addon']; if (!isset($config['addons'][$addon])) { message($langmessage['OOPS']); return; } $order = false; if (isset($config['addons'][$addon]['order'])) { $order = $config['addons'][$addon]['order']; } //tracking $history = array(); $history['name'] = $config['addons'][$addon]['name']; $history['action'] = 'uninstalled'; if (isset($config['addons'][$addon]['id'])) { $history['id'] = $config['addons'][$addon]['id']; } unset($config['addons'][$addon]); //remove links $installedGadgets = $this->GetInstalledComponents($config['gadgets'], $addon); $this->RemoveFromHandlers($installedGadgets); //remove from gp_index, gp_menu $installedLinks = $this->GetInstalledComponents($gp_titles, $addon); foreach ($installedLinks as $index) { if (isset($gp_menu[$index])) { unset($gp_menu[$index]); } $title = common::IndexToTitle($index); if ($title) { unset($gp_index[$title]); } } $this->RemoveFromConfig($config['gadgets'], $addon); $this->RemoveFromConfig($config['admin_links'], $addon); $this->RemoveFromConfig($gp_titles, $addon); $this->CleanHooks($addon); if (!admin_tools::SaveAllConfig()) { message($langmessage['OOPS']); $this->Uninstall(); return false; } /* * Delete the data folders */ $installFolder = $dataDir . '/data/_addoncode/' . $addon; if (file_exists($installFolder)) { gpFiles::RmAll($installFolder); } $data_folder_name = gpPlugin::GetDataFolder($addon); $dataFolder = $dataDir . '/data/_addondata/' . $data_folder_name; if (file_exists($dataFolder)) { gpFiles::RmAll($dataFolder); } /* * Record the history */ $history['time'] = time(); $this->addonHistory[] = $history; $this->SaveAddonData(); if ($order) { $img_path = common::IdUrl('ci'); common::IdReq($img_path); } message($langmessage['SAVED']); }
/** * Set global path variables for the current addon * @param string $addon_key Key used to identify a plugin uniquely in the configuration * */ function SetDataFolder($addon_key) { global $dataDir, $config; global $addonDataFolder, $addonCodeFolder; //deprecated global $addonRelativeCode, $addonRelativeData, $addonPathData, $addonPathCode, $addonFolderName, $addon_current_id, $addon_current_version; if (!isset($config['addons'][$addon_key])) { return; } gpPlugin::StackPush(); $data_folder = gpPlugin::GetDataFolder($addon_key); $addon_current_id = $addon_current_version = false; if (isset($config['addons'][$addon_key]['id'])) { $addon_current_id = $config['addons'][$addon_key]['id']; } if (isset($config['addons'][$addon_key]['version'])) { $addon_current_version = $config['addons'][$addon_key]['version']; } $addonFolderName = $addon_key; $addonPathCode = $addonCodeFolder = $dataDir . '/data/_addoncode/' . $addon_key; $addonPathData = $addonDataFolder = $dataDir . '/data/_addondata/' . $data_folder; $addonRelativeCode = common::GetDir('/data/_addoncode/' . $addon_key); $addonRelativeData = common::GetDir('/data/_addondata/' . $data_folder); }