| Current Path : /home/bijouxly/www/plugins/system/rsfppayment/ |
| Current File : /home/bijouxly/www/plugins/system/rsfppayment/script.php |
<?php
/**
* @package RSForm!Pro
* @copyright (C) 2007-2014 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
class plgSystemRSFPPaymentInstallerScript
{
public function preflight($type, $parent) {
if ($type != 'uninstall') {
$app = JFactory::getApplication();
if (!file_exists(JPATH_ADMINISTRATOR.'/components/com_rsform/helpers/rsform.php')) {
$app->enqueueMessage('Please install the RSForm! Pro component before continuing.', 'error');
return false;
}
if (!file_exists(JPATH_ADMINISTRATOR.'/components/com_rsform/helpers/version.php')) {
$app->enqueueMessage('Please upgrade RSForm! Pro to at least R45 before continuing!', 'error');
return false;
}
$jversion = new JVersion();
if (!$jversion->isCompatible('2.5.5')) {
$app->enqueueMessage('Please upgrade to at least Joomla! 2.5.5 before continuing!', 'error');
return false;
}
}
return true;
}
public function postflight($type, $parent) {
if ($type == 'uninstall') {
return true;
}
$installer = $parent->getParent();
$src = $installer->getPath('source').'/admin';
$dest = JPATH_ADMINISTRATOR.'/components/com_rsform';
JFolder::copy($src, $dest, '', true);
if ($type == 'update') {
// update, run sql again for the payment package
$this->runSQL($installer->getPath('source'), 'install.sql');
}
}
protected function runSQL($source, $file) {
$db = JFactory::getDbo();
$driver = strtolower($db->name);
if ($driver == 'mysqli') {
$driver = 'mysql';
} elseif ($driver == 'sqlsrv') {
$driver = 'sqlazure';
}
$sqlfile = $source.'/sql/'.$driver.'/'.$file;
if (file_exists($sqlfile)) {
$buffer = file_get_contents($sqlfile);
if ($buffer !== false) {
$queries = JInstallerHelper::splitSql($buffer);
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query{0} != '#') {
$db->setQuery($query);
if (!$db->execute()) {
JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
}
}
}
}
}
}
}