install.php (2040B)
1 <?php 2 /******************************************************************** 3 Product : GNU Taler Gateway for Payage 4 Date : 26 Feburary 2023 5 Copyright : Tim Leibacher 6 Contact : https://www.tim-leibacher.ch/contact 7 Licence : GNU General Public License 8 *********************************************************************/ 9 defined('_JEXEC') or die('Restricted Access'); 10 11 class Payage_Taler_LeibacherInstallerScript 12 { 13 public function preflight($type, $parent) 14 { 15 $app = JFactory::getApplication(); 16 $payage_xml_file = JPATH_ADMINISTRATOR.'/components/com_payage/payage.xml'; 17 if (!file_exists($payage_xml_file)) 18 { 19 $app->enqueueMessage("Please install Payage before installing gateway addons", 'error'); 20 return false; 21 } 22 23 $xml_array = JInstaller::parseXMLInstallFile($payage_xml_file); 24 $payage_version = $xml_array['version']; 25 if (version_compare($payage_version,"2.28","<")) 26 { 27 $app->enqueueMessage("This Payage addon requires at least Payage 2.28. Please install the latest version of Payage first.", 'error'); 28 return false; 29 } 30 31 // get the previously installed version, if any 32 33 if (file_exists(JPATH_ADMINISTRATOR.'/components/com_payage/payage_taler_leibacher.xml')) 34 { 35 $xml_array = JInstaller::parseXMLInstallFile(JPATH_ADMINISTRATOR.'/components/com_payage/payage_taler_leibacher.xml'); 36 $this->previous_version = $xml_array['version']; 37 } 38 39 return true; 40 } 41 42 //------------------------------------------------------------------------------- 43 // Called at uninstall time 44 // 45 public function uninstall($parent) 46 { 47 $app = JFactory::getApplication(); 48 $app->enqueueMessage("Taler gateway for Payage has been uninstalled."); 49 } 50 51 //------------------------------------------------------------------------------- 52 // The main install function 53 // 54 public function postflight($type, $parent) 55 { 56 $this->app = JFactory::getApplication(); 57 $this_version = $parent->getManifest()->version; 58 $this->app->enqueueMessage("Payage Taler version $this_version installed.", 'message'); 59 return true; 60 } 61 62 }