| Current Path : /home/g/i/t/giteleslfp/www/plugins/system/tooltipgc/ |
| Current File : /home/g/i/t/giteleslfp/www/plugins/system/tooltipgc/install.php |
<?php
defined('_JEXEC') or die('Restricted access');
/*
preflight which is executed before install and update
install
update
uninstall
postflight which is executed after install and update
*/
class plgSystemTooltipgcInstallerScript {
function install($parent) {
}
function update($parent) {
}
function uninstall($parent) {
// disable all plugins and modules
// $db = JFactory::getDbo();
// $db->setQuery("UPDATE `#__modules` SET `published` = 0 WHERE `plugin` LIKE '%tooltipgc%'");
// $db->execute();
// $db->setQuery("UPDATE `#__extensions` SET `enabled` = 0 WHERE `type` = 'plugin' AND `element` LIKE '%tooltipgc%' AND `folder` LIKE '%system%'");
// $db->execute();
return true;
}
function preflight($type, $parent) {
// check if a pro version already installed
$xmlPath = JPATH_ROOT . '/plugins/system/tooltipgc/tooltipgc.xml';
// if no file already exists
if (! file_exists($xmlPath)) return true;
$xmlData = $this->getXmlData($xmlPath);
$isProInstalled = ((int)$xmlData->ckpro);
if ($isProInstalled) {
throw new RuntimeException('Tooltip GC Light cannot be installed over Tooltip GC Pro. Please install Tooltip GC Pro. To downgrade, please first uninstall Tooltip GC Pro.');
// return false;
}
// check if a V1 version is installed with the params (needs the pro)
$xmlPath = JPATH_ROOT . '/plugins/editors-xtd/tooltipgcparams/tooltipgcparams.xml';
// if no file already exists
if (! file_exists($xmlPath)) return true;
$xmlData = $this->getXmlData($xmlPath);
$installedVersion = ((int)$xmlData->version );
// if the installed version is the V1
if(version_compare($installedVersion, '4.2.0', '<')) {
// if the params is also installed
if (file_exists(JPATH_ROOT . '/plugins/editors-xtd/tooltipgcparams/tooltipgcparams.xml')) {
throw new RuntimeException('Tooltip GC Light cannot be installed over Tooltip GC (old version) + Params. Please install Tooltip GC Pro to get the same features as previously, else you may loose your existing settings. To downgrade, please first uninstall Tooltip GC Params.');
// return false;
}
}
return true;
}
public function getXmlData($file) {
if ( ! is_file($file))
{
return '';
}
$xml = simplexml_load_file($file);
if ( ! $xml || ! isset($xml['version']))
{
return '';
}
return $xml;
}
// run on install and update
function postflight($type, $parent) {
// install modules and plugins
jimport('joomla.installer.installer');
$db = JFactory::getDbo();
$status = array();
// enable system plugin
$db->setQuery("UPDATE #__extensions SET enabled = '1' WHERE `element` = 'tooltipgc' AND `type` = 'plugin'");
$result = $db->execute();
$status[] = array('name'=>'System - Tooltip GC','type'=>'plugin', 'result' => $result);
// disable the old update site
$db->setQuery("UPDATE #__update_sites SET enabled = '0' WHERE `location` = 'http://update.joomlack.fr/plg_tooltipgc_update.xml'");
$result3 = $db->execute();
foreach ($status as $statu) {
if ($statu['result'] == true) {
$alert = 'success';
$icon = 'icon-ok';
$text = 'Successful';
} else {
$alert = 'warning';
$icon = 'icon-cancel';
$text = 'Failed';
}
echo '<div class="alert alert-' . $alert . '"><i class="icon ' . $icon . '"></i>Installation and activation of the <b>' . $statu['type'] . ' ' . $statu['name'] . '</b> : ' . $text . '</div>';
}
return true;
}
}